annotate layout_widget.h @ 9:0d7875c26974

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