comparison layout_widget.h @ 8:c63d67895cbe

layout designer: first draft
author Goffi <goffi@goffi.org>
date Wed, 24 Aug 2011 20:38:55 +0200
parents
children
comparison
equal deleted inserted replaced
7:017925589d4c 8:c63d67895cbe
1 /*
2 Bellaciao: a Salut à Toi frontend
3 Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Affero General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef LAYOUT_WIDGETS_H
20 #define LAYOUT_WIDGETS_H
21
22 #include <QtGui>
23
24 #define LAYOUT_WIDGET_MIME "application/x-bellaciao-widget"
25
26 typedef enum {
27 NONE, BOOL, LIST
28 } WidgetPropertyType;
29
30 class WidgetProperty
31 {
32 public:
33 WidgetProperty(const QString& name, const QString& tooltip);
34
35 protected:
36 QString m_name, m_tooltip;
37 WidgetPropertyType m_type;
38
39 };
40
41 class WidgetPropertyBool: public WidgetProperty
42 {
43 public:
44 WidgetPropertyBool(const QString& name, bool checked=false, const QString& tooltip = QString());
45
46 protected:
47 bool m_checked;
48 };
49
50
51
52 class LayoutWidget
53 {
54 public:
55 LayoutWidget(const QString &name, const QString& icon="");
56 ~LayoutWidget();
57 const QString& getName() const;
58
59 private:
60 QString m_name, m_icon;
61 QList<WidgetProperty> m_properties;
62 };
63
64 class LayoutWidgetModel: public QAbstractListModel
65 {
66 Q_OBJECT
67
68 public:
69 LayoutWidgetModel(QObject* parent=0);
70 ~LayoutWidgetModel();
71 int rowCount(const QModelIndex &parent = QModelIndex()) const;
72 QVariant data(const QModelIndex &index, int role) const;
73 Qt::ItemFlags flags (const QModelIndex& index) const;
74 QStringList mimeTypes() const;
75 QMimeData* mimeData (const QModelIndexList& indexes ) const;
76 void append(LayoutWidget* layout_widget);
77 const QList<LayoutWidget*>& getLayoutWidgets() const;
78 const QHash<QString, LayoutWidget*>& getLayoutWidgetsDict() const;
79 private:
80 QList<LayoutWidget*> m_layout_widgets;
81 QHash<QString, LayoutWidget*> m_layout_widgets_dict;
82 };
83 #endif