qBittorrent
transferlistwidget.cpp
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * In addition, as a special exception, the copyright holders give permission to
20  * link this program with the OpenSSL project's "OpenSSL" library (or with
21  * modified versions of it that use the same license as the "OpenSSL" library),
22  * and distribute the linked executables. You must obey the GNU General Public
23  * License in all respects for all of the code used other than "OpenSSL". If you
24  * modify file(s), you may extend this exception to your version of the file(s),
25  * but you are not obligated to do so. If you do not wish to do so, delete this
26  * exception statement from your version.
27  */
28 
29 #include "transferlistwidget.h"
30 
31 #include <algorithm>
32 
33 #include <QClipboard>
34 #include <QDebug>
35 #include <QFileDialog>
36 #include <QHeaderView>
37 #include <QMenu>
38 #include <QMessageBox>
39 #include <QRegularExpression>
40 #include <QSet>
41 #include <QShortcut>
42 #include <QTableView>
43 #include <QVector>
44 #include <QWheelEvent>
45 
49 #include "base/global.h"
50 #include "base/logger.h"
51 #include "base/preferences.h"
52 #include "base/torrentfilter.h"
53 #include "base/utils/compare.h"
54 #include "base/utils/fs.h"
55 #include "base/utils/misc.h"
56 #include "base/utils/string.h"
57 #include "autoexpandabledialog.h"
59 #include "mainwindow.h"
60 #include "optionsdialog.h"
61 #include "previewselectdialog.h"
62 #include "speedlimitdialog.h"
63 #include "torrentcategorydialog.h"
64 #include "torrentoptionsdialog.h"
65 #include "trackerentriesdialog.h"
66 #include "transferlistdelegate.h"
67 #include "transferlistmodel.h"
68 #include "transferlistsortmodel.h"
69 #include "tristateaction.h"
70 #include "uithememanager.h"
71 #include "utils.h"
72 
73 #ifdef Q_OS_MACOS
74 #include "macutilities.h"
75 #endif
76 
77 namespace
78 {
79  QVector<BitTorrent::TorrentID> extractIDs(const QVector<BitTorrent::Torrent *> &torrents)
80  {
81  QVector<BitTorrent::TorrentID> torrentIDs;
82  torrentIDs.reserve(torrents.size());
83  for (const BitTorrent::Torrent *torrent : torrents)
84  torrentIDs << torrent->id();
85  return torrentIDs;
86  }
87 
89  {
90  if (!torrent->hasMetadata())
91  return false;
92 
93  for (const QString &filePath : asConst(torrent->filePaths()))
94  {
95  const QString fileName = Utils::Fs::fileName(filePath);
97  return true;
98  }
99 
100  return false;
101  }
102 
103  void openDestinationFolder(const BitTorrent::Torrent *const torrent)
104  {
105 #ifdef Q_OS_MACOS
106  MacUtils::openFiles({torrent->contentPath()});
107 #else
108  if (torrent->filesCount() == 1)
110  else
111  Utils::Gui::openPath(torrent->contentPath());
112 #endif
113  }
114 
115  void removeTorrents(const QVector<BitTorrent::Torrent *> &torrents, const bool isDeleteFileSelected)
116  {
117  auto *session = BitTorrent::Session::instance();
118  const DeleteOption deleteOption = isDeleteFileSelected ? DeleteTorrentAndFiles : DeleteTorrent;
119  for (const BitTorrent::Torrent *torrent : torrents)
120  session->deleteTorrent(torrent->id(), deleteOption);
121  }
122 }
123 
125  : QTreeView {parent}
126  , m_listModel {new TransferListModel {this}}
127  , m_sortFilterModel {new TransferListSortModel {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 }
232 
234 {
235  // Save settings
236  saveSettings();
237 }
238 
240 {
241  return m_listModel;
242 }
243 
244 void TransferListWidget::previewFile(const QString &filePath)
245 {
246  Utils::Gui::openPath(filePath);
247 }
248 
249 QModelIndex TransferListWidget::mapToSource(const QModelIndex &index) const
250 {
251  Q_ASSERT(index.isValid());
252  if (index.model() == m_sortFilterModel)
253  return m_sortFilterModel->mapToSource(index);
254  return index;
255 }
256 
257 QModelIndex TransferListWidget::mapFromSource(const QModelIndex &index) const
258 {
259  Q_ASSERT(index.isValid());
260  Q_ASSERT(index.model() == m_sortFilterModel);
261  return m_sortFilterModel->mapFromSource(index);
262 }
263 
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 }
308 
309 QVector<BitTorrent::Torrent *> TransferListWidget::getSelectedTorrents() const
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 }
319 
320 QVector<BitTorrent::Torrent *> TransferListWidget::getVisibleTorrents() const
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 }
330 
332 {
333  for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
334  torrent->pause();
335 }
336 
338 {
339  for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
340  torrent->resume();
341 }
342 
344 {
345  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
346  torrent->resume();
347 }
348 
350 {
351  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
352  torrent->resume(BitTorrent::TorrentOperatingMode::Forced);
353 }
354 
356 {
357  for (BitTorrent::Torrent *const torrent : asConst(getVisibleTorrents()))
358  torrent->resume();
359 }
360 
362 {
363  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
364  torrent->pause();
365 }
366 
368 {
369  for (BitTorrent::Torrent *const torrent : asConst(getVisibleTorrents()))
370  torrent->pause();
371 }
372 
374 {
375  deleteSelectedTorrents(false);
376 }
377 
379 {
381 }
382 
383 void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles)
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 }
407 
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 }
430 
432 {
433  qDebug() << Q_FUNC_INFO;
434  if (m_mainWindow->currentTabWidget() == this)
436 }
437 
439 {
440  qDebug() << Q_FUNC_INFO;
441  if (m_mainWindow->currentTabWidget() == this)
443 }
444 
446 {
447  if (m_mainWindow->currentTabWidget() == this)
449 }
450 
452 {
453  if (m_mainWindow->currentTabWidget() == this)
455 }
456 
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 }
465 
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 }
474 
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 }
500 
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 }
509 
511 {
512  setColumnHidden(TransferListModel::TR_QUEUE_POSITION, hide);
513  if (!hide && (columnWidth(TransferListModel::TR_QUEUE_POSITION) == 0))
514  resizeColumnToContents(TransferListModel::TR_QUEUE_POSITION);
515 }
516 
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 }
544 
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 }
563 
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 }
573 
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 }
585 
587 {
588  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
589  torrent->forceReannounce();
590 }
591 
592 // hide/show columns menu
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 }
637 
639 {
640  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
641  {
642  if (torrent->hasMetadata())
643  torrent->setSuperSeeding(enabled);
644  }
645 }
646 
647 void TransferListWidget::setSelectedAutoTMMEnabled(const bool enabled) const
648 {
649  for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
650  torrent->setAutoTMMEnabled(enabled);
651 }
652 
654 {
655  const QString newCategoryName = TorrentCategoryDialog::createCategory(this);
656  if (!newCategoryName.isEmpty())
657  setSelectionCategory(newCategoryName);
658 }
659 
661 {
662  const QStringList tags = askTagsForSelection(tr("Add Tags"));
663  for (const QString &tag : tags)
664  addSelectionTag(tag);
665 }
666 
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 }
701 
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 }
710 
711 QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle)
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 }
737 
738 void TransferListWidget::applyToSelectedTorrents(const std::function<void (BitTorrent::Torrent *const)> &fn)
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 }
747 
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 }
767 
768 void TransferListWidget::setSelectionCategory(const QString &category)
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 }
773 
774 void TransferListWidget::addSelectionTag(const QString &tag)
775 {
776  applyToSelectedTorrents([&tag](BitTorrent::Torrent *const torrent) { torrent->addTag(tag); });
777 }
778 
780 {
781  applyToSelectedTorrents([&tag](BitTorrent::Torrent *const torrent) { torrent->removeTag(tag); });
782 }
783 
785 {
786  applyToSelectedTorrents([](BitTorrent::Torrent *const torrent) { torrent->removeAllTags(); });
787 }
788 
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 }
1048 
1049 void TransferListWidget::currentChanged(const QModelIndex &current, const QModelIndex&)
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 }
1061 
1062 void TransferListWidget::applyCategoryFilter(const QString &category)
1063 {
1064  if (category.isNull())
1066  else
1068 }
1069 
1070 void TransferListWidget::applyTagFilter(const QString &tag)
1071 {
1072  if (tag.isNull())
1074  else
1076 }
1077 
1079 {
1081 }
1082 
1083 void TransferListWidget::applyTrackerFilter(const QSet<BitTorrent::TorrentID> &torrentIDs)
1084 {
1085  m_sortFilterModel->setTrackerFilter(torrentIDs);
1086 }
1087 
1088 void TransferListWidget::applyNameFilter(const QString &name)
1089 {
1091  ? name : Utils::String::wildcardToRegexPattern(name));
1092  m_sortFilterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
1093 }
1094 
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 }
1105 
1107 {
1108  Preferences::instance()->setTransHeaderState(header()->saveState());
1109 }
1110 
1112 {
1113  return header()->restoreState(Preferences::instance()->getTransHeaderState());
1114 }
1115 
1116 void TransferListWidget::wheelEvent(QWheelEvent *event)
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 }
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)
virtual int filesCount() const =0
SHA1Hash v1() const
Definition: infohash.cpp:44
SHA256Hash v2() const
Definition: infohash.cpp:53
static Session * instance()
Definition: session.cpp:997
void decreaseTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1889
void bottomTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1942
bool isQueueingSystemEnabled() const
Definition: session.cpp:3411
static bool isValidTag(const QString &tag)
Definition: session.cpp:829
void topTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1917
void increaseTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1862
virtual bool isErrored() const =0
virtual TagSet tags() const =0
virtual bool removeTag(const QString &tag)=0
virtual bool hasFirstLastPiecePriority() const =0
virtual QString category() const =0
virtual bool hasMissingFiles() const =0
virtual InfoHash infoHash() const =0
virtual QStringList filePaths() const =0
virtual bool superSeeding() const =0
virtual void resume(TorrentOperatingMode mode=TorrentOperatingMode::AutoManaged)=0
virtual void removeAllTags()=0
virtual bool isPaused() const =0
virtual bool addTag(const QString &tag)=0
virtual bool isForced() const =0
virtual bool isSeed() const =0
virtual bool isSequentialDownload() const =0
virtual void pause()=0
virtual bool hasMetadata() const =0
virtual QString name() const =0
virtual QString contentPath() const =0
bool isValid() const
Definition: digest32.h:58
QWidget * currentTabWidget() const
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 setTransHeaderState(const QByteArray &state)
static Preferences * instance()
int getActionOnDblClOnTorrentFn() const
bool getRegexAsFilteringPatternForTransferList() const
int getActionOnDblClOnTorrentDl() const
void readyToPreviewFile(QString) const
static QString createCategory(QWidget *parent, const QString &parentCategoryName={})
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
BitTorrent::Torrent * torrentHandle(const QModelIndex &index) const
int columnCount(const QModelIndex &parent={}) const override
void setStatusFilter(TorrentFilter::Type filter)
void setTagFilter(const QString &tag)
void setCategoryFilter(const QString &category)
void setTrackerFilter(const QSet< BitTorrent::TorrentID > &torrentIDs)
void addSelectionTag(const QString &tag)
void copySelectedInfohashes(CopyInfohashPolicy policy) const
void setSelectedAutoTMMEnabled(bool enabled) const
TransferListModel * getSourceModel() const
void setSelectionCategory(const QString &category)
void displayDLHoSMenu(const QPoint &)
void previewFile(const QString &filePath)
void applyCategoryFilter(const QString &category)
void setSelectedTorrentsSuperSeeding(bool enabled) const
void wheelEvent(QWheelEvent *event) override
void currentTorrentChanged(BitTorrent::Torrent *const torrent)
void deleteSelectedTorrents(bool deleteLocalFiles)
QVector< BitTorrent::Torrent * > getSelectedTorrents() const
void removeSelectionTag(const QString &tag)
TransferListModel * m_listModel
void displayListMenu(const QPoint &)
TransferListWidget(QWidget *parent, MainWindow *mainWindow)
void hideQueuePosColumn(bool hide)
void applyTrackerFilter(const QSet< BitTorrent::TorrentID > &torrentIDs)
TransferListSortModel * m_sortFilterModel
QModelIndex mapToSource(const QModelIndex &index) const
void applyTagFilter(const QString &tag)
QVector< BitTorrent::Torrent * > getVisibleTorrents() const
QStringList askTagsForSelection(const QString &dialogTitle)
void openSelectedTorrentsFolder() const
void applyNameFilter(const QString &name)
void currentChanged(const QModelIndex &current, const QModelIndex &) override
QModelIndex mapFromSource(const QModelIndex &index) const
void copySelectedNames() const
void copySelectedMagnetURIs() const
void applyToSelectedTorrents(const std::function< void(BitTorrent::Torrent *const)> &fn)
static UIThemeManager * instance()
QIcon getIcon(const QString &iconId, const QString &fallback={}) const
constexpr std::add_const_t< T > & asConst(T &t) noexcept
Definition: global.h:42
void openFiles(const QSet< QString > &pathsList)
Definition: macutilities.mm:98
QString fileName(const QString &filePath)
Definition: fs.cpp:87
void openFolderSelect(const QString &absolutePath)
Definition: utils.cpp:158
void openPath(const QString &absolutePath)
Definition: utils.cpp:146
bool isPreviewable(const QString &filename)
Definition: misc.cpp:295
QString wildcardToRegexPattern(const QString &pattern)
Definition: string.cpp:57
bool torrentContainsPreviewableFiles(const BitTorrent::Torrent *const torrent)
void removeTorrents(const QVector< BitTorrent::Torrent * > &torrents, const bool isDeleteFileSelected)
QVector< BitTorrent::TorrentID > extractIDs(const QVector< BitTorrent::Torrent * > &torrents)
void openDestinationFolder(const BitTorrent::Torrent *const torrent)
action
Definition: tstool.py:143
@ TOGGLE_PAUSE
Definition: optionsdialog.h:43
@ OPEN_DEST
Definition: optionsdialog.h:44
@ PREVIEW_FILE
Definition: optionsdialog.h:45
@ SHOW_OPTIONS
Definition: optionsdialog.h:47
DeleteOption
Definition: session.h:80
@ DeleteTorrent
Definition: session.h:81
@ DeleteTorrentAndFiles
Definition: session.h:82
Definition: trackerentry.h:38
void f()
Definition: test2.c:1
CopyInfohashPolicy