tools/designer/src/lib/sdk/abstractwidgetbox.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the Qt Designer of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
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

Generated on Thu Mar 15 12:01:23 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1