mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
parent
3daae802eb
commit
5512576022
@ -52,6 +52,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent)
|
||||
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
|
||||
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
|
||||
previewList->setModel(previewListModel);
|
||||
previewList->hideColumn(FILE_INDEX);
|
||||
listDelegate = new PreviewListDelegate(this);
|
||||
previewList->setItemDelegate(listDelegate);
|
||||
previewList->header()->resizeSection(0, 200);
|
||||
@ -71,7 +72,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent)
|
||||
previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName));
|
||||
previewListModel->setData(previewListModel->index(row, SIZE), QVariant((qlonglong)h.filesize_at(i)));
|
||||
previewListModel->setData(previewListModel->index(row, PROGRESS), QVariant((double)fp[i]/h.filesize_at(i)));
|
||||
indexes << i;
|
||||
previewListModel->setData(previewListModel->index(row, FILE_INDEX), QVariant(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,26 +105,19 @@ PreviewSelect::~PreviewSelect() {
|
||||
|
||||
void PreviewSelect::on_previewButton_clicked() {
|
||||
QModelIndex index;
|
||||
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME);
|
||||
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(FILE_INDEX);
|
||||
if (selectedIndexes.size() == 0) return;
|
||||
// Flush data
|
||||
h.flush_cache();
|
||||
|
||||
QStringList absolute_paths(h.absolute_files_path());
|
||||
QString path;
|
||||
foreach (index, selectedIndexes) {
|
||||
path = absolute_paths.at(indexes.at(index.row()));
|
||||
// File
|
||||
if (QFile::exists(path)) {
|
||||
emit readyToPreviewFile(path);
|
||||
} else {
|
||||
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||
}
|
||||
close();
|
||||
return;
|
||||
}
|
||||
qDebug("Cannot find file: %s", path.toLocal8Bit().data());
|
||||
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||
//only one file should be selected
|
||||
QString path = absolute_paths.at(selectedIndexes.at(0).data().toInt());
|
||||
// File
|
||||
if (QFile::exists(path))
|
||||
emit readyToPreviewFile(path);
|
||||
else
|
||||
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||
close();
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class PreviewSelect: public QDialog, private Ui::preview {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum PreviewColumn { NAME, SIZE, PROGRESS, NB_COLUMNS };
|
||||
enum PreviewColumn { NAME, SIZE, PROGRESS, FILE_INDEX, NB_COLUMNS };
|
||||
|
||||
public:
|
||||
PreviewSelect(QWidget* parent, QTorrentHandle h);
|
||||
@ -63,7 +63,6 @@ private:
|
||||
QStandardItemModel *previewListModel;
|
||||
PreviewListDelegate *listDelegate;
|
||||
QTorrentHandle h;
|
||||
QList<int> indexes;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user