mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 15:56:17 -07:00
Coding style for many files
This commit is contained in:
parent
acdb7a27dc
commit
ae1634623e
23 changed files with 637 additions and 662 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -24,8 +24,6 @@
|
|||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "propertieswidget.h"
|
||||
|
@ -67,23 +65,23 @@
|
|||
|
||||
#include "ui_propertieswidget.h"
|
||||
|
||||
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, TransferListWidget *transferList)
|
||||
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, TransferListWidget *transferList)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::PropertiesWidget())
|
||||
, transferList(transferList)
|
||||
, main_window(main_window)
|
||||
, m_transferList(transferList)
|
||||
, m_mainWindow(mainWindow)
|
||||
, m_torrent(nullptr)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setAutoFillBackground(true);
|
||||
|
||||
state = VISIBLE;
|
||||
m_state = VISIBLE;
|
||||
|
||||
// Set Properties list model
|
||||
PropListModel = new TorrentContentFilterModel();
|
||||
m_ui->filesList->setModel(PropListModel);
|
||||
PropDelegate = new PropListDelegate(this);
|
||||
m_ui->filesList->setItemDelegate(PropDelegate);
|
||||
m_propListModel = new TorrentContentFilterModel();
|
||||
m_ui->filesList->setModel(m_propListModel);
|
||||
m_propListDelegate = new PropListDelegate(this);
|
||||
m_ui->filesList->setItemDelegate(m_propListDelegate);
|
||||
m_ui->filesList->setSortingEnabled(true);
|
||||
// Torrent content filtering
|
||||
m_contentFilterLine = new LineEdit(this);
|
||||
|
@ -94,17 +92,17 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
|
|||
|
||||
// SIGNAL/SLOTS
|
||||
connect(m_ui->filesList, SIGNAL(clicked(const QModelIndex&)), m_ui->filesList, SLOT(edit(const QModelIndex&)));
|
||||
connect(m_ui->selectAllButton, SIGNAL(clicked()), PropListModel, SLOT(selectAll()));
|
||||
connect(m_ui->selectNoneButton, SIGNAL(clicked()), PropListModel, SLOT(selectNone()));
|
||||
connect(m_ui->selectAllButton, SIGNAL(clicked()), m_propListModel, SLOT(selectAll()));
|
||||
connect(m_ui->selectNoneButton, SIGNAL(clicked()), m_propListModel, SLOT(selectNone()));
|
||||
connect(m_ui->filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
|
||||
connect(m_ui->filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(openDoubleClickedFile(const QModelIndex&)));
|
||||
connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||
connect(m_propListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||
connect(m_ui->listWebSeeds, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayWebSeedListMenu(const QPoint&)));
|
||||
connect(transferList, SIGNAL(currentTorrentChanged(BitTorrent::TorrentHandle * const)), this, SLOT(loadTorrentInfos(BitTorrent::TorrentHandle * const)));
|
||||
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||
connect(transferList, SIGNAL(currentTorrentChanged(BitTorrent::TorrentHandle *const)), this, SLOT(loadTorrentInfos(BitTorrent::TorrentHandle *const)));
|
||||
connect(m_propListDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||
connect(m_ui->stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
||||
connect(BitTorrent::Session::instance(), SIGNAL(torrentSavePathChanged(BitTorrent::TorrentHandle * const)), this, SLOT(updateSavePath(BitTorrent::TorrentHandle * const)));
|
||||
connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle * const)), this, SLOT(updateTorrentInfos(BitTorrent::TorrentHandle * const)));
|
||||
connect(BitTorrent::Session::instance(), SIGNAL(torrentSavePathChanged(BitTorrent::TorrentHandle *const)), this, SLOT(updateSavePath(BitTorrent::TorrentHandle *const)));
|
||||
connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle *const)), this, SLOT(updateTorrentInfos(BitTorrent::TorrentHandle *const)));
|
||||
connect(m_ui->filesList->header(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveSettings()));
|
||||
connect(m_ui->filesList->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveSettings()));
|
||||
connect(m_ui->filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
|
||||
|
@ -114,39 +112,39 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
|
|||
|
||||
// Downloaded pieces progress bar
|
||||
m_ui->tempProgressBarArea->setVisible(false);
|
||||
downloaded_pieces = new DownloadedPiecesBar(this);
|
||||
m_ui->groupBarLayout->addWidget(downloaded_pieces, 0, 1);
|
||||
downloaded_pieces->setFixedHeight(barHeight);
|
||||
downloaded_pieces->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_downloadedPieces = new DownloadedPiecesBar(this);
|
||||
m_ui->groupBarLayout->addWidget(m_downloadedPieces, 0, 1);
|
||||
m_downloadedPieces->setFixedHeight(barHeight);
|
||||
m_downloadedPieces->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
// Pieces availability bar
|
||||
m_ui->tempAvailabilityBarArea->setVisible(false);
|
||||
pieces_availability = new PieceAvailabilityBar(this);
|
||||
m_ui->groupBarLayout->addWidget(pieces_availability, 1, 1);
|
||||
pieces_availability->setFixedHeight(barHeight);
|
||||
pieces_availability->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_piecesAvailability = new PieceAvailabilityBar(this);
|
||||
m_ui->groupBarLayout->addWidget(m_piecesAvailability, 1, 1);
|
||||
m_piecesAvailability->setFixedHeight(barHeight);
|
||||
m_piecesAvailability->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
// Tracker list
|
||||
trackerList = new TrackerList(this);
|
||||
m_trackerList = new TrackerList(this);
|
||||
m_ui->trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up"));
|
||||
m_ui->trackerUpButton->setIconSize(Utils::Misc::smallIconSize());
|
||||
m_ui->trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down"));
|
||||
m_ui->trackerDownButton->setIconSize(Utils::Misc::smallIconSize());
|
||||
connect(m_ui->trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp()));
|
||||
connect(m_ui->trackerDownButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionDown()));
|
||||
m_ui->horizontalLayout_trackers->insertWidget(0, trackerList);
|
||||
connect(trackerList->header(), SIGNAL(sectionMoved(int,int,int)), trackerList, SLOT(saveSettings()));
|
||||
connect(trackerList->header(), SIGNAL(sectionResized(int,int,int)), trackerList, SLOT(saveSettings()));
|
||||
connect(trackerList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), trackerList, SLOT(saveSettings()));
|
||||
connect(m_ui->trackerUpButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionUp()));
|
||||
connect(m_ui->trackerDownButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionDown()));
|
||||
m_ui->horizontalLayout_trackers->insertWidget(0, m_trackerList);
|
||||
connect(m_trackerList->header(), SIGNAL(sectionMoved(int,int,int)), m_trackerList, SLOT(saveSettings()));
|
||||
connect(m_trackerList->header(), SIGNAL(sectionResized(int,int,int)), m_trackerList, SLOT(saveSettings()));
|
||||
connect(m_trackerList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), m_trackerList, SLOT(saveSettings()));
|
||||
// Peers list
|
||||
peersList = new PeerListWidget(this);
|
||||
m_ui->peerpage_layout->addWidget(peersList);
|
||||
connect(peersList->header(), SIGNAL(sectionMoved(int,int,int)), peersList, SLOT(saveSettings()));
|
||||
connect(peersList->header(), SIGNAL(sectionResized(int,int,int)), peersList, SLOT(saveSettings()));
|
||||
connect(peersList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), peersList, SLOT(saveSettings()));
|
||||
m_peerList = new PeerListWidget(this);
|
||||
m_ui->peerpage_layout->addWidget(m_peerList);
|
||||
connect(m_peerList->header(), SIGNAL(sectionMoved(int,int,int)), m_peerList, SLOT(saveSettings()));
|
||||
connect(m_peerList->header(), SIGNAL(sectionResized(int,int,int)), m_peerList, SLOT(saveSettings()));
|
||||
connect(m_peerList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), m_peerList, SLOT(saveSettings()));
|
||||
// Speed widget
|
||||
speedWidget = new SpeedWidget(this);
|
||||
m_ui->speed_layout->addWidget(speedWidget);
|
||||
m_speedWidget = new SpeedWidget(this);
|
||||
m_ui->speedLayout->addWidget(m_speedWidget);
|
||||
// Tab bar
|
||||
m_tabBar = new PropTabBar();
|
||||
m_tabBar->setContentsMargins(0, 5, 0, 0);
|
||||
|
@ -156,79 +154,79 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
|
|||
connect(m_tabBar, SIGNAL(visibilityToggled(bool)), SLOT(setVisibility(bool)));
|
||||
connect(m_tabBar, SIGNAL(visibilityToggled(bool)), this, SLOT(saveSettings()));
|
||||
// Dynamic data refresher
|
||||
refreshTimer = new QTimer(this);
|
||||
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
|
||||
refreshTimer->start(3000); // 3sec
|
||||
editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, 0, 0, Qt::WidgetShortcut);
|
||||
connect(editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile()));
|
||||
editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, 0, 0, Qt::WidgetShortcut);
|
||||
connect(editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed()));
|
||||
m_refreshTimer = new QTimer(this);
|
||||
connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
|
||||
m_refreshTimer->start(3000); // 3sec
|
||||
m_editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, 0, 0, Qt::WidgetShortcut);
|
||||
connect(m_editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile()));
|
||||
m_editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, 0, 0, Qt::WidgetShortcut);
|
||||
connect(m_editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed()));
|
||||
connect(m_ui->listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed()));
|
||||
deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, m_ui->listWebSeeds, 0, 0, Qt::WidgetShortcut);
|
||||
connect(deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds()));
|
||||
openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, 0, 0, Qt::WidgetShortcut);
|
||||
connect(openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile()));
|
||||
m_deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, m_ui->listWebSeeds, 0, 0, Qt::WidgetShortcut);
|
||||
connect(m_deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds()));
|
||||
m_openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, 0, 0, Qt::WidgetShortcut);
|
||||
connect(m_openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile()));
|
||||
}
|
||||
|
||||
PropertiesWidget::~PropertiesWidget()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "ENTER";
|
||||
delete refreshTimer;
|
||||
delete trackerList;
|
||||
delete peersList;
|
||||
delete speedWidget;
|
||||
delete downloaded_pieces;
|
||||
delete pieces_availability;
|
||||
delete PropListModel;
|
||||
delete PropDelegate;
|
||||
delete m_refreshTimer;
|
||||
delete m_trackerList;
|
||||
delete m_peerList;
|
||||
delete m_speedWidget;
|
||||
delete m_downloadedPieces;
|
||||
delete m_piecesAvailability;
|
||||
delete m_propListModel;
|
||||
delete m_propListDelegate;
|
||||
delete m_tabBar;
|
||||
delete editHotkeyFile;
|
||||
delete editHotkeyWeb;
|
||||
delete deleteHotkeyWeb;
|
||||
delete openHotkeyFile;
|
||||
delete m_editHotkeyFile;
|
||||
delete m_editHotkeyWeb;
|
||||
delete m_deleteHotkeyWeb;
|
||||
delete m_openHotkeyFile;
|
||||
delete m_ui;
|
||||
qDebug() << Q_FUNC_INFO << "EXIT";
|
||||
}
|
||||
|
||||
void PropertiesWidget::showPiecesAvailability(bool show)
|
||||
{
|
||||
m_ui->avail_pieces_lbl->setVisible(show);
|
||||
pieces_availability->setVisible(show);
|
||||
m_ui->avail_average_lbl->setVisible(show);
|
||||
if (show || !downloaded_pieces->isVisible())
|
||||
m_ui->line_2->setVisible(show);
|
||||
m_ui->labelPiecesAvailability->setVisible(show);
|
||||
m_piecesAvailability->setVisible(show);
|
||||
m_ui->labelAverageAvailabilityVal->setVisible(show);
|
||||
if (show || !m_downloadedPieces->isVisible())
|
||||
m_ui->lineBelowBars->setVisible(show);
|
||||
}
|
||||
|
||||
void PropertiesWidget::showPiecesDownloaded(bool show)
|
||||
{
|
||||
m_ui->downloaded_pieces_lbl->setVisible(show);
|
||||
downloaded_pieces->setVisible(show);
|
||||
m_ui->progress_lbl->setVisible(show);
|
||||
if (show || !pieces_availability->isVisible())
|
||||
m_ui->line_2->setVisible(show);
|
||||
m_ui->labelDownloadedPieces->setVisible(show);
|
||||
m_downloadedPieces->setVisible(show);
|
||||
m_ui->labelProgressVal->setVisible(show);
|
||||
if (show || !m_piecesAvailability->isVisible())
|
||||
m_ui->lineBelowBars->setVisible(show);
|
||||
}
|
||||
|
||||
void PropertiesWidget::setVisibility(bool visible)
|
||||
{
|
||||
if (!visible && (state == VISIBLE)) {
|
||||
if (!visible && (m_state == VISIBLE)) {
|
||||
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
|
||||
m_ui->stackedProperties->setVisible(false);
|
||||
slideSizes = hSplitter->sizes();
|
||||
m_slideSizes = hSplitter->sizes();
|
||||
hSplitter->handle(1)->setVisible(false);
|
||||
hSplitter->handle(1)->setDisabled(true);
|
||||
QList<int> sizes = QList<int>() << hSplitter->geometry().height() - 30 << 30;
|
||||
hSplitter->setSizes(sizes);
|
||||
state = REDUCED;
|
||||
m_state = REDUCED;
|
||||
return;
|
||||
}
|
||||
|
||||
if (visible && (state == REDUCED)) {
|
||||
if (visible && (m_state == REDUCED)) {
|
||||
m_ui->stackedProperties->setVisible(true);
|
||||
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
|
||||
hSplitter->handle(1)->setDisabled(false);
|
||||
hSplitter->handle(1)->setVisible(true);
|
||||
hSplitter->setSizes(slideSizes);
|
||||
state = VISIBLE;
|
||||
hSplitter->setSizes(m_slideSizes);
|
||||
m_state = VISIBLE;
|
||||
// Force refresh
|
||||
loadDynamicData();
|
||||
}
|
||||
|
@ -237,39 +235,39 @@ void PropertiesWidget::setVisibility(bool visible)
|
|||
void PropertiesWidget::clear()
|
||||
{
|
||||
qDebug("Clearing torrent properties");
|
||||
m_ui->save_path->clear();
|
||||
m_ui->lbl_creationDate->clear();
|
||||
m_ui->label_total_pieces_val->clear();
|
||||
m_ui->hash_lbl->clear();
|
||||
m_ui->comment_text->clear();
|
||||
m_ui->progress_lbl->clear();
|
||||
trackerList->clear();
|
||||
downloaded_pieces->clear();
|
||||
pieces_availability->clear();
|
||||
m_ui->avail_average_lbl->clear();
|
||||
m_ui->wasted->clear();
|
||||
m_ui->upTotal->clear();
|
||||
m_ui->dlTotal->clear();
|
||||
peersList->clear();
|
||||
m_ui->lbl_uplimit->clear();
|
||||
m_ui->lbl_dllimit->clear();
|
||||
m_ui->lbl_elapsed->clear();
|
||||
m_ui->lbl_connections->clear();
|
||||
m_ui->reannounce_lbl->clear();
|
||||
m_ui->shareRatio->clear();
|
||||
m_ui->labelSavePathVal->clear();
|
||||
m_ui->labelCreatedOnVal->clear();
|
||||
m_ui->labelTotalPiecesVal->clear();
|
||||
m_ui->labelHashVal->clear();
|
||||
m_ui->labelCommentVal->clear();
|
||||
m_ui->labelProgressVal->clear();
|
||||
m_ui->labelAverageAvailabilityVal->clear();
|
||||
m_ui->labelWastedVal->clear();
|
||||
m_ui->labelUpTotalVal->clear();
|
||||
m_ui->labelDlTotalVal->clear();
|
||||
m_ui->labelUpLimitVal->clear();
|
||||
m_ui->labelDlLimitVal->clear();
|
||||
m_ui->labelElapsedVal->clear();
|
||||
m_ui->labelConnectionsVal->clear();
|
||||
m_ui->labelReannounceInVal->clear();
|
||||
m_ui->labelShareRatioVal->clear();
|
||||
m_ui->listWebSeeds->clear();
|
||||
m_ui->labelETAVal->clear();
|
||||
m_ui->labelSeedsVal->clear();
|
||||
m_ui->labelPeersVal->clear();
|
||||
m_ui->labelDlSpeedVal->clear();
|
||||
m_ui->labelUpSpeedVal->clear();
|
||||
m_ui->labelTotalSizeVal->clear();
|
||||
m_ui->labelCompletedOnVal->clear();
|
||||
m_ui->labelLastSeenCompleteVal->clear();
|
||||
m_ui->labelCreatedByVal->clear();
|
||||
m_ui->labelAddedOnVal->clear();
|
||||
m_trackerList->clear();
|
||||
m_downloadedPieces->clear();
|
||||
m_piecesAvailability->clear();
|
||||
m_peerList->clear();
|
||||
m_contentFilterLine->clear();
|
||||
PropListModel->model()->clear();
|
||||
m_ui->label_eta_val->clear();
|
||||
m_ui->label_seeds_val->clear();
|
||||
m_ui->label_peers_val->clear();
|
||||
m_ui->label_dl_speed_val->clear();
|
||||
m_ui->label_upload_speed_val->clear();
|
||||
m_ui->label_total_size_val->clear();
|
||||
m_ui->label_completed_on_val->clear();
|
||||
m_ui->label_last_complete_val->clear();
|
||||
m_ui->label_created_by_val->clear();
|
||||
m_ui->label_added_on_val->clear();
|
||||
m_propListModel->model()->clear();
|
||||
}
|
||||
|
||||
BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const
|
||||
|
@ -277,26 +275,41 @@ BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const
|
|||
return m_torrent;
|
||||
}
|
||||
|
||||
TrackerList *PropertiesWidget::getTrackerList() const
|
||||
{
|
||||
return m_trackerList;
|
||||
}
|
||||
|
||||
PeerListWidget *PropertiesWidget::getPeerList() const
|
||||
{
|
||||
return m_peerList;
|
||||
}
|
||||
|
||||
QTreeView *PropertiesWidget::getFilesList() const
|
||||
{
|
||||
return m_ui->filesList;
|
||||
}
|
||||
|
||||
SpeedWidget *PropertiesWidget::getSpeedWidget() const
|
||||
{
|
||||
return m_speedWidget;
|
||||
}
|
||||
|
||||
void PropertiesWidget::updateSavePath(BitTorrent::TorrentHandle *const torrent)
|
||||
{
|
||||
if (m_torrent == torrent)
|
||||
m_ui->save_path->setText(Utils::Fs::toNativePath(m_torrent->savePath()));
|
||||
if (torrent == m_torrent)
|
||||
m_ui->labelSavePathVal->setText(Utils::Fs::toNativePath(m_torrent->savePath()));
|
||||
}
|
||||
|
||||
void PropertiesWidget::loadTrackers(BitTorrent::TorrentHandle *const torrent)
|
||||
{
|
||||
if (torrent == m_torrent)
|
||||
trackerList->loadTrackers();
|
||||
m_trackerList->loadTrackers();
|
||||
}
|
||||
|
||||
void PropertiesWidget::updateTorrentInfos(BitTorrent::TorrentHandle *const torrent)
|
||||
{
|
||||
if (m_torrent == torrent)
|
||||
if (torrent == m_torrent)
|
||||
loadTorrentInfos(m_torrent);
|
||||
}
|
||||
|
||||
|
@ -304,36 +317,36 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent
|
|||
{
|
||||
clear();
|
||||
m_torrent = torrent;
|
||||
downloaded_pieces->setTorrent(m_torrent);
|
||||
pieces_availability->setTorrent(m_torrent);
|
||||
m_downloadedPieces->setTorrent(m_torrent);
|
||||
m_piecesAvailability->setTorrent(m_torrent);
|
||||
if (!m_torrent) return;
|
||||
|
||||
// Save path
|
||||
updateSavePath(m_torrent);
|
||||
// Hash
|
||||
m_ui->hash_lbl->setText(m_torrent->hash());
|
||||
PropListModel->model()->clear();
|
||||
m_ui->labelHashVal->setText(m_torrent->hash());
|
||||
m_propListModel->model()->clear();
|
||||
if (m_torrent->hasMetadata()) {
|
||||
// Creation date
|
||||
m_ui->lbl_creationDate->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate));
|
||||
m_ui->labelCreatedOnVal->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate));
|
||||
|
||||
m_ui->label_total_size_val->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize()));
|
||||
m_ui->labelTotalSizeVal->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize()));
|
||||
|
||||
// Comment
|
||||
m_ui->comment_text->setText(Utils::Misc::parseHtmlLinks(m_torrent->comment().toHtmlEscaped()));
|
||||
m_ui->labelCommentVal->setText(Utils::Misc::parseHtmlLinks(m_torrent->comment().toHtmlEscaped()));
|
||||
|
||||
// URL seeds
|
||||
loadUrlSeeds();
|
||||
|
||||
m_ui->label_created_by_val->setText(m_torrent->creator().toHtmlEscaped());
|
||||
m_ui->labelCreatedByVal->setText(m_torrent->creator().toHtmlEscaped());
|
||||
|
||||
// List files in torrent
|
||||
PropListModel->model()->setupModelData(m_torrent->info());
|
||||
if (PropListModel->model()->rowCount() == 1)
|
||||
m_ui->filesList->setExpanded(PropListModel->index(0, 0), true);
|
||||
m_propListModel->model()->setupModelData(m_torrent->info());
|
||||
if (m_propListModel->model()->rowCount() == 1)
|
||||
m_ui->filesList->setExpanded(m_propListModel->index(0, 0), true);
|
||||
|
||||
// Load file priorities
|
||||
PropListModel->model()->updateFilesPriorities(m_torrent->filePriorities());
|
||||
m_propListModel->model()->updateFilesPriorities(m_torrent->filePriorities());
|
||||
}
|
||||
// Load dynamic data
|
||||
loadDynamicData();
|
||||
|
@ -343,12 +356,12 @@ void PropertiesWidget::readSettings()
|
|||
{
|
||||
const Preferences *const pref = Preferences::instance();
|
||||
// Restore splitter sizes
|
||||
QStringList sizes_str = pref->getPropSplitterSizes().split(",");
|
||||
if (sizes_str.size() == 2) {
|
||||
slideSizes << sizes_str.first().toInt();
|
||||
slideSizes << sizes_str.last().toInt();
|
||||
QStringList sizesStr = pref->getPropSplitterSizes().split(",");
|
||||
if (sizesStr.size() == 2) {
|
||||
m_slideSizes << sizesStr.first().toInt();
|
||||
m_slideSizes << sizesStr.last().toInt();
|
||||
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
|
||||
hSplitter->setSizes(slideSizes);
|
||||
hSplitter->setSizes(m_slideSizes);
|
||||
}
|
||||
const int current_tab = pref->getPropCurTab();
|
||||
const bool visible = pref->getPropVisible();
|
||||
|
@ -363,14 +376,14 @@ void PropertiesWidget::readSettings()
|
|||
void PropertiesWidget::saveSettings()
|
||||
{
|
||||
Preferences *const pref = Preferences::instance();
|
||||
pref->setPropVisible(state == VISIBLE);
|
||||
pref->setPropVisible(m_state == VISIBLE);
|
||||
// Splitter sizes
|
||||
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
|
||||
QList<int> sizes;
|
||||
if (state == VISIBLE)
|
||||
if (m_state == VISIBLE)
|
||||
sizes = hSplitter->sizes();
|
||||
else
|
||||
sizes = slideSizes;
|
||||
sizes = m_slideSizes;
|
||||
qDebug("Sizes: %d", sizes.size());
|
||||
if (sizes.size() == 2)
|
||||
pref->setPropSplitterSizes(QString::number(sizes.first()) + ',' + QString::number(sizes.last()));
|
||||
|
@ -382,118 +395,112 @@ void PropertiesWidget::saveSettings()
|
|||
void PropertiesWidget::reloadPreferences()
|
||||
{
|
||||
// Take program preferences into consideration
|
||||
peersList->updatePeerHostNameResolutionState();
|
||||
peersList->updatePeerCountryResolutionState();
|
||||
m_peerList->updatePeerHostNameResolutionState();
|
||||
m_peerList->updatePeerCountryResolutionState();
|
||||
}
|
||||
|
||||
void PropertiesWidget::loadDynamicData()
|
||||
{
|
||||
// Refresh only if the torrent handle is valid and if visible
|
||||
if (!m_torrent || (main_window->currentTabWidget() != transferList) || (state != VISIBLE)) return;
|
||||
// Refresh only if the torrent handle is valid and visible
|
||||
if (!m_torrent || (m_mainWindow->currentTabWidget() != m_transferList) || (m_state != VISIBLE)) return;
|
||||
|
||||
// Transfer infos
|
||||
switch (m_ui->stackedProperties->currentIndex()) {
|
||||
case PropTabBar::MAIN_TAB: {
|
||||
m_ui->wasted->setText(Utils::Misc::friendlyUnit(m_torrent->wastedSize()));
|
||||
case PropTabBar::MainTab: {
|
||||
m_ui->labelWastedVal->setText(Utils::Misc::friendlyUnit(m_torrent->wastedSize()));
|
||||
|
||||
m_ui->upTotal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload()))
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload())));
|
||||
m_ui->labelUpTotalVal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload()))
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload())));
|
||||
|
||||
m_ui->dlTotal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload()))
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload())));
|
||||
m_ui->labelDlTotalVal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload()))
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload())));
|
||||
|
||||
m_ui->lbl_uplimit->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->uploadLimit(), true));
|
||||
m_ui->labelUpLimitVal->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->uploadLimit(), true));
|
||||
|
||||
m_ui->lbl_dllimit->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->downloadLimit(), true));
|
||||
m_ui->labelDlLimitVal->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->downloadLimit(), true));
|
||||
|
||||
QString elapsed_txt;
|
||||
if (m_torrent->isSeed())
|
||||
elapsed_txt = tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)")
|
||||
.arg(Utils::Misc::userFriendlyDuration(m_torrent->activeTime()))
|
||||
.arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()));
|
||||
else
|
||||
elapsed_txt = Utils::Misc::userFriendlyDuration(m_torrent->activeTime());
|
||||
m_ui->lbl_elapsed->setText(elapsed_txt);
|
||||
QString elapsedString;
|
||||
if (m_torrent->isSeed())
|
||||
elapsedString = tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)")
|
||||
.arg(Utils::Misc::userFriendlyDuration(m_torrent->activeTime()))
|
||||
.arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()));
|
||||
else
|
||||
elapsedString = Utils::Misc::userFriendlyDuration(m_torrent->activeTime());
|
||||
m_ui->labelElapsedVal->setText(elapsedString);
|
||||
|
||||
m_ui->lbl_connections->setText(tr("%1 (%2 max)", "%1 and %2 are numbers, e.g. 3 (10 max)")
|
||||
.arg(m_torrent->connectionsCount())
|
||||
.arg(m_torrent->connectionsLimit() < 0 ? QString::fromUtf8(C_INFINITY) : QString::number(m_torrent->connectionsLimit())));
|
||||
m_ui->labelConnectionsVal->setText(tr("%1 (%2 max)", "%1 and %2 are numbers, e.g. 3 (10 max)")
|
||||
.arg(m_torrent->connectionsCount())
|
||||
.arg(m_torrent->connectionsLimit() < 0 ? QString::fromUtf8(C_INFINITY) : QString::number(m_torrent->connectionsLimit())));
|
||||
|
||||
m_ui->label_eta_val->setText(Utils::Misc::userFriendlyDuration(m_torrent->eta()));
|
||||
m_ui->labelETAVal->setText(Utils::Misc::userFriendlyDuration(m_torrent->eta()));
|
||||
|
||||
// Update next announce time
|
||||
m_ui->reannounce_lbl->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce()));
|
||||
// Update next announce time
|
||||
m_ui->labelReannounceInVal->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce()));
|
||||
|
||||
// Update ratio info
|
||||
const qreal ratio = m_torrent->realRatio();
|
||||
m_ui->shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2));
|
||||
// Update ratio info
|
||||
const qreal ratio = m_torrent->realRatio();
|
||||
m_ui->labelShareRatioVal->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2));
|
||||
|
||||
m_ui->label_seeds_val->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)")
|
||||
.arg(QString::number(m_torrent->seedsCount()))
|
||||
.arg(QString::number(m_torrent->totalSeedsCount())));
|
||||
m_ui->labelSeedsVal->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)")
|
||||
.arg(QString::number(m_torrent->seedsCount()))
|
||||
.arg(QString::number(m_torrent->totalSeedsCount())));
|
||||
|
||||
m_ui->label_peers_val->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)")
|
||||
.arg(QString::number(m_torrent->leechsCount()))
|
||||
.arg(QString::number(m_torrent->totalLeechersCount())));
|
||||
m_ui->labelPeersVal->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)")
|
||||
.arg(QString::number(m_torrent->leechsCount()))
|
||||
.arg(QString::number(m_torrent->totalLeechersCount())));
|
||||
|
||||
m_ui->label_dl_speed_val->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)")
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->downloadPayloadRate(), true))
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload() / (1 + m_torrent->activeTime() - m_torrent->finishedTime()), true)));
|
||||
m_ui->labelDlSpeedVal->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)")
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->downloadPayloadRate(), true))
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload() / (1 + m_torrent->activeTime() - m_torrent->finishedTime()), true)));
|
||||
|
||||
m_ui->label_upload_speed_val->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)")
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate(), true))
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload() / (1 + m_torrent->activeTime()), true)));
|
||||
m_ui->labelUpSpeedVal->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)")
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate(), true))
|
||||
.arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload() / (1 + m_torrent->activeTime()), true)));
|
||||
|
||||
m_ui->label_last_complete_val->setText(m_torrent->lastSeenComplete().isValid() ? m_torrent->lastSeenComplete().toString(Qt::DefaultLocaleShortDate) : tr("Never"));
|
||||
m_ui->labelLastSeenCompleteVal->setText(m_torrent->lastSeenComplete().isValid() ? m_torrent->lastSeenComplete().toString(Qt::DefaultLocaleShortDate) : tr("Never"));
|
||||
|
||||
m_ui->label_completed_on_val->setText(m_torrent->completedTime().isValid() ? m_torrent->completedTime().toString(Qt::DefaultLocaleShortDate) : "");
|
||||
m_ui->labelCompletedOnVal->setText(m_torrent->completedTime().isValid() ? m_torrent->completedTime().toString(Qt::DefaultLocaleShortDate) : "");
|
||||
|
||||
m_ui->label_added_on_val->setText(m_torrent->addedTime().toString(Qt::DefaultLocaleShortDate));
|
||||
m_ui->labelAddedOnVal->setText(m_torrent->addedTime().toString(Qt::DefaultLocaleShortDate));
|
||||
|
||||
if (m_torrent->hasMetadata()) {
|
||||
m_ui->label_total_pieces_val->setText(tr("%1 x %2 (have %3)", "(torrent pieces) eg 152 x 4MB (have 25)").arg(m_torrent->piecesCount()).arg(Utils::Misc::friendlyUnit(m_torrent->pieceLength())).arg(m_torrent->piecesHave()));
|
||||
if (m_torrent->hasMetadata()) {
|
||||
m_ui->labelTotalPiecesVal->setText(tr("%1 x %2 (have %3)", "(torrent pieces) eg 152 x 4MB (have 25)").arg(m_torrent->piecesCount()).arg(Utils::Misc::friendlyUnit(m_torrent->pieceLength())).arg(m_torrent->piecesHave()));
|
||||
|
||||
if (!m_torrent->isSeed() && !m_torrent->isPaused() && !m_torrent->isQueued() && !m_torrent->isChecking()) {
|
||||
// Pieces availability
|
||||
showPiecesAvailability(true);
|
||||
pieces_availability->setAvailability(m_torrent->pieceAvailability());
|
||||
m_ui->avail_average_lbl->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3));
|
||||
if (!m_torrent->isSeed() && !m_torrent->isPaused() && !m_torrent->isQueued() && !m_torrent->isChecking()) {
|
||||
// Pieces availability
|
||||
showPiecesAvailability(true);
|
||||
m_piecesAvailability->setAvailability(m_torrent->pieceAvailability());
|
||||
m_ui->labelAverageAvailabilityVal->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3));
|
||||
}
|
||||
else {
|
||||
showPiecesAvailability(false);
|
||||
}
|
||||
|
||||
// Progress
|
||||
qreal progress = m_torrent->progress() * 100.;
|
||||
m_ui->labelProgressVal->setText(Utils::String::fromDouble(progress, 1) + "%");
|
||||
m_downloadedPieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
|
||||
}
|
||||
else {
|
||||
showPiecesAvailability(false);
|
||||
}
|
||||
|
||||
// Progress
|
||||
qreal progress = m_torrent->progress() * 100.;
|
||||
m_ui->progress_lbl->setText(Utils::String::fromDouble(progress, 1) + "%");
|
||||
downloaded_pieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
|
||||
}
|
||||
else {
|
||||
showPiecesAvailability(false);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PropTabBar::TRACKERS_TAB: {
|
||||
case PropTabBar::TrackersTab:
|
||||
// Trackers
|
||||
trackerList->loadTrackers();
|
||||
m_trackerList->loadTrackers();
|
||||
break;
|
||||
}
|
||||
|
||||
case PropTabBar::PEERS_TAB: {
|
||||
case PropTabBar::PeersTab:
|
||||
// Load peers
|
||||
peersList->loadPeers(m_torrent);
|
||||
m_peerList->loadPeers(m_torrent);
|
||||
break;
|
||||
}
|
||||
|
||||
case PropTabBar::FILES_TAB: {
|
||||
case PropTabBar::FilesTab:
|
||||
// Files progress
|
||||
if (m_torrent->hasMetadata()) {
|
||||
qDebug("Updating priorities in files tab");
|
||||
m_ui->filesList->setUpdatesEnabled(false);
|
||||
PropListModel->model()->updateFilesProgress(m_torrent->filesProgress());
|
||||
PropListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
|
||||
m_propListModel->model()->updateFilesProgress(m_torrent->filesProgress());
|
||||
m_propListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
|
||||
// XXX: We don't update file priorities regularly for performance
|
||||
// reasons. This means that priorities will not be updated if
|
||||
// set from the Web UI.
|
||||
|
@ -501,8 +508,6 @@ void PropertiesWidget::loadDynamicData()
|
|||
m_ui->filesList->setUpdatesEnabled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
@ -511,19 +516,19 @@ void PropertiesWidget::loadUrlSeeds()
|
|||
{
|
||||
m_ui->listWebSeeds->clear();
|
||||
qDebug("Loading URL seeds");
|
||||
const QList<QUrl> hc_seeds = m_torrent->urlSeeds();
|
||||
const QList<QUrl> hcSeeds = m_torrent->urlSeeds();
|
||||
// Add url seeds
|
||||
foreach (const QUrl &hc_seed, hc_seeds) {
|
||||
qDebug("Loading URL seed: %s", qUtf8Printable(hc_seed.toString()));
|
||||
new QListWidgetItem(hc_seed.toString(), m_ui->listWebSeeds);
|
||||
foreach (const QUrl &hcSeed, hcSeeds) {
|
||||
qDebug("Loading URL seed: %s", qUtf8Printable(hcSeed.toString()));
|
||||
new QListWidgetItem(hcSeed.toString(), m_ui->listWebSeeds);
|
||||
}
|
||||
}
|
||||
|
||||
void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid()) return;
|
||||
if (!m_torrent || !m_torrent->hasMetadata()) return;
|
||||
if (PropListModel->itemType(index) == TorrentContentModelItem::FileType)
|
||||
if (!index.isValid() || !m_torrent || !m_torrent->hasMetadata()) return;
|
||||
|
||||
if (m_propListModel->itemType(index) == TorrentContentModelItem::FileType)
|
||||
openFile(index);
|
||||
else
|
||||
openFolder(index, false);
|
||||
|
@ -531,48 +536,48 @@ void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index)
|
|||
|
||||
void PropertiesWidget::openFile(const QModelIndex &index)
|
||||
{
|
||||
int i = PropListModel->getFileIndex(index);
|
||||
int i = m_propListModel->getFileIndex(index);
|
||||
const QDir saveDir(m_torrent->savePath(true));
|
||||
const QString filename = m_torrent->filePath(i);
|
||||
const QString file_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(filename));
|
||||
qDebug("Trying to open file at %s", qUtf8Printable(file_path));
|
||||
const QString filePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(filename));
|
||||
qDebug("Trying to open file at %s", qUtf8Printable(filePath));
|
||||
// Flush data
|
||||
m_torrent->flushCache();
|
||||
Utils::Misc::openPath(file_path);
|
||||
Utils::Misc::openPath(filePath);
|
||||
}
|
||||
|
||||
void PropertiesWidget::openFolder(const QModelIndex &index, bool containing_folder)
|
||||
void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolder)
|
||||
{
|
||||
QString absolute_path;
|
||||
QString absolutePath;
|
||||
// FOLDER
|
||||
if (PropListModel->itemType(index) == TorrentContentModelItem::FolderType) {
|
||||
if (m_propListModel->itemType(index) == TorrentContentModelItem::FolderType) {
|
||||
// Generate relative path to selected folder
|
||||
QStringList path_items;
|
||||
path_items << index.data().toString();
|
||||
QModelIndex parent = PropListModel->parent(index);
|
||||
QStringList pathItems;
|
||||
pathItems << index.data().toString();
|
||||
QModelIndex parent = m_propListModel->parent(index);
|
||||
while (parent.isValid()) {
|
||||
path_items.prepend(parent.data().toString());
|
||||
parent = PropListModel->parent(parent);
|
||||
pathItems.prepend(parent.data().toString());
|
||||
parent = m_propListModel->parent(parent);
|
||||
}
|
||||
if (path_items.isEmpty())
|
||||
if (pathItems.isEmpty())
|
||||
return;
|
||||
const QDir saveDir(m_torrent->savePath(true));
|
||||
const QString relative_path = path_items.join("/");
|
||||
absolute_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(relative_path));
|
||||
const QString relativePath = pathItems.join("/");
|
||||
absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath));
|
||||
}
|
||||
else {
|
||||
int i = PropListModel->getFileIndex(index);
|
||||
int i = m_propListModel->getFileIndex(index);
|
||||
const QDir saveDir(m_torrent->savePath(true));
|
||||
const QString relative_path = m_torrent->filePath(i);
|
||||
absolute_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(relative_path));
|
||||
const QString relativePath = m_torrent->filePath(i);
|
||||
absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath));
|
||||
}
|
||||
|
||||
// Flush data
|
||||
m_torrent->flushCache();
|
||||
if (containing_folder)
|
||||
Utils::Misc::openFolderSelect(absolute_path);
|
||||
if (containingFolder)
|
||||
Utils::Misc::openFolderSelect(absolutePath);
|
||||
else
|
||||
Utils::Misc::openPath(absolute_path);
|
||||
Utils::Misc::openPath(absolutePath);
|
||||
}
|
||||
|
||||
void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
||||
|
@ -580,8 +585,8 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
|||
if (!m_torrent) return;
|
||||
|
||||
QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0);
|
||||
if (selectedRows.empty())
|
||||
return;
|
||||
if (selectedRows.empty()) return;
|
||||
|
||||
QMenu myFilesLlistMenu;
|
||||
QAction *actOpen = nullptr;
|
||||
QAction *actOpenContainingFolder = nullptr;
|
||||
|
@ -606,35 +611,33 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
|||
// The selected torrent might have disappeared during exec()
|
||||
// from the current view thus leaving invalid indices.
|
||||
const QModelIndex index = *(selectedRows.begin());
|
||||
if (!index.isValid())
|
||||
return;
|
||||
if (act) {
|
||||
if (act == actOpen) {
|
||||
openDoubleClickedFile(index);
|
||||
}
|
||||
else if (act == actOpenContainingFolder) {
|
||||
openFolder(index, true);
|
||||
}
|
||||
else if (act == actRename) {
|
||||
renameSelectedFile();
|
||||
}
|
||||
else {
|
||||
int prio = prio::NORMAL;
|
||||
if (act == m_ui->actionHigh)
|
||||
prio = prio::HIGH;
|
||||
else if (act == m_ui->actionMaximum)
|
||||
prio = prio::MAXIMUM;
|
||||
else if (act == m_ui->actionNot_downloaded)
|
||||
prio = prio::IGNORED;
|
||||
if (!index.isValid() || !act) return;
|
||||
|
||||
qDebug("Setting files priority");
|
||||
foreach (QModelIndex index, selectedRows) {
|
||||
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
|
||||
PropListModel->setData(PropListModel->index(index.row(), PRIORITY, index.parent()), prio);
|
||||
}
|
||||
// Save changes
|
||||
filteredFilesChanged();
|
||||
if (act == actOpen) {
|
||||
openDoubleClickedFile(index);
|
||||
}
|
||||
else if (act == actOpenContainingFolder) {
|
||||
openFolder(index, true);
|
||||
}
|
||||
else if (act == actRename) {
|
||||
renameSelectedFile();
|
||||
}
|
||||
else {
|
||||
int prio = prio::NORMAL;
|
||||
if (act == m_ui->actionHigh)
|
||||
prio = prio::HIGH;
|
||||
else if (act == m_ui->actionMaximum)
|
||||
prio = prio::MAXIMUM;
|
||||
else if (act == m_ui->actionNot_downloaded)
|
||||
prio = prio::IGNORED;
|
||||
|
||||
qDebug("Setting files priority");
|
||||
foreach (QModelIndex index, selectedRows) {
|
||||
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
|
||||
m_propListModel->setData(m_propListModel->index(index.row(), PRIORITY, index.parent()), prio);
|
||||
}
|
||||
// Save changes
|
||||
filteredFilesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -657,16 +660,16 @@ void PropertiesWidget::displayWebSeedListMenu(const QPoint &)
|
|||
}
|
||||
|
||||
const QAction *act = seedMenu.exec(QCursor::pos());
|
||||
if (act) {
|
||||
if (act == actAdd)
|
||||
askWebSeed();
|
||||
else if (act == actDel)
|
||||
deleteSelectedUrlSeeds();
|
||||
else if (act == actCpy)
|
||||
copySelectedWebSeedsToClipboard();
|
||||
else if (act == actEdit)
|
||||
editWebSeed();
|
||||
}
|
||||
if (!act) return;
|
||||
|
||||
if (act == actAdd)
|
||||
askWebSeed();
|
||||
else if (act == actDel)
|
||||
deleteSelectedUrlSeeds();
|
||||
else if (act == actCpy)
|
||||
copySelectedWebSeedsToClipboard();
|
||||
else if (act == actEdit)
|
||||
editWebSeed();
|
||||
}
|
||||
|
||||
void PropertiesWidget::renameSelectedFile()
|
||||
|
@ -692,9 +695,9 @@ void PropertiesWidget::renameSelectedFile()
|
|||
return;
|
||||
}
|
||||
|
||||
if (PropListModel->itemType(modelIndex) == TorrentContentModelItem::FileType) {
|
||||
if (m_propListModel->itemType(modelIndex) == TorrentContentModelItem::FileType) {
|
||||
// renaming a file
|
||||
const int fileIndex = PropListModel->getFileIndex(modelIndex);
|
||||
const int fileIndex = m_propListModel->getFileIndex(modelIndex);
|
||||
|
||||
if (newName.endsWith(QB_EXT))
|
||||
newName.chop(QB_EXT.size());
|
||||
|
@ -722,16 +725,16 @@ void PropertiesWidget::renameSelectedFile()
|
|||
qDebug("Renaming %s to %s", qUtf8Printable(oldFilePath), qUtf8Printable(newFilePath));
|
||||
m_torrent->renameFile(fileIndex, newFilePath);
|
||||
|
||||
PropListModel->setData(modelIndex, newName);
|
||||
m_propListModel->setData(modelIndex, newName);
|
||||
}
|
||||
else {
|
||||
// renaming a folder
|
||||
QStringList pathItems;
|
||||
pathItems << modelIndex.data().toString();
|
||||
QModelIndex parent = PropListModel->parent(modelIndex);
|
||||
QModelIndex parent = m_propListModel->parent(modelIndex);
|
||||
while (parent.isValid()) {
|
||||
pathItems.prepend(parent.data().toString());
|
||||
parent = PropListModel->parent(parent);
|
||||
parent = m_propListModel->parent(parent);
|
||||
}
|
||||
const QString oldPath = pathItems.join("/");
|
||||
pathItems.removeLast();
|
||||
|
@ -773,7 +776,7 @@ void PropertiesWidget::renameSelectedFile()
|
|||
// Force recheck
|
||||
if (forceRecheck) m_torrent->forceRecheck();
|
||||
// Rename folder in torrent files model too
|
||||
PropListModel->setData(modelIndex, newName);
|
||||
m_propListModel->setData(modelIndex, newName);
|
||||
// Remove old folder
|
||||
const QDir oldFolder(m_torrent->savePath(true) + "/" + oldPath);
|
||||
int timeout = 10;
|
||||
|
@ -830,52 +833,48 @@ void PropertiesWidget::deleteSelectedUrlSeeds()
|
|||
|
||||
void PropertiesWidget::copySelectedWebSeedsToClipboard() const
|
||||
{
|
||||
const QList<QListWidgetItem *> selected_items = m_ui->listWebSeeds->selectedItems();
|
||||
if (selected_items.isEmpty())
|
||||
return;
|
||||
const QList<QListWidgetItem *> selectedItems = m_ui->listWebSeeds->selectedItems();
|
||||
if (selectedItems.isEmpty()) return;
|
||||
|
||||
QStringList urls_to_copy;
|
||||
foreach (QListWidgetItem *item, selected_items)
|
||||
urls_to_copy << item->text();
|
||||
QStringList urlsToCopy;
|
||||
foreach (QListWidgetItem *item, selectedItems)
|
||||
urlsToCopy << item->text();
|
||||
|
||||
QApplication::clipboard()->setText(urls_to_copy.join("\n"));
|
||||
QApplication::clipboard()->setText(urlsToCopy.join("\n"));
|
||||
}
|
||||
|
||||
void PropertiesWidget::editWebSeed()
|
||||
{
|
||||
const QList<QListWidgetItem *> selected_items = m_ui->listWebSeeds->selectedItems();
|
||||
if (selected_items.size() != 1)
|
||||
return;
|
||||
const QList<QListWidgetItem *> selectedItems = m_ui->listWebSeeds->selectedItems();
|
||||
if (selectedItems.size() != 1) return;
|
||||
|
||||
const QListWidgetItem *selected_item = selected_items.last();
|
||||
const QString old_seed = selected_item->text();
|
||||
const QListWidgetItem *selectedItem = selectedItems.last();
|
||||
const QString oldSeed = selectedItem->text();
|
||||
bool result;
|
||||
const QString new_seed = AutoExpandableDialog::getText(this, tr("Web seed editing"),
|
||||
const QString newSeed = AutoExpandableDialog::getText(this, tr("Web seed editing"),
|
||||
tr("Web seed URL:"), QLineEdit::Normal,
|
||||
old_seed, &result);
|
||||
if (!result)
|
||||
return;
|
||||
oldSeed, &result);
|
||||
if (!result) return;
|
||||
|
||||
if (!m_ui->listWebSeeds->findItems(new_seed, Qt::MatchFixedString).empty()) {
|
||||
if (!m_ui->listWebSeeds->findItems(newSeed, Qt::MatchFixedString).empty()) {
|
||||
QMessageBox::warning(this, tr("qBittorrent"),
|
||||
tr("This URL seed is already in the list."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
m_torrent->removeUrlSeeds(QList<QUrl>() << old_seed);
|
||||
m_torrent->addUrlSeeds(QList<QUrl>() << new_seed);
|
||||
m_torrent->removeUrlSeeds(QList<QUrl>() << oldSeed);
|
||||
m_torrent->addUrlSeeds(QList<QUrl>() << newSeed);
|
||||
loadUrlSeeds();
|
||||
}
|
||||
|
||||
bool PropertiesWidget::applyPriorities()
|
||||
void PropertiesWidget::applyPriorities()
|
||||
{
|
||||
qDebug("Saving files priorities");
|
||||
const QVector<int> priorities = PropListModel->model()->getFilePriorities();
|
||||
const QVector<int> priorities = m_propListModel->model()->getFilePriorities();
|
||||
// Prioritize the files
|
||||
qDebug("prioritize files: %d", priorities[0]);
|
||||
m_torrent->prioritizeFiles(priorities);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PropertiesWidget::filteredFilesChanged()
|
||||
|
@ -886,10 +885,10 @@ void PropertiesWidget::filteredFilesChanged()
|
|||
|
||||
void PropertiesWidget::filterText(const QString &filter)
|
||||
{
|
||||
PropListModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::WildcardUnix));
|
||||
m_propListModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::WildcardUnix));
|
||||
if (filter.isEmpty()) {
|
||||
m_ui->filesList->collapseAll();
|
||||
m_ui->filesList->expand(PropListModel->index(0, 0));
|
||||
m_ui->filesList->expand(m_propListModel->index(0, 0));
|
||||
}
|
||||
else {
|
||||
m_ui->filesList->expandAll();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue