From 000895322f954301ab145e39421af646b8cbfd12 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Sat, 24 Oct 2015 20:56:45 +0000 Subject: [PATCH] Clear filter upon double clicking on filtered torrent list notice --- qt/FilterBar.cc | 12 ++++++++++++ qt/FilterBar.h | 3 +++ qt/MainWindow.cc | 1 + qt/TorrentView.cc | 7 ++++++- qt/TorrentView.h | 3 +++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/qt/FilterBar.cc b/qt/FilterBar.cc index 251390cc5..faecb718c 100644 --- a/qt/FilterBar.cc +++ b/qt/FilterBar.cc @@ -276,6 +276,18 @@ FilterBar::~FilterBar () **** ***/ +void +FilterBar::clear () +{ + myActivityCombo->setCurrentIndex (0); + myTrackerCombo->setCurrentIndex (0); + myLineEdit->clear (); +} + +/*** +**** +***/ + void FilterBar::refreshPref (int key) { diff --git a/qt/FilterBar.h b/qt/FilterBar.h index 4dffe72fd..70476c758 100644 --- a/qt/FilterBar.h +++ b/qt/FilterBar.h @@ -30,6 +30,9 @@ class FilterBar: public QWidget FilterBar (Prefs& prefs, const TorrentModel& torrents, const TorrentFilter& filter, QWidget * parent = nullptr); virtual ~FilterBar (); + public slots: + void clear (); + private: FilterBarComboBox * createTrackerCombo (QStandardItemModel *); FilterBarComboBox * createActivityCombo (); diff --git a/qt/MainWindow.cc b/qt/MainWindow.cc index 5732c3a94..bb12a86f5 100644 --- a/qt/MainWindow.cc +++ b/qt/MainWindow.cc @@ -258,6 +258,7 @@ MainWindow::MainWindow (Session& session, Prefs& prefs, TorrentModel& model, boo connect (&myModel, SIGNAL (rowsRemoved (QModelIndex, int, int)), SLOT (refreshTorrentViewHeader ())); connect (&myFilterModel, SIGNAL (rowsInserted (QModelIndex, int, int)), SLOT (refreshTorrentViewHeader ())); connect (&myFilterModel, SIGNAL (rowsRemoved (QModelIndex, int, int)), SLOT (refreshTorrentViewHeader ())); + connect (ui.listView, SIGNAL (headerDoubleClicked ()), myFilterBar, SLOT (clear ())); QList initKeys; initKeys << Prefs::MAIN_WINDOW_X diff --git a/qt/TorrentView.cc b/qt/TorrentView.cc index be1b186bc..3344df0e2 100644 --- a/qt/TorrentView.cc +++ b/qt/TorrentView.cc @@ -16,7 +16,7 @@ class TorrentView::HeaderWidget: public QWidget { public: - HeaderWidget (QWidget * parent): + HeaderWidget (TorrentView * parent): QWidget (parent), myText () { @@ -56,6 +56,11 @@ class TorrentView::HeaderWidget: public QWidget painter.drawItemText (option.rect, Qt::AlignCenter, option.palette, true, myText, QPalette::ButtonText); } + virtual void mouseDoubleClickEvent (QMouseEvent * /*event*/) + { + emit static_cast (parent ())->headerDoubleClicked (); + } + private: QString myText; }; diff --git a/qt/TorrentView.h b/qt/TorrentView.h index cda3eb0d9..b07530160 100644 --- a/qt/TorrentView.h +++ b/qt/TorrentView.h @@ -22,6 +22,9 @@ class TorrentView: public QListView public slots: void setHeaderText (const QString& text); + signals: + void headerDoubleClicked (); + protected: virtual void resizeEvent (QResizeEvent * event);