2010-05-09 22:18:05 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-05-09 22:18:05 +02:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBRARYFILTERWIDGET_H
|
|
|
|
#define LIBRARYFILTERWIDGET_H
|
|
|
|
|
2019-11-10 15:07:12 +01:00
|
|
|
#include <QMap>
|
2019-11-10 15:16:39 +01:00
|
|
|
#include <QWidget>
|
2020-09-18 16:15:19 +02:00
|
|
|
#include <memory>
|
2010-05-09 22:18:05 +02:00
|
|
|
|
|
|
|
#include "librarymodel.h"
|
2015-12-12 04:49:51 +01:00
|
|
|
#include "savedgroupingmanager.h"
|
2010-05-09 22:18:05 +02:00
|
|
|
|
|
|
|
class GroupByDialog;
|
2010-06-09 01:06:29 +02:00
|
|
|
class SettingsDialog;
|
2010-05-10 23:50:31 +02:00
|
|
|
class Ui_LibraryFilterWidget;
|
2010-05-09 22:18:05 +02:00
|
|
|
|
2011-02-06 15:34:47 +01:00
|
|
|
struct QueryOptions;
|
|
|
|
|
2010-05-09 22:18:05 +02:00
|
|
|
class QMenu;
|
|
|
|
class QActionGroup;
|
|
|
|
|
|
|
|
class LibraryFilterWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
LibraryFilterWidget(QWidget* parent = nullptr);
|
2010-05-09 22:18:05 +02:00
|
|
|
~LibraryFilterWidget();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
static const int kFilterDelay = 500; // msec
|
2010-11-27 21:20:26 +01:00
|
|
|
|
2011-04-27 18:38:28 +02:00
|
|
|
enum DelayBehaviour {
|
|
|
|
AlwaysInstant,
|
|
|
|
DelayedOnLargeLibraries,
|
|
|
|
AlwaysDelayed,
|
|
|
|
};
|
|
|
|
|
2012-06-17 17:20:40 +02:00
|
|
|
static QActionGroup* CreateGroupByActions(QObject* parent);
|
|
|
|
|
2015-12-12 00:58:06 +01:00
|
|
|
void UpdateGroupByActions();
|
2010-05-09 22:18:05 +02:00
|
|
|
void SetFilterHint(const QString& hint);
|
2014-02-07 16:34:20 +01:00
|
|
|
void SetApplyFilterToLibrary(bool filter_applies_to_model) {
|
|
|
|
filter_applies_to_model_ = filter_applies_to_model;
|
|
|
|
}
|
|
|
|
void SetDelayBehaviour(DelayBehaviour behaviour) {
|
|
|
|
delay_behaviour_ = behaviour;
|
|
|
|
}
|
2010-05-09 22:18:05 +02:00
|
|
|
void SetAgeFilterEnabled(bool enabled);
|
|
|
|
void SetGroupByEnabled(bool enabled);
|
2014-01-11 21:03:32 +01:00
|
|
|
void ShowInLibrary(const QString& search);
|
2011-01-30 22:00:49 +01:00
|
|
|
|
2011-11-05 20:09:02 +01:00
|
|
|
QMenu* menu() const { return library_menu_; }
|
2010-06-09 17:38:00 +02:00
|
|
|
void AddMenuAction(QAction* action);
|
2010-05-09 22:18:05 +02:00
|
|
|
|
|
|
|
void SetSettingsGroup(const QString& group) { settings_group_ = group; }
|
|
|
|
void SetLibraryModel(LibraryModel* model);
|
|
|
|
|
2010-08-29 14:15:30 +02:00
|
|
|
public slots:
|
2011-02-06 14:18:18 +01:00
|
|
|
void SetQueryMode(QueryOptions::QueryMode view);
|
2011-03-13 15:14:16 +01:00
|
|
|
void FocusOnFilter(QKeyEvent* e);
|
2010-08-29 14:15:30 +02:00
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
signals:
|
2010-08-29 14:15:30 +02:00
|
|
|
void UpPressed();
|
|
|
|
void DownPressed();
|
|
|
|
void ReturnPressed();
|
2011-04-27 18:38:28 +02:00
|
|
|
void Filter(const QString& text);
|
2010-08-29 14:15:30 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void keyReleaseEvent(QKeyEvent* e);
|
|
|
|
|
2010-05-09 22:18:05 +02:00
|
|
|
private slots:
|
|
|
|
void GroupingChanged(const LibraryModel::Grouping& g);
|
|
|
|
void GroupByClicked(QAction* action);
|
2015-12-11 20:59:55 +01:00
|
|
|
void SaveGroupBy();
|
2015-12-12 04:49:51 +01:00
|
|
|
void ShowGroupingManager();
|
2010-05-09 22:18:05 +02:00
|
|
|
|
2010-11-27 21:20:26 +01:00
|
|
|
void FilterTextChanged(const QString& text);
|
|
|
|
void FilterDelayTimeout();
|
|
|
|
|
2012-06-17 17:20:40 +02:00
|
|
|
private:
|
|
|
|
static QAction* CreateGroupByAction(const QString& text, QObject* parent,
|
|
|
|
const LibraryModel::Grouping& grouping);
|
2015-12-12 00:58:06 +01:00
|
|
|
void CheckCurrentGrouping(const LibraryModel::Grouping& g);
|
2012-06-17 17:20:40 +02:00
|
|
|
|
2010-05-09 22:18:05 +02:00
|
|
|
private:
|
2010-05-10 23:50:31 +02:00
|
|
|
Ui_LibraryFilterWidget* ui_;
|
2010-05-09 22:18:05 +02:00
|
|
|
LibraryModel* model_;
|
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
std::unique_ptr<GroupByDialog> group_by_dialog_;
|
2015-12-12 04:49:51 +01:00
|
|
|
std::unique_ptr<SavedGroupingManager> groupings_manager_;
|
2010-06-09 01:06:29 +02:00
|
|
|
SettingsDialog* settings_dialog_;
|
2010-05-09 22:18:05 +02:00
|
|
|
|
|
|
|
QMenu* filter_age_menu_;
|
|
|
|
QMenu* group_by_menu_;
|
2010-06-09 17:38:00 +02:00
|
|
|
QMenu* library_menu_;
|
2010-05-09 22:18:05 +02:00
|
|
|
QActionGroup* group_by_group_;
|
2019-11-10 15:07:12 +01:00
|
|
|
QMap<QAction*, int> filter_ages_;
|
2010-05-09 22:18:05 +02:00
|
|
|
|
2010-11-27 21:20:26 +01:00
|
|
|
QTimer* filter_delay_;
|
|
|
|
|
2011-04-27 18:38:28 +02:00
|
|
|
bool filter_applies_to_model_;
|
|
|
|
DelayBehaviour delay_behaviour_;
|
|
|
|
|
2010-05-09 22:18:05 +02:00
|
|
|
QString settings_group_;
|
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // LIBRARYFILTERWIDGET_H
|