pqExpressionsTableModel.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef pqExpressionsTableModel_h
6 #define pqExpressionsTableModel_h
7 
8 #include "pqComponentsModule.h"
9 
10 #include <QAbstractTableModel>
11 
12 #include "pqExpressionsManager.h" // for pqExpression
13 
14 class PQCOMPONENTS_EXPORT pqExpressionsTableModel : public QAbstractTableModel
15 {
16  Q_OBJECT
17  typedef QAbstractTableModel Superclass;
18 
19 public:
20  pqExpressionsTableModel(QObject* parent = nullptr);
21  ~pqExpressionsTableModel() override = default;
22 
23  enum ColumnKey
24  {
25  GroupColumn = 0,
28  NumberOfColumns
29  };
30 
35  QModelIndex addNewExpression();
36 
40  QList<pqExpressionsManager::pqExpression> getExpressions();
41 
45  QList<pqExpressionsManager::pqExpression> getExpressions(const QString& group);
46 
50  QString getExpressionAsString(const QModelIndex& idx);
51 
56  QModelIndex expressionIndex(const pqExpressionsManager::pqExpression& expression);
57 
61  QString getGroup(const QModelIndex& idx);
62 
66  void setExpressions(const QList<pqExpressionsManager::pqExpression>& expressions);
67 
72  void addExpressions(const QList<pqExpressionsManager::pqExpression>& expressions);
73 
77  QSet<QString> getGroups();
78 
82  bool setExpressionName(int idx, const QString& group);
83 
87  bool setExpressionGroup(int idx, const QString& group);
88 
92  void removeExpressions(const QModelIndexList& index);
93 
97  void removeAllExpressions();
98 
100 
103  int rowCount(const QModelIndex& parent) const override;
104  int columnCount(const QModelIndex& parent) const override;
105  QVariant data(const QModelIndex& index, int role) const override;
106  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
107  Qt::ItemFlags flags(const QModelIndex& index) const override;
108  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
109  bool insertRows(int position, int rows, const QModelIndex& parent) override;
110  bool removeRows(int position, int rows, const QModelIndex& parent) override;
112 
113 protected:
117  bool setExpression(int idx, const QString& expression);
121  bool removeExpression(int idx);
122 
123  QList<pqExpressionsManager::pqExpression> Expressions;
124 };
125 
126 #endif
data
#define PQCOMPONENTS_EXPORT
Data structure to handle an expression and its group name.
QList< pqExpressionsManager::pqExpression > Expressions