mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-24 13:34:27 +00:00
parent
e4f90730b2
commit
0bb0829a9a
@ -35,11 +35,13 @@
|
||||
#include <QActionGroup>
|
||||
#include <QClipboard>
|
||||
#include <QCloseEvent>
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaObject>
|
||||
#include <QMimeData>
|
||||
@ -187,15 +189,23 @@ MainWindow::MainWindow(IGUIApplication *app, WindowState initialState)
|
||||
hSplitter->setChildrenCollapsible(false);
|
||||
hSplitter->setFrameShape(QFrame::NoFrame);
|
||||
|
||||
// Name filter
|
||||
// Torrent filter
|
||||
m_searchFilter = new LineEdit(this);
|
||||
m_searchFilter->setPlaceholderText(tr("Filter torrent names..."));
|
||||
m_searchFilter->setPlaceholderText(tr("Filter torrents..."));
|
||||
m_searchFilter->setFixedWidth(200);
|
||||
m_searchFilter->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_searchFilter, &QWidget::customContextMenuRequested, this, &MainWindow::showFilterContextMenu);
|
||||
m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter);
|
||||
|
||||
QWidget *spacer = new QWidget(this);
|
||||
auto *filterColumnWidget = new QWidget(this);
|
||||
auto *filterLabel = new QLabel(tr("Filter by:"));
|
||||
filterLabel->setMargin(7);
|
||||
m_filterColumnComboBox = new QComboBox(this);
|
||||
QHBoxLayout *filterColumnLayout = new QHBoxLayout(this);
|
||||
filterColumnLayout->addWidget(filterLabel);
|
||||
filterColumnLayout->addWidget(m_filterColumnComboBox);
|
||||
filterColumnWidget->setLayout(filterColumnLayout);
|
||||
m_ui->toolBar->insertWidget(m_ui->actionLock, filterColumnWidget);
|
||||
auto *spacer = new QWidget(this);
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_ui->toolBar->insertWidget(m_searchFilterAction, spacer);
|
||||
|
||||
@ -213,8 +223,15 @@ MainWindow::MainWindow(IGUIApplication *app, WindowState initialState)
|
||||
UIThemeManager::instance()->getIcon(u"folder-remote"_qs),
|
||||
#endif
|
||||
tr("Transfers"));
|
||||
|
||||
connect(m_searchFilter, &LineEdit::textChanged, m_transferListWidget, &TransferListWidget::applyNameFilter);
|
||||
// Filter types
|
||||
const QVector<TransferListModel::Column> filterTypes = {TransferListModel::Column::TR_NAME, TransferListModel::Column::TR_SAVE_PATH};
|
||||
for (const TransferListModel::Column type : filterTypes)
|
||||
{
|
||||
const QString typeName = m_transferListWidget->getSourceModel()->headerData(type, Qt::Horizontal, Qt::DisplayRole).value<QString>();
|
||||
m_filterColumnComboBox->addItem(typeName, type);
|
||||
}
|
||||
connect(m_filterColumnComboBox, &QComboBox::currentIndexChanged, this, &MainWindow::applyTransferListFilter);
|
||||
connect(m_searchFilter, &LineEdit::textChanged, this, &MainWindow::applyTransferListFilter);
|
||||
connect(hSplitter, &QSplitter::splitterMoved, this, &MainWindow::saveSettings);
|
||||
connect(m_splitter, &QSplitter::splitterMoved, this, &MainWindow::saveSplitterSettings);
|
||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersChanged, m_propertiesWidget, &PropertiesWidget::loadTrackers);
|
||||
@ -670,7 +687,7 @@ void MainWindow::showFilterContextMenu()
|
||||
useRegexAct->setCheckable(true);
|
||||
useRegexAct->setChecked(pref->getRegexAsFilteringPatternForTransferList());
|
||||
connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPatternForTransferList);
|
||||
connect(useRegexAct, &QAction::toggled, this, [this]() { m_transferListWidget->applyNameFilter(m_searchFilter->text()); });
|
||||
connect(useRegexAct, &QAction::toggled, this, &MainWindow::applyTransferListFilter);
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
@ -1917,6 +1934,11 @@ void MainWindow::updatePowerManagementState()
|
||||
m_pwr->setActivityState(inhibitSuspend);
|
||||
}
|
||||
|
||||
void MainWindow::applyTransferListFilter()
|
||||
{
|
||||
m_transferListWidget->applyFilter(m_searchFilter->text(), m_filterColumnComboBox->currentData().value<TransferListModel::Column>());
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
|
||||
void MainWindow::checkProgramUpdate(const bool invokedByUser)
|
||||
{
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "windowstate.h"
|
||||
|
||||
class QCloseEvent;
|
||||
class QComboBox;
|
||||
class QFileSystemWatcher;
|
||||
class QSplitter;
|
||||
class QTabWidget;
|
||||
@ -194,6 +195,7 @@ private:
|
||||
void createTorrentTriggered(const Path &path);
|
||||
void showStatusBar(bool show);
|
||||
void showFiltersSidebar(bool show);
|
||||
void applyTransferListFilter();
|
||||
|
||||
Ui::MainWindow *m_ui = nullptr;
|
||||
|
||||
@ -219,6 +221,7 @@ private:
|
||||
bool m_unlockDlgShowing = false;
|
||||
LineEdit *m_searchFilter = nullptr;
|
||||
QAction *m_searchFilterAction = nullptr;
|
||||
QComboBox *m_filterColumnComboBox = nullptr;
|
||||
// Widgets
|
||||
QAction *m_queueSeparator = nullptr;
|
||||
QAction *m_queueSeparatorMenu = nullptr;
|
||||
|
@ -143,3 +143,5 @@ private:
|
||||
QIcon m_stalledUPIcon;
|
||||
QIcon m_uploadingIcon;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(TransferListModel::Column)
|
||||
|
@ -64,7 +64,6 @@
|
||||
#include "torrentoptionsdialog.h"
|
||||
#include "trackerentriesdialog.h"
|
||||
#include "transferlistdelegate.h"
|
||||
#include "transferlistmodel.h"
|
||||
#include "transferlistsortmodel.h"
|
||||
#include "tristateaction.h"
|
||||
#include "uithememanager.h"
|
||||
@ -1299,8 +1298,9 @@ void TransferListWidget::applyTrackerFilter(const QSet<BitTorrent::TorrentID> &t
|
||||
m_sortFilterModel->setTrackerFilter(torrentIDs);
|
||||
}
|
||||
|
||||
void TransferListWidget::applyNameFilter(const QString &name)
|
||||
void TransferListWidget::applyFilter(const QString &name, const TransferListModel::Column &type)
|
||||
{
|
||||
m_sortFilterModel->setFilterKeyColumn(type);
|
||||
const QString pattern = (Preferences::instance()->getRegexAsFilteringPatternForTransferList()
|
||||
? name : Utils::String::wildcardToRegexPattern(name));
|
||||
m_sortFilterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
|
||||
|
@ -34,10 +34,10 @@
|
||||
#include <QTreeView>
|
||||
|
||||
#include "base/bittorrent/infohash.h"
|
||||
#include "transferlistmodel.h"
|
||||
|
||||
class MainWindow;
|
||||
class Path;
|
||||
class TransferListModel;
|
||||
class TransferListSortModel;
|
||||
|
||||
namespace BitTorrent
|
||||
@ -92,7 +92,7 @@ public slots:
|
||||
void setTorrentOptions();
|
||||
void previewSelectedTorrents();
|
||||
void hideQueuePosColumn(bool hide);
|
||||
void applyNameFilter(const QString &name);
|
||||
void applyFilter(const QString &name, const TransferListModel::Column &type);
|
||||
void applyStatusFilter(int f);
|
||||
void applyCategoryFilter(const QString &category);
|
||||
void applyTagFilter(const QString &tag);
|
||||
|
Loading…
x
Reference in New Issue
Block a user