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