pqProxySILModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqProxySILModel.h
5 
6  Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqProxySILModel_h
33 #define pqProxySILModel_h
34 
35 #include "pqComponentsModule.h"
36 #include "pqTimer.h"
37 #include <QAbstractProxyModel>
38 
39 #include <QPixmap>
40 
47 class PQCOMPONENTS_EXPORT pqProxySILModel : public QAbstractProxyModel
48 {
49  Q_OBJECT
50  typedef QAbstractProxyModel Superclass;
51  Q_PROPERTY(QList<QVariant> values READ values WRITE setValues)
52 
53 public:
54  pqProxySILModel(const QString& hierarchyName, QObject* parent = 0);
55  ~pqProxySILModel() override;
56 
68  int rowCount(const QModelIndex& theParent = QModelIndex()) const override
69  {
70  return this->sourceModel()->rowCount(this->mapToSource(theParent));
71  }
72 
80  int columnCount(const QModelIndex& theParent = QModelIndex()) const override
81  {
82  return this->sourceModel()->columnCount(this->mapToSource(theParent));
83  }
84 
92  bool hasChildren(const QModelIndex& theParent = QModelIndex()) const override
93  {
94  return this->sourceModel()->hasChildren(this->mapToSource(theParent));
95  }
96 
106  QModelIndex index(
107  int row, int column, const QModelIndex& theParent = QModelIndex()) const override
108  {
109  QModelIndex sourceIndex = this->sourceModel()->index(row, column, this->mapToSource(theParent));
110  return this->mapFromSource(sourceIndex);
111  }
112 
120  QModelIndex parent(const QModelIndex& theIndex) const override
121  {
122  QModelIndex sourceIndex = this->sourceModel()->parent(this->mapToSource(theIndex));
123  return this->mapFromSource(sourceIndex);
124  }
125 
131  bool setData(const QModelIndex& theIndex, const QVariant& value, int role = Qt::EditRole) override
132  {
133  return this->sourceModel()->setData(this->mapToSource(theIndex), value, role);
134  }
136 
140  QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override;
141  QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
142  void setSourceModel(QAbstractItemModel* sourceModel) override;
143 
150  QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override;
151 
155  bool setHeaderData(int section, Qt::Orientation orientation, const QVariant& value,
156  int role = Qt::EditRole) override;
157 
161  QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override;
162 
167  Qt::ItemFlags flags(const QModelIndex& index) const override;
168 
172  QList<QVariant> values() const;
173 
177  void setNoCheckBoxes(bool val);
178 
182  void setHeaderTitle(QString& title);
183 
184 public Q_SLOTS:
188  void setValues(const QList<QVariant>&);
189 
190 Q_SIGNALS:
191  void valuesChanged();
192 
193 protected Q_SLOTS:
194  void sourceDataChanged(const QModelIndex& idx1, const QModelIndex& idx2)
195  {
196  QModelIndex pidx1 = this->mapFromSource(idx1);
197  QModelIndex pidx2 = this->mapFromSource(idx2);
198  if (!pidx1.isValid() || !pidx2.isValid())
199  {
200  // index is root, that mean header data may have changed as well.
201  Q_EMIT this->headerDataChanged(Qt::Horizontal, 0, 0);
202  }
203  Q_EMIT this->dataChanged(pidx1, pidx2);
204  }
205 
206  void onCheckStatusChanged();
207 
208 private:
209  Q_DISABLE_COPY(pqProxySILModel)
210 
211  pqTimer DelayedValuesChangedSignalTimer;
212  QPixmap CheckboxPixmaps[3];
213  QString HierarchyName;
214  bool noCheckBoxes;
215  QString HeaderTitle;
216 };
217 
218 #endif
data
QModelIndex index(int row, int column, const QModelIndex &theParent=QModelIndex()) const override
Gets a model index for a given location.
#define PQCOMPONENTS_EXPORT
int columnCount(const QModelIndex &theParent=QModelIndex()) const override
Gets the number of columns for a given index.
bool setData(const QModelIndex &theIndex, const QVariant &value, int role=Qt::EditRole) override
Sets the role data for the item at index to value.
pqProxySILModel is a proxy model for pqSILModel.
bool hasChildren(const QModelIndex &theParent=QModelIndex()) const override
Gets whether or not the given index has child items.
QModelIndex parent(const QModelIndex &theIndex) const override
Gets the parent for a given index.
void sourceDataChanged(const QModelIndex &idx1, const QModelIndex &idx2)
value
orientation
int rowCount(const QModelIndex &theParent=QModelIndex()) const override
Gets the number of rows for a given index.
index
title