|
|
@ -52,6 +52,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent) |
|
|
|
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size")); |
|
|
|
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size")); |
|
|
|
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress")); |
|
|
|
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress")); |
|
|
|
previewList->setModel(previewListModel); |
|
|
|
previewList->setModel(previewListModel); |
|
|
|
|
|
|
|
previewList->hideColumn(FILE_INDEX); |
|
|
|
listDelegate = new PreviewListDelegate(this); |
|
|
|
listDelegate = new PreviewListDelegate(this); |
|
|
|
previewList->setItemDelegate(listDelegate); |
|
|
|
previewList->setItemDelegate(listDelegate); |
|
|
|
previewList->header()->resizeSection(0, 200); |
|
|
|
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, NAME), QVariant(fileName)); |
|
|
|
previewListModel->setData(previewListModel->index(row, SIZE), QVariant((qlonglong)h.filesize_at(i))); |
|
|
|
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))); |
|
|
|
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() { |
|
|
|
void PreviewSelect::on_previewButton_clicked() { |
|
|
|
QModelIndex index; |
|
|
|
QModelIndex index; |
|
|
|
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME); |
|
|
|
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(FILE_INDEX); |
|
|
|
if (selectedIndexes.size() == 0) return; |
|
|
|
if (selectedIndexes.size() == 0) return; |
|
|
|
// Flush data
|
|
|
|
// Flush data
|
|
|
|
h.flush_cache(); |
|
|
|
h.flush_cache(); |
|
|
|
|
|
|
|
|
|
|
|
QStringList absolute_paths(h.absolute_files_path()); |
|
|
|
QStringList absolute_paths(h.absolute_files_path()); |
|
|
|
QString path; |
|
|
|
//only one file should be selected
|
|
|
|
foreach (index, selectedIndexes) { |
|
|
|
QString path = absolute_paths.at(selectedIndexes.at(0).data().toInt()); |
|
|
|
path = absolute_paths.at(indexes.at(index.row())); |
|
|
|
// File
|
|
|
|
// File
|
|
|
|
if (QFile::exists(path)) |
|
|
|
if (QFile::exists(path)) { |
|
|
|
emit readyToPreviewFile(path); |
|
|
|
emit readyToPreviewFile(path); |
|
|
|
else |
|
|
|
} else { |
|
|
|
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file")); |
|
|
|
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")); |
|
|
|
|
|
|
|
close(); |
|
|
|
close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|