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
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
#include "librarymodel.h"
|
|
|
|
|
|
|
|
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 QSignalMapper;
|
|
|
|
|
|
|
|
class LibraryFilterWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
LibraryFilterWidget(QWidget* parent = 0);
|
|
|
|
~LibraryFilterWidget();
|
|
|
|
|
2010-11-27 21:20:26 +01:00
|
|
|
static const int kFilterDelay = 500; // msec
|
|
|
|
|
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);
|
|
|
|
|
2010-05-09 22:18:05 +02:00
|
|
|
void SetFilterHint(const QString& hint);
|
2011-04-27 18:38:28 +02: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
|
|
|
|
|
|
|
signals:
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
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_;
|
|
|
|
|
|
|
|
boost::scoped_ptr<GroupByDialog> group_by_dialog_;
|
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_;
|
|
|
|
QSignalMapper* filter_age_mapper_;
|
|
|
|
|
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_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LIBRARYFILTERWIDGET_H
|