00001 #ifndef IG_QT_TREE_BROWSER_IG_QT_TREE_REP_H
00002 # define IG_QT_TREE_BROWSER_IG_QT_TREE_REP_H
00003
00004
00005
00006 # include "Iguana/Studio/interface/config.h"
00007 # include "Iguana/Framework/interface/IgRep.h"
00008
00009 # include <qlistview.h>
00010 # include <qstring.h>
00011
00012
00013
00014
00015
00016 class IgQtTreeBrowser;
00017
00018
00019
00020
00021
00022 class IGUANA_STUDIO_API IgQtTreeRep : public QListViewItem, public IgRep
00023 {
00024 public:
00025 static const int VISIBLE_FIELD = 1;
00026 static const int TRAVERSE_FIELD = 2;
00027 static const int CASCADE_FIELD = 3;
00028
00029 static IgQtTreeRep * create (IgQtTreeBrowser *in,
00030 IgQtTreeRep *parent,
00031 IgQtTreeRep *before,
00032 QString name, bool traverse,
00033 bool visible, bool opened);
00034
00035 IgQtTreeRep (IgQtTreeRep *parent, IgQtTreeRep *before,
00036 QString name, bool traverse, bool visible, bool opened);
00037 IgQtTreeRep (IgQtTreeRep *parent,
00038 QString name, bool traverse, bool visible, bool opened);
00039 IgQtTreeRep (IgQtTreeBrowser *in, IgQtTreeRep *before,
00040 QString name, bool traverse, bool visible, bool opened);
00041 IgQtTreeRep (IgQtTreeBrowser *in,
00042 QString name, bool traverse, bool visible, bool opened);
00043 ~IgQtTreeRep (void);
00044
00045 virtual IgRepContext * context (void) const;
00046 virtual IgModel * model (void) const;
00047
00048 bool bold (void) const;
00049 void bold (bool value);
00050
00051 bool italic (void) const;
00052 void italic (bool value);
00053
00054 bool magic (void) const;
00055 void magic (bool value);
00056
00057 virtual void setOpen (bool opened);
00058 void setCheck (int column, bool value, bool known);
00059
00060 protected:
00061 virtual void context (IgRepContext *context);
00062
00063 void init (bool traverse, bool visible, bool opened);
00064 bool traversed (void) const;
00065 void repaintChildren (QListViewItem *item);
00066 QColorGroup columnColor (int column, const QColorGroup &cg) const;
00067
00068 virtual void paintCell (QPainter *painter,
00069 const QColorGroup &cg,
00070 int column, int width, int align);
00071 virtual int width (const QFontMetrics &,
00072 const QListView *lv,
00073 int c) const;
00074
00075 private:
00076 bool flag (unsigned n) const;
00077 void flag (unsigned n, bool value);
00078
00079 static const unsigned int CHECKABLE = 1;
00080 static const unsigned int BOLD = 2;
00081 static const unsigned int ITALIC = 4;
00082 static const unsigned int MAGIC = 8;
00083 static const unsigned int EXPANDED = 16;
00084 static const unsigned int TRAVERSE = 32;
00085 static const unsigned int VISIBLE = 64;
00086 static const unsigned int AUTO_OPEN = 128;
00087
00088 IgRepContext *m_context;
00089 unsigned m_flags;
00090
00091
00092 IgQtTreeRep (const IgQtTreeRep &);
00093 IgQtTreeRep &operator= (const IgQtTreeRep &);
00094 };
00095
00096
00097
00098
00099 inline bool
00100 IgQtTreeRep::flag (unsigned n) const
00101 { return m_flags & n; }
00102
00103 inline void
00104 IgQtTreeRep::flag (unsigned n, bool value)
00105 { m_flags = (m_flags & ~n) | (n * value); }
00106
00107 inline bool
00108 IgQtTreeRep::bold (void) const
00109 { return flag (BOLD); }
00110
00111 inline void
00112 IgQtTreeRep::bold (bool value)
00113 { flag (BOLD, value); }
00114
00115 inline bool
00116 IgQtTreeRep::italic (void) const
00117 { return flag (ITALIC); }
00118
00119 inline void
00120 IgQtTreeRep::italic (bool value)
00121 { flag (ITALIC, value); }
00122
00123 inline bool
00124 IgQtTreeRep::magic (void) const
00125 { return flag (MAGIC); }
00126
00127 inline void
00128 IgQtTreeRep::magic (bool value)
00129 { flag (MAGIC, value); }
00130
00131 #endif // IG_QT_TREE_BROWSER_IG_QT_TREE_REP_H