Sayonara Player
Searchbar.h
1 /* SearchBar.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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 sigCurrentModeChanged();
47  void sigTextChanged(const QString& text);
48 
49  public:
50  SearchBar(QWidget* parent=nullptr);
51  ~SearchBar() override;
52 
60  void setInvalidGenreMode(bool b);
61 
62  [[maybe_unused]]
66  bool hasInvalidGenreMode() const;
67 
68  [[maybe_unused]]
73 
74  [[maybe_unused]]
79 
84  void setCurrentMode(Filter::Mode mode);
85 
91 
96  void setNextMode();
97 
101  Filter::Mode currentMode() const;
102 
106  void reset();
107 
108  private:
109  void initContextMenu();
110 
111  private slots:
112  void currentTextChanged(const QString& text);
113  void searchShortcutPressed();
114 
115  void livesearchChanged();
116  void livesearchTriggered(bool b);
117 
118  protected:
119  void keyPressEvent(QKeyEvent* e) override;
120  void languageChanged() override;
121  void skinChanged() override;
122  };
123 }
124 
125 #endif // LIBRARYSEARCHBAR_H
Library::SearchBar::setInvalidGenreMode
void setInvalidGenreMode(bool b)
this method does not set the genre mode implicitly. You also have to use set_mode()....
Library::SearchBar::setModes
void setModes(const QList< Filter::Mode > &modes)
Sets the supported modes. See Library::Filter::Mode.
Library::SearchBar::reset
void reset()
Clears the input and sets mode back to Fulltext search.
QList
Definition: EngineUtils.h:33
Library::SearchBar::setPreviousMode
void setPreviousMode()
fast toggling between modes by using arrow up key
Gui::WidgetTemplate
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:87
Library::SearchBar::modes
QList< Filter::Mode > modes() const
returns supported modes. See Library::Filter::Mode
Library
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31
Library::SearchBar::hasInvalidGenreMode
bool hasInvalidGenreMode() const
if the current state is the invalid genre mode
Library::SearchBar::setNextMode
void setNextMode()
fast toggling between modes by using arrow down key
Library::SearchBar
The searchbar has a special context menu which allows to select the search mode. A special search mod...
Definition: Searchbar.h:39
Library::SearchBar::currentMode
Filter::Mode currentMode() const
current selected mode
Library::SearchBar::setCurrentMode
void setCurrentMode(Filter::Mode mode)
If mode is Filter::Mode::Genre but the genre should be empty, also use set_invalid_genre_mode()