pqSpreadSheetViewModel.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 #ifndef pqSpreadSheetViewModel_h
5 #define pqSpreadSheetViewModel_h
6 
7 #include "pqCoreModule.h"
8 #include "vtkTuple.h" // needed for vtkTuple.
9 #include "vtkType.h" // needed for vtkIdType.
10 #include <QAbstractTableModel>
11 #include <QPair>
12 #include <QSet>
13 
21 class QItemSelection;
22 class QItemSelectionModel;
23 class vtkObject;
24 class vtkSelection;
25 class vtkSelectionNode;
26 class vtkSMProxy;
27 class vtkSpreadSheetView;
28 
29 class PQCORE_EXPORT pqSpreadSheetViewModel : public QAbstractTableModel
30 {
31  Q_OBJECT
32  typedef QAbstractTableModel Superclass;
33 
34 public:
35  pqSpreadSheetViewModel(vtkSMProxy* viewProxy, QObject* parent = nullptr);
36  ~pqSpreadSheetViewModel() override;
37 
38  class vtkIndex : public vtkTuple<vtkIdType, 3>
39  {
40  };
41 
45  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
46 
50  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
51 
56  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
57 
71  QVariant headerData(
72  int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
73 
78  bool setHeaderData(
79  int section, Qt::Orientation orientation, const QVariant& value, int role) override;
80 
84  void sortSection(int section, Qt::SortOrder order);
85 
89  bool isSortable(int section);
90 
94  int getFieldType() const;
95 
96  // Returns the vtk indices for the view indices.
97  QSet<vtkIndex> getVTKIndices(const QModelIndexList& indexes);
98 
102  void setDecimalPrecision(int);
103  int getDecimalPrecision();
104 
108  void setFixedRepresentation(bool);
109  bool getFixedRepresentation();
110 
117  void setActiveRegion(int row_top, int row_bottom);
118 
123  pqDataRepresentation* activeRepresentation() const;
124  vtkSMProxy* activeRepresentationProxy() const;
125 
129  Qt::ItemFlags flags(const QModelIndex& index) const override;
130  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
131 
132  enum
133  {
134  SectionInternal = Qt::UserRole + 1,
136  // This value can be temporarily set by a caller, and if it is set, the header display
137  // string will be returned as being the number of 'a' characters that is returned as
138  // an int value.
139  // The default value is -1, which will return the real header string
140  // note: The purpose of this is the proper calculation of display width of columns for
141  // a multi-component column
142  SectionHeaderTemp
143  };
144 
149  QString GetRowsAsString() const;
150 
151 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
155  void forceUpdate();
156 
161  void setActiveRepresentation(pqDataRepresentation*);
162 
168  void setActiveRepresentationProxy(vtkSMProxy*);
169 
170 Q_SIGNALS:
174  void selectionChanged(const QItemSelection& selection);
175 
176 private Q_SLOTS:
180  void delayedUpdate();
181 
182  void triggerSelectionChanged();
183 
188  void onDataFetched(vtkObject*, unsigned long, void*, void* call_data);
189 
193  void hiddenColumnsChanged();
194 
195 protected:
200  bool isDataValid(const QModelIndex& idx) const;
201 
202  vtkSpreadSheetView* GetView() const;
203 
204 private:
205  Q_DISABLE_COPY(pqSpreadSheetViewModel)
206 
207  class pqInternal;
208  pqInternal* Internal;
209 
210  vtkSMProxy* ViewProxy;
211 };
212 
213 #endif
data
pqDataRepresentation is the superclass for a display for a pqPipelineSource i.e.
order
vtkSpreadSheetView is a vtkPVView subclass for a view used to show any data as a spreadsheet.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
value
orientation
index