Sayonara Player
TableView.h
1 /* TableView.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 LIBRARYTABLEVIEW_H
22 #define LIBRARYTABLEVIEW_H
23 
24 #include "Gui/Library/ItemView.h"
25 #include "Gui/Library/Header/ColumnHeader.h"
26 
27 #include "Utils/Pimpl.h"
28 #include "Utils/Library/Sortorder.h"
29 
30 namespace Library
31 {
36  class TableView :
37  public ItemView
38  {
39  Q_OBJECT
40  PIMPL(TableView)
41 
42  signals:
43  void sigSortorderChanged(SortOrder);
44 
45  private:
46  TableView(const TableView& other) = delete;
47  TableView& operator=(const TableView& other) = delete;
48 
49  public:
50  explicit TableView(QWidget* parent = nullptr);
51  virtual ~TableView() override;
52 
53  virtual void init(AbstractLibrary* library);
54 
55  protected:
61 
67  virtual void initView(AbstractLibrary* library) = 0;
68 
75  virtual ColumnHeaderList columnHeaders() const = 0;
76 
83  virtual QByteArray columnHeaderState() const = 0;
84 
90  virtual void saveColumnHeaderState(const QByteArray& state) = 0;
91 
95  virtual SortOrder sortorder() const = 0;
96 
100  virtual void applySortorder(SortOrder s) = 0;
101 
102  virtual bool autoResizeState() const = 0;
103  virtual void saveAutoResizeState(bool b) = 0;
104 
105  void languageChanged() override;
106 
107  // SayonaraSelectionView.h
108  int mapModelIndexToIndex(const QModelIndex& idx) const override;
109  ModelIndexRange mapIndexToModelIndexes(int idx) const override;
110 
111  protected slots:
112  void headerColumnsChanged(int oldCount, int newCount);
113  void sortorderChanged(int index, Qt::SortOrder sortorder);
114  void sectionResized(int logicalIndex, int oldSize, int newSize);
115  void sectionMoved(int logicalIndex, int old_visualIndex, int newVisualIndex);
116  void autoResizeTriggered(bool b);
117  };
118 }
119 
120 #endif // LIBRARYTABLEVIEW_H
Library::TableView::initView
virtual void initView(AbstractLibrary *library)=0
here, the model and delegate should be instantiated as well as connections and setting listeners
QPair
Definition: typedefs.h:32
Library::TableView
The TableView class.
Definition: TableView.h:38
Library::TableView::applySortorder
virtual void applySortorder(SortOrder s)=0
saves the current sortorder
Library::ItemView
The main task of the ItemView is to display a context menu for various selections....
Definition: ItemView.h:57
QList
Definition: EngineUtils.h:33
Library::TableView::columnHeaderState
virtual QByteArray columnHeaderState() const =0
This method returns the SAVED column header sizes as they were remembered since the last time sayonar...
AbstractLibrary
Definition: AbstractLibrary.h:43
Library
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31
Library::TableView::saveColumnHeaderState
virtual void saveColumnHeaderState(const QByteArray &state)=0
Here, the column headers sizes should be saved somewhere.
Library::TableView::setupColumnNames
void setupColumnNames()
the column names are reloaded and updated with their corresponding texts
Library::TableView::sortorder
virtual SortOrder sortorder() const =0
returns the current sortorder for the table view
Library::TableView::columnHeaders
virtual ColumnHeaderList columnHeaders() const =0
returns a list of ColumnHeader objects containing name, sortorder. Everytime when the language is cha...
Library::SortOrder
SortOrder
The SortOrder enum.
Definition: Sortorder.h:32