2012-06-04 19:18:37 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2012, David Sansome <me@davidsansome.com>
|
2014-02-07 16:34:20 +01:00
|
|
|
|
2012-06-04 19:18:37 +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.
|
2014-02-07 16:34:20 +01:00
|
|
|
|
2012-06-04 19:18:37 +02:00
|
|
|
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.
|
2014-02-07 16:34:20 +01:00
|
|
|
|
2012-06-04 19:18:37 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GLOBALSEARCHVIEW_H
|
|
|
|
#define GLOBALSEARCHVIEW_H
|
|
|
|
|
|
|
|
#include "searchprovider.h"
|
|
|
|
#include "library/librarymodel.h"
|
|
|
|
#include "ui/settingsdialog.h"
|
2017-08-09 15:12:36 +02:00
|
|
|
#include "playlist/playlistmanager.h"
|
2012-06-04 19:18:37 +02:00
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class Application;
|
2012-06-10 22:11:55 +02:00
|
|
|
class GlobalSearchModel;
|
2012-06-17 17:20:40 +02:00
|
|
|
class GroupByDialog;
|
2012-06-10 20:00:51 +02:00
|
|
|
class SearchProviderStatusWidget;
|
2012-06-11 00:05:30 +02:00
|
|
|
class SuggestionWidget;
|
2012-06-04 19:18:37 +02:00
|
|
|
class Ui_GlobalSearchView;
|
|
|
|
|
2012-06-17 17:20:40 +02:00
|
|
|
class QActionGroup;
|
2012-06-04 19:18:37 +02:00
|
|
|
class QMimeData;
|
|
|
|
class QSortFilterProxyModel;
|
|
|
|
class QStandardItem;
|
|
|
|
class QStandardItemModel;
|
|
|
|
|
|
|
|
class GlobalSearchView : public QWidget {
|
|
|
|
Q_OBJECT
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
GlobalSearchView(Application* app, QWidget* parent = nullptr);
|
2012-06-04 19:18:37 +02:00
|
|
|
~GlobalSearchView();
|
|
|
|
|
|
|
|
static const int kSwapModelsTimeoutMsec;
|
2012-06-11 00:05:30 +02:00
|
|
|
static const int kMaxSuggestions;
|
|
|
|
static const int kUpdateSuggestionsTimeoutMsec;
|
2012-06-04 19:18:37 +02:00
|
|
|
|
|
|
|
// Called by the delegate
|
|
|
|
void LazyLoadArt(const QModelIndex& index);
|
|
|
|
|
2012-06-11 00:05:30 +02:00
|
|
|
// QWidget
|
|
|
|
void showEvent(QShowEvent* e);
|
|
|
|
void hideEvent(QHideEvent* e);
|
|
|
|
|
2012-06-10 22:56:17 +02:00
|
|
|
// QObject
|
|
|
|
bool eventFilter(QObject* object, QEvent* event);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public slots:
|
2012-06-11 00:05:30 +02:00
|
|
|
void ReloadSettings();
|
2012-06-04 19:18:37 +02:00
|
|
|
void StartSearch(const QString& query);
|
2012-06-16 22:17:13 +02:00
|
|
|
void FocusSearchField();
|
|
|
|
void OpenSettingsDialog();
|
2012-06-04 19:18:37 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void AddToPlaylist(QMimeData* data);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2012-06-11 00:05:30 +02:00
|
|
|
void UpdateSuggestions();
|
2012-06-10 20:00:51 +02:00
|
|
|
|
2012-06-04 19:18:37 +02:00
|
|
|
void SwapModels();
|
|
|
|
void TextEdited(const QString& text);
|
|
|
|
void AddResults(int id, const SearchProvider::ResultList& results);
|
|
|
|
void ArtLoaded(int id, const QPixmap& pixmap);
|
|
|
|
|
2012-06-11 22:06:26 +02:00
|
|
|
void FocusOnFilter(QKeyEvent* event);
|
|
|
|
|
2012-06-10 22:56:17 +02:00
|
|
|
void AddSelectedToPlaylist();
|
|
|
|
void LoadSelected();
|
|
|
|
void OpenSelectedInNewPlaylist();
|
|
|
|
void AddSelectedToPlaylistEnqueue();
|
|
|
|
|
2017-08-09 15:12:36 +02:00
|
|
|
void SearchForThis();
|
|
|
|
|
2012-06-17 17:20:40 +02:00
|
|
|
void GroupByClicked(QAction* action);
|
|
|
|
void SetGroupBy(const LibraryModel::Grouping& grouping);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2012-06-10 22:56:17 +02:00
|
|
|
MimeData* SelectedMimeData();
|
|
|
|
|
|
|
|
bool SearchKeyEvent(QKeyEvent* event);
|
|
|
|
bool ResultsContextMenuEvent(QContextMenuEvent* event);
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
private:
|
2012-06-04 19:18:37 +02:00
|
|
|
Application* app_;
|
|
|
|
GlobalSearch* engine_;
|
|
|
|
Ui_GlobalSearchView* ui_;
|
2012-06-17 17:20:40 +02:00
|
|
|
QScopedPointer<GroupByDialog> group_by_dialog_;
|
2012-06-04 19:18:37 +02:00
|
|
|
|
2012-06-10 22:56:17 +02:00
|
|
|
QMenu* context_menu_;
|
2012-06-16 22:17:13 +02:00
|
|
|
QList<QAction*> context_actions_;
|
2012-06-17 17:20:40 +02:00
|
|
|
QActionGroup* group_by_actions_;
|
2012-06-10 22:56:17 +02:00
|
|
|
|
2012-06-04 19:18:37 +02:00
|
|
|
int last_search_id_;
|
|
|
|
|
|
|
|
// Like graphics APIs have a front buffer and a back buffer, there's a front
|
|
|
|
// model and a back model - the front model is the one that's shown in the
|
|
|
|
// UI and the back model is the one that lies in wait. current_model_ will
|
|
|
|
// point to either the front or the back model.
|
2012-06-10 22:11:55 +02:00
|
|
|
GlobalSearchModel* front_model_;
|
|
|
|
GlobalSearchModel* back_model_;
|
|
|
|
GlobalSearchModel* current_model_;
|
2012-06-04 19:18:37 +02:00
|
|
|
|
|
|
|
QSortFilterProxyModel* front_proxy_;
|
|
|
|
QSortFilterProxyModel* back_proxy_;
|
|
|
|
QSortFilterProxyModel* current_proxy_;
|
|
|
|
|
|
|
|
QMap<int, QModelIndex> art_requests_;
|
2012-06-10 18:15:32 +02:00
|
|
|
|
2012-06-10 22:11:55 +02:00
|
|
|
QTimer* swap_models_timer_;
|
2012-06-11 00:05:30 +02:00
|
|
|
QTimer* update_suggestions_timer_;
|
2012-06-10 20:00:51 +02:00
|
|
|
|
|
|
|
QList<SearchProviderStatusWidget*> provider_status_widgets_;
|
2012-06-11 00:05:30 +02:00
|
|
|
QList<SuggestionWidget*> suggestion_widgets_;
|
|
|
|
|
|
|
|
QIcon search_icon_;
|
|
|
|
QIcon warning_icon_;
|
2014-02-07 16:34:20 +01:00
|
|
|
|
2012-06-11 17:26:33 +02:00
|
|
|
bool show_providers_;
|
|
|
|
bool show_suggestions_;
|
2012-06-04 19:18:37 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // GLOBALSEARCHVIEW_H
|