pqCompositeDataInformationTreeModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqCompositeDataInformationTreeModel.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 pqCompositeDataInformationTreeModel_h
33 #define pqCompositeDataInformationTreeModel_h
34 
35 #include "pqComponentsModule.h" // for exports.
36 #include <QAbstractItemModel>
37 #include <QPair> // for QPair.
38 #include <QScopedPointer> // for ivar.
39 
41 
43 {
44 class CNode;
45 }
46 
151 {
152  Q_OBJECT
153  Q_PROPERTY(bool userCheckable READ userCheckable WRITE setUserCheckable);
154  Q_PROPERTY(bool expandMultiPiece READ expandMultiPiece WRITE setExpandMultiPiece);
155  Q_PROPERTY(bool exclusivity READ exclusivity WRITE setExclusivity);
156  Q_PROPERTY(bool defaultCheckState READ defaultCheckState WRITE setDefaultCheckState);
157 
158  typedef QAbstractItemModel Superclass;
159 
160 public:
161  pqCompositeDataInformationTreeModel(QObject* parent = 0);
163 
165 
168  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
169  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
170  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
171  QModelIndex parent(const QModelIndex& index = QModelIndex()) const override;
172  QVariant data(const QModelIndex& index, int role) const override;
173  Qt::ItemFlags flags(const QModelIndex& index) const override;
174  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
175  QVariant headerData(
176  int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
177  bool setHeaderData(int section, Qt::Orientation orientation, const QVariant& value,
178  int role = Qt::DisplayRole) override;
180 
182 
186  void setUserCheckable(bool val) { this->UserCheckable = val; }
187  bool userCheckable() const { return this->UserCheckable; }
189 
191 
196  void setOnlyLeavesAreUserCheckable(bool val) { this->OnlyLeavesAreUserCheckable = val; }
197  bool onlyLeavesAreUserCheckable() const { return this->OnlyLeavesAreUserCheckable; }
199 
201 
205  void setDefaultCheckState(bool checked) { this->DefaultCheckState = checked; }
206  bool defaultCheckState() const { return this->DefaultCheckState; }
207 
209 
213  void setExpandMultiPiece(bool val) { this->ExpandMultiPiece = val; }
214  bool expandMultiPiece() const { return this->ExpandMultiPiece; }
216 
218 
222  void setExclusivity(bool val) { this->Exclusivity = val; }
223  bool exclusivity() const { return this->Exclusivity; }
225 
232  QList<unsigned int> checkedNodes() const;
233 
238  QList<unsigned int> checkedLeaves() const;
239 
245  void setChecked(const QList<unsigned int>& indices);
246 
250  QList<QPair<unsigned int, bool> > checkStates() const;
251 
255  void setCheckStates(const QList<QPair<unsigned int, bool> >& states);
256 
258 
263  QList<unsigned int> checkedLevels() const;
264  void setCheckedLevels(const QList<unsigned int>& indices);
266 
268 
272  QList<QPair<unsigned int, unsigned int> > checkedLevelDatasets() const;
273  void setCheckedLevelDatasets(const QList<QPair<unsigned int, unsigned int> >& indices);
275 
280  unsigned int compositeIndex(const QModelIndex& idx) const;
281 
286  QModelIndex find(unsigned int compositeIndex) const;
287 
291  const QModelIndex rootIndex() const;
292 
297  int addColumn(const QString& propertyName);
298 
303  int columnIndex(const QString& propertyName);
304 
310  void clearColumns();
311 
313 
322  void setColumnStates(
323  const QString& propertyName, const QList<QPair<unsigned int, QVariant> >& values);
324  QList<QPair<unsigned int, QVariant> > columnStates(const QString& propertyName) const;
326 
330  enum
331  {
337  ValueInheritedRole = Qt::UserRole,
338 
346 
350  CompositeIndexRole
351  };
352 
353 public Q_SLOTS:
362  bool reset(vtkPVDataInformation* info = nullptr);
363 
364 private:
365  Q_DISABLE_COPY(pqCompositeDataInformationTreeModel);
366 
367  class pqInternals;
368  QScopedPointer<pqInternals> Internals;
369  QString HeaderLabel;
370  bool UserCheckable;
371  bool OnlyLeavesAreUserCheckable;
372  bool ExpandMultiPiece;
373  bool Exclusivity;
374  bool DefaultCheckState;
375 
376  friend class pqCompositeDataInformationTreeModelNS::CNode;
377 };
378 
379 #endif
data
Light object for holding data information.
#define PQCOMPONENTS_EXPORT
void setOnlyLeavesAreUserCheckable(bool val)
When UserCheckable is true, this limits use-checkability to leaf nodes only.
void setExclusivity(bool val)
When set to true for a userCheckable model, if the user checks a node, the all other nodes that are n...
bool userCheckable() const
Toggle whether the model allows user to change check state.
bool defaultCheckState() const
Get/Set the default check state for nodes.
bool expandMultiPiece() const
Get/Set the default check state for nodes.
bool exclusivity() const
When set to true for a userCheckable model, if the user checks a node, the all other nodes that are n...
void setDefaultCheckState(bool checked)
Get/Set the default check state for nodes.
bool onlyLeavesAreUserCheckable() const
When UserCheckable is true, this limits use-checkability to leaf nodes only.
For a leaf node (i.e node with any children) return it&#39;s position in a ordered list of simply all lea...
void setUserCheckable(bool val)
Toggle whether the model allows user to change check state.
void setExpandMultiPiece(bool val)
Toggle whether multipiece datasets are expanded (default false).
Tree model that use vtkPVDataInformation to model composite data tree.
index