KChart

KChartDatasetProxyModel.h
1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KCHARTDATASETPROXYMODEL_H
21 #define KCHARTDATASETPROXYMODEL_H
22 
23 #include <QVector>
24 #include <QSortFilterProxyModel>
25 
26 #include "kchart_export.h"
27 
28 namespace KChart {
29 
30  class IndexOutOfBoundsException;
31 
32  typedef QVector<int> DatasetDescriptionVector;
33 
52  class KCHART_EXPORT DatasetProxyModel : public QSortFilterProxyModel
53  {
54  Q_OBJECT
55  public:
60  explicit DatasetProxyModel ( QObject* parent = nullptr );
61 
62  QModelIndex buddy( const QModelIndex& index ) const override;
63 
64  Qt::ItemFlags flags( const QModelIndex& index ) const override;
65 
66  QModelIndex index( int row, int column,
67  const QModelIndex &parent = QModelIndex() ) const override;
68  QModelIndex parent(const QModelIndex &child ) const override;
69 
71  QModelIndex mapFromSource ( const QModelIndex & sourceIndex ) const override;
72 
74  QModelIndex mapToSource ( const QModelIndex& proxyIndex ) const override;
75 
77  QVariant data(const QModelIndex &index, int role) const override;
78 
80  bool setData( const QModelIndex& index, const QVariant& value, int role ) override;
81 
83  QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
84 
86  void setSourceModel(QAbstractItemModel *sourceModel) override;
87 
90  void setSourceRootIndex(const QModelIndex& rootIdx);
91 
92 
93  public Q_SLOTS:
98  void resetDatasetDescriptions();
99 
104  void setDatasetColumnDescriptionVector ( const DatasetDescriptionVector& columnConfig );
105 
110  void setDatasetRowDescriptionVector ( const DatasetDescriptionVector& rowConfig );
111 
113  void setDatasetDescriptionVectors (
114  const DatasetDescriptionVector& rowConfig,
115  const DatasetDescriptionVector& columnConfig );
116 
117  // FIXME: add convenience methods to configure common dataset
118  // selections (like rectangular areas etc)
119 
120  protected:
122  bool filterAcceptsColumn ( int sourceColumn,
123  const QModelIndex & ) const override;
124 
125 
127  bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const override;
128 
129  private:
130 
132  int mapProxyColumnToSource ( const int& proxyColumn ) const;
133 
135  int mapSourceColumnToProxy ( const int& sourceColumn ) const;
136 
138  int mapProxyRowToSource ( const int& proxyRow ) const;
139 
141  int mapSourceRowToProxy ( const int& sourceRow ) const;
142 
166  void initializeDatasetDecriptors (
167  const DatasetDescriptionVector& inConfiguration,
168  int sourceCount,
169  DatasetDescriptionVector& outSourceToProxyMap,
170  DatasetDescriptionVector& outProxyToSourceMap );
171 
172  DatasetDescriptionVector mColSrcToProxyMap;
173  DatasetDescriptionVector mColProxyToSrcMap;
174  DatasetDescriptionVector mRowSrcToProxyMap;
175  DatasetDescriptionVector mRowProxyToSrcMap;
176 
177  int mProxyRowCount;
178  int mProxyColumnCount;
179  QModelIndex mRootIndex;
180  };
181 
182 }
183 
184 
185 #endif
Class only listed here to document inheritance of some KChart classes.
DisplayRole
Class only listed here to document inheritance of some KChart classes.
Orientation
Global namespace.
DatasetProxyModel takes a KChart dataset configuration and translates it into a filtering proxy model...
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Sep 23 2020 22:36:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.