Mercurial > bellaciao
annotate layout_view.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 | 877a005c2b42 |
rev | line source |
---|---|
8 | 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_VIEW_H | |
20 #define LAYOUT_VIEW_H | |
21 | |
22 #include <QWidget> | |
23 #include <QDragEnterEvent> | |
24 #include "layout_widget.h" | |
25 | |
26 #define LAYOUT_WIDGET_MIME "application/x-bellaciao-widget" | |
27 | |
9
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
28 class WidgetView : public QLabel |
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
29 { |
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
30 Q_OBJECT |
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
31 public: |
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
32 WidgetView(const QString& name); |
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
33 }; |
8 | 34 |
35 class LayoutView : public QWidget | |
36 { | |
37 Q_OBJECT | |
38 | |
39 public: | |
40 LayoutView(QWidget* parent=0); | |
41 ~LayoutView(); | |
42 void setLayoutWidgets(const QHash<QString, LayoutWidget*>& layout_widgets); | |
43 void dragEnterEvent (QDragEnterEvent* event ); | |
9
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
44 void dragLeaveEvent (QDragLeaveEvent* event ); |
8 | 45 void dragMoveEvent (QDragMoveEvent* event ); |
46 void dropEvent (QDropEvent * event); | |
47 protected: | |
48 void addWidget(const QString& name); | |
9
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
49 void paintEvent(QPaintEvent* event); |
8 | 50 private: |
51 QHash<QString, LayoutWidget*> m_layout_widgets; | |
52 QList<LayoutWidget> m_widgets_list; | |
53 QVBoxLayout* m_layout; | |
9
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
54 QRect m_loc_hint; |
0d7875c26974
layout designer: hints on widget placement during drag and drop
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
55 int m_insert_pos; //position in the layout when a widget must be inserted |
8 | 56 }; |
57 #endif |