UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
db_tree_wid.hpp
1 /* hds_db_tree_wid.hpp */
2 /* $Id$ */
3 #ifndef __db_tree_wid_hpp
4 #define __db_tree_wid_hpp
5 
6 #include <QTreeWidgetItem>
7 
8 class QTreeWidget;
9 class QAction;
10 class QMenu;
11 
13 namespace hds
14 {
16  class DbTreeWid : public QWidget
17  {
18  Q_OBJECT
19 
20  public:
21 
23  enum ItemType
24  {
25  IT_NONE = QTreeWidgetItem::UserType,
30  };
31 
34  {
38  };
39 
41  DbTreeWid(QWidget *parent = 0, Qt::WindowFlags f = 0);
42 
44  virtual ~DbTreeWid();
45 
46 
50  void selectProject(const QString &project_str);
51 
52 
55  void setRemoveObjectsMode(const bool mode);
56 
59  void setOpenObjectsMode(const bool mode);
60 
61 
62  signals:
63 
65  void itemChanged(const int type,
66  const QString &project,
67  const QString &name);
68 
71  void errorOccurred(const int &ec);
72 
73  public slots:
74 
76  virtual void refreshTree();
77 
79  virtual void expandTree();
80 
82  virtual void collapseTree();
83 
84  protected slots:
85 
87  virtual void showContextMenu(QPoint pos);
88 
90  virtual void openObject(QTreeWidgetItem*)
91  {/* do nothing by default. */}
92 
94  virtual void removeObject(QTreeWidgetItem*)
95  {/* do nothing by default. */}
96 
100  virtual void changeCurrentItem(QTreeWidgetItem* /*cur_item*/,
101  QTreeWidgetItem* /*prev_item*/)
102  {/* do nothing by default. */}
103 
104  protected:
105 
107  QTreeWidget* ptw() {return mp_tw;}
108 
110  const QTreeWidget* ptw() const {return mp_tw;}
111 
113  const QPoint& contextMenuPos() const {return m_cm_pos;}
114 
115 
120  virtual QTreeWidgetItem* newTreeWidgetItem(const ItemType type,
121  const QString &name,
122  QTreeWidgetItem *parent = NULL) const;
123 
129  QTreeWidgetItem* projectItem(QTreeWidgetItem *item) const;
130 
135  QTreeWidgetItem* projectItem(const QString &project_str) const;
136 
141  QString projectNameStr(QTreeWidgetItem *item) const;
142 
144  int itemOptions(const QTreeWidgetItem *item) const;
145 
147  void setItemOptions(QTreeWidgetItem *item, const int &mask) const;
148 
150  virtual bool event(QEvent *ev);
151 
152  private:
153 
154  // context menu actions
155  QAction *mp_open_object_action;
156  QAction *mp_refresh_tree_action;
157  QAction *mp_expand_tree_action;
158  QAction *mp_collapse_tree_action;
159  QAction *mp_remove_object_action;
160 
162  QMenu *mp_context_menu;
163 
165  QPoint m_cm_pos;
166 
168  QTreeWidget *mp_tw;
169 
171  QString m_selected_project_str;
172 
174  bool m_open_objects_flag;
175 
177  bool m_remove_objects_flag;
178 
180  void prepare_context_menu();
181 
182  private slots:
183 
185  void openObjectFromContextMenu();
186 
188  void openObjectFromDoubleClick(QTreeWidgetItem *item, int column);
189 
191  void removeObjectFromContextMenu();
192  };
193 
194 }; // hds
195 
196 #endif /* db_tree_wid.hpp */
Definition: db_tree_wid.hpp:25
const QPoint & contextMenuPos() const
Definition: db_tree_wid.hpp:113
virtual void refreshTree()
void setItemOptions(QTreeWidgetItem *item, const int &mask) const
Definition: db_tree_wid.hpp:16
virtual bool event(QEvent *ev)
virtual void expandTree()
void setRemoveObjectsMode(const bool mode)
virtual void collapseTree()
void itemChanged(const int type, const QString &project, const QString &name)
QString projectNameStr(QTreeWidgetItem *item) const
virtual void removeObject(QTreeWidgetItem *)
Definition: db_tree_wid.hpp:94
QTreeWidgetItem * projectItem(QTreeWidgetItem *item) const
Definition: db_tree_wid.hpp:26
virtual void changeCurrentItem(QTreeWidgetItem *, QTreeWidgetItem *)
Definition: db_tree_wid.hpp:100
virtual ~DbTreeWid()
Definition: db_tree_wid.hpp:29
Definition: db_tree_wid.hpp:37
ItemType
Definition: db_tree_wid.hpp:23
Definition: db_tree_wid.hpp:35
const QTreeWidget * ptw() const
Definition: db_tree_wid.hpp:110
QTreeWidget * ptw()
Definition: db_tree_wid.hpp:107
void setOpenObjectsMode(const bool mode)
DbTreeWid(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: db_tree_wid.hpp:36
Definition: db_tree_wid.hpp:28
int itemOptions(const QTreeWidgetItem *item) const
void errorOccurred(const int &ec)
Definition: db_tree_wid.hpp:27
ItemOptions
Definition: db_tree_wid.hpp:33
virtual void showContextMenu(QPoint pos)
virtual void openObject(QTreeWidgetItem *)
Definition: db_tree_wid.hpp:90
void selectProject(const QString &project_str)