Sayonara Player
SearchableListView.h
1 /* SearchableListView.h */
2 
3 /* Copyright (C) 2011-2016 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 
22 
23 #ifndef SEARCHABLELISTVIEW_H
24 #define SEARCHABLELISTVIEW_H
25 
26 
27 #include "SayonaraSelectionView.h"
28 
29 #include <QListView>
30 #include <QMouseEvent>
31 #include <QKeyEvent>
32 #include <QModelIndexList>
33 
34 class MiniSearcher;
37  public QListView,
39 {
40  Q_OBJECT
41 
42 signals:
43  void sig_mouse_moved();
44  void sig_mouse_pressed();
45  void sig_mouse_released();
46  void sig_focus_out();
47  void sig_key_pressed(QKeyEvent*);
48  void sig_selection_changed(const QModelIndexList& idxs);
49 
50 
51 private slots:
52  void edit_changed(const QString& str);
53  void fwd_clicked();
54  void bwd_clicked();
55 
56 private:
57 
58  MiniSearcher* _mini_searcher=nullptr;
59  AbstractSearchListModel* _abstr_model=nullptr;
60  int _cur_row;
61 
62  virtual void set_current_index(int idx) override;
63  virtual QAbstractItemModel* get_model() const override;
64  virtual QItemSelectionModel* get_selection_model() const override;
65 
66 public:
67  SearchableListView(QWidget* parent=nullptr);
68  virtual ~SearchableListView();
69  void setAbstractModel(AbstractSearchListModel* model);
70 
71 protected:
72  void mouseMoveEvent(QMouseEvent *) override;
73  void mousePressEvent(QMouseEvent *) override;
74  void mouseReleaseEvent(QMouseEvent *) override;
75  void keyPressEvent(QKeyEvent *) override;
76  void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override;
77 };
78 
79 
80 #endif // SEARCHABLELISTVIEW_H
Definition: MiniSearcher.h:67
Definition: SearchableListView.h:36
Definition: AbstractSearchModel.h:56
Definition: SayonaraSelectionView.h:35