source: trunk/tools/linguist/shared/proitems.cpp@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 6.9 KB
Line 
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
47QT_BEGIN_NAMESPACE
48
49// --------------- ProItem ------------
50void ProItem::setComment(const QString &comment)
51{
52 m_comment = comment;
53}
54
55QString ProItem::comment() const
56{
57 return m_comment;
58}
59
60// --------------- ProBlock ----------------
61ProBlock::ProBlock(ProBlock *parent)
62{
63 m_blockKind = 0;
64 m_parent = parent;
65}
66
67ProBlock::~ProBlock()
68{
69 qDeleteAll(m_proitems);
70}
71
72void ProBlock::appendItem(ProItem *proitem)
73{
74 m_proitems << proitem;
75}
76
77void ProBlock::setItems(const QList<ProItem *> &proitems)
78{
79 m_proitems = proitems;
80}
81
82QList<ProItem *> ProBlock::items() const
83{
84 return m_proitems;
85}
86
87void ProBlock::setBlockKind(int blockKind)
88{
89 m_blockKind = blockKind;
90}
91
92int ProBlock::blockKind() const
93{
94 return m_blockKind;
95}
96
97void ProBlock::setParent(ProBlock *parent)
98{
99 m_parent = parent;
100}
101
102ProBlock *ProBlock::parent() const
103{
104 return m_parent;
105}
106
107ProItem::ProItemKind ProBlock::kind() const
108{
109 return ProItem::BlockKind;
110}
111
112bool 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 ----------------
123ProVariable::ProVariable(const QString &name, ProBlock *parent)
124 : ProBlock(parent)
125{
126 setBlockKind(ProBlock::VariableKind);
127 m_variable = name;
128 m_variableKind = SetOperator;
129}
130
131void ProVariable::setVariableOperator(VariableOperator variableKind)
132{
133 m_variableKind = variableKind;
134}
135
136ProVariable::VariableOperator ProVariable::variableOperator() const
137{
138 return m_variableKind;
139}
140
141void ProVariable::setVariable(const QString &name)
142{
143 m_variable = name;
144}
145
146QString ProVariable::variable() const
147{
148 return m_variable;
149}
150
151bool 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 ----------------
162ProValue::ProValue(const QString &value, ProVariable *variable)
163{
164 m_variable = variable;
165 m_value = value;
166}
167
168void ProValue::setValue(const QString &value)
169{
170 m_value = value;
171}
172
173QString ProValue::value() const
174{
175 return m_value;
176}
177
178void ProValue::setVariable(ProVariable *variable)
179{
180 m_variable = variable;
181}
182
183ProVariable *ProValue::variable() const
184{
185 return m_variable;
186}
187
188ProItem::ProItemKind ProValue::kind() const
189{
190 return ProItem::ValueKind;
191}
192
193bool ProValue::Accept(AbstractProItemVisitor *visitor)
194{
195 return visitor->visitProValue(this);
196}
197
198// --------------- ProFunction ----------------
199ProFunction::ProFunction(const QString &text)
200{
201 m_text = text;
202}
203
204void ProFunction::setText(const QString &text)
205{
206 m_text = text;
207}
208
209QString ProFunction::text() const
210{
211 return m_text;
212}
213
214ProItem::ProItemKind ProFunction::kind() const
215{
216 return ProItem::FunctionKind;
217}
218
219bool ProFunction::Accept(AbstractProItemVisitor *visitor)
220{
221 return visitor->visitProFunction(this);
222}
223
224// --------------- ProCondition ----------------
225ProCondition::ProCondition(const QString &text)
226{
227 m_text = text;
228}
229
230void ProCondition::setText(const QString &text)
231{
232 m_text = text;
233}
234
235QString ProCondition::text() const
236{
237 return m_text;
238}
239
240ProItem::ProItemKind ProCondition::kind() const
241{
242 return ProItem::ConditionKind;
243}
244
245bool ProCondition::Accept(AbstractProItemVisitor *visitor)
246{
247 return visitor->visitProCondition(this);
248}
249
250// --------------- ProOperator ----------------
251ProOperator::ProOperator(OperatorKind operatorKind)
252{
253 m_operatorKind = operatorKind;
254}
255
256void ProOperator::setOperatorKind(OperatorKind operatorKind)
257{
258 m_operatorKind = operatorKind;
259}
260
261ProOperator::OperatorKind ProOperator::operatorKind() const
262{
263 return m_operatorKind;
264}
265
266ProItem::ProItemKind ProOperator::kind() const
267{
268 return ProItem::OperatorKind;
269}
270
271bool ProOperator::Accept(AbstractProItemVisitor *visitor)
272{
273 return visitor->visitProOperator(this);
274}
275
276// --------------- ProFile ----------------
277ProFile::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
289ProFile::~ProFile()
290{
291}
292
293QString ProFile::displayFileName() const
294{
295 return m_displayFileName;
296}
297
298QString ProFile::fileName() const
299{
300 return m_fileName;
301}
302
303QString ProFile::directoryName() const
304{
305 return m_directoryName;
306}
307
308void ProFile::setModified(bool modified)
309{
310 m_modified = modified;
311}
312
313bool ProFile::isModified() const
314{
315 return m_modified;
316}
317
318bool 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
328QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.