• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

QtExtraComponents

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • qtextracomponents
columnproxymodel.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 by Aleix Pol Gonzalez <aleixpol@blue-systems.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef COLUMNPROXYMODEL_H
21 #define COLUMNPROXYMODEL_H
22 
23 #include <QAbstractListModel>
24 
25 class ColumnProxyModel : public QAbstractListModel
26 {
27  Q_OBJECT
28  Q_PROPERTY(QModelIndex rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
29 // Q_PROPERTY(QAbstractItemModel* sourceModel READ sourceModel WRITE setSourceModel) //rootIndex sets the model
30  Q_PROPERTY(int column READ column WRITE setColumn)
31  public:
32  ColumnProxyModel(QObject* parent = 0);
33 
34  void setRootIndex(const QModelIndex& idx);
35  QModelIndex rootIndex() const;
36 
37  void setSourceModel(QAbstractItemModel* sourceModel);
38  QAbstractItemModel* sourceModel() const { return m_sourceModel; }
39 
40  int column() const;
41  void setColumn(int col);
42 
43  Q_SCRIPTABLE static QModelIndex indexFromModel(QAbstractItemModel* model, int row, int column=0, const QModelIndex& parent=QModelIndex());
44  Q_SCRIPTABLE QModelIndex indexAt(int row, const QModelIndex& parent = QModelIndex()) const;
45 
46  virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
47  virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
48  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
49 
50  signals:
51  void rootIndexChanged();
52 
53  private:
54  QModelIndex proxyIndex(const QModelIndex& sourceIndex) const;
55  QModelIndex sourceIndex(const QModelIndex& proxyIndex) const;
56 
57  int m_column;
58  QModelIndex m_index;
59  QAbstractItemModel* m_sourceModel;
60 
61  private slots:
62  void considerRowsAboutToBeInserted(const QModelIndex&,int,int);
63  void considerRowsAboutToBeMoved(const QModelIndex& sourceParent, int rA, int rB, const QModelIndex& destParent, int rD);
64  void considerRowsAboutToBeRemoved(const QModelIndex&,int,int);
65  void considerRowsRemoved(const QModelIndex&,int,int);
66  void considerRowsMoved(const QModelIndex&,int,int,const QModelIndex&,int);
67  void considerRowsInserted(const QModelIndex&,int,int);
68  void considerDataChanged(const QModelIndex& idxA, const QModelIndex& idxB);
69  void sourceDestroyed(QObject* source);
70 };
71 
72 #endif
QModelIndex
ColumnProxyModel::setColumn
void setColumn(int col)
Definition: columnproxymodel.cpp:101
ColumnProxyModel::setSourceModel
void setSourceModel(QAbstractItemModel *sourceModel)
Definition: columnproxymodel.cpp:29
ColumnProxyModel::setRootIndex
void setRootIndex(const QModelIndex &idx)
Definition: columnproxymodel.cpp:118
ColumnProxyModel::rootIndex
QModelIndex rootIndex() const
QObject
QAbstractListModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
QAbstractListModel
ColumnProxyModel::rowCount
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: columnproxymodel.cpp:150
ColumnProxyModel::rootIndexChanged
void rootIndexChanged()
ColumnProxyModel::headerData
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: columnproxymodel.cpp:140
ColumnProxyModel
Definition: columnproxymodel.h:25
ColumnProxyModel::indexAt
Q_SCRIPTABLE QModelIndex indexAt(int row, const QModelIndex &parent=QModelIndex()) const
Definition: columnproxymodel.cpp:172
ColumnProxyModel::indexFromModel
static Q_SCRIPTABLE QModelIndex indexFromModel(QAbstractItemModel *model, int row, int column=0, const QModelIndex &parent=QModelIndex())
Definition: columnproxymodel.cpp:130
ColumnProxyModel::column
int column() const
QAbstractItemModel
ColumnProxyModel::data
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: columnproxymodel.cpp:135
QObject::parent
QObject * parent() const
ColumnProxyModel::sourceModel
QAbstractItemModel * sourceModel() const
Definition: columnproxymodel.h:38
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

QtExtraComponents

Skip menu "QtExtraComponents"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal