Isis Developer Reference
AbstractTreeModel.h
Go to the documentation of this file.
1#ifndef AbstractTreeModel_H
2#define AbstractTreeModel_H
3
10/* SPDX-License-Identifier: CC0-1.0 */
11#include <functional>
12
13#include <QObject>
14
15
16class QFont;
17template <typename A> class QFutureWatcher;
18class QModelIndex;
19class QMutex;
20template< typename A, typename B > struct QPair;
21class QSize;
22class QString;
23
24
25namespace Isis {
26 class AbstractTreeItem;
27 class BusyLeafItem;
28 class ControlNet;
29 class FilterWidget;
30 class RootItem;
31 class TreeView;
32
48 class AbstractTreeModel : public QObject {
49 Q_OBJECT
50
51 public:
58 Q_DECLARE_FLAGS(InterestingItemsFlag, InterestingItems)
59
60
61 public:
63 QObject *parent = 0);
64 virtual ~AbstractTreeModel();
65
66 QList< AbstractTreeItem * > getItems(int, int,
67 InterestingItemsFlag = AllItems, bool = false);
68 QList< AbstractTreeItem * > getItems(AbstractTreeItem *,
69 AbstractTreeItem *, InterestingItemsFlag = AllItems, bool = false);
70 QList< AbstractTreeItem * > getSelectedItems(
71 InterestingItemsFlag = AllItems, bool = false);
72 QMutex *getMutex() const;
73 int getItemCount(InterestingItemsFlag) const;
74 int getTopLevelItemCount() const;
75 int getVisibleItemCount(InterestingItemsFlag, bool) const;
77 TreeView *getView() const;
78 void setDrivable(bool drivableStatus);
79 bool isDrivable() const;
80 bool isFiltering() const;
81 bool isRebuilding() const;
82 void setRebuilding(bool running) { m_rebuildRunning = running; }
83 void setFilter(FilterWidget *newFilter);
84 void setGlobalSelection(bool selected, InterestingItemsFlag = AllItems);
85 void stopWorking();
86 QSize getVisibleSize(int indentation) const;
88 InterestingItemsFlag = AllItems,
89 bool = false) const;
90 void setFrozen(bool);
91 bool isFrozen() const;
92 void queueRebuild();
93
94
95 public slots:
96 void applyFilter();
97
98
99 signals:
106 void treeSelectionChanged(QList<AbstractTreeItem *>);
107 void tableSelectionChanged(QList<AbstractTreeItem *>);
108
114 void filterCountsChanged(int visibleTopLevelItemCount,
115 int topLevelItemCount);
116
117
118 public:
119 virtual void rebuildItems() = 0;
120
121
122 private:
124 AbstractTreeModel &operator=(const AbstractTreeModel &);
125
126
127 private:
128 AbstractTreeItem *nextItem(AbstractTreeItem *current,
129 InterestingItemsFlag flags, bool ignoreExpansion) const;
130 void selectItems(AbstractTreeItem *item, bool select,
131 InterestingItemsFlag flags);
132 static bool itemIsInteresting(
133 AbstractTreeItem *, InterestingItemsFlag);
134 int getItemCount(AbstractTreeItem *, InterestingItemsFlag) const;
135
136
137 private slots:
138 void applyFilterDone();
139 void rebuildItemsDone();
140
141
142 protected:
143 void clear();
146
147 QFutureWatcher< QAtomicPointer< RootItem > > *
148 getRebuildWatcher() const;
149
150 RootItem *getRootItem() const;
151
152
153 protected:
155
156
157 private: // data
158 QFutureWatcher< QAtomicPointer< AbstractTreeItem > > * m_filterWatcher;
159 QFutureWatcher< QAtomicPointer< RootItem > > * m_rebuildWatcher;
160 QList< QPair< QString, QString > > * m_expandedState;
161 QList< QPair< QString, QString > > * m_selectedState;
162 QMutex *m_mutex;
163 BusyLeafItem *m_busyItem;
164 TreeView *m_view;
165 ControlNet *m_cNet;
166 FilterWidget *m_guisFilterWidget;
167 FilterWidget *m_localFilterWidgetCopy;
168 bool m_drivable;
169 bool m_filterAgain;
170 bool m_filterRunning;
171 bool m_rebuildRunning;
172 bool m_frozen;
173 bool m_rebuildPending;
174
175
176 private:
182 class FilterFunctor
183 : public std::function<bool(AbstractTreeItem *const &)> {
184 public:
185 FilterFunctor(FilterWidget *fw);
186 FilterFunctor(FilterFunctor const &other);
187 ~FilterFunctor();
188 bool operator()(AbstractTreeItem *const &) const;
189 FilterFunctor &operator=(FilterFunctor const &);
190 void filterWorker(AbstractTreeItem *) const;
191
192 static void updateTopLevelLinks(
193 QAtomicPointer< AbstractTreeItem > & root,
194 AbstractTreeItem *const &item);
195
196
197 private:
198 FilterWidget *m_filter;
199 };
200 };
201
202 Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractTreeModel::InterestingItemsFlag)
203
204}
205
206
207#endif
Base class for an item in the tree.
Definition AbstractTreeItem.h:39
Base class for tree models.
Definition AbstractTreeModel.h:48
QList< AbstractTreeItem * > getSelectedItems(InterestingItemsFlag=AllItems, bool=false)
Definition AbstractTreeModel.cpp:228
RootItem * getRootItem() const
Definition AbstractTreeModel.cpp:388
void filterProgressRangeChanged(int, int)
int getItemCount(InterestingItemsFlag) const
Definition AbstractTreeModel.cpp:255
void setRebuilding(bool running)
Definition AbstractTreeModel.h:82
void setFrozen(bool)
Definition AbstractTreeModel.cpp:325
QList< AbstractTreeItem * > getItems(int, int, InterestingItemsFlag=AllItems, bool=false)
Definition AbstractTreeModel.cpp:118
void setDrivable(bool drivableStatus)
void filterProgressChanged(int)
int indexOfVisibleItem(AbstractTreeItem const *item, InterestingItemsFlag=AllItems, bool=false) const
Definition AbstractTreeModel.cpp:302
void filterCountsChanged(int visibleTopLevelItemCount, int topLevelItemCount)
This signal is emitted after filtering to provide the number of visible top-level items remaining aft...
RootItem * rootItem
Definition AbstractTreeModel.h:154
void clear()
Definition AbstractTreeModel.cpp:369
void setFilter(FilterWidget *newFilter)
Definition AbstractTreeModel.cpp:359
TreeView * getView() const
Definition AbstractTreeModel.cpp:393
FilterWidget * getFilterWidget() const
QMutex * getMutex() const
Definition AbstractTreeModel.cpp:250
InterestingItems
Definition AbstractTreeModel.h:52
@ MeasureItems
Definition AbstractTreeModel.h:54
@ AllItems
Definition AbstractTreeModel.h:56
@ ImageItems
Definition AbstractTreeModel.h:55
@ PointItems
Definition AbstractTreeModel.h:53
int getTopLevelItemCount() const
Definition AbstractTreeModel.cpp:260
void setGlobalSelection(bool selected, InterestingItemsFlag=AllItems)
Definition AbstractTreeModel.cpp:476
int getVisibleTopLevelItemCount() const
Definition AbstractTreeModel.cpp:285
bool isFiltering() const
Definition AbstractTreeModel.cpp:349
QFutureWatcher< QAtomicPointer< RootItem > > * getRebuildWatcher() const
Definition AbstractTreeModel.cpp:383
void rebuildProgressChanged(int)
virtual void rebuildItems()=0
bool isRebuilding() const
Definition AbstractTreeModel.cpp:354
void queueRebuild()
Definition AbstractTreeModel.cpp:344
int getVisibleItemCount(InterestingItemsFlag, bool) const
Definition AbstractTreeModel.cpp:264
bool isFrozen() const
Definition AbstractTreeModel.cpp:339
void rebuildProgressRangeChanged(int, int)
virtual ~AbstractTreeModel()
Definition AbstractTreeModel.cpp:85
QSize getVisibleSize(int indentation) const
indentation is in pixels
Definition AbstractTreeModel.cpp:407
void treeSelectionChanged(QList< AbstractTreeItem * >)
void applyFilter()
Definition AbstractTreeModel.cpp:434
void stopWorking()
Definition AbstractTreeModel.cpp:398
void tableSelectionChanged(QList< AbstractTreeItem * >)
AbstractTreeModel(ControlNet *controlNet, TreeView *v, QObject *parent=0)
Definition AbstractTreeModel.cpp:42
ControlNet * getControlNetwork() const
Definition AbstractTreeModel.cpp:377
A leaf item that is not ready for user interaction.
Definition BusyLeafItem.h:33
a control network
Definition ControlNet.h:258
This widget contains filtering capabilities for a single filter type.
Definition FilterWidget.h:58
The root of a tree.
Definition RootItem.h:37
Definition TreeView.h:31
This is free and unencumbered software released into the public domain.
Definition AbstractTableModel.h:24
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
This is free and unencumbered software released into the public domain.
Definition CubeIoHandler.h:23