Crossfire Server, Trunk  R20513
CRETreeItem.h
Go to the documentation of this file.
1 #ifndef CRETREEITEM_H
2 #define CRETREEITEM_H
3 
4 #include <QObject>
5 #include <QMenu>
6 
7 #include "CREPanel.h"
8 
9 class CRETreeItem : public QObject
10 {
11  Q_OBJECT
12 
13  public:
14  virtual QString getPanelName() const = 0;
15  virtual void fillPanel(QWidget* panel) = 0;
16  virtual void fillContextMenu(QMenu*) { };
17 };
18 
19 template<typename T>
20 class CRETTreeItem : public CRETreeItem
21 {
22 public:
23  CRETTreeItem(T* item, const QString& name)
24  {
25  myItem = item;
26  myName = name;
27  };
28  virtual QString getPanelName() const
29  {
30  return myName;
31  }
32  virtual void fillPanel(QWidget* panel)
33  {
34  CRETPanel<T>* p = static_cast<CRETPanel<T>*>(panel);
35  p->setItem(myItem);
36  }
37 protected:
38  T* myItem;
39  QString myName;
40 };
41 
42 #endif // CRETREEITEM_H
virtual QString getPanelName() const =0
virtual void setItem(T *item)=0
virtual void fillPanel(QWidget *panel)=0
virtual void fillPanel(QWidget *panel)
Definition: CRETreeItem.h:32
virtual QString getPanelName() const
Definition: CRETreeItem.h:28
QString myName
Definition: CRETreeItem.h:39
CRETTreeItem(T *item, const QString &name)
Definition: CRETreeItem.h:23
virtual void fillContextMenu(QMenu *)
Definition: CRETreeItem.h:16