Isis 3.0 Programmer Reference
Back | Home
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 ControlNet;
18 
19  namespace CnetViz {
20  class AbstractTreeItem;
21  class BusyLeafItem;
22  class TreeView;
23  class FilterWidget;
24  class RootItem;
25 
40  class AbstractTreeModel : public QObject {
41  Q_OBJECT
42 
43  public:
44  enum InterestingItems {
45  PointItems = 1,
46  MeasureItems = 2,
47  SerialItems = 4,
48  AllItems = PointItems | MeasureItems | SerialItems
49  };
50  Q_DECLARE_FLAGS(InterestingItemsFlag, InterestingItems)
51 
52 
53  public:
54  AbstractTreeModel(ControlNet *controlNet, TreeView *v,
55  QObject *parent = 0);
56  virtual ~AbstractTreeModel();
57 
58  QList< AbstractTreeItem * > getItems(int, int,
59  InterestingItemsFlag = AllItems, bool = false);
61  AbstractTreeItem *, InterestingItemsFlag = AllItems, bool = false);
62  QList< AbstractTreeItem * > getSelectedItems(
63  InterestingItemsFlag = AllItems, bool = false);
64  QMutex *getMutex() const;
65  int getItemCount(InterestingItemsFlag) const;
66  int getTopLevelItemCount() const;
67  int getVisibleItemCount(InterestingItemsFlag, bool) const;
68  int getVisibleTopLevelItemCount() const;
69  TreeView *getView() const;
70  void setDrivable(bool drivableStatus);
71  bool isDrivable() const;
72  bool isFiltering() const;
73  bool isRebuilding() const;
74  void setRebuilding(bool running) { m_rebuildRunning = running; }
75  void setFilter(FilterWidget *newFilter);
76  void setGlobalSelection(bool selected, InterestingItemsFlag = AllItems);
77  void stopWorking();
78  QSize getVisibleSize(int indentation) const;
79  int indexOfVisibleItem(AbstractTreeItem const *item,
80  InterestingItemsFlag = AllItems,
81  bool = false) const;
82  void setFrozen(bool);
83  bool isFrozen() const;
84  void queueRebuild();
85 
86 
87  public slots:
88  void applyFilter();
89 
90 
91  signals:
92  void cancelSort();
93  void modelModified();
94  void filterProgressChanged(int);
95  void filterProgressRangeChanged(int, int);
96  void rebuildProgressChanged(int);
97  void rebuildProgressRangeChanged(int, int);
98  void treeSelectionChanged(QList<AbstractTreeItem *>);
99  void tableSelectionChanged(QList<AbstractTreeItem *>);
100 
106  void filterCountsChanged(int visibleTopLevelItemCount,
107  int topLevelItemCount);
108 
109 
110  public:
111  virtual void rebuildItems() = 0;
112 
113 
114  private:
116  AbstractTreeModel &operator=(const AbstractTreeModel &);
117 
118 
119  private:
120  AbstractTreeItem *nextItem(AbstractTreeItem *current,
121  InterestingItemsFlag flags, bool ignoreExpansion) const;
122  void selectItems(AbstractTreeItem *item, bool select,
123  InterestingItemsFlag flags);
124  static bool itemIsInteresting(
125  AbstractTreeItem *, InterestingItemsFlag);
126  int getItemCount(AbstractTreeItem *, InterestingItemsFlag) const;
127 
128 
129  private slots:
130  void applyFilterDone();
131  void rebuildItemsDone();
132 
133 
134  protected:
135  void clear();
136  ControlNet *getControlNetwork() const;
137  FilterWidget *getFilterWidget() const;
138 
140  getRebuildWatcher() const;
141 
142  RootItem *getRootItem() const;
143 
144 
145  protected:
146  RootItem *rootItem;
147 
148 
149  private: // data
151  QFutureWatcher< QAtomicPointer< RootItem > > * m_rebuildWatcher;
152  QList< QPair< QString, QString > > * m_expandedState;
153  QList< QPair< QString, QString > > * m_selectedState;
154  QMutex *m_mutex;
155  BusyLeafItem *m_busyItem;
156  TreeView *m_view;
157  ControlNet *m_cNet;
158  FilterWidget *m_guisFilterWidget;
159  FilterWidget *m_localFilterWidgetCopy;
160  bool m_drivable;
161  bool m_filterAgain;
162  bool m_filterRunning;
163  bool m_rebuildRunning;
164  bool m_frozen;
165  bool m_rebuildPending;
166 
167 
168  private:
175  : public std::unary_function< AbstractTreeItem *const &, bool > {
176  public:
178  FilterFunctor(FilterFunctor const &other);
179  ~FilterFunctor();
180  bool operator()(AbstractTreeItem *const &) const;
181  FilterFunctor &operator=(FilterFunctor const &);
182  void filterWorker(AbstractTreeItem *) const;
183 
184  static void updateTopLevelLinks(
186  AbstractTreeItem *const &item);
187 
188 
189  private:
190  FilterWidget *m_filter;
191  };
192  };
193 
194  Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractTreeModel::InterestingItemsFlag)
195  }
196 }
197 
198 #endif
A leaf item that is not ready for user interaction.
Definition: BusyLeafItem.h:25
The root of a tree.
Definition: RootItem.h:31
This widget contains filtering capabilities for a single filter type.
Definition: FilterWidget.h:47
Base class for an item in the tree.
a control network
Definition: ControlNet.h:207
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...
QSize getVisibleSize(int indentation) const
indentation is in pixels

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:13:53