Sayonara Player
SayonaraSelectionView.h
1 /* SayonaraSelectionView.h */
2 
3 /* Copyright (C) 2011-2017 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 SAYONARASELECTIONVIEW_H
22 #define SAYONARASELECTIONVIEW_H
23 
24 #include <QList>
25 #include <QItemSelectionModel>
26 #include <QAbstractItemModel>
27 
28 class QModelIndex;
29 
30 namespace SP
31 {
32  template<typename T>
33  class Set;
34 }
35 
41 {
42 
43 public:
44 
45  enum class SelectionType
46  {
47  Rows=0,
48  Columns,
49  Items
50  };
51 
52 
53 protected:
54  SelectionType _selection_type;
55 
56  virtual QItemSelectionModel* get_selection_model() const=0;
57  virtual QModelIndex get_index(int row, int col, const QModelIndex& parent=QModelIndex()) const=0;
58  virtual int get_row_count(const QModelIndex& parent=QModelIndex()) const=0;
59  virtual int get_column_count(const QModelIndex& parent=QModelIndex()) const=0;
60  virtual void set_current_index(int idx)=0;
61 
62  void select_rows(const SP::Set<int>& indexes, int min_col=-1, int max_col=-1);
63  void select_row(int row);
64 
65  void select_columns(const SP::Set<int>& indexes, int min_row=-1, int max_row=-1);
66  void select_column(int col);
67 
68  void select_items(const SP::Set<int>& items);
69  void select_item(int item);
70 
71  void select_all();
72 
73  void clear_selection();
74 
75  int get_min_selected_item() const;
76 
77 
78 public:
79 
80  SP::Set<int> get_selected_items() const;
81 
82  virtual void set_selection_type(SayonaraSelectionView::SelectionType type);
83  SayonaraSelectionView::SelectionType selection_type() const;
84 
85  virtual int get_index_by_model_index(const QModelIndex& idx) const=0;
86  virtual QModelIndex get_model_index_by_index(int idx) const=0;
87 
88  virtual SP::Set<int> get_indexes_by_model_indexes(const QModelIndexList& idxs) const;
89  virtual QModelIndexList get_model_indexes_by_indexes(const SP::Set<int>& idxs) const;
90 
91 protected:
93  virtual ~SayonaraSelectionView();
94 };
95 
96 #endif // SAYONARASELECTIONVIEW_H
The MetaDataList class.
Definition: AbstractPlaylist.h:34
Set namespace defines the setting: Which key and which type.
Definition: SettingKey.h:200
The SayonaraSelectionView class.
Definition: SayonaraSelectionView.h:40
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:37