00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ABSTRACTWIDGETBOX_H
00025 #define ABSTRACTWIDGETBOX_H
00026
00027 #include <QtDesigner/sdk_global.h>
00028
00029 #include <QtCore/QMetaType>
00030 #include <QtGui/QWidget>
00031 #include <QtGui/QIcon>
00032
00033 QT_BEGIN_HEADER
00034
00035 class DomUI;
00036 class QDesignerDnDItemInterface;
00037
00038 class QDESIGNER_SDK_EXPORT QDesignerWidgetBoxInterface : public QWidget
00039 {
00040 Q_OBJECT
00041 public:
00042 class Widget {
00043 public:
00044 enum Type { Default, Custom };
00045 Widget(const QString &aname = QString(), const QString &xml = QString(),
00046 const QString &icon_name = QString(), Type atype = Default)
00047 : m_name(aname), m_xml(xml), m_icon_name(icon_name), m_type(atype) {}
00048 QString name() const { return m_name; }
00049 void setName(const QString &aname) { m_name = aname; }
00050 QString domXml() const { return m_xml; }
00051 void setDomXml(const QString &xml) { m_xml = xml; }
00052 QString iconName() const { return m_icon_name; }
00053 void setIconName(const QString &icon_name) { m_icon_name = icon_name; }
00054 Type type() const { return m_type; }
00055 void setType(Type atype) { m_type = atype; }
00056
00057 bool isNull() const { return m_name.isEmpty(); }
00058
00059 private:
00060 QString m_name;
00061 QString m_xml;
00062 QString m_icon_name;
00063 Type m_type;
00064 };
00065 typedef QList<Widget> WidgetList;
00066
00067 class Category {
00068 public:
00069 enum Type { Default, Scratchpad };
00070
00071 Category(const QString &aname = QString(), Type atype = Default)
00072 : m_name(aname), m_type(atype) {}
00073
00074 QString name() const { return m_name; }
00075 void setName(const QString &aname) { m_name = aname; }
00076 int widgetCount() const { return m_widget_list.size(); }
00077 Widget widget(int idx) const { return m_widget_list.at(idx); }
00078 void removeWidget(int idx) { m_widget_list.removeAt(idx); }
00079 void addWidget(const Widget &awidget) { m_widget_list.append(awidget); }
00080 Type type() const { return m_type; }
00081 void setType(Type atype) { m_type = atype; }
00082
00083 bool isNull() const { return m_name.isEmpty(); }
00084
00085 private:
00086 QString m_name;
00087 Type m_type;
00088 QList<Widget> m_widget_list;
00089 };
00090 typedef QList<Category> CategoryList;
00091
00092 QDesignerWidgetBoxInterface(QWidget *parent = 0, Qt::WindowFlags flags = 0);
00093 virtual ~QDesignerWidgetBoxInterface();
00094
00095 virtual int categoryCount() const = 0;
00096 virtual Category category(int cat_idx) const = 0;
00097 virtual void addCategory(const Category &cat) = 0;
00098 virtual void removeCategory(int cat_idx) = 0;
00099
00100 virtual int widgetCount(int cat_idx) const = 0;
00101 virtual Widget widget(int cat_idx, int wgt_idx) const = 0;
00102 virtual void addWidget(int cat_idx, const Widget &wgt) = 0;
00103 virtual void removeWidget(int cat_idx, int wgt_idx) = 0;
00104
00105 int findOrInsertCategory(const QString &categoryName);
00106
00107 virtual void dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list,
00108 const QPoint &global_mouse_pos) = 0;
00109
00110 virtual void setFileName(const QString &file_name) = 0;
00111 virtual QString fileName() const = 0;
00112 virtual bool load() = 0;
00113 virtual bool save() = 0;
00114 };
00115
00116 Q_DECLARE_METATYPE(QDesignerWidgetBoxInterface::Widget)
00117
00118 QT_END_HEADER
00119
00120 #endif // ABSTRACTWIDGETBOX_H