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 
12 #include <QObject>
13 
14 
15 class QFont;
16 template <typename A> class QFutureWatcher;
17 class QModelIndex;
18 class QMutex;
19 template< typename A, typename B > struct QPair;
20 class QSize;
21 class QString;
22 
23 
24 namespace Isis {
25  class AbstractTreeItem;
26  class BusyLeafItem;
27  class ControlNet;
28  class FilterWidget;
29  class RootItem;
30  class TreeView;
31 
47  class AbstractTreeModel : public QObject {
48  Q_OBJECT
49 
50  public:
56  };
57  Q_DECLARE_FLAGS(InterestingItemsFlag, InterestingItems)
58 
59 
60  public:
61  AbstractTreeModel(ControlNet *controlNet, TreeView *v,
62  QObject *parent = 0);
63  virtual ~AbstractTreeModel();
64 
66  InterestingItemsFlag = AllItems, bool = false);
68  AbstractTreeItem *, InterestingItemsFlag = AllItems, bool = false);
70  InterestingItemsFlag = AllItems, bool = false);
71  QMutex *getMutex() const;
72  int getItemCount(InterestingItemsFlag) const;
73  int getTopLevelItemCount() const;
74  int getVisibleItemCount(InterestingItemsFlag, bool) const;
75  int getVisibleTopLevelItemCount() const;
76  TreeView *getView() const;
77  void setDrivable(bool drivableStatus);
78  bool isDrivable() const;
79  bool isFiltering() const;
80  bool isRebuilding() const;
81  void setRebuilding(bool running) { m_rebuildRunning = running; }
82  void setFilter(FilterWidget *newFilter);
83  void setGlobalSelection(bool selected, InterestingItemsFlag = AllItems);
84  void stopWorking();
85  QSize getVisibleSize(int indentation) const;
86  int indexOfVisibleItem(AbstractTreeItem const *item,
87  InterestingItemsFlag = AllItems,
88  bool = false) const;
89  void setFrozen(bool);
90  bool isFrozen() const;
91  void queueRebuild();
92 
93 
94  public slots:
95  void applyFilter();
96 
97 
98  signals:
99  void cancelSort();
107 
113  void filterCountsChanged(int visibleTopLevelItemCount,
114  int topLevelItemCount);
115 
116 
117  public:
118  virtual void rebuildItems() = 0;
119 
120 
121  private:
123  AbstractTreeModel &operator=(const AbstractTreeModel &);
124 
125 
126  private:
127  AbstractTreeItem *nextItem(AbstractTreeItem *current,
128  InterestingItemsFlag flags, bool ignoreExpansion) const;
129  void selectItems(AbstractTreeItem *item, bool select,
130  InterestingItemsFlag flags);
131  static bool itemIsInteresting(
132  AbstractTreeItem *, InterestingItemsFlag);
133  int getItemCount(AbstractTreeItem *, InterestingItemsFlag) const;
134 
135 
136  private slots:
137  void applyFilterDone();
138  void rebuildItemsDone();
139 
140 
141  protected:
142  void clear();
143  ControlNet *getControlNetwork() const;
145 
147  getRebuildWatcher() const;
148 
149  RootItem *getRootItem() const;
150 
151 
152  protected:
154 
155 
156  private: // data
158  QFutureWatcher< QAtomicPointer< RootItem > > * m_rebuildWatcher;
159  QList< QPair< QString, QString > > * m_expandedState;
160  QList< QPair< QString, QString > > * m_selectedState;
161  QMutex *m_mutex;
162  BusyLeafItem *m_busyItem;
163  TreeView *m_view;
164  ControlNet *m_cNet;
165  FilterWidget *m_guisFilterWidget;
166  FilterWidget *m_localFilterWidgetCopy;
167  bool m_drivable;
168  bool m_filterAgain;
169  bool m_filterRunning;
170  bool m_rebuildRunning;
171  bool m_frozen;
172  bool m_rebuildPending;
173 
174 
175  private:
181  class FilterFunctor
182  : public std::unary_function< AbstractTreeItem *const &, bool > {
183  public:
184  FilterFunctor(FilterWidget *fw);
185  FilterFunctor(FilterFunctor const &other);
186  ~FilterFunctor();
187  bool operator()(AbstractTreeItem *const &) const;
188  FilterFunctor &operator=(FilterFunctor const &);
189  void filterWorker(AbstractTreeItem *) const;
190 
191  static void updateTopLevelLinks(
193  AbstractTreeItem *const &item);
194 
195 
196  private:
197  FilterWidget *m_filter;
198  };
199  };
200 
201  Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractTreeModel::InterestingItemsFlag)
202 
203 }
204 
205 
206 #endif
Isis::AbstractTreeModel::modelModified
void modelModified()
Isis::AbstractTreeModel::getVisibleSize
QSize getVisibleSize(int indentation) const
indentation is in pixels
Definition: AbstractTreeModel.cpp:414
Isis::AbstractTreeModel::setFrozen
void setFrozen(bool)
Definition: AbstractTreeModel.cpp:331
Isis::RootItem::setLastVisibleFilteredItem
void setLastVisibleFilteredItem(AbstractTreeItem *item)
Definition: RootItem.cpp:26
Isis::AbstractTreeItem::Point
@ Point
Definition: AbstractTreeItem.h:46
Isis::AbstractTreeModel::filterCountsChanged
void filterCountsChanged(int visibleTopLevelItemCount, int topLevelItemCount)
This signal is emitted after filtering to provide the number of visible top-level items remaining aft...
Isis::AbstractTreeModel::PointItems
@ PointItems
Definition: AbstractTreeModel.h:52
Isis::AbstractTreeModel::AllItems
@ AllItems
Definition: AbstractTreeModel.h:55
Isis::AbstractTreeItem::parent
AbstractTreeItem * parent() const
Definition: AbstractTreeItem.cpp:46
Isis::RootItem::getLastVisibleFilteredItem
const AbstractTreeItem * getLastVisibleFilteredItem() const
Definition: RootItem.cpp:31
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::AbstractTreeModel::getItemCount
int getItemCount(InterestingItemsFlag) const
Definition: AbstractTreeModel.cpp:261
Isis::AbstractTreeModel::setGlobalSelection
void setGlobalSelection(bool selected, InterestingItemsFlag=AllItems)
Definition: AbstractTreeModel.cpp:483
Isis::AbstractTreeModel::getRebuildWatcher
QFutureWatcher< QAtomicPointer< RootItem > > * getRebuildWatcher() const
Definition: AbstractTreeModel.cpp:390
Isis::AbstractTreeModel::rebuildProgressChanged
void rebuildProgressChanged(int)
Isis::AbstractTreeModel
Base class for tree models.
Definition: AbstractTreeModel.h:47
Isis::AbstractTreeModel::filterProgressChanged
void filterProgressChanged(int)
Isis::AbstractTreeModel::stopWorking
void stopWorking()
Definition: AbstractTreeModel.cpp:405
Isis::BusyLeafItem
A leaf item that is not ready for user interaction.
Definition: BusyLeafItem.h:33
Isis::AbstractTreeItem::Measure
@ Measure
Definition: AbstractTreeItem.h:47
Isis::AbstractTreeModel::getView
TreeView * getView() const
Definition: AbstractTreeModel.cpp:400
Isis::AbstractTreeModel::rootItem
RootItem * rootItem
Definition: AbstractTreeModel.h:153
Isis::AbstractTreeItem::getNextVisiblePeer
virtual AbstractTreeItem * getNextVisiblePeer() const
Definition: AbstractTreeItem.cpp:76
Isis::AbstractTreeModel::setDrivable
void setDrivable(bool drivableStatus)
Isis::AbstractTreeModel::getRootItem
RootItem * getRootItem() const
Definition: AbstractTreeModel.cpp:395
Isis::AbstractTreeItem::setSelected
virtual void setSelected(bool newState)
Definition: AbstractTreeItem.cpp:126
Isis::AbstractTreeModel::clear
void clear()
Definition: AbstractTreeModel.cpp:375
Isis::AbstractTreeItem::isSelected
virtual bool isSelected() const
Definition: AbstractTreeItem.cpp:136
FilterWidget.h
Isis::AbstractTreeModel::applyFilter
void applyFilter()
Definition: AbstractTreeModel.cpp:441
Isis::AbstractTreeModel::rebuildItems
virtual void rebuildItems()=0
Isis::AbstractTreeModel::isFrozen
bool isFrozen() const
Definition: AbstractTreeModel.cpp:345
ControlNet.h
Isis::AbstractTreeModel::setRebuilding
void setRebuilding(bool running)
Definition: AbstractTreeModel.h:81
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::AbstractTreeModel::getControlNetwork
ControlNet * getControlNetwork() const
Definition: AbstractTreeModel.cpp:384
Isis::AbstractTreeModel::ImageItems
@ ImageItems
Definition: AbstractTreeModel.h:54
Isis::AbstractTreeModel::setFilter
void setFilter(FilterWidget *newFilter)
Definition: AbstractTreeModel.cpp:365
Isis::AbstractTreeModel::getSelectedItems
QList< AbstractTreeItem * > getSelectedItems(InterestingItemsFlag=AllItems, bool=false)
Definition: AbstractTreeModel.cpp:232
Isis::AbstractTreeItem::getLastVisibleChild
virtual AbstractTreeItem * getLastVisibleChild() const =0
Isis::AbstractTreeModel::treeSelectionChanged
void treeSelectionChanged(QList< AbstractTreeItem * >)
AbstractTreeItem.h
Isis::AbstractTreeItem::getChildren
virtual QList< AbstractTreeItem * > getChildren() const =0
Isis::AbstractParentItem::getChildren
virtual QList< AbstractTreeItem * > getChildren() const
Definition: AbstractParentItem.cpp:55
RootItem.h
Isis::AbstractParentItem::getFirstVisibleChild
virtual AbstractTreeItem * getFirstVisibleChild() const
Definition: AbstractParentItem.cpp:61
Isis::AbstractTreeModel::getMutex
QMutex * getMutex() const
Definition: AbstractTreeModel.cpp:256
Isis::AbstractTreeModel::isRebuilding
bool isRebuilding() const
Definition: AbstractTreeModel.cpp:360
Isis::AbstractTreeModel::tableSelectionChanged
void tableSelectionChanged(QList< AbstractTreeItem * >)
ControlPoint.h
Isis::ControlNet
a control network
Definition: ControlNet.h:257
Isis::AbstractTreeItem::getDataWidth
virtual int getDataWidth() const
Definition: AbstractTreeItem.cpp:156
TreeView.h
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::AbstractTreeModel::getTopLevelItemCount
int getTopLevelItemCount() const
Definition: AbstractTreeModel.cpp:266
ASSERT
#define ASSERT(x)
Definition: IsisDebug.h:134
Isis::AbstractTreeModel::isDrivable
bool isDrivable() const
Isis::AbstractTreeModel::getFilterWidget
FilterWidget * getFilterWidget() const
Isis::AbstractTreeModel::cancelSort
void cancelSort()
Isis::AbstractTreeModel::isFiltering
bool isFiltering() const
Definition: AbstractTreeModel.cpp:355
Isis::AbstractTreeModel::MeasureItems
@ MeasureItems
Definition: AbstractTreeModel.h:53
Isis::AbstractTreeItem::getDepth
virtual int getDepth() const
Definition: AbstractTreeItem.cpp:167
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::AbstractTreeModel::rebuildProgressRangeChanged
void rebuildProgressRangeChanged(int, int)
Isis::AbstractTreeItem::None
@ None
Definition: AbstractTreeItem.h:45
QPair
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:23
AbstractTreeModel.h
Isis::FilterWidget
This widget contains filtering capabilities for a single filter type.
Definition: FilterWidget.h:58
Isis::AbstractTreeItem::ImageAndNet
@ ImageAndNet
Definition: AbstractTreeItem.h:48
Isis::AbstractParentItem::childCount
virtual int childCount() const
Definition: AbstractParentItem.cpp:78
QFutureWatcher
This is free and unencumbered software released into the public domain.
Definition: AbstractTableModel.h:24
QAtomicPointer
This is free and unencumbered software released into the public domain.
Definition: ConcurrentControlNetReader.h:20
Isis::AbstractTreeItem::childCount
virtual int childCount() const =0
Isis::AbstractTreeModel::InterestingItems
InterestingItems
Definition: AbstractTreeModel.h:51
Isis::TreeView
Definition: TreeView.h:31
Isis::AbstractTreeModel::getVisibleTopLevelItemCount
int getVisibleTopLevelItemCount() const
Definition: AbstractTreeModel.cpp:291
QObject
BusyLeafItem.h
Isis::AbstractTreeModel::AbstractTreeModel
AbstractTreeModel(ControlNet *controlNet, TreeView *v, QObject *parent=0)
Definition: AbstractTreeModel.cpp:44
IsisDebug.h
Isis::AbstractTreeModel::filterProgressRangeChanged
void filterProgressRangeChanged(int, int)
Isis::AbstractTreeItem
Base class for an item in the tree.
Definition: AbstractTreeItem.h:39
Isis::AbstractTreeModel::indexOfVisibleItem
int indexOfVisibleItem(AbstractTreeItem const *item, InterestingItemsFlag=AllItems, bool=false) const
Definition: AbstractTreeModel.cpp:308
Isis::AbstractTreeModel::getItems
QList< AbstractTreeItem * > getItems(int, int, InterestingItemsFlag=AllItems, bool=false)
Definition: AbstractTreeModel.cpp:121
Isis::AbstractTreeItem::InternalPointerType
InternalPointerType
Definition: AbstractTreeItem.h:44
Isis::AbstractTreeModel::queueRebuild
void queueRebuild()
Definition: AbstractTreeModel.cpp:350
Isis::AbstractTreeModel::getVisibleItemCount
int getVisibleItemCount(InterestingItemsFlag, bool) const
Definition: AbstractTreeModel.cpp:270
ControlMeasure.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::AbstractTreeModel::~AbstractTreeModel
virtual ~AbstractTreeModel()
Definition: AbstractTreeModel.cpp:88
Isis::RootItem
The root of a tree.
Definition: RootItem.h:37