|
|
@ -44,7 +44,6 @@ class previewSelect: public QDialog, private Ui::preview { |
|
|
|
private: |
|
|
|
private: |
|
|
|
QStandardItemModel *previewListModel; |
|
|
|
QStandardItemModel *previewListModel; |
|
|
|
PreviewListDelegate *listDelegate; |
|
|
|
PreviewListDelegate *listDelegate; |
|
|
|
QStringList supported_preview_extensions; |
|
|
|
|
|
|
|
QTorrentHandle h; |
|
|
|
QTorrentHandle h; |
|
|
|
|
|
|
|
|
|
|
|
signals: |
|
|
|
signals: |
|
|
@ -53,36 +52,22 @@ class previewSelect: public QDialog, private Ui::preview { |
|
|
|
protected slots: |
|
|
|
protected slots: |
|
|
|
void on_previewButton_clicked(){ |
|
|
|
void on_previewButton_clicked(){ |
|
|
|
QModelIndex index; |
|
|
|
QModelIndex index; |
|
|
|
bool found = false; |
|
|
|
|
|
|
|
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedIndexes(); |
|
|
|
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedIndexes(); |
|
|
|
|
|
|
|
if(selectedIndexes.size() == 0) return; |
|
|
|
|
|
|
|
QString path; |
|
|
|
foreach(index, selectedIndexes){ |
|
|
|
foreach(index, selectedIndexes){ |
|
|
|
if(index.column() == NAME){ |
|
|
|
if(index.column() == NAME){ |
|
|
|
QString root_path = h.save_path(); |
|
|
|
path = h.files_path().at(index.row()); |
|
|
|
if(root_path.at(root_path.length()-1) != QDir::separator()){ |
|
|
|
|
|
|
|
root_path += QString::fromUtf8("/"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Get the file name
|
|
|
|
|
|
|
|
QString fileName = index.data().toString(); |
|
|
|
|
|
|
|
// File
|
|
|
|
// File
|
|
|
|
if(QFile::exists(root_path+fileName)){ |
|
|
|
if(QFile::exists(path)){ |
|
|
|
emit readyToPreviewFile(root_path+fileName); |
|
|
|
emit readyToPreviewFile(path); |
|
|
|
found = true; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
// Folder
|
|
|
|
|
|
|
|
QString folder_name = h.name(); |
|
|
|
|
|
|
|
// Will find the file even if it is in a sub directory
|
|
|
|
|
|
|
|
QString result = misc::findFileInDir(root_path+folder_name, fileName); |
|
|
|
|
|
|
|
if(!result.isNull()){ |
|
|
|
|
|
|
|
emit readyToPreviewFile(result); |
|
|
|
|
|
|
|
found = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
close(); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(!found){ |
|
|
|
qDebug("Cannot find file: %s", path.toUtf8().data()); |
|
|
|
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(); |
|
|
|
close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -102,7 +87,6 @@ class previewSelect: public QDialog, private Ui::preview { |
|
|
|
previewList->setModel(previewListModel); |
|
|
|
previewList->setModel(previewListModel); |
|
|
|
listDelegate = new PreviewListDelegate(this); |
|
|
|
listDelegate = new PreviewListDelegate(this); |
|
|
|
previewList->setItemDelegate(listDelegate); |
|
|
|
previewList->setItemDelegate(listDelegate); |
|
|
|
supported_preview_extensions << QString::fromUtf8("AVI") << QString::fromUtf8("DIVX") << QString::fromUtf8("MPG") << QString::fromUtf8("MPEG") << QString::fromUtf8("MPE") << QString::fromUtf8("MP3") << QString::fromUtf8("OGG") << QString::fromUtf8("WMV") << QString::fromUtf8("WMA") << QString::fromUtf8("RMV") << QString::fromUtf8("RMVB") << QString::fromUtf8("ASF") << QString::fromUtf8("MOV") << QString::fromUtf8("WAV") << QString::fromUtf8("MP2") << QString::fromUtf8("SWF") << QString::fromUtf8("AC3") << QString::fromUtf8("OGM") << QString::fromUtf8("MP4") << QString::fromUtf8("FLV") << QString::fromUtf8("VOB") << QString::fromUtf8("QT") << QString::fromUtf8("MKV") << QString::fromUtf8("AIF") << QString::fromUtf8("AIFF") << QString::fromUtf8("AIFC") << QString::fromUtf8("MID") << QString::fromUtf8("MPG") << QString::fromUtf8("RA") << QString::fromUtf8("RAM") << QString::fromUtf8("AU") << QString::fromUtf8("M4A") << QString::fromUtf8("FLAC") << QString::fromUtf8("M4P") << QString::fromUtf8("3GP") << QString::fromUtf8("AAC") << QString::fromUtf8("RM") << QString::fromUtf8("SWA") << QString::fromUtf8("MPC") << QString::fromUtf8("MPP"); |
|
|
|
|
|
|
|
previewList->header()->resizeSection(0, 200); |
|
|
|
previewList->header()->resizeSection(0, 200); |
|
|
|
// Fill list in
|
|
|
|
// Fill list in
|
|
|
|
std::vector<float> fp; |
|
|
|
std::vector<float> fp; |
|
|
@ -111,7 +95,7 @@ class previewSelect: public QDialog, private Ui::preview { |
|
|
|
for(unsigned int i=0; i<nbFiles; ++i){ |
|
|
|
for(unsigned int i=0; i<nbFiles; ++i){ |
|
|
|
QString fileName = h.file_at(i); |
|
|
|
QString fileName = h.file_at(i); |
|
|
|
QString extension = fileName.split(QString::fromUtf8(".")).last().toUpper(); |
|
|
|
QString extension = fileName.split(QString::fromUtf8(".")).last().toUpper(); |
|
|
|
if(supported_preview_extensions.indexOf(extension) >= 0){ |
|
|
|
if(misc::isPreviewable(extension)) { |
|
|
|
int row = previewListModel->rowCount(); |
|
|
|
int row = previewListModel->rowCount(); |
|
|
|
previewListModel->insertRow(row); |
|
|
|
previewListModel->insertRow(row); |
|
|
|
previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName)); |
|
|
|
previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName)); |
|
|
|