1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the Qt Linguist of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "proitems.h"
|
---|
43 | #include "abstractproitemvisitor.h"
|
---|
44 |
|
---|
45 | #include <QtCore/QFileInfo>
|
---|
46 |
|
---|
47 | QT_BEGIN_NAMESPACE
|
---|
48 |
|
---|
49 | // --------------- ProItem ------------
|
---|
50 | void ProItem::setComment(const QString &comment)
|
---|
51 | {
|
---|
52 | m_comment = comment;
|
---|
53 | }
|
---|
54 |
|
---|
55 | QString ProItem::comment() const
|
---|
56 | {
|
---|
57 | return m_comment;
|
---|
58 | }
|
---|
59 |
|
---|
60 | // --------------- ProBlock ----------------
|
---|
61 | ProBlock::ProBlock(ProBlock *parent)
|
---|
62 | {
|
---|
63 | m_blockKind = 0;
|
---|
64 | m_parent = parent;
|
---|
65 | }
|
---|
66 |
|
---|
67 | ProBlock::~ProBlock()
|
---|
68 | {
|
---|
69 | qDeleteAll(m_proitems);
|
---|
70 | }
|
---|
71 |
|
---|
72 | void ProBlock::appendItem(ProItem *proitem)
|
---|
73 | {
|
---|
74 | m_proitems << proitem;
|
---|
75 | }
|
---|
76 |
|
---|
77 | void ProBlock::setItems(const QList<ProItem *> &proitems)
|
---|
78 | {
|
---|
79 | m_proitems = proitems;
|
---|
80 | }
|
---|
81 |
|
---|
82 | QList<ProItem *> ProBlock::items() const
|
---|
83 | {
|
---|
84 | return m_proitems;
|
---|
85 | }
|
---|
86 |
|
---|
87 | void ProBlock::setBlockKind(int blockKind)
|
---|
88 | {
|
---|
89 | m_blockKind = blockKind;
|
---|
90 | }
|
---|
91 |
|
---|
92 | int ProBlock::blockKind() const
|
---|
93 | {
|
---|
94 | return m_blockKind;
|
---|
95 | }
|
---|
96 |
|
---|
97 | void ProBlock::setParent(ProBlock *parent)
|
---|
98 | {
|
---|
99 | m_parent = parent;
|
---|
100 | }
|
---|
101 |
|
---|
102 | ProBlock *ProBlock::parent() const
|
---|
103 | {
|
---|
104 | return m_parent;
|
---|
105 | }
|
---|
106 |
|
---|
107 | ProItem::ProItemKind ProBlock::kind() const
|
---|
108 | {
|
---|
109 | return ProItem::BlockKind;
|
---|
110 | }
|
---|
111 |
|
---|
112 | bool ProBlock::Accept(AbstractProItemVisitor *visitor)
|
---|
113 | {
|
---|
114 | visitor->visitBeginProBlock(this);
|
---|
115 | foreach (ProItem *item, m_proitems) {
|
---|
116 | if (!item->Accept(visitor))
|
---|
117 | return false;
|
---|
118 | }
|
---|
119 | return visitor->visitEndProBlock(this);
|
---|
120 | }
|
---|
121 |
|
---|
122 | // --------------- ProVariable ----------------
|
---|
123 | ProVariable::ProVariable(const QString &name, ProBlock *parent)
|
---|
124 | : ProBlock(parent)
|
---|
125 | {
|
---|
126 | setBlockKind(ProBlock::VariableKind);
|
---|
127 | m_variable = name;
|
---|
128 | m_variableKind = SetOperator;
|
---|
129 | }
|
---|
130 |
|
---|
131 | void ProVariable::setVariableOperator(VariableOperator variableKind)
|
---|
132 | {
|
---|
133 | m_variableKind = variableKind;
|
---|
134 | }
|
---|
135 |
|
---|
136 | ProVariable::VariableOperator ProVariable::variableOperator() const
|
---|
137 | {
|
---|
138 | return m_variableKind;
|
---|
139 | }
|
---|
140 |
|
---|
141 | void ProVariable::setVariable(const QString &name)
|
---|
142 | {
|
---|
143 | m_variable = name;
|
---|
144 | }
|
---|
145 |
|
---|
146 | QString ProVariable::variable() const
|
---|
147 | {
|
---|
148 | return m_variable;
|
---|
149 | }
|
---|
150 |
|
---|
151 | bool ProVariable::Accept(AbstractProItemVisitor *visitor)
|
---|
152 | {
|
---|
153 | visitor->visitBeginProVariable(this);
|
---|
154 | foreach (ProItem *item, m_proitems) {
|
---|
155 | if (!item->Accept(visitor))
|
---|
156 | return false;
|
---|
157 | }
|
---|
158 | return visitor->visitEndProVariable(this);
|
---|
159 | }
|
---|
160 |
|
---|
161 | // --------------- ProValue ----------------
|
---|
162 | ProValue::ProValue(const QString &value, ProVariable *variable)
|
---|
163 | {
|
---|
164 | m_variable = variable;
|
---|
165 | m_value = value;
|
---|
166 | }
|
---|
167 |
|
---|
168 | void ProValue::setValue(const QString &value)
|
---|
169 | {
|
---|
170 | m_value = value;
|
---|
171 | }
|
---|
172 |
|
---|
173 | QString ProValue::value() const
|
---|
174 | {
|
---|
175 | return m_value;
|
---|
176 | }
|
---|
177 |
|
---|
178 | void ProValue::setVariable(ProVariable *variable)
|
---|
179 | {
|
---|
180 | m_variable = variable;
|
---|
181 | }
|
---|
182 |
|
---|
183 | ProVariable *ProValue::variable() const
|
---|
184 | {
|
---|
185 | return m_variable;
|
---|
186 | }
|
---|
187 |
|
---|
188 | ProItem::ProItemKind ProValue::kind() const
|
---|
189 | {
|
---|
190 | return ProItem::ValueKind;
|
---|
191 | }
|
---|
192 |
|
---|
193 | bool ProValue::Accept(AbstractProItemVisitor *visitor)
|
---|
194 | {
|
---|
195 | return visitor->visitProValue(this);
|
---|
196 | }
|
---|
197 |
|
---|
198 | // --------------- ProFunction ----------------
|
---|
199 | ProFunction::ProFunction(const QString &text)
|
---|
200 | {
|
---|
201 | m_text = text;
|
---|
202 | }
|
---|
203 |
|
---|
204 | void ProFunction::setText(const QString &text)
|
---|
205 | {
|
---|
206 | m_text = text;
|
---|
207 | }
|
---|
208 |
|
---|
209 | QString ProFunction::text() const
|
---|
210 | {
|
---|
211 | return m_text;
|
---|
212 | }
|
---|
213 |
|
---|
214 | ProItem::ProItemKind ProFunction::kind() const
|
---|
215 | {
|
---|
216 | return ProItem::FunctionKind;
|
---|
217 | }
|
---|
218 |
|
---|
219 | bool ProFunction::Accept(AbstractProItemVisitor *visitor)
|
---|
220 | {
|
---|
221 | return visitor->visitProFunction(this);
|
---|
222 | }
|
---|
223 |
|
---|
224 | // --------------- ProCondition ----------------
|
---|
225 | ProCondition::ProCondition(const QString &text)
|
---|
226 | {
|
---|
227 | m_text = text;
|
---|
228 | }
|
---|
229 |
|
---|
230 | void ProCondition::setText(const QString &text)
|
---|
231 | {
|
---|
232 | m_text = text;
|
---|
233 | }
|
---|
234 |
|
---|
235 | QString ProCondition::text() const
|
---|
236 | {
|
---|
237 | return m_text;
|
---|
238 | }
|
---|
239 |
|
---|
240 | ProItem::ProItemKind ProCondition::kind() const
|
---|
241 | {
|
---|
242 | return ProItem::ConditionKind;
|
---|
243 | }
|
---|
244 |
|
---|
245 | bool ProCondition::Accept(AbstractProItemVisitor *visitor)
|
---|
246 | {
|
---|
247 | return visitor->visitProCondition(this);
|
---|
248 | }
|
---|
249 |
|
---|
250 | // --------------- ProOperator ----------------
|
---|
251 | ProOperator::ProOperator(OperatorKind operatorKind)
|
---|
252 | {
|
---|
253 | m_operatorKind = operatorKind;
|
---|
254 | }
|
---|
255 |
|
---|
256 | void ProOperator::setOperatorKind(OperatorKind operatorKind)
|
---|
257 | {
|
---|
258 | m_operatorKind = operatorKind;
|
---|
259 | }
|
---|
260 |
|
---|
261 | ProOperator::OperatorKind ProOperator::operatorKind() const
|
---|
262 | {
|
---|
263 | return m_operatorKind;
|
---|
264 | }
|
---|
265 |
|
---|
266 | ProItem::ProItemKind ProOperator::kind() const
|
---|
267 | {
|
---|
268 | return ProItem::OperatorKind;
|
---|
269 | }
|
---|
270 |
|
---|
271 | bool ProOperator::Accept(AbstractProItemVisitor *visitor)
|
---|
272 | {
|
---|
273 | return visitor->visitProOperator(this);
|
---|
274 | }
|
---|
275 |
|
---|
276 | // --------------- ProFile ----------------
|
---|
277 | ProFile::ProFile(const QString &fileName)
|
---|
278 | : ProBlock(0)
|
---|
279 | {
|
---|
280 | m_modified = false;
|
---|
281 | setBlockKind(ProBlock::ProFileKind);
|
---|
282 | m_fileName = fileName;
|
---|
283 |
|
---|
284 | QFileInfo fi(fileName);
|
---|
285 | m_displayFileName = fi.fileName();
|
---|
286 | m_directoryName = fi.absolutePath();
|
---|
287 | }
|
---|
288 |
|
---|
289 | ProFile::~ProFile()
|
---|
290 | {
|
---|
291 | }
|
---|
292 |
|
---|
293 | QString ProFile::displayFileName() const
|
---|
294 | {
|
---|
295 | return m_displayFileName;
|
---|
296 | }
|
---|
297 |
|
---|
298 | QString ProFile::fileName() const
|
---|
299 | {
|
---|
300 | return m_fileName;
|
---|
301 | }
|
---|
302 |
|
---|
303 | QString ProFile::directoryName() const
|
---|
304 | {
|
---|
305 | return m_directoryName;
|
---|
306 | }
|
---|
307 |
|
---|
308 | void ProFile::setModified(bool modified)
|
---|
309 | {
|
---|
310 | m_modified = modified;
|
---|
311 | }
|
---|
312 |
|
---|
313 | bool ProFile::isModified() const
|
---|
314 | {
|
---|
315 | return m_modified;
|
---|
316 | }
|
---|
317 |
|
---|
318 | bool ProFile::Accept(AbstractProItemVisitor *visitor)
|
---|
319 | {
|
---|
320 | visitor->visitBeginProFile(this);
|
---|
321 | foreach (ProItem *item, m_proitems) {
|
---|
322 | if (!item->Accept(visitor))
|
---|
323 | return false;
|
---|
324 | }
|
---|
325 | return visitor->visitEndProFile(this);
|
---|
326 | }
|
---|
327 |
|
---|
328 | QT_END_NAMESPACE
|
---|