qBittorrent
TransferListWidget Class Referencefinal

#include <transferlistwidget.h>

Inheritance diagram for TransferListWidget:
Collaboration diagram for TransferListWidget:

Public Slots

void setSelectionCategory (const QString &category)
 
void addSelectionTag (const QString &tag)
 
void removeSelectionTag (const QString &tag)
 
void clearSelectionTags ()
 
void pauseAllTorrents ()
 
void resumeAllTorrents ()
 
void startSelectedTorrents ()
 
void forceStartSelectedTorrents ()
 
void startVisibleTorrents ()
 
void pauseSelectedTorrents ()
 
void pauseVisibleTorrents ()
 
void softDeleteSelectedTorrents ()
 
void permDeleteSelectedTorrents ()
 
void deleteSelectedTorrents (bool deleteLocalFiles)
 
void deleteVisibleTorrents ()
 
void increaseQueuePosSelectedTorrents ()
 
void decreaseQueuePosSelectedTorrents ()
 
void topQueuePosSelectedTorrents ()
 
void bottomQueuePosSelectedTorrents ()
 
void copySelectedMagnetURIs () const
 
void copySelectedNames () const
 
void copySelectedInfohashes (CopyInfohashPolicy policy) const
 
void copySelectedIDs () const
 
void openSelectedTorrentsFolder () const
 
void recheckSelectedTorrents ()
 
void reannounceSelectedTorrents ()
 
void setTorrentOptions ()
 
void previewSelectedTorrents ()
 
void hideQueuePosColumn (bool hide)
 
void displayDLHoSMenu (const QPoint &)
 
void applyNameFilter (const QString &name)
 
void applyStatusFilter (int f)
 
void applyCategoryFilter (const QString &category)
 
void applyTagFilter (const QString &tag)
 
void applyTrackerFilterAll ()
 
void applyTrackerFilter (const QSet< BitTorrent::TorrentID > &torrentIDs)
 
void previewFile (const QString &filePath)
 
void renameSelectedTorrent ()
 

Signals

void currentTorrentChanged (BitTorrent::Torrent *const torrent)
 

Public Member Functions

 TransferListWidget (QWidget *parent, MainWindow *mainWindow)
 
 ~TransferListWidget () override
 
TransferListModelgetSourceModel () const
 

Private Slots

void torrentDoubleClicked ()
 
void displayListMenu (const QPoint &)
 
void currentChanged (const QModelIndex &current, const QModelIndex &) override
 
void setSelectedTorrentsSuperSeeding (bool enabled) const
 
void setSelectedAutoTMMEnabled (bool enabled) const
 
void askNewCategoryForSelection ()
 
void saveSettings ()
 

Private Member Functions

void wheelEvent (QWheelEvent *event) override
 
QModelIndex mapToSource (const QModelIndex &index) const
 
QModelIndex mapFromSource (const QModelIndex &index) const
 
bool loadSettings ()
 
QVector< BitTorrent::Torrent * > getSelectedTorrents () const
 
void askAddTagsForSelection ()
 
void editTorrentTrackers ()
 
void confirmRemoveAllTagsForSelection ()
 
QStringList askTagsForSelection (const QString &dialogTitle)
 
void applyToSelectedTorrents (const std::function< void(BitTorrent::Torrent *const)> &fn)
 
QVector< BitTorrent::Torrent * > getVisibleTorrents () const
 

Private Attributes

TransferListModelm_listModel
 
TransferListSortModelm_sortFilterModel
 
MainWindowm_mainWindow
 

Detailed Description

Definition at line 53 of file transferlistwidget.h.

Constructor & Destructor Documentation

◆ TransferListWidget()

TransferListWidget::TransferListWidget ( QWidget *  parent,
MainWindow mainWindow 
)

Definition at line 124 of file transferlistwidget.cpp.

125  : QTreeView {parent}
126  , m_listModel {new TransferListModel {this}}
128  , m_mainWindow {mainWindow}
129 {
130  // Load settings
131  const bool columnLoaded = loadSettings();
132 
133  // Create and apply delegate
134  setItemDelegate(new TransferListDelegate {this});
135 
136  m_sortFilterModel->setDynamicSortFilter(true);
137  m_sortFilterModel->setSourceModel(m_listModel);
138  m_sortFilterModel->setFilterKeyColumn(TransferListModel::TR_NAME);
139  m_sortFilterModel->setFilterRole(Qt::DisplayRole);
140  m_sortFilterModel->setSortCaseSensitivity(Qt::CaseInsensitive);
142  setModel(m_sortFilterModel);
143 
144  // Visual settings
145  setUniformRowHeights(true);
146  setRootIsDecorated(false);
147  setAllColumnsShowFocus(true);
148  setSortingEnabled(true);
149  setSelectionMode(QAbstractItemView::ExtendedSelection);
150  setItemsExpandable(false);
151  setAutoScroll(true);
152  setDragDropMode(QAbstractItemView::DragOnly);
153 #if defined(Q_OS_MACOS)
154  setAttribute(Qt::WA_MacShowFocusRect, false);
155 #endif
156  header()->setStretchLastSection(false);
157  header()->setTextElideMode(Qt::ElideRight);
158 
159  // Default hidden columns
160  if (!columnLoaded)
161  {
162  setColumnHidden(TransferListModel::TR_ADD_DATE, true);
163  setColumnHidden(TransferListModel::TR_SEED_DATE, true);
164  setColumnHidden(TransferListModel::TR_UPLIMIT, true);
165  setColumnHidden(TransferListModel::TR_DLLIMIT, true);
166  setColumnHidden(TransferListModel::TR_TRACKER, true);
167  setColumnHidden(TransferListModel::TR_AMOUNT_DOWNLOADED, true);
168  setColumnHidden(TransferListModel::TR_AMOUNT_UPLOADED, true);
170  setColumnHidden(TransferListModel::TR_AMOUNT_UPLOADED_SESSION, true);
171  setColumnHidden(TransferListModel::TR_AMOUNT_LEFT, true);
172  setColumnHidden(TransferListModel::TR_TIME_ELAPSED, true);
173  setColumnHidden(TransferListModel::TR_SAVE_PATH, true);
174  setColumnHidden(TransferListModel::TR_COMPLETED, true);
175  setColumnHidden(TransferListModel::TR_RATIO_LIMIT, true);
176  setColumnHidden(TransferListModel::TR_SEEN_COMPLETE_DATE, true);
177  setColumnHidden(TransferListModel::TR_LAST_ACTIVITY, true);
178  setColumnHidden(TransferListModel::TR_TOTAL_SIZE, true);
179  }
180 
181  //Ensure that at least one column is visible at all times
182  bool atLeastOne = false;
183  for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i)
184  {
185  if (!isColumnHidden(i))
186  {
187  atLeastOne = true;
188  break;
189  }
190  }
191  if (!atLeastOne)
192  setColumnHidden(TransferListModel::TR_NAME, false);
193 
194  //When adding/removing columns between versions some may
195  //end up being size 0 when the new version is launched with
196  //a conf file from the previous version.
197  for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i)
198  if ((columnWidth(i) <= 0) && (!isColumnHidden(i)))
199  resizeColumnToContents(i);
200 
201  setContextMenuPolicy(Qt::CustomContextMenu);
202 
203  // Listen for list events
204  connect(this, &QAbstractItemView::doubleClicked, this, &TransferListWidget::torrentDoubleClicked);
205  connect(this, &QWidget::customContextMenuRequested, this, &TransferListWidget::displayListMenu);
206  header()->setContextMenuPolicy(Qt::CustomContextMenu);
207  connect(header(), &QWidget::customContextMenuRequested, this, &TransferListWidget::displayDLHoSMenu);
208  connect(header(), &QHeaderView::sectionMoved, this, &TransferListWidget::saveSettings);
209  connect(header(), &QHeaderView::sectionResized, this, &TransferListWidget::saveSettings);
210  connect(header(), &QHeaderView::sortIndicatorChanged, this, &TransferListWidget::saveSettings);
211 
212  const auto *editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut);
213  connect(editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent);
214  const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
215  connect(deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents);
216  const auto *permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
217  connect(permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents);
218  const auto *doubleClickHotkeyReturn = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut);
219  connect(doubleClickHotkeyReturn, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
220  const auto *doubleClickHotkeyEnter = new QShortcut(Qt::Key_Enter, this, nullptr, nullptr, Qt::WidgetShortcut);
221  connect(doubleClickHotkeyEnter, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
222  const auto *recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut);
223  connect(recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents);
224 
225  // This hack fixes reordering of first column with Qt5.
226  // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
227  QTableView unused;
228  unused.setVerticalHeader(header());
229  header()->setParent(this);
230  unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
231 }
void displayDLHoSMenu(const QPoint &)
TransferListModel * m_listModel
void displayListMenu(const QPoint &)
TransferListSortModel * m_sortFilterModel

References displayDLHoSMenu(), displayListMenu(), loadSettings(), m_listModel, m_sortFilterModel, TransferListModel::NB_COLUMNS, permDeleteSelectedTorrents(), recheckSelectedTorrents(), renameSelectedTorrent(), saveSettings(), softDeleteSelectedTorrents(), torrentDoubleClicked(), TransferListModel::TR_ADD_DATE, TransferListModel::TR_AMOUNT_DOWNLOADED, TransferListModel::TR_AMOUNT_DOWNLOADED_SESSION, TransferListModel::TR_AMOUNT_LEFT, TransferListModel::TR_AMOUNT_UPLOADED, TransferListModel::TR_AMOUNT_UPLOADED_SESSION, TransferListModel::TR_COMPLETED, TransferListModel::TR_DLLIMIT, TransferListModel::TR_LAST_ACTIVITY, TransferListModel::TR_NAME, TransferListModel::TR_RATIO_LIMIT, TransferListModel::TR_SAVE_PATH, TransferListModel::TR_SEED_DATE, TransferListModel::TR_SEEN_COMPLETE_DATE, TransferListModel::TR_TIME_ELAPSED, TransferListModel::TR_TOTAL_SIZE, TransferListModel::TR_TRACKER, TransferListModel::TR_UPLIMIT, and TransferListModel::UnderlyingDataRole.

Here is the call graph for this function:

◆ ~TransferListWidget()

TransferListWidget::~TransferListWidget ( )
override

Definition at line 233 of file transferlistwidget.cpp.

234 {
235  // Save settings
236  saveSettings();
237 }

References saveSettings().

Here is the call graph for this function:

Member Function Documentation

◆ addSelectionTag

void TransferListWidget::addSelectionTag ( const QString &  tag)
slot

Definition at line 774 of file transferlistwidget.cpp.

775 {
776  applyToSelectedTorrents([&tag](BitTorrent::Torrent *const torrent) { torrent->addTag(tag); });
777 }
virtual bool addTag(const QString &tag)=0
void applyToSelectedTorrents(const std::function< void(BitTorrent::Torrent *const)> &fn)

References BitTorrent::Torrent::addTag(), and applyToSelectedTorrents().

Referenced by askAddTagsForSelection(), and displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyCategoryFilter

void TransferListWidget::applyCategoryFilter ( const QString &  category)
slot

Definition at line 1062 of file transferlistwidget.cpp.

1063 {
1064  if (category.isNull())
1066  else
1068 }
void setCategoryFilter(const QString &category)

References TransferListSortModel::disableCategoryFilter(), m_sortFilterModel, and TransferListSortModel::setCategoryFilter().

Referenced by TransferListFiltersWidget::toggleCategoryFilter(), and TransferListFiltersWidget::TransferListFiltersWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyNameFilter

void TransferListWidget::applyNameFilter ( const QString &  name)
slot

Definition at line 1088 of file transferlistwidget.cpp.

1089 {
1091  ? name : Utils::String::wildcardToRegexPattern(name));
1092  m_sortFilterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
1093 }
static Preferences * instance()
bool getRegexAsFilteringPatternForTransferList() const
QString wildcardToRegexPattern(const QString &pattern)
Definition: string.cpp:57

References Preferences::getRegexAsFilteringPatternForTransferList(), Preferences::instance(), m_sortFilterModel, and Utils::String::wildcardToRegexPattern().

Referenced by MainWindow::MainWindow(), and MainWindow::showFilterContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyStatusFilter

void TransferListWidget::applyStatusFilter ( int  f)
slot

Definition at line 1095 of file transferlistwidget.cpp.

1096 {
1098  // Select first item if nothing is selected
1099  if (selectionModel()->selectedRows(0).empty() && (m_sortFilterModel->rowCount() > 0))
1100  {
1101  qDebug("Nothing is selected, selecting first row: %s", qUtf8Printable(m_sortFilterModel->index(0, TransferListModel::TR_NAME).data().toString()));
1102  selectionModel()->setCurrentIndex(m_sortFilterModel->index(0, TransferListModel::TR_NAME), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
1103  }
1104 }
void setStatusFilter(TorrentFilter::Type filter)
void f()
Definition: test2.c:1

References f(), m_sortFilterModel, TransferListSortModel::setStatusFilter(), and TransferListModel::TR_NAME.

Referenced by StatusFilterWidget::applyFilter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyTagFilter

void TransferListWidget::applyTagFilter ( const QString &  tag)
slot

Definition at line 1070 of file transferlistwidget.cpp.

1071 {
1072  if (tag.isNull())
1074  else
1076 }
void setTagFilter(const QString &tag)

References TransferListSortModel::disableTagFilter(), m_sortFilterModel, and TransferListSortModel::setTagFilter().

Referenced by TransferListFiltersWidget::toggleTagFilter(), and TransferListFiltersWidget::TransferListFiltersWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyToSelectedTorrents()

void TransferListWidget::applyToSelectedTorrents ( const std::function< void(BitTorrent::Torrent *const)> &  fn)
private

Definition at line 738 of file transferlistwidget.cpp.

739 {
740  for (const QModelIndex &index : asConst(selectionModel()->selectedRows()))
741  {
742  BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(mapToSource(index));
743  Q_ASSERT(torrent);
744  fn(torrent);
745  }
746 }
BitTorrent::Torrent * torrentHandle(const QModelIndex &index) const
QModelIndex mapToSource(const QModelIndex &index) const
constexpr std::add_const_t< T > & asConst(T &t) noexcept
Definition: global.h:42

References asConst(), m_listModel, mapToSource(), and TransferListModel::torrentHandle().

Referenced by addSelectionTag(), clearSelectionTags(), and removeSelectionTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyTrackerFilter

void TransferListWidget::applyTrackerFilter ( const QSet< BitTorrent::TorrentID > &  torrentIDs)
slot

Definition at line 1083 of file transferlistwidget.cpp.

1084 {
1085  m_sortFilterModel->setTrackerFilter(torrentIDs);
1086 }
void setTrackerFilter(const QSet< BitTorrent::TorrentID > &torrentIDs)

References m_sortFilterModel, and TransferListSortModel::setTrackerFilter().

Referenced by TrackerFiltersList::applyFilter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyTrackerFilterAll

void TransferListWidget::applyTrackerFilterAll ( )
slot

Definition at line 1078 of file transferlistwidget.cpp.

References TransferListSortModel::disableTrackerFilter(), and m_sortFilterModel.

Referenced by TrackerFiltersList::applyFilter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ askAddTagsForSelection()

void TransferListWidget::askAddTagsForSelection ( )
private

Definition at line 660 of file transferlistwidget.cpp.

661 {
662  const QStringList tags = askTagsForSelection(tr("Add Tags"));
663  for (const QString &tag : tags)
664  addSelectionTag(tag);
665 }
void addSelectionTag(const QString &tag)
QStringList askTagsForSelection(const QString &dialogTitle)

References addSelectionTag(), and askTagsForSelection().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ askNewCategoryForSelection

void TransferListWidget::askNewCategoryForSelection ( )
privateslot

Definition at line 653 of file transferlistwidget.cpp.

654 {
655  const QString newCategoryName = TorrentCategoryDialog::createCategory(this);
656  if (!newCategoryName.isEmpty())
657  setSelectionCategory(newCategoryName);
658 }
static QString createCategory(QWidget *parent, const QString &parentCategoryName={})
void setSelectionCategory(const QString &category)

References TorrentCategoryDialog::createCategory(), and setSelectionCategory().

Here is the call graph for this function:

◆ askTagsForSelection()

QStringList TransferListWidget::askTagsForSelection ( const QString &  dialogTitle)
private

Definition at line 711 of file transferlistwidget.cpp.

712 {
713  QStringList tags;
714  bool invalid = true;
715  while (invalid)
716  {
717  bool ok = false;
718  invalid = false;
719  const QString tagsInput = AutoExpandableDialog::getText(
720  this, dialogTitle, tr("Comma-separated tags:"), QLineEdit::Normal, "", &ok).trimmed();
721  if (!ok || tagsInput.isEmpty())
722  return {};
723  tags = tagsInput.split(',', Qt::SkipEmptyParts);
724  for (QString &tag : tags)
725  {
726  tag = tag.trimmed();
728  {
729  QMessageBox::warning(this, tr("Invalid tag")
730  , tr("Tag name: '%1' is invalid").arg(tag));
731  invalid = true;
732  }
733  }
734  }
735  return tags;
736 }
static QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode=QLineEdit::Normal, const QString &text={}, bool *ok=nullptr, bool excludeExtension=false, Qt::InputMethodHints inputMethodHints=Qt::ImhNone)
static bool isValidTag(const QString &tag)
Definition: session.cpp:829

References AutoExpandableDialog::getText(), and BitTorrent::Session::isValidTag().

Referenced by askAddTagsForSelection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bottomQueuePosSelectedTorrents

void TransferListWidget::bottomQueuePosSelectedTorrents ( )
slot

Definition at line 451 of file transferlistwidget.cpp.

452 {
453  if (m_mainWindow->currentTabWidget() == this)
455 }
static Session * instance()
Definition: session.cpp:997
void bottomTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1942
QWidget * currentTabWidget() const
QVector< BitTorrent::Torrent * > getSelectedTorrents() const
QVector< BitTorrent::TorrentID > extractIDs(const QVector< BitTorrent::Torrent * > &torrents)

References BitTorrent::Session::bottomTorrentsQueuePos(), MainWindow::currentTabWidget(), anonymous_namespace{transferlistwidget.cpp}::extractIDs(), getSelectedTorrents(), BitTorrent::Session::instance(), and m_mainWindow.

Referenced by displayListMenu(), and MainWindow::MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearSelectionTags

void TransferListWidget::clearSelectionTags ( )
slot

Definition at line 784 of file transferlistwidget.cpp.

785 {
786  applyToSelectedTorrents([](BitTorrent::Torrent *const torrent) { torrent->removeAllTags(); });
787 }
virtual void removeAllTags()=0

References applyToSelectedTorrents(), and BitTorrent::Torrent::removeAllTags().

Referenced by confirmRemoveAllTagsForSelection(), and displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ confirmRemoveAllTagsForSelection()

void TransferListWidget::confirmRemoveAllTagsForSelection ( )
private

Definition at line 702 of file transferlistwidget.cpp.

703 {
704  QMessageBox::StandardButton response = QMessageBox::question(
705  this, tr("Remove All Tags"), tr("Remove all tags from selected torrents?"),
706  QMessageBox::Yes | QMessageBox::No);
707  if (response == QMessageBox::Yes)
709 }

References clearSelectionTags().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copySelectedIDs

void TransferListWidget::copySelectedIDs ( ) const
slot

Definition at line 501 of file transferlistwidget.cpp.

502 {
503  QStringList torrentIDs;
504  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
505  torrentIDs << torrent->id().toString();
506 
507  qApp->clipboard()->setText(torrentIDs.join('\n'));
508 }

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copySelectedInfohashes

void TransferListWidget::copySelectedInfohashes ( CopyInfohashPolicy  policy) const
slot

Definition at line 475 of file transferlistwidget.cpp.

476 {
477  const auto selectedTorrents = getSelectedTorrents();
478  QStringList infoHashes;
479  infoHashes.reserve(selectedTorrents.size());
480  switch (policy)
481  {
483  for (const BitTorrent::Torrent *torrent : selectedTorrents)
484  {
485  if (const auto infoHash = torrent->infoHash().v1(); infoHash.isValid())
486  infoHashes << infoHash.toString();
487  }
488  break;
490  for (const BitTorrent::Torrent *torrent : selectedTorrents)
491  {
492  if (const auto infoHash = torrent->infoHash().v2(); infoHash.isValid())
493  infoHashes << infoHash.toString();
494  }
495  break;
496  }
497 
498  qApp->clipboard()->setText(infoHashes.join('\n'));
499 }

References getSelectedTorrents(), Version1, and Version2.

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copySelectedMagnetURIs

void TransferListWidget::copySelectedMagnetURIs ( ) const
slot

Definition at line 457 of file transferlistwidget.cpp.

458 {
459  QStringList magnetUris;
460  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
461  magnetUris << torrent->createMagnetURI();
462 
463  qApp->clipboard()->setText(magnetUris.join('\n'));
464 }

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copySelectedNames

void TransferListWidget::copySelectedNames ( ) const
slot

Definition at line 466 of file transferlistwidget.cpp.

467 {
468  QStringList torrentNames;
469  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
470  torrentNames << torrent->name();
471 
472  qApp->clipboard()->setText(torrentNames.join('\n'));
473 }

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentChanged

void TransferListWidget::currentChanged ( const QModelIndex &  current,
const QModelIndex &   
)
overrideprivateslot

Definition at line 1049 of file transferlistwidget.cpp.

1050 {
1051  qDebug("CURRENT CHANGED");
1052  BitTorrent::Torrent *torrent = nullptr;
1053  if (current.isValid())
1054  {
1055  torrent = m_listModel->torrentHandle(mapToSource(current));
1056  // Scroll Fix
1057  scrollTo(current);
1058  }
1059  emit currentTorrentChanged(torrent);
1060 }
void currentTorrentChanged(BitTorrent::Torrent *const torrent)

References currentTorrentChanged(), m_listModel, mapToSource(), and TransferListModel::torrentHandle().

Here is the call graph for this function:

◆ currentTorrentChanged

void TransferListWidget::currentTorrentChanged ( BitTorrent::Torrent *const  torrent)
signal

Referenced by currentChanged(), and MainWindow::MainWindow().

Here is the caller graph for this function:

◆ decreaseQueuePosSelectedTorrents

void TransferListWidget::decreaseQueuePosSelectedTorrents ( )
slot

Definition at line 438 of file transferlistwidget.cpp.

439 {
440  qDebug() << Q_FUNC_INFO;
441  if (m_mainWindow->currentTabWidget() == this)
443 }
void decreaseTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1889

References MainWindow::currentTabWidget(), BitTorrent::Session::decreaseTorrentsQueuePos(), anonymous_namespace{transferlistwidget.cpp}::extractIDs(), getSelectedTorrents(), BitTorrent::Session::instance(), and m_mainWindow.

Referenced by displayListMenu(), and MainWindow::MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteSelectedTorrents

void TransferListWidget::deleteSelectedTorrents ( bool  deleteLocalFiles)
slot

Definition at line 383 of file transferlistwidget.cpp.

384 {
385  if (m_mainWindow->currentTabWidget() != this) return;
386 
387  const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
388  if (torrents.empty()) return;
389 
390  if (Preferences::instance()->confirmTorrentDeletion())
391  {
392  auto *dialog = new DeletionConfirmationDialog(this, torrents.size(), torrents[0]->name(), deleteLocalFiles);
393  dialog->setAttribute(Qt::WA_DeleteOnClose);
394  connect(dialog, &DeletionConfirmationDialog::accepted, this, [this, dialog]()
395  {
396  // Some torrents might be removed when waiting for user input, so refetch the torrent list
397  // NOTE: this will only work when dialog is modal
398  removeTorrents(getSelectedTorrents(), dialog->isDeleteFileSelected());
399  });
400  dialog->open();
401  }
402  else
403  {
404  removeTorrents(torrents, deleteLocalFiles);
405  }
406 }
void removeTorrents(const QVector< BitTorrent::Torrent * > &torrents, const bool isDeleteFileSelected)

References MainWindow::currentTabWidget(), getSelectedTorrents(), Preferences::instance(), m_mainWindow, and anonymous_namespace{transferlistwidget.cpp}::removeTorrents().

Referenced by permDeleteSelectedTorrents(), and softDeleteSelectedTorrents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteVisibleTorrents

void TransferListWidget::deleteVisibleTorrents ( )
slot

Definition at line 408 of file transferlistwidget.cpp.

409 {
410  const QVector<BitTorrent::Torrent *> torrents = getVisibleTorrents();
411  if (torrents.empty()) return;
412 
413  if (Preferences::instance()->confirmTorrentDeletion())
414  {
415  auto *dialog = new DeletionConfirmationDialog(this, torrents.size(), torrents[0]->name(), false);
416  dialog->setAttribute(Qt::WA_DeleteOnClose);
417  connect(dialog, &DeletionConfirmationDialog::accepted, this, [this, dialog]()
418  {
419  // Some torrents might be removed when waiting for user input, so refetch the torrent list
420  // NOTE: this will only work when dialog is modal
421  removeTorrents(getVisibleTorrents(), dialog->isDeleteFileSelected());
422  });
423  dialog->open();
424  }
425  else
426  {
427  removeTorrents(torrents, false);
428  }
429 }
QVector< BitTorrent::Torrent * > getVisibleTorrents() const

References getVisibleTorrents(), Preferences::instance(), and anonymous_namespace{transferlistwidget.cpp}::removeTorrents().

Referenced by TrackerFiltersList::showMenu(), and TransferListFiltersWidget::TransferListFiltersWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ displayDLHoSMenu

void TransferListWidget::displayDLHoSMenu ( const QPoint &  )
slot

Definition at line 593 of file transferlistwidget.cpp.

594 {
595  auto menu = new QMenu(this);
596  menu->setAttribute(Qt::WA_DeleteOnClose);
597  menu->setTitle(tr("Column visibility"));
598 
599  for (int i = 0; i < m_listModel->columnCount(); ++i)
600  {
601  if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && (i == TransferListModel::TR_QUEUE_POSITION))
602  continue;
603 
604  QAction *myAct = menu->addAction(m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
605  myAct->setCheckable(true);
606  myAct->setChecked(!isColumnHidden(i));
607  myAct->setData(i);
608  }
609 
610  connect(menu, &QMenu::triggered, this, [this](const QAction *action)
611  {
612  int visibleCols = 0;
613  for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i)
614  {
615  if (!isColumnHidden(i))
616  ++visibleCols;
617 
618  if (visibleCols > 1)
619  break;
620  }
621 
622  const int col = action->data().toInt();
623 
624  if (!isColumnHidden(col) && visibleCols == 1)
625  return;
626 
627  setColumnHidden(col, !isColumnHidden(col));
628 
629  if (!isColumnHidden(col) && columnWidth(col) <= 5)
630  resizeColumnToContents(col);
631 
632  saveSettings();
633  });
634 
635  menu->popup(QCursor::pos());
636 }
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
int columnCount(const QModelIndex &parent={}) const override
action
Definition: tstool.py:143

References tstool::action, TransferListModel::columnCount(), TransferListModel::headerData(), BitTorrent::Session::instance(), m_listModel, TransferListModel::NB_COLUMNS, saveSettings(), and TransferListModel::TR_QUEUE_POSITION.

Referenced by TransferListWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ displayListMenu

void TransferListWidget::displayListMenu ( const QPoint &  )
privateslot

Definition at line 789 of file transferlistwidget.cpp.

790 {
791  const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
792  if (selectedIndexes.isEmpty()) return;
793 
794  auto *listMenu = new QMenu(this);
795  listMenu->setAttribute(Qt::WA_DeleteOnClose);
796 
797  // Create actions
798 
799  auto *actionStart = new QAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume", "Resume/start the torrent"), listMenu);
800  connect(actionStart, &QAction::triggered, this, &TransferListWidget::startSelectedTorrents);
801  auto *actionPause = new QAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause", "Pause the torrent"), listMenu);
802  connect(actionPause, &QAction::triggered, this, &TransferListWidget::pauseSelectedTorrents);
803  auto *actionForceStart = new QAction(UIThemeManager::instance()->getIcon("media-seek-forward"), tr("Force Resume", "Force Resume/start the torrent"), listMenu);
804  connect(actionForceStart, &QAction::triggered, this, &TransferListWidget::forceStartSelectedTorrents);
805  auto *actionDelete = new QAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete", "Delete the torrent"), listMenu);
806  connect(actionDelete, &QAction::triggered, this, &TransferListWidget::softDeleteSelectedTorrents);
807  auto *actionPreviewFile = new QAction(UIThemeManager::instance()->getIcon("view-preview"), tr("Preview file..."), listMenu);
808  connect(actionPreviewFile, &QAction::triggered, this, &TransferListWidget::previewSelectedTorrents);
809  auto *actionTorrentOptions = new QAction(UIThemeManager::instance()->getIcon("configure"), tr("Torrent options..."), listMenu);
810  connect(actionTorrentOptions, &QAction::triggered, this, &TransferListWidget::setTorrentOptions);
811  auto *actionOpenDestinationFolder = new QAction(UIThemeManager::instance()->getIcon("inode-directory"), tr("Open destination folder"), listMenu);
812  connect(actionOpenDestinationFolder, &QAction::triggered, this, &TransferListWidget::openSelectedTorrentsFolder);
813  auto *actionIncreaseQueuePos = new QAction(UIThemeManager::instance()->getIcon("go-up"), tr("Move up", "i.e. move up in the queue"), listMenu);
814  connect(actionIncreaseQueuePos, &QAction::triggered, this, &TransferListWidget::increaseQueuePosSelectedTorrents);
815  auto *actionDecreaseQueuePos = new QAction(UIThemeManager::instance()->getIcon("go-down"), tr("Move down", "i.e. Move down in the queue"), listMenu);
816  connect(actionDecreaseQueuePos, &QAction::triggered, this, &TransferListWidget::decreaseQueuePosSelectedTorrents);
817  auto *actionTopQueuePos = new QAction(UIThemeManager::instance()->getIcon("go-top"), tr("Move to top", "i.e. Move to top of the queue"), listMenu);
818  connect(actionTopQueuePos, &QAction::triggered, this, &TransferListWidget::topQueuePosSelectedTorrents);
819  auto *actionBottomQueuePos = new QAction(UIThemeManager::instance()->getIcon("go-bottom"), tr("Move to bottom", "i.e. Move to bottom of the queue"), listMenu);
820  connect(actionBottomQueuePos, &QAction::triggered, this, &TransferListWidget::bottomQueuePosSelectedTorrents);
821  auto *actionForceRecheck = new QAction(UIThemeManager::instance()->getIcon("document-edit-verify"), tr("Force recheck"), listMenu);
822  connect(actionForceRecheck, &QAction::triggered, this, &TransferListWidget::recheckSelectedTorrents);
823  auto *actionForceReannounce = new QAction(UIThemeManager::instance()->getIcon("document-edit-verify"), tr("Force reannounce"), listMenu);
824  connect(actionForceReannounce, &QAction::triggered, this, &TransferListWidget::reannounceSelectedTorrents);
825  auto *actionCopyMagnetLink = new QAction(UIThemeManager::instance()->getIcon("kt-magnet"), tr("Magnet link"), listMenu);
826  connect(actionCopyMagnetLink, &QAction::triggered, this, &TransferListWidget::copySelectedMagnetURIs);
827  auto *actionCopyID = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Torrent ID"), listMenu);
828  connect(actionCopyID, &QAction::triggered, this, &TransferListWidget::copySelectedIDs);
829  auto *actionCopyName = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Name"), listMenu);
830  connect(actionCopyName, &QAction::triggered, this, &TransferListWidget::copySelectedNames);
831  auto *actionCopyHash1 = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Info hash v1"), listMenu);
832  connect(actionCopyHash1, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version1); });
833  auto *actionCopyHash2 = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Info hash v2"), listMenu);
834  connect(actionCopyHash2, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version2); });
835  auto *actionSuperSeedingMode = new TriStateAction(tr("Super seeding mode"), listMenu);
836  connect(actionSuperSeedingMode, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsSuperSeeding);
837  auto *actionRename = new QAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename..."), listMenu);
838  connect(actionRename, &QAction::triggered, this, &TransferListWidget::renameSelectedTorrent);
839  auto *actionEditTracker = new QAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Edit trackers..."), listMenu);
840  connect(actionEditTracker, &QAction::triggered, this, &TransferListWidget::editTorrentTrackers);
841  // End of actions
842 
843  // Enable/disable pause/start action given the DL state
844  bool needsPause = false, needsStart = false, needsForce = false, needsPreview = false;
845  bool allSameSuperSeeding = true;
846  bool superSeedingMode = false;
847  bool allSameSequentialDownloadMode = true, allSamePrioFirstlast = true;
848  bool sequentialDownloadMode = false, prioritizeFirstLast = false;
849  bool oneHasMetadata = false, oneNotSeed = false;
850  bool allSameCategory = true;
851  QString firstCategory;
852  bool first = true;
853  TagSet tagsInAny;
854  TagSet tagsInAll;
855  bool hasInfohashV1 = false, hasInfohashV2 = false;
856 
857  for (const QModelIndex &index : selectedIndexes)
858  {
859  // Get the file name
860  // Get handle and pause the torrent
861  const BitTorrent::Torrent *torrent = m_listModel->torrentHandle(mapToSource(index));
862  if (!torrent) continue;
863 
864  if (firstCategory.isEmpty() && first)
865  firstCategory = torrent->category();
866  if (firstCategory != torrent->category())
867  allSameCategory = false;
868 
869  const TagSet torrentTags = torrent->tags();
870  tagsInAny.unite(torrentTags);
871 
872  if (first)
873  {
874  tagsInAll = torrentTags;
875  }
876  else
877  {
878  tagsInAll.intersect(torrentTags);
879  }
880 
881  if (torrent->hasMetadata())
882  oneHasMetadata = true;
883  if (!torrent->isSeed())
884  {
885  oneNotSeed = true;
886  if (first)
887  {
888  sequentialDownloadMode = torrent->isSequentialDownload();
889  prioritizeFirstLast = torrent->hasFirstLastPiecePriority();
890  }
891  else
892  {
893  if (sequentialDownloadMode != torrent->isSequentialDownload())
894  allSameSequentialDownloadMode = false;
895  if (prioritizeFirstLast != torrent->hasFirstLastPiecePriority())
896  allSamePrioFirstlast = false;
897  }
898  }
899  else
900  {
901  if (!oneNotSeed && allSameSuperSeeding && torrent->hasMetadata())
902  {
903  if (first)
904  superSeedingMode = torrent->superSeeding();
905  else if (superSeedingMode != torrent->superSeeding())
906  allSameSuperSeeding = false;
907  }
908  }
909 
910  if (!torrent->isForced())
911  needsForce = true;
912  else
913  needsStart = true;
914 
915  if (torrent->isPaused())
916  needsStart = true;
917  else
918  needsPause = true;
919 
920  if (torrent->isErrored() || torrent->hasMissingFiles())
921  {
922  // If torrent is in "errored" or "missing files" state
923  // it cannot keep further processing until you restart it.
924  needsStart = true;
925  needsForce = true;
926  }
927 
928  if (torrent->hasMetadata())
929  needsPreview = true;
930 
931  if (!hasInfohashV1 && torrent->infoHash().v1().isValid())
932  hasInfohashV1 = true;
933  if (!hasInfohashV2 && torrent->infoHash().v2().isValid())
934  hasInfohashV2 = true;
935 
936  first = false;
937 
938  if (oneHasMetadata && oneNotSeed && !allSameSequentialDownloadMode
939  && !allSamePrioFirstlast && !allSameSuperSeeding && !allSameCategory
940  && needsStart && needsForce && needsPause && needsPreview
941  && hasInfohashV1 && hasInfohashV2)
942  {
943  break;
944  }
945  }
946 
947  if (needsStart)
948  listMenu->addAction(actionStart);
949  if (needsPause)
950  listMenu->addAction(actionPause);
951  if (needsForce)
952  listMenu->addAction(actionForceStart);
953  listMenu->addSeparator();
954  listMenu->addAction(actionDelete);
955  listMenu->addSeparator();
956  if (selectedIndexes.size() == 1)
957  listMenu->addAction(actionRename);
958  listMenu->addAction(actionEditTracker);
959 
960  // Tag Menu
961  QStringList tags(BitTorrent::Session::instance()->tags().values());
962  std::sort(tags.begin(), tags.end(), Utils::Compare::NaturalLessThan<Qt::CaseInsensitive>());
963 
964  QMenu *tagsMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Tags"));
965 
966  tagsMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add...", "Add / assign multiple tags...")
968  tagsMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Remove All", "Remove all tags")
969  , this, [this]()
970  {
971  if (Preferences::instance()->confirmRemoveAllTags())
973  else
975  });
976  tagsMenu->addSeparator();
977 
978  for (const QString &tag : asConst(tags))
979  {
980  auto *action = new TriStateAction(tag, tagsMenu);
981  action->setCloseOnInteraction(false);
982 
983  const Qt::CheckState initialState = tagsInAll.contains(tag) ? Qt::Checked
984  : tagsInAny.contains(tag) ? Qt::PartiallyChecked : Qt::Unchecked;
985  action->setCheckState(initialState);
986 
987  connect(action, &QAction::toggled, this, [this, tag](const bool checked)
988  {
989  if (checked)
990  addSelectionTag(tag);
991  else
992  removeSelectionTag(tag);
993  });
994 
995  tagsMenu->addAction(action);
996  }
997 
998  listMenu->addSeparator();
999  listMenu->addAction(actionTorrentOptions);
1000  if (!oneNotSeed && oneHasMetadata)
1001  {
1002  actionSuperSeedingMode->setCheckState(allSameSuperSeeding
1003  ? (superSeedingMode ? Qt::Checked : Qt::Unchecked)
1004  : Qt::PartiallyChecked);
1005  listMenu->addAction(actionSuperSeedingMode);
1006  }
1007  listMenu->addSeparator();
1008  bool addedPreviewAction = false;
1009  if (needsPreview)
1010  {
1011  listMenu->addAction(actionPreviewFile);
1012  addedPreviewAction = true;
1013  }
1014  if (oneNotSeed)
1015  addedPreviewAction = true;
1016 
1017  if (addedPreviewAction)
1018  listMenu->addSeparator();
1019  if (oneHasMetadata)
1020  {
1021  listMenu->addAction(actionForceRecheck);
1022  listMenu->addAction(actionForceReannounce);
1023  listMenu->addSeparator();
1024  }
1025  listMenu->addAction(actionOpenDestinationFolder);
1027  {
1028  listMenu->addSeparator();
1029  QMenu *queueMenu = listMenu->addMenu(tr("Queue"));
1030  queueMenu->addAction(actionTopQueuePos);
1031  queueMenu->addAction(actionIncreaseQueuePos);
1032  queueMenu->addAction(actionDecreaseQueuePos);
1033  queueMenu->addAction(actionBottomQueuePos);
1034  }
1035 
1036  QMenu *copySubMenu = listMenu->addMenu(
1037  UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy"));
1038  copySubMenu->addAction(actionCopyName);
1039  copySubMenu->addAction(actionCopyHash1);
1040  actionCopyHash1->setEnabled(hasInfohashV1);
1041  copySubMenu->addAction(actionCopyHash2);
1042  actionCopyHash2->setEnabled(hasInfohashV2);
1043  copySubMenu->addAction(actionCopyMagnetLink);
1044  copySubMenu->addAction(actionCopyID);
1045 
1046  listMenu->popup(QCursor::pos());
1047 }
SHA1Hash v1() const
Definition: infohash.cpp:44
SHA256Hash v2() const
Definition: infohash.cpp:53
bool isQueueingSystemEnabled() const
Definition: session.cpp:3411
virtual bool isErrored() const =0
virtual TagSet tags() const =0
virtual bool hasFirstLastPiecePriority() const =0
virtual QString category() const =0
virtual bool hasMissingFiles() const =0
virtual InfoHash infoHash() const =0
virtual bool superSeeding() const =0
virtual bool isPaused() const =0
virtual bool isForced() const =0
virtual bool isSeed() const =0
virtual bool isSequentialDownload() const =0
virtual bool hasMetadata() const =0
bool isValid() const
Definition: digest32.h:58
bool contains(const key_type &value) const
Definition: orderedset.h:54
ThisType & unite(const ThisType &other)
Definition: orderedset.h:103
ThisType & intersect(const ThisType &other)
Definition: orderedset.h:65
void copySelectedInfohashes(CopyInfohashPolicy policy) const
void setSelectedTorrentsSuperSeeding(bool enabled) const
void removeSelectionTag(const QString &tag)
void openSelectedTorrentsFolder() const
void copySelectedNames() const
void copySelectedMagnetURIs() const
static UIThemeManager * instance()
QIcon getIcon(const QString &iconId, const QString &fallback={}) const

References tstool::action, addSelectionTag(), asConst(), askAddTagsForSelection(), bottomQueuePosSelectedTorrents(), BitTorrent::Torrent::category(), clearSelectionTags(), confirmRemoveAllTagsForSelection(), OrderedSet< T, Compare >::contains(), copySelectedIDs(), copySelectedInfohashes(), copySelectedMagnetURIs(), copySelectedNames(), decreaseQueuePosSelectedTorrents(), editTorrentTrackers(), forceStartSelectedTorrents(), UIThemeManager::getIcon(), BitTorrent::Torrent::hasFirstLastPiecePriority(), BitTorrent::Torrent::hasMetadata(), BitTorrent::Torrent::hasMissingFiles(), increaseQueuePosSelectedTorrents(), BitTorrent::Torrent::infoHash(), BitTorrent::Session::instance(), Preferences::instance(), UIThemeManager::instance(), OrderedSet< T, Compare >::intersect(), BitTorrent::Torrent::isErrored(), BitTorrent::Torrent::isForced(), BitTorrent::Torrent::isPaused(), BitTorrent::Session::isQueueingSystemEnabled(), BitTorrent::Torrent::isSeed(), BitTorrent::Torrent::isSequentialDownload(), Digest32< N >::isValid(), m_listModel, mapToSource(), openSelectedTorrentsFolder(), pauseSelectedTorrents(), previewSelectedTorrents(), reannounceSelectedTorrents(), recheckSelectedTorrents(), removeSelectionTag(), renameSelectedTorrent(), setSelectedTorrentsSuperSeeding(), setTorrentOptions(), softDeleteSelectedTorrents(), startSelectedTorrents(), BitTorrent::Torrent::superSeeding(), BitTorrent::Torrent::tags(), topQueuePosSelectedTorrents(), TransferListModel::torrentHandle(), OrderedSet< T, Compare >::unite(), BitTorrent::InfoHash::v1(), BitTorrent::InfoHash::v2(), Version1, and Version2.

Referenced by TransferListWidget().

Here is the caller graph for this function:

◆ editTorrentTrackers()

void TransferListWidget::editTorrentTrackers ( )
private

Definition at line 667 of file transferlistwidget.cpp.

668 {
669  const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
670  QVector<BitTorrent::TrackerEntry> commonTrackers;
671 
672  if (!torrents.empty())
673  {
674  commonTrackers = torrents[0]->trackers();
675 
676  for (const BitTorrent::Torrent *torrent : torrents)
677  {
678  QSet<BitTorrent::TrackerEntry> trackerSet;
679 
680  for (const BitTorrent::TrackerEntry &entry : asConst(torrent->trackers()))
681  trackerSet.insert(entry);
682 
683  commonTrackers.erase(std::remove_if(commonTrackers.begin(), commonTrackers.end()
684  , [&trackerSet](const BitTorrent::TrackerEntry &entry) { return !trackerSet.contains(entry); })
685  , commonTrackers.end());
686  }
687  }
688 
689  auto trackerDialog = new TrackerEntriesDialog(this);
690  trackerDialog->setAttribute(Qt::WA_DeleteOnClose);
691  trackerDialog->setTrackers(commonTrackers);
692 
693  connect(trackerDialog, &QDialog::accepted, this, [torrents, trackerDialog]()
694  {
695  for (BitTorrent::Torrent *torrent : torrents)
696  torrent->replaceTrackers(trackerDialog->trackers());
697  });
698 
699  trackerDialog->open();
700 }
Definition: trackerentry.h:38

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ forceStartSelectedTorrents

void TransferListWidget::forceStartSelectedTorrents ( )
slot

Definition at line 349 of file transferlistwidget.cpp.

350 {
351  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
352  torrent->resume(BitTorrent::TorrentOperatingMode::Forced);
353 }

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSelectedTorrents()

QVector< BitTorrent::Torrent * > TransferListWidget::getSelectedTorrents ( ) const
private

Definition at line 309 of file transferlistwidget.cpp.

310 {
311  const QModelIndexList selectedRows = selectionModel()->selectedRows();
312 
313  QVector<BitTorrent::Torrent *> torrents;
314  torrents.reserve(selectedRows.size());
315  for (const QModelIndex &index : selectedRows)
316  torrents << m_listModel->torrentHandle(mapToSource(index));
317  return torrents;
318 }

References m_listModel, mapToSource(), and TransferListModel::torrentHandle().

Referenced by bottomQueuePosSelectedTorrents(), copySelectedIDs(), copySelectedInfohashes(), copySelectedMagnetURIs(), copySelectedNames(), decreaseQueuePosSelectedTorrents(), deleteSelectedTorrents(), editTorrentTrackers(), forceStartSelectedTorrents(), increaseQueuePosSelectedTorrents(), openSelectedTorrentsFolder(), pauseSelectedTorrents(), previewSelectedTorrents(), reannounceSelectedTorrents(), recheckSelectedTorrents(), setSelectedAutoTMMEnabled(), setSelectedTorrentsSuperSeeding(), setTorrentOptions(), startSelectedTorrents(), and topQueuePosSelectedTorrents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSourceModel()

TransferListModel * TransferListWidget::getSourceModel ( ) const

Definition at line 239 of file transferlistwidget.cpp.

240 {
241  return m_listModel;
242 }

References m_listModel.

Referenced by MainWindow::MainWindow(), and MainWindow::updateNbTorrents().

Here is the caller graph for this function:

◆ getVisibleTorrents()

QVector< BitTorrent::Torrent * > TransferListWidget::getVisibleTorrents ( ) const
private

Definition at line 320 of file transferlistwidget.cpp.

321 {
322  const int visibleTorrentsCount = m_sortFilterModel->rowCount();
323 
324  QVector<BitTorrent::Torrent *> torrents;
325  torrents.reserve(visibleTorrentsCount);
326  for (int i = 0; i < visibleTorrentsCount; ++i)
327  torrents << m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0)));
328  return torrents;
329 }

References m_listModel, m_sortFilterModel, mapToSource(), and TransferListModel::torrentHandle().

Referenced by deleteVisibleTorrents(), pauseVisibleTorrents(), and startVisibleTorrents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hideQueuePosColumn

void TransferListWidget::hideQueuePosColumn ( bool  hide)
slot

Definition at line 510 of file transferlistwidget.cpp.

511 {
512  setColumnHidden(TransferListModel::TR_QUEUE_POSITION, hide);
513  if (!hide && (columnWidth(TransferListModel::TR_QUEUE_POSITION) == 0))
514  resizeColumnToContents(TransferListModel::TR_QUEUE_POSITION);
515 }

References TransferListModel::TR_QUEUE_POSITION.

Referenced by MainWindow::loadPreferences().

Here is the caller graph for this function:

◆ increaseQueuePosSelectedTorrents

void TransferListWidget::increaseQueuePosSelectedTorrents ( )
slot

Definition at line 431 of file transferlistwidget.cpp.

432 {
433  qDebug() << Q_FUNC_INFO;
434  if (m_mainWindow->currentTabWidget() == this)
436 }
void increaseTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1862

References MainWindow::currentTabWidget(), anonymous_namespace{transferlistwidget.cpp}::extractIDs(), getSelectedTorrents(), BitTorrent::Session::increaseTorrentsQueuePos(), BitTorrent::Session::instance(), and m_mainWindow.

Referenced by displayListMenu(), and MainWindow::MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadSettings()

bool TransferListWidget::loadSettings ( )
private

Definition at line 1111 of file transferlistwidget.cpp.

1112 {
1113  return header()->restoreState(Preferences::instance()->getTransHeaderState());
1114 }

References Preferences::instance().

Referenced by TransferListWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mapFromSource()

QModelIndex TransferListWidget::mapFromSource ( const QModelIndex &  index) const
private

Definition at line 257 of file transferlistwidget.cpp.

258 {
259  Q_ASSERT(index.isValid());
260  Q_ASSERT(index.model() == m_sortFilterModel);
261  return m_sortFilterModel->mapFromSource(index);
262 }

References m_sortFilterModel.

◆ mapToSource()

QModelIndex TransferListWidget::mapToSource ( const QModelIndex &  index) const
private

Definition at line 249 of file transferlistwidget.cpp.

250 {
251  Q_ASSERT(index.isValid());
252  if (index.model() == m_sortFilterModel)
253  return m_sortFilterModel->mapToSource(index);
254  return index;
255 }

References m_sortFilterModel.

Referenced by applyToSelectedTorrents(), currentChanged(), displayListMenu(), getSelectedTorrents(), getVisibleTorrents(), renameSelectedTorrent(), setSelectionCategory(), and torrentDoubleClicked().

Here is the caller graph for this function:

◆ openSelectedTorrentsFolder

void TransferListWidget::openSelectedTorrentsFolder ( ) const
slot

Definition at line 517 of file transferlistwidget.cpp.

518 {
519  QSet<QString> pathsList;
520 #ifdef Q_OS_MACOS
521  // On macOS you expect both the files and folders to be opened in their parent
522  // folders prehilighted for opening, so we use a custom method.
523  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
524  {
525  const QString contentPath = QDir(torrent->actualStorageLocation()).absoluteFilePath(torrent->contentPath());
526  pathsList.insert(contentPath);
527  }
528  MacUtils::openFiles(pathsList);
529 #else
530  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
531  {
532  const QString contentPath = torrent->contentPath();
533  if (!pathsList.contains(contentPath))
534  {
535  if (torrent->filesCount() == 1)
536  Utils::Gui::openFolderSelect(contentPath);
537  else
538  Utils::Gui::openPath(contentPath);
539  }
540  pathsList.insert(contentPath);
541  }
542 #endif // Q_OS_MACOS
543 }
void openFiles(const QSet< QString > &pathsList)
Definition: macutilities.mm:98
void openFolderSelect(const QString &absolutePath)
Definition: utils.cpp:158
void openPath(const QString &absolutePath)
Definition: utils.cpp:146

References asConst(), getSelectedTorrents(), MacUtils::openFiles(), Utils::Gui::openFolderSelect(), and Utils::Gui::openPath().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pauseAllTorrents

void TransferListWidget::pauseAllTorrents ( )
slot

Definition at line 331 of file transferlistwidget.cpp.

332 {
333  for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
334  torrent->pause();
335 }

References asConst(), and BitTorrent::Session::instance().

Referenced by MainWindow::MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pauseSelectedTorrents

void TransferListWidget::pauseSelectedTorrents ( )
slot

Definition at line 361 of file transferlistwidget.cpp.

362 {
363  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
364  torrent->pause();
365 }

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu(), and MainWindow::MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pauseVisibleTorrents

void TransferListWidget::pauseVisibleTorrents ( )
slot

Definition at line 367 of file transferlistwidget.cpp.

368 {
369  for (BitTorrent::Torrent *const torrent : asConst(getVisibleTorrents()))
370  torrent->pause();
371 }

References asConst(), and getVisibleTorrents().

Referenced by TrackerFiltersList::showMenu(), and TransferListFiltersWidget::TransferListFiltersWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ permDeleteSelectedTorrents

void TransferListWidget::permDeleteSelectedTorrents ( )
slot

Definition at line 378 of file transferlistwidget.cpp.

379 {
381 }
void deleteSelectedTorrents(bool deleteLocalFiles)

References deleteSelectedTorrents().

Referenced by TransferListWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ previewFile

void TransferListWidget::previewFile ( const QString &  filePath)
slot

Definition at line 244 of file transferlistwidget.cpp.

245 {
246  Utils::Gui::openPath(filePath);
247 }

References Utils::Gui::openPath().

Referenced by previewSelectedTorrents(), and torrentDoubleClicked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ previewSelectedTorrents

void TransferListWidget::previewSelectedTorrents ( )
slot

Definition at line 545 of file transferlistwidget.cpp.

546 {
547  for (const BitTorrent::Torrent *torrent : asConst(getSelectedTorrents()))
548  {
549  if (torrentContainsPreviewableFiles(torrent))
550  {
551  auto *dialog = new PreviewSelectDialog(this, torrent);
552  dialog->setAttribute(Qt::WA_DeleteOnClose);
554  dialog->show();
555  }
556  else
557  {
558  QMessageBox::critical(this, tr("Unable to preview"), tr("The selected torrent \"%1\" does not contain previewable files")
559  .arg(torrent->name()));
560  }
561  }
562 }
void readyToPreviewFile(QString) const
void previewFile(const QString &filePath)
bool torrentContainsPreviewableFiles(const BitTorrent::Torrent *const torrent)

References asConst(), getSelectedTorrents(), previewFile(), PreviewSelectDialog::readyToPreviewFile(), and anonymous_namespace{transferlistwidget.cpp}::torrentContainsPreviewableFiles().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reannounceSelectedTorrents

void TransferListWidget::reannounceSelectedTorrents ( )
slot

Definition at line 586 of file transferlistwidget.cpp.

587 {
588  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
589  torrent->forceReannounce();
590 }

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recheckSelectedTorrents

void TransferListWidget::recheckSelectedTorrents ( )
slot

Definition at line 574 of file transferlistwidget.cpp.

575 {
576  if (Preferences::instance()->confirmTorrentRecheck())
577  {
578  QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Recheck confirmation"), tr("Are you sure you want to recheck the selected torrent(s)?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
579  if (ret != QMessageBox::Yes) return;
580  }
581 
582  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
583  torrent->forceRecheck();
584 }

References asConst(), getSelectedTorrents(), and Preferences::instance().

Referenced by displayListMenu(), and TransferListWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeSelectionTag

void TransferListWidget::removeSelectionTag ( const QString &  tag)
slot

Definition at line 779 of file transferlistwidget.cpp.

780 {
781  applyToSelectedTorrents([&tag](BitTorrent::Torrent *const torrent) { torrent->removeTag(tag); });
782 }
virtual bool removeTag(const QString &tag)=0

References applyToSelectedTorrents(), and BitTorrent::Torrent::removeTag().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renameSelectedTorrent

void TransferListWidget::renameSelectedTorrent ( )
slot

Definition at line 748 of file transferlistwidget.cpp.

749 {
750  const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
751  if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return;
752 
753  const QModelIndex mi = m_listModel->index(mapToSource(selectedIndexes.first()).row(), TransferListModel::TR_NAME);
754  BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(mi);
755  if (!torrent) return;
756 
757  // Ask for a new Name
758  bool ok = false;
759  QString name = AutoExpandableDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, torrent->name(), &ok);
760  if (ok && !name.isEmpty())
761  {
762  name.replace(QRegularExpression("\r?\n|\r"), " ");
763  // Rename the torrent
764  m_listModel->setData(mi, name, Qt::DisplayRole);
765  }
766 }
virtual QString name() const =0
bool setData(const QModelIndex &index, const QVariant &value, int role) override

References AutoExpandableDialog::getText(), m_listModel, mapToSource(), BitTorrent::Torrent::name(), TransferListModel::setData(), TransferListModel::torrentHandle(), and TransferListModel::TR_NAME.

Referenced by displayListMenu(), and TransferListWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resumeAllTorrents

void TransferListWidget::resumeAllTorrents ( )
slot

Definition at line 337 of file transferlistwidget.cpp.

338 {
339  for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
340  torrent->resume();
341 }

References asConst(), and BitTorrent::Session::instance().

Referenced by MainWindow::MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveSettings

void TransferListWidget::saveSettings ( )
privateslot

Definition at line 1106 of file transferlistwidget.cpp.

1107 {
1108  Preferences::instance()->setTransHeaderState(header()->saveState());
1109 }
void setTransHeaderState(const QByteArray &state)

References Preferences::instance(), and Preferences::setTransHeaderState().

Referenced by displayDLHoSMenu(), TransferListWidget(), and ~TransferListWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSelectedAutoTMMEnabled

void TransferListWidget::setSelectedAutoTMMEnabled ( bool  enabled) const
privateslot

Definition at line 647 of file transferlistwidget.cpp.

648 {
649  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
650  torrent->setAutoTMMEnabled(enabled);
651 }

References asConst(), and getSelectedTorrents().

Here is the call graph for this function:

◆ setSelectedTorrentsSuperSeeding

void TransferListWidget::setSelectedTorrentsSuperSeeding ( bool  enabled) const
privateslot

Definition at line 638 of file transferlistwidget.cpp.

639 {
640  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
641  {
642  if (torrent->hasMetadata())
643  torrent->setSuperSeeding(enabled);
644  }
645 }

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSelectionCategory

void TransferListWidget::setSelectionCategory ( const QString &  category)
slot

Definition at line 768 of file transferlistwidget.cpp.

769 {
770  for (const QModelIndex &index : asConst(selectionModel()->selectedRows()))
771  m_listModel->setData(m_listModel->index(mapToSource(index).row(), TransferListModel::TR_CATEGORY), category, Qt::DisplayRole);
772 }

References asConst(), m_listModel, mapToSource(), TransferListModel::setData(), and TransferListModel::TR_CATEGORY.

Referenced by askNewCategoryForSelection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTorrentOptions

void TransferListWidget::setTorrentOptions ( )
slot

Definition at line 564 of file transferlistwidget.cpp.

565 {
566  const QVector<BitTorrent::Torrent *> selectedTorrents = getSelectedTorrents();
567  if (selectedTorrents.empty()) return;
568 
569  auto dialog = new TorrentOptionsDialog {this, selectedTorrents};
570  dialog->setAttribute(Qt::WA_DeleteOnClose);
571  dialog->open();
572 }

References getSelectedTorrents().

Referenced by displayListMenu(), and torrentDoubleClicked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ softDeleteSelectedTorrents

void TransferListWidget::softDeleteSelectedTorrents ( )
slot

Definition at line 373 of file transferlistwidget.cpp.

374 {
375  deleteSelectedTorrents(false);
376 }

References deleteSelectedTorrents().

Referenced by displayListMenu(), MainWindow::MainWindow(), and TransferListWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startSelectedTorrents

void TransferListWidget::startSelectedTorrents ( )
slot

Definition at line 343 of file transferlistwidget.cpp.

344 {
345  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
346  torrent->resume();
347 }

References asConst(), and getSelectedTorrents().

Referenced by displayListMenu(), and MainWindow::MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startVisibleTorrents

void TransferListWidget::startVisibleTorrents ( )
slot

Definition at line 355 of file transferlistwidget.cpp.

356 {
357  for (BitTorrent::Torrent *const torrent : asConst(getVisibleTorrents()))
358  torrent->resume();
359 }

References asConst(), and getVisibleTorrents().

Referenced by TrackerFiltersList::showMenu(), and TransferListFiltersWidget::TransferListFiltersWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ topQueuePosSelectedTorrents

void TransferListWidget::topQueuePosSelectedTorrents ( )
slot

Definition at line 445 of file transferlistwidget.cpp.

446 {
447  if (m_mainWindow->currentTabWidget() == this)
449 }
void topTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1917

References MainWindow::currentTabWidget(), anonymous_namespace{transferlistwidget.cpp}::extractIDs(), getSelectedTorrents(), BitTorrent::Session::instance(), m_mainWindow, and BitTorrent::Session::topTorrentsQueuePos().

Referenced by displayListMenu(), and MainWindow::MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ torrentDoubleClicked

void TransferListWidget::torrentDoubleClicked ( )
privateslot

Definition at line 264 of file transferlistwidget.cpp.

265 {
266  const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
267  if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return;
268 
269  const QModelIndex index = m_listModel->index(mapToSource(selectedIndexes.first()).row());
270  BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(index);
271  if (!torrent) return;
272 
273  int action;
274  if (torrent->isSeed())
276  else
278 
279  switch (action)
280  {
281  case TOGGLE_PAUSE:
282  if (torrent->isPaused())
283  torrent->resume();
284  else
285  torrent->pause();
286  break;
287  case PREVIEW_FILE:
288  if (torrentContainsPreviewableFiles(torrent))
289  {
290  auto *dialog = new PreviewSelectDialog(this, torrent);
291  dialog->setAttribute(Qt::WA_DeleteOnClose);
293  dialog->show();
294  }
295  else
296  {
297  openDestinationFolder(torrent);
298  }
299  break;
300  case OPEN_DEST:
301  openDestinationFolder(torrent);
302  break;
303  case SHOW_OPTIONS:
305  break;
306  }
307 }
virtual void resume(TorrentOperatingMode mode=TorrentOperatingMode::AutoManaged)=0
virtual void pause()=0
int getActionOnDblClOnTorrentFn() const
int getActionOnDblClOnTorrentDl() const
void openDestinationFolder(const BitTorrent::Torrent *const torrent)
@ TOGGLE_PAUSE
Definition: optionsdialog.h:43
@ OPEN_DEST
Definition: optionsdialog.h:44
@ PREVIEW_FILE
Definition: optionsdialog.h:45
@ SHOW_OPTIONS
Definition: optionsdialog.h:47

References tstool::action, Preferences::getActionOnDblClOnTorrentDl(), Preferences::getActionOnDblClOnTorrentFn(), Preferences::instance(), BitTorrent::Torrent::isPaused(), BitTorrent::Torrent::isSeed(), m_listModel, mapToSource(), OPEN_DEST, anonymous_namespace{transferlistwidget.cpp}::openDestinationFolder(), BitTorrent::Torrent::pause(), PREVIEW_FILE, previewFile(), PreviewSelectDialog::readyToPreviewFile(), BitTorrent::Torrent::resume(), setTorrentOptions(), SHOW_OPTIONS, TOGGLE_PAUSE, anonymous_namespace{transferlistwidget.cpp}::torrentContainsPreviewableFiles(), and TransferListModel::torrentHandle().

Referenced by TransferListWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wheelEvent()

void TransferListWidget::wheelEvent ( QWheelEvent *  event)
overrideprivate

Definition at line 1116 of file transferlistwidget.cpp.

1117 {
1118  if (event->modifiers() & Qt::ShiftModifier)
1119  {
1120  // Shift + scroll = horizontal scroll
1121  event->accept();
1122  QWheelEvent scrollHEvent(event->position(), event->globalPosition()
1123  , event->pixelDelta(), event->angleDelta().transposed(), event->buttons()
1124  , event->modifiers(), event->phase(), event->inverted(), event->source());
1125  QTreeView::wheelEvent(&scrollHEvent);
1126  return;
1127  }
1128 
1129  QTreeView::wheelEvent(event); // event delegated to base class
1130 }

Member Data Documentation

◆ m_listModel

◆ m_mainWindow

◆ m_sortFilterModel


The documentation for this class was generated from the following files: