Isis 3 Programmer Reference
AbstractTreeModel.h
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:
43  enum InterestingItems {
44  PointItems = 1,
45  MeasureItems = 2,
46  ImageItems = 4,
47  AllItems = PointItems | MeasureItems | ImageItems
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 
57  QList< AbstractTreeItem * > getItems(int, int,
58  InterestingItemsFlag = AllItems, bool = false);
60  AbstractTreeItem *, InterestingItemsFlag = AllItems, bool = false);
61  QList< AbstractTreeItem * > getSelectedItems(
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);
97  void treeSelectionChanged(QList<AbstractTreeItem *>);
98  void tableSelectionChanged(QList<AbstractTreeItem *>);
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:
145  RootItem *rootItem;
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:
174  : public std::unary_function< AbstractTreeItem *const &, bool > {
175  public:
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
QSize getVisibleSize(int indentation) const
indentation is in pixels
Base class for tree models.
void filterCountsChanged(int visibleTopLevelItemCount, int topLevelItemCount)
This signal is emitted after filtering to provide the number of visible top-level items remaining aft...
a control network
Definition: ControlNet.h:271
A leaf item that is not ready for user interaction.
Definition: BusyLeafItem.h:25
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
This widget contains filtering capabilities for a single filter type.
Definition: FilterWidget.h:51
Base class for an item in the tree.
The root of a tree.
Definition: RootItem.h:30