Isis 3 Developer Reference
AbstractTreeModel.h
Go to the documentation of this file.
1 #ifndef AbstractTreeModel_H
2 #define AbstractTreeModel_H
3 
4 #include <QObject>
5 
6 
7 class QFont;
8 template <typename A> class QFutureWatcher;
9 class QModelIndex;
10 class QMutex;
11 template< typename A, typename B > struct QPair;
12 class QSize;
13 class QString;
14 
15 
16 namespace Isis {
17  class AbstractTreeItem;
18  class BusyLeafItem;
19  class ControlNet;
20  class FilterWidget;
21  class RootItem;
22  class TreeView;
23 
39  class AbstractTreeModel : public QObject {
40  Q_OBJECT
41 
42  public:
48  };
49  Q_DECLARE_FLAGS(InterestingItemsFlag, InterestingItems)
50 
51 
52  public:
53  AbstractTreeModel(ControlNet *controlNet, TreeView *v,
54  QObject *parent = 0);
55  virtual ~AbstractTreeModel();
56 
58  InterestingItemsFlag = AllItems, bool = false);
60  AbstractTreeItem *, InterestingItemsFlag = AllItems, bool = false);
62  InterestingItemsFlag = AllItems, bool = false);
63  QMutex *getMutex() const;
64  int getItemCount(InterestingItemsFlag) const;
65  int getTopLevelItemCount() const;
66  int getVisibleItemCount(InterestingItemsFlag, bool) const;
67  int getVisibleTopLevelItemCount() const;
68  TreeView *getView() const;
69  void setDrivable(bool drivableStatus);
70  bool isDrivable() const;
71  bool isFiltering() const;
72  bool isRebuilding() const;
73  void setRebuilding(bool running) { m_rebuildRunning = running; }
74  void setFilter(FilterWidget *newFilter);
75  void setGlobalSelection(bool selected, InterestingItemsFlag = AllItems);
76  void stopWorking();
77  QSize getVisibleSize(int indentation) const;
78  int indexOfVisibleItem(AbstractTreeItem const *item,
79  InterestingItemsFlag = AllItems,
80  bool = false) const;
81  void setFrozen(bool);
82  bool isFrozen() const;
83  void queueRebuild();
84 
85 
86  public slots:
87  void applyFilter();
88 
89 
90  signals:
91  void cancelSort();
92  void modelModified();
93  void filterProgressChanged(int);
94  void filterProgressRangeChanged(int, int);
95  void rebuildProgressChanged(int);
96  void rebuildProgressRangeChanged(int, int);
99 
105  void filterCountsChanged(int visibleTopLevelItemCount,
106  int topLevelItemCount);
107 
108 
109  public:
110  virtual void rebuildItems() = 0;
111 
112 
113  private:
115  AbstractTreeModel &operator=(const AbstractTreeModel &);
116 
117 
118  private:
119  AbstractTreeItem *nextItem(AbstractTreeItem *current,
120  InterestingItemsFlag flags, bool ignoreExpansion) const;
121  void selectItems(AbstractTreeItem *item, bool select,
122  InterestingItemsFlag flags);
123  static bool itemIsInteresting(
124  AbstractTreeItem *, InterestingItemsFlag);
125  int getItemCount(AbstractTreeItem *, InterestingItemsFlag) const;
126 
127 
128  private slots:
129  void applyFilterDone();
130  void rebuildItemsDone();
131 
132 
133  protected:
134  void clear();
135  ControlNet *getControlNetwork() const;
136  FilterWidget *getFilterWidget() const;
137 
139  getRebuildWatcher() const;
140 
141  RootItem *getRootItem() const;
142 
143 
144  protected:
146 
147 
148  private: // data
150  QFutureWatcher< QAtomicPointer< RootItem > > * m_rebuildWatcher;
151  QList< QPair< QString, QString > > * m_expandedState;
152  QList< QPair< QString, QString > > * m_selectedState;
153  QMutex *m_mutex;
154  BusyLeafItem *m_busyItem;
155  TreeView *m_view;
156  ControlNet *m_cNet;
157  FilterWidget *m_guisFilterWidget;
158  FilterWidget *m_localFilterWidgetCopy;
159  bool m_drivable;
160  bool m_filterAgain;
161  bool m_filterRunning;
162  bool m_rebuildRunning;
163  bool m_frozen;
164  bool m_rebuildPending;
165 
166 
167  private:
173  class FilterFunctor
174  : public std::unary_function< AbstractTreeItem *const &, bool > {
175  public:
176  FilterFunctor(FilterWidget *fw);
177  FilterFunctor(FilterFunctor const &other);
178  ~FilterFunctor();
179  bool operator()(AbstractTreeItem *const &) const;
180  FilterFunctor &operator=(FilterFunctor const &);
181  void filterWorker(AbstractTreeItem *) const;
182 
183  static void updateTopLevelLinks(
185  AbstractTreeItem *const &item);
186 
187 
188  private:
189  FilterWidget *m_filter;
190  };
191  };
192 
193  Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractTreeModel::InterestingItemsFlag)
194 
195 }
196 
197 
198 #endif
void queueRebuild()
Definition: AbstractTreeModel.cpp:342
void filterProgressChanged(int)
void treeSelectionChanged(QList< AbstractTreeItem *>)
Definition: AbstractTreeModel.h:47
AbstractTreeModel(ControlNet *controlNet, TreeView *v, QObject *parent=0)
Definition: AbstractTreeModel.cpp:36
QSize getVisibleSize(int indentation) const
indentation is in pixels
Definition: AbstractTreeModel.cpp:406
QFutureWatcher< QAtomicPointer< RootItem > > * getRebuildWatcher() const
Definition: AbstractTreeModel.cpp:382
void stopWorking()
Definition: AbstractTreeModel.cpp:397
int indexOfVisibleItem(AbstractTreeItem const *item, InterestingItemsFlag=AllItems, bool=false) const
Definition: AbstractTreeModel.cpp:300
void setGlobalSelection(bool selected, InterestingItemsFlag=AllItems)
Definition: AbstractTreeModel.cpp:475
void rebuildProgressChanged(int)
QList< AbstractTreeItem *> getSelectedItems(InterestingItemsFlag=AllItems, bool=false)
Definition: AbstractTreeModel.cpp:224
Base class for tree models.
Definition: AbstractTreeModel.h:39
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:145
void setDrivable(bool drivableStatus)
void applyFilter()
Definition: AbstractTreeModel.cpp:433
TreeView * getView() const
Definition: AbstractTreeModel.cpp:392
Definition: ConcurrentControlNetReader.h:34
bool isFrozen() const
Definition: AbstractTreeModel.cpp:337
void clear()
Definition: AbstractTreeModel.cpp:367
Definition: AbstractTreeModel.h:46
bool isRebuilding() const
Definition: AbstractTreeModel.cpp:352
a control network
Definition: ControlNet.h:271
Definition: TreeView.h:23
int getTopLevelItemCount() const
Definition: AbstractTreeModel.cpp:258
Definition: AbstractTableModel.h:16
QMutex * getMutex() const
Definition: AbstractTreeModel.cpp:248
RootItem * getRootItem() const
Definition: AbstractTreeModel.cpp:387
void setRebuilding(bool running)
Definition: AbstractTreeModel.h:73
ControlNet * getControlNetwork() const
Definition: AbstractTreeModel.cpp:376
void rebuildProgressRangeChanged(int, int)
virtual void rebuildItems()=0
void tableSelectionChanged(QList< AbstractTreeItem *>)
bool isFiltering() const
Definition: AbstractTreeModel.cpp:347
InterestingItems
Definition: AbstractTreeModel.h:43
void setFilter(FilterWidget *newFilter)
Definition: AbstractTreeModel.cpp:357
Definition: AbstractTreeModel.h:44
A leaf item that is not ready for user interaction.
Definition: BusyLeafItem.h:25
Definition: BoxcarCachingAlgorithm.h:29
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
FilterWidget * getFilterWidget() const
This widget contains filtering capabilities for a single filter type.
Definition: FilterWidget.h:51
void filterProgressRangeChanged(int, int)
void setFrozen(bool)
Definition: AbstractTreeModel.cpp:323
Base class for an item in the tree.
Definition: AbstractTreeItem.h:31
int getVisibleItemCount(InterestingItemsFlag, bool) const
Definition: AbstractTreeModel.cpp:262
Definition: CubeIoHandler.h:39
virtual ~AbstractTreeModel()
Definition: AbstractTreeModel.cpp:80
int getVisibleTopLevelItemCount() const
Definition: AbstractTreeModel.cpp:283
QList< AbstractTreeItem *> getItems(int, int, InterestingItemsFlag=AllItems, bool=false)
Definition: AbstractTreeModel.cpp:113
Definition: AbstractTreeModel.h:45
int getItemCount(InterestingItemsFlag) const
Definition: AbstractTreeModel.cpp:253
The root of a tree.
Definition: RootItem.h:30