Quark  0.1
BasicTreeView.h++
Go to the documentation of this file.
1 #ifndef __libquark_gui_BasicTreeView_hxx
2 #define __libquark_gui_BasicTreeView_hxx
3 
4 #include <QList>
5 #include <QResizeEvent>
6 #include <QTimer>
7 #include <QTreeView>
8 
9 #include <quark/Quark.h++>
10 #include <quark/BasicTreeModel.h++>
12 
13 namespace quark {
14 namespace gui {
15 
16 class ActivityIndicator;
17 
18 class LIBQUARK_API BasicTreeView : public QTreeView
19 {
20  Q_OBJECT;
21 
22  public:
23 
24  explicit BasicTreeView(QWidget *parent = NULL);
25  virtual ~BasicTreeView();
26 
27  template<class T>
29  {
30  QTreeView::setModel(model);
31  _modelBase = model;
32  applyFieldWidths();
33  }
34 
35  template<class T>
37  {
38  QTreeView::setModel(model);
39  _modelBase = model;
40  applyFieldWidths();
41  }
42 
43  void setPreference(const QString &preference);
44 
45  public slots:
46 
47  void restoreState();
48  void saveState() const;
49 
50  // Toggles the "loading" state; when on, an animated busy indicator
51  // appears centered over the content area.
52  void setLoading(bool loading);
53 
54  void resizeColumnsToContents();
55 
56  protected:
57 
58  virtual bool event(QEvent *event);
59  virtual void resizeEvent(QResizeEvent *event);
60 
61  private:
62 
63  void applyFieldWidths();
64 
65  BasicTreeModelBase *_modelBase;
66  ActivityIndicator *_activityIndicator;
67  QList<int> _fieldPreferredWidths;
68  QString _preference;
69  mutable QTimer _saveTimer;
70  mutable qint64 _lastStateChange;
71 };
72 
73 } // namespace gui
74 } // namespace quark
75 
76 #endif // __libquark_gui_BasicTreeView_hxx
Definition: BasicTreeModel.h++:22
void setModel(BasicFilterTreeModel< T > *model)
Definition: BasicTreeView.h++:36
Definition: BasicTreeView.h++:18
An animated component (a "throbber") that indicates ongoing activity in an application.
Definition: ActivityIndicator.h++:22
An abstract subclass of QSortFilterProxyModel for sorting and filtering of AbstractTreeModels.
Definition: BasicFilterTreeModel.h++:25
void setModel(BasicTreeModel< T > *model)
Definition: BasicTreeView.h++:28
Definition: BasicTreeModelBase.h++:13
Definition: BarChartView.h++:6
#define LIBQUARK_API
Definition: Quark.h++:18