Mercurial > bellaciao
comparison layout_view.h @ 10:877a005c2b42
Layout designer: WidgetView class, with two types: WidgetViewItem and WidgetViewBox which contains items.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 26 Aug 2011 15:58:46 +0200 |
parents | 0d7875c26974 |
children |
comparison
equal
deleted
inserted
replaced
9:0d7875c26974 | 10:877a005c2b42 |
---|---|
23 #include <QDragEnterEvent> | 23 #include <QDragEnterEvent> |
24 #include "layout_widget.h" | 24 #include "layout_widget.h" |
25 | 25 |
26 #define LAYOUT_WIDGET_MIME "application/x-bellaciao-widget" | 26 #define LAYOUT_WIDGET_MIME "application/x-bellaciao-widget" |
27 | 27 |
28 class WidgetView : public QLabel | 28 typedef enum |
29 { | |
30 HORIZONTAL, VERTICAL | |
31 } LayoutDirection; | |
32 | |
33 class WidgetView | |
34 { | |
35 public: | |
36 WidgetView(const QString& name); | |
37 ~WidgetView(); | |
38 }; | |
39 | |
40 class WidgetViewItem : public QLabel, public WidgetView | |
29 { | 41 { |
30 Q_OBJECT | 42 Q_OBJECT |
31 public: | 43 public: |
32 WidgetView(const QString& name); | 44 WidgetViewItem(const QString& name); |
45 }; | |
46 | |
47 class WidgetViewBox : public QScrollArea, public WidgetView | |
48 { | |
49 Q_OBJECT | |
50 public: | |
51 WidgetViewBox(const QString& name); | |
33 }; | 52 }; |
34 | 53 |
35 class LayoutView : public QWidget | 54 class LayoutView : public QWidget |
36 { | 55 { |
37 Q_OBJECT | 56 Q_OBJECT |
38 | 57 |
39 public: | 58 public: |
40 LayoutView(QWidget* parent=0); | 59 LayoutView(QWidget* parent = 0, LayoutDirection direction = VERTICAL); |
41 ~LayoutView(); | 60 ~LayoutView(); |
42 void setLayoutWidgets(const QHash<QString, LayoutWidget*>& layout_widgets); | 61 void setLayoutWidgets(const QHash<QString, LayoutWidget*>& layout_widgets); |
43 void dragEnterEvent (QDragEnterEvent* event ); | 62 void dragEnterEvent (QDragEnterEvent* event ); |
44 void dragLeaveEvent (QDragLeaveEvent* event ); | 63 void dragLeaveEvent (QDragLeaveEvent* event ); |
45 void dragMoveEvent (QDragMoveEvent* event ); | 64 void dragMoveEvent (QDragMoveEvent* event ); |
48 void addWidget(const QString& name); | 67 void addWidget(const QString& name); |
49 void paintEvent(QPaintEvent* event); | 68 void paintEvent(QPaintEvent* event); |
50 private: | 69 private: |
51 QHash<QString, LayoutWidget*> m_layout_widgets; | 70 QHash<QString, LayoutWidget*> m_layout_widgets; |
52 QList<LayoutWidget> m_widgets_list; | 71 QList<LayoutWidget> m_widgets_list; |
53 QVBoxLayout* m_layout; | 72 QBoxLayout* m_layout; |
54 QRect m_loc_hint; | 73 QRect m_loc_hint; |
55 int m_insert_pos; //position in the layout when a widget must be inserted | 74 int m_insert_pos; //position in the layout when a widget must be inserted |
75 LayoutDirection m_direction; | |
56 }; | 76 }; |
77 | |
57 #endif | 78 #endif |