Browse Source

FEATURE: Files contained in a torrent are opened on double click (files panel)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
a18e325c18
  1. 1
      Changelog
  2. 18
      src/propertieswidget.cpp
  3. 1
      src/propertieswidget.h
  4. 4
      src/qtorrenthandle.cpp

1
Changelog

@ -11,6 +11,7 @@
- FEATURE: qBittorrent can identify itself as uTorrent, Vuze or KTorrent (Any stable version) - FEATURE: qBittorrent can identify itself as uTorrent, Vuze or KTorrent (Any stable version)
- FEATURE: Torrents can be renamed in transfer list - FEATURE: Torrents can be renamed in transfer list
- FEATURE: Display torrent addition dialog for magnet links too - FEATURE: Display torrent addition dialog for magnet links too
- FEATURE: Files contained in a torrent are opened on double click (files panel)
- BUGFIX: Use XDG folders (.cache, .local) instead of .qbittorrent - BUGFIX: Use XDG folders (.cache, .local) instead of .qbittorrent
- COSMETIC: Use checkboxes to filter torrent content instead of comboboxes - COSMETIC: Use checkboxes to filter torrent content instead of comboboxes
- COSMETIC: Use alternating row colors in transfer list (set in program preferences) - COSMETIC: Use alternating row colors in transfer list (set in program preferences)

18
src/propertieswidget.cpp

@ -38,6 +38,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>
#include <QFileDialog> #include <QFileDialog>
#include <QDesktopServices>
#include <QInputDialog> #include <QInputDialog>
#include "propertieswidget.h" #include "propertieswidget.h"
#include "transferlistwidget.h" #include "transferlistwidget.h"
@ -83,6 +84,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi
connect(collapseAllButton, SIGNAL(clicked()), filesList, SLOT(collapseAll())); connect(collapseAllButton, SIGNAL(clicked()), filesList, SLOT(collapseAll()));
connect(expandAllButton, SIGNAL(clicked()), filesList, SLOT(expandAll())); connect(expandAllButton, SIGNAL(clicked()), filesList, SLOT(expandAll()));
connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&))); connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
connect(filesList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openDoubleClickedFile(QModelIndex)));
connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
connect(addWS_button, SIGNAL(clicked()), this, SLOT(askWebSeed())); connect(addWS_button, SIGNAL(clicked()), this, SLOT(askWebSeed()));
connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds())); connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds()));
@ -467,6 +469,22 @@ void PropertiesWidget::on_files_button_clicked() {
} }
} }
void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
if(!index.isValid()) return;
if(!h.is_valid() || !h.has_metadata()) return;
if(PropListModel->getType(index) == TFILE) {
int i = PropListModel->getFileIndex(index);
QDir saveDir(h.save_path());
QString filename = misc::toQString(h.get_torrent_info().file_at(i).path.string());
QString file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename));
qDebug("Trying to open file at %s", file_path.toLocal8Bit().data());
if(QFile::exists(file_path))
QDesktopServices::openUrl("file://"+file_path);
else
QMessageBox::warning(this, tr("I/O Error"), tr("This file does not exist yet."));
}
}
void PropertiesWidget::displayFilesListMenu(const QPoint&){ void PropertiesWidget::displayFilesListMenu(const QPoint&){
QMenu myFilesLlistMenu; QMenu myFilesLlistMenu;
QModelIndexList selectedRows = filesList->selectionModel()->selectedRows(0); QModelIndexList selectedRows = filesList->selectionModel()->selectedRows(0);

1
src/propertieswidget.h

@ -100,6 +100,7 @@ public slots:
void readSettings(); void readSettings();
void saveSettings(); void saveSettings();
void reloadPreferences(); void reloadPreferences();
void openDoubleClickedFile(QModelIndex);
public: public:
PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, Bittorrent* BTSession); PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, Bittorrent* BTSession);

4
src/qtorrenthandle.cpp

@ -357,11 +357,11 @@ size_type QTorrentHandle::total_payload_upload() {
// to all files in a torrent // to all files in a torrent
QStringList QTorrentHandle::files_path() const { QStringList QTorrentHandle::files_path() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
QString saveDir = misc::toQString(h.save_path().string()) + QDir::separator(); QDir saveDir(misc::toQString(h.save_path().string()));
QStringList res; QStringList res;
torrent_info::file_iterator fi = h.get_torrent_info().begin_files(); torrent_info::file_iterator fi = h.get_torrent_info().begin_files();
while(fi != h.get_torrent_info().end_files()) { while(fi != h.get_torrent_info().end_files()) {
res << QDir::cleanPath(saveDir + misc::toQString(fi->path.string())); res << QDir::cleanPath(saveDir.absoluteFilePath(misc::toQString(fi->path.string())));
fi++; fi++;
} }
return res; return res;

Loading…
Cancel
Save