|
|
|
@ -50,32 +50,32 @@ using namespace libtorrent;
@@ -50,32 +50,32 @@ using namespace libtorrent;
|
|
|
|
|
class previewSelect: public QDialog, private Ui::preview { |
|
|
|
|
Q_OBJECT |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
private: |
|
|
|
|
QStandardItemModel *previewListModel; |
|
|
|
|
PreviewListDelegate *listDelegate; |
|
|
|
|
QTorrentHandle h; |
|
|
|
|
QList<int> indexes; |
|
|
|
|
|
|
|
|
|
signals: |
|
|
|
|
signals: |
|
|
|
|
void readyToPreviewFile(QString) const; |
|
|
|
|
|
|
|
|
|
protected slots: |
|
|
|
|
protected slots: |
|
|
|
|
void on_previewButton_clicked(){ |
|
|
|
|
QModelIndex index; |
|
|
|
|
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedIndexes(); |
|
|
|
|
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME); |
|
|
|
|
if(selectedIndexes.size() == 0) return; |
|
|
|
|
QString path; |
|
|
|
|
foreach(index, selectedIndexes){ |
|
|
|
|
if(index.column() == NAME){ |
|
|
|
|
path = h.files_path().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")); |
|
|
|
|
close(); |
|
|
|
@ -85,7 +85,7 @@ class previewSelect: public QDialog, private Ui::preview {
@@ -85,7 +85,7 @@ class previewSelect: public QDialog, private Ui::preview {
|
|
|
|
|
close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
public: |
|
|
|
|
previewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h){ |
|
|
|
|
setupUi(this); |
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
@ -123,9 +123,11 @@ class previewSelect: public QDialog, private Ui::preview {
@@ -123,9 +123,11 @@ class previewSelect: public QDialog, private Ui::preview {
|
|
|
|
|
} |
|
|
|
|
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString))); |
|
|
|
|
if(previewListModel->rowCount() == 1){ |
|
|
|
|
qDebug("Torrent file only contains one file, no need to display selection dialog before preview"); |
|
|
|
|
// Only one file : no choice
|
|
|
|
|
on_previewButton_clicked(); |
|
|
|
|
}else{ |
|
|
|
|
qDebug("Displaying media file selection dialog for preview"); |
|
|
|
|
show(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|