Debian Codegraph @

qml/Lomiri/Action/qml-preview-action.cpp

raw
1 /* This file is part of lomiri-action-api
2 * Copyright 2013 Canonical Ltd.
3 *
4 * lomiri-action-api is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * lomiri-action-api is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include "qml-preview-action.h"
18
19 using namespace lomiri::action;
20
21 qml::PreviewAction::PreviewAction(QObject *parent)
22 : lomiri::action::PreviewAction(parent)
23 {
24
25 }
26
27 qml::PreviewAction::~PreviewAction()
28 {
29 foreach(PreviewParameter *parameter, parameters()) {
30 removeParameter(parameter);
31 }
32 }
33
34
35 QQmlListProperty<lomiri::action::PreviewParameter>
36 qml::PreviewAction::parameters_list()
37 {
38 return QQmlListProperty<lomiri::action::PreviewParameter>(this,
39 0,
40 qml::PreviewAction::append,
41 qml::PreviewAction::count,
42 qml::PreviewAction::at,
43 qml::PreviewAction::clear);
44 }
45
46 void
47 qml::PreviewAction::append(QQmlListProperty<lomiri::action::PreviewParameter> *list,
48 lomiri::action::PreviewParameter *parameter)
49 {
50 qml::PreviewAction *action = qobject_cast<qml::PreviewAction *>(list->object);
51 if (action) {
52 action->addParameter(parameter);
53 return;
54 }
55
56 Q_ASSERT(0); // should not be reached
57 }
58
59 PreviewParameter *
60 qml::PreviewAction::at(QQmlListProperty<lomiri::action::PreviewParameter> *list, QQMLISTPROPERTY_INT index)
61 {
62 qml::PreviewAction *action = qobject_cast<qml::PreviewAction *>(list->object);
63 if (action)
64 return action->parameters().at(index);
65
66 Q_ASSERT(0); // should not be reached
67 return 0;
68 }
69
70 void
71 qml::PreviewAction::clear(QQmlListProperty<lomiri::action::PreviewParameter> *list)
72 {
73 qml::PreviewAction *action = qobject_cast<qml::PreviewAction *>(list->object);
74 if (action) {
75 foreach(PreviewParameter *parameter, action->parameters()) {
76 action->removeParameter(parameter);
77 }
78 return;
79 }
80
81 Q_ASSERT(0); // should not be reached
82 }
83
84 QQMLISTPROPERTY_INT
85 qml::PreviewAction::count(QQmlListProperty<lomiri::action::PreviewParameter> *list)
86 {
87 qml::PreviewAction *action = qobject_cast<qml::PreviewAction *>(list->object);
88 if (action) {
89 return action->parameters().count();
90 }
91
92 Q_ASSERT(0); // should not be reached
93 return 0;
94 }