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 #include "layout_builder.h" |
|
20 |
|
21 |
|
22 LayoutBuilder::LayoutBuilder(QWidget* parent) |
|
23 : QWidget(parent) |
|
24 { |
|
25 setupUi(this); |
|
26 LayoutWidgetModel* model = new LayoutWidgetModel(this); |
|
27 widgetsList->setModel(model); |
|
28 } |
|
29 |
|
30 LayoutBuilder::~LayoutBuilder() |
|
31 { |
|
32 } |
|
33 |
|
34 const QHash<QString, LayoutWidget*>& LayoutBuilder::getLayoutWidgetsDict() |
|
35 { |
|
36 return dynamic_cast<LayoutWidgetModel*>(widgetsList->model())->getLayoutWidgetsDict(); |
|
37 } |
|
38 |
|
39 void LayoutBuilder::addWidget(LayoutWidget* widget) |
|
40 { |
|
41 dynamic_cast<LayoutWidgetModel*>(widgetsList->model())->append(widget); |
|
42 } |
|
43 |
|
44 LayoutBuilderContactList::LayoutBuilderContactList(QWidget* parent) |
|
45 : LayoutBuilder(parent) |
|
46 { |
|
47 addWidget(new LayoutWidget("List")); |
|
48 addWidget(new LayoutWidget("Box")); |
|
49 layoutView->setLayoutWidgets(getLayoutWidgetsDict()); |
|
50 } |
|
51 |
|
52 LayoutBuilderContactList::~LayoutBuilderContactList() |
|
53 { |
|
54 } |
|
55 |
|
56 LayoutBuilder* LayoutBuilderFactory::Create(LayoutType type, QWidget* parent) |
|
57 { |
|
58 switch (type) { |
|
59 case CONTACT_LIST: |
|
60 return new LayoutBuilderContactList(parent); |
|
61 break; |
|
62 case CONTACT_ITEM: |
|
63 break; |
|
64 default: |
|
65 qCritical() << "Unknwon LayoutBuilder type"; |
|
66 } |
|
67 |
|
68 return 0; |
|
69 } |