Handle .!qB extension behind the scenes

PR #15920.
This commit is contained in:
Vladimir Golovnev 2022-01-08 08:45:50 +03:00 committed by GitHub
parent 9f6130cbaa
commit f44341a8e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 63 additions and 105 deletions

View file

@ -28,6 +28,7 @@
#include "previewselectdialog.h"
#include <QDir>
#include <QFile>
#include <QHeaderView>
#include <QMessageBox>
@ -36,7 +37,6 @@
#include <QStandardItemModel>
#include <QTableView>
#include "base/bittorrent/common.h"
#include "base/bittorrent/torrent.h"
#include "base/preferences.h"
#include "base/utils/fs.h"
@ -91,9 +91,7 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
const QVector<qreal> fp = torrent->filesProgress();
for (int i = 0; i < torrent->filesCount(); ++i)
{
QString fileName = Utils::Fs::fileName(torrent->filePath(i));
if (fileName.endsWith(QB_EXT))
fileName.chop(QB_EXT.length());
const QString fileName = Utils::Fs::fileName(torrent->filePath(i));
if (Utils::Misc::isPreviewable(fileName))
{
int row = m_previewListModel->rowCount();
@ -128,9 +126,9 @@ void PreviewSelectDialog::previewButtonClicked()
// Flush data
m_torrent->flushCache();
const QStringList absolutePaths = m_torrent->absoluteFilePaths();
// Only one file should be selected
const QString path = absolutePaths.at(selectedIndexes.at(0).data().toInt());
const int fileIndex = selectedIndexes.at(0).data().toInt();
const QString path = QDir(m_torrent->actualStorageLocation()).absoluteFilePath(m_torrent->actualFilePath(fileIndex));
// File
if (!QFile::exists(path))
{