source: trunk/tools/linguist/shared/proitems.h@ 239

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

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

File size: 5.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#ifndef PROITEMS_H
43#define PROITEMS_H
44
45#include <QtCore/QObject>
46#include <QtCore/QString>
47#include <QtCore/QList>
48
49QT_BEGIN_NAMESPACE
50
51struct AbstractProItemVisitor;
52
53class ProItem
54{
55public:
56 enum ProItemKind {
57 ValueKind,
58 FunctionKind,
59 ConditionKind,
60 OperatorKind,
61 BlockKind
62 };
63
64 ProItem() : m_lineNumber(0) {}
65 virtual ~ProItem() {}
66
67 virtual ProItemKind kind() const = 0;
68
69 void setComment(const QString &comment);
70 QString comment() const;
71
72 virtual bool Accept(AbstractProItemVisitor *visitor) = 0;
73 int lineNumber() const { return m_lineNumber; }
74 void setLineNumber(int lineNumber) { m_lineNumber = lineNumber; }
75
76private:
77 QString m_comment;
78 int m_lineNumber;
79};
80
81class ProBlock : public ProItem
82{
83public:
84 enum ProBlockKind {
85 NormalKind = 0x00,
86 ScopeKind = 0x01,
87 ScopeContentsKind = 0x02,
88 VariableKind = 0x04,
89 ProFileKind = 0x08,
90 SingleLine = 0x10
91 };
92
93 ProBlock(ProBlock *parent);
94 ~ProBlock();
95
96 void appendItem(ProItem *proitem);
97 void setItems(const QList<ProItem *> &proitems);
98 QList<ProItem *> items() const;
99
100 void setBlockKind(int blockKind);
101 int blockKind() const;
102
103 void setParent(ProBlock *parent);
104 ProBlock *parent() const;
105
106 ProItem::ProItemKind kind() const;
107
108 virtual bool Accept(AbstractProItemVisitor *visitor);
109protected:
110 QList<ProItem *> m_proitems;
111private:
112 ProBlock *m_parent;
113 int m_blockKind;
114};
115
116class ProVariable : public ProBlock
117{
118public:
119 enum VariableOperator {
120 AddOperator = 0,
121 RemoveOperator = 1,
122 ReplaceOperator = 2,
123 SetOperator = 3,
124 UniqueAddOperator = 4
125 };
126
127 ProVariable(const QString &name, ProBlock *parent);
128
129 void setVariableOperator(VariableOperator variableKind);
130 VariableOperator variableOperator() const;
131
132 void setVariable(const QString &name);
133 QString variable() const;
134
135 virtual bool Accept(AbstractProItemVisitor *visitor);
136private:
137 VariableOperator m_variableKind;
138 QString m_variable;
139};
140
141class ProValue : public ProItem
142{
143public:
144 ProValue(const QString &value, ProVariable *variable);
145
146 void setValue(const QString &value);
147 QString value() const;
148
149 void setVariable(ProVariable *variable);
150 ProVariable *variable() const;
151
152 ProItem::ProItemKind kind() const;
153
154 virtual bool Accept(AbstractProItemVisitor *visitor);
155private:
156 QString m_value;
157 ProVariable *m_variable;
158};
159
160class ProFunction : public ProItem
161{
162public:
163 explicit ProFunction(const QString &text);
164
165 void setText(const QString &text);
166 QString text() const;
167
168 ProItem::ProItemKind kind() const;
169
170 virtual bool Accept(AbstractProItemVisitor *visitor);
171private:
172 QString m_text;
173};
174
175class ProCondition : public ProItem
176{
177public:
178 explicit ProCondition(const QString &text);
179
180 void setText(const QString &text);
181 QString text() const;
182
183 ProItem::ProItemKind kind() const;
184
185 virtual bool Accept(AbstractProItemVisitor *visitor);
186private:
187 QString m_text;
188};
189
190class ProOperator : public ProItem
191{
192public:
193 enum OperatorKind {
194 OrOperator = 1,
195 NotOperator = 2
196 };
197
198 explicit ProOperator(OperatorKind operatorKind);
199
200 void setOperatorKind(OperatorKind operatorKind);
201 OperatorKind operatorKind() const;
202
203 ProItem::ProItemKind kind() const;
204
205 virtual bool Accept(AbstractProItemVisitor *visitor);
206private:
207 OperatorKind m_operatorKind;
208};
209
210class ProFile : public QObject, public ProBlock
211{
212 Q_OBJECT
213
214public:
215 explicit ProFile(const QString &fileName);
216 ~ProFile();
217
218 QString displayFileName() const;
219 QString fileName() const;
220 QString directoryName() const;
221
222 void setModified(bool modified);
223 bool isModified() const;
224
225 virtual bool Accept(AbstractProItemVisitor *visitor);
226
227private:
228 QString m_fileName;
229 QString m_displayFileName;
230 QString m_directoryName;
231 bool m_modified;
232};
233
234QT_END_NAMESPACE
235
236#endif // PROITEMS_H
Note: See TracBrowser for help on using the repository browser.