annotate layout_builder.cpp @ 11:98485ebbdb86 default tip

LayoutView: WidgetViewBox fix
author Goffi <goffi@goffi.org>
date Sat, 27 Aug 2011 00:31:20 +0200
parents 0d7875c26974
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 #include "layout_builder.h"
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
20
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 LayoutBuilder::LayoutBuilder(QWidget* parent)
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
23 : QWidget(parent)
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 {
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 setupUi(this);
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 LayoutWidgetModel* model = new LayoutWidgetModel(this);
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27 widgetsList->setModel(model);
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28 }
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 LayoutBuilder::~LayoutBuilder()
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 }
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
33
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
34 const QHash<QString, LayoutWidget*>& LayoutBuilder::getLayoutWidgetsDict()
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
35 {
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
36 return dynamic_cast<LayoutWidgetModel*>(widgetsList->model())->getLayoutWidgetsDict();
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37 }
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 void LayoutBuilder::addWidget(LayoutWidget* widget)
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 dynamic_cast<LayoutWidgetModel*>(widgetsList->model())->append(widget);
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
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
44 LayoutBuilderContactList::LayoutBuilderContactList(QWidget* parent)
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45 : LayoutBuilder(parent)
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
46 {
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
47 addWidget(new LayoutWidget("List"));
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48 addWidget(new LayoutWidget("Box"));
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
49 layoutView->setLayoutWidgets(getLayoutWidgetsDict());
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 LayoutBuilderContactList::~LayoutBuilderContactList()
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 }
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
55
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
56 LayoutBuilder* LayoutBuilderFactory::Create(LayoutType type, QWidget* parent)
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57 {
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58 switch (type) {
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
59 case CONTACT_LIST:
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
60 return new LayoutBuilderContactList(parent);
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
61 break;
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
62 case CONTACT_ITEM:
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
63 break;
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
64 default:
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
65 qCritical() << "Unknwon LayoutBuilder type";
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
66 }
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 return 0;
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
69 }