Sayonara Player
LibrarySearchBar.h
1 /* LibrarySearchBar.h */
2 
3 /* Copyright (C) 2011-2019 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef LIBRARYSEARCHBAR_H
22 #define LIBRARYSEARCHBAR_H
23 
24 #include <QLineEdit>
25 #include "Utils/Pimpl.h"
26 #include "Utils/Library/Filter.h"
27 #include "Gui/Utils/Widgets/WidgetTemplate.h"
28 
29 namespace Library
30 {
38  class SearchBar : public Gui::WidgetTemplate<QLineEdit>
39  {
40  Q_OBJECT
41  PIMPL(SearchBar)
42 
44 
45  signals:
46  void sig_current_mode_changed();
47  void sig_text_changed(const QString& text);
48 
49  public:
50  SearchBar(QWidget* parent=nullptr);
51  ~SearchBar() override;
52 
60  void set_invalid_genre_mode(bool b);
61 
66  bool has_invalid_genre_mode() const;
67 
72  void set_modes(const QList<Filter::Mode>& modes);
73 
78  QList<Filter::Mode> modes() const;
79 
84  void set_current_mode(Filter::Mode mode);
85 
90  void set_previous_mode();
91 
96  void set_next_mode();
97 
101  Filter::Mode current_mode() const;
102 
106  void reset();
107 
108  protected:
109  void init_context_menu();
110  void keyPressEvent(QKeyEvent* e) override;
111  void language_changed() override;
112  void skin_changed() override;
113 
114  private slots:
115  void text_changed(const QString& text);
116  void search_shortcut_pressed();
117 
118  void livesearch_changed();
119  void livesearch_triggered(bool b);
120  };
121 }
122 
123 #endif // LIBRARYSEARCHBAR_H
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:84
void reset()
Clears the input and sets mode back to Fulltext search.
void set_current_mode(Filter::Mode mode)
If mode is Filter::Mode::Genre but the genre should be empty, also use set_invalid_genre_mode() ...
void set_previous_mode()
fast toggling between modes by using arrow up key
Filter::Mode current_mode() const
current selected mode
void set_invalid_genre_mode(bool b)
this method does not set the genre mode implicitly. You also have to use set_mode(). The invalid genre mode searchs for an empty genre. This is used to fetch tracks which do not have a genre.
The searchbar has a special context menu which allows to select the search mode. A special search mod...
Definition: LibrarySearchBar.h:38
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:32
QList< Filter::Mode > modes() const
returns supported modes. See Library::Filter::Mode
bool has_invalid_genre_mode() const
if the current state is the invalid genre mode
void set_modes(const QList< Filter::Mode > &modes)
Sets the supported modes. See Library::Filter::Mode.
Definition: EngineUtils.h:33
void set_next_mode()
fast toggling between modes by using arrow down key