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 QtSCriptTools module 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 "qscriptdebuggerevent_p.h"
|
---|
43 | #include "qscriptdebuggervalue_p.h"
|
---|
44 |
|
---|
45 | #include <QtCore/qhash.h>
|
---|
46 | #include <QtCore/qdatastream.h>
|
---|
47 |
|
---|
48 | Q_DECLARE_METATYPE(QScriptDebuggerValue)
|
---|
49 |
|
---|
50 | QT_BEGIN_NAMESPACE
|
---|
51 |
|
---|
52 | class QScriptDebuggerEventPrivate
|
---|
53 | {
|
---|
54 | public:
|
---|
55 | QScriptDebuggerEventPrivate();
|
---|
56 | ~QScriptDebuggerEventPrivate();
|
---|
57 |
|
---|
58 | QScriptDebuggerEvent::Type type;
|
---|
59 | QHash<QScriptDebuggerEvent::Attribute, QVariant> attributes;
|
---|
60 | };
|
---|
61 |
|
---|
62 | QScriptDebuggerEventPrivate::QScriptDebuggerEventPrivate()
|
---|
63 | {
|
---|
64 | }
|
---|
65 |
|
---|
66 | QScriptDebuggerEventPrivate::~QScriptDebuggerEventPrivate()
|
---|
67 | {
|
---|
68 | }
|
---|
69 |
|
---|
70 | QScriptDebuggerEvent::QScriptDebuggerEvent()
|
---|
71 | : d_ptr(new QScriptDebuggerEventPrivate)
|
---|
72 | {
|
---|
73 | d_ptr->type = None;
|
---|
74 | }
|
---|
75 |
|
---|
76 | QScriptDebuggerEvent::QScriptDebuggerEvent(Type type)
|
---|
77 | : d_ptr(new QScriptDebuggerEventPrivate)
|
---|
78 | {
|
---|
79 | d_ptr->type = type;
|
---|
80 | }
|
---|
81 |
|
---|
82 | QScriptDebuggerEvent::QScriptDebuggerEvent(Type type, qint64 scriptId,
|
---|
83 | int lineNumber, int columnNumber)
|
---|
84 | : d_ptr(new QScriptDebuggerEventPrivate)
|
---|
85 | {
|
---|
86 | d_ptr->type = type;
|
---|
87 | d_ptr->attributes[ScriptID] = scriptId;
|
---|
88 | d_ptr->attributes[LineNumber] = lineNumber;
|
---|
89 | d_ptr->attributes[ColumnNumber] = columnNumber;
|
---|
90 | }
|
---|
91 |
|
---|
92 | QScriptDebuggerEvent::QScriptDebuggerEvent(const QScriptDebuggerEvent &other)
|
---|
93 | : d_ptr(new QScriptDebuggerEventPrivate)
|
---|
94 | {
|
---|
95 | *d_ptr = *other.d_ptr;
|
---|
96 | }
|
---|
97 |
|
---|
98 | QScriptDebuggerEvent::~QScriptDebuggerEvent()
|
---|
99 | {
|
---|
100 | delete d_ptr;
|
---|
101 | }
|
---|
102 |
|
---|
103 | QScriptDebuggerEvent &QScriptDebuggerEvent::operator=(const QScriptDebuggerEvent &other)
|
---|
104 | {
|
---|
105 | *d_ptr = *other.d_ptr;
|
---|
106 | return *this;
|
---|
107 | }
|
---|
108 |
|
---|
109 | QScriptDebuggerEvent::Type QScriptDebuggerEvent::type() const
|
---|
110 | {
|
---|
111 | Q_D(const QScriptDebuggerEvent);
|
---|
112 | return d->type;
|
---|
113 | }
|
---|
114 |
|
---|
115 | QVariant QScriptDebuggerEvent::attribute(Attribute attribute,
|
---|
116 | const QVariant &defaultValue) const
|
---|
117 | {
|
---|
118 | Q_D(const QScriptDebuggerEvent);
|
---|
119 | return d->attributes.value(attribute, defaultValue);
|
---|
120 | }
|
---|
121 |
|
---|
122 | void QScriptDebuggerEvent::setAttribute(Attribute attribute,
|
---|
123 | const QVariant &value)
|
---|
124 | {
|
---|
125 | Q_D(QScriptDebuggerEvent);
|
---|
126 | if (!value.isValid())
|
---|
127 | d->attributes.remove(attribute);
|
---|
128 | else
|
---|
129 | d->attributes[attribute] = value;
|
---|
130 | }
|
---|
131 |
|
---|
132 | QHash<QScriptDebuggerEvent::Attribute, QVariant> QScriptDebuggerEvent::attributes() const
|
---|
133 | {
|
---|
134 | Q_D(const QScriptDebuggerEvent);
|
---|
135 | return d->attributes;
|
---|
136 | }
|
---|
137 |
|
---|
138 | qint64 QScriptDebuggerEvent::scriptId() const
|
---|
139 | {
|
---|
140 | Q_D(const QScriptDebuggerEvent);
|
---|
141 | return d->attributes.value(ScriptID, -1).toLongLong();
|
---|
142 | }
|
---|
143 |
|
---|
144 | void QScriptDebuggerEvent::setScriptId(qint64 id)
|
---|
145 | {
|
---|
146 | Q_D(QScriptDebuggerEvent);
|
---|
147 | d->attributes[ScriptID] = id;
|
---|
148 | }
|
---|
149 |
|
---|
150 | QString QScriptDebuggerEvent::fileName() const
|
---|
151 | {
|
---|
152 | Q_D(const QScriptDebuggerEvent);
|
---|
153 | return d->attributes.value(FileName).toString();
|
---|
154 | }
|
---|
155 |
|
---|
156 | void QScriptDebuggerEvent::setFileName(const QString &fileName)
|
---|
157 | {
|
---|
158 | Q_D(QScriptDebuggerEvent);
|
---|
159 | d->attributes[FileName] = fileName;
|
---|
160 | }
|
---|
161 |
|
---|
162 | int QScriptDebuggerEvent::lineNumber() const
|
---|
163 | {
|
---|
164 | Q_D(const QScriptDebuggerEvent);
|
---|
165 | return d->attributes.value(LineNumber, -1).toInt();
|
---|
166 | }
|
---|
167 |
|
---|
168 | void QScriptDebuggerEvent::setLineNumber(int lineNumber)
|
---|
169 | {
|
---|
170 | Q_D(QScriptDebuggerEvent);
|
---|
171 | d->attributes[LineNumber] = lineNumber;
|
---|
172 | }
|
---|
173 |
|
---|
174 | int QScriptDebuggerEvent::columnNumber() const
|
---|
175 | {
|
---|
176 | Q_D(const QScriptDebuggerEvent);
|
---|
177 | return d->attributes.value(ColumnNumber, -1).toInt();
|
---|
178 | }
|
---|
179 |
|
---|
180 | void QScriptDebuggerEvent::setColumnNumber(int columnNumber)
|
---|
181 | {
|
---|
182 | Q_D(QScriptDebuggerEvent);
|
---|
183 | d->attributes[ColumnNumber] = columnNumber;
|
---|
184 | }
|
---|
185 |
|
---|
186 | int QScriptDebuggerEvent::breakpointId() const
|
---|
187 | {
|
---|
188 | Q_D(const QScriptDebuggerEvent);
|
---|
189 | return d->attributes.value(BreakpointID, -1).toInt();
|
---|
190 | }
|
---|
191 |
|
---|
192 | void QScriptDebuggerEvent::setBreakpointId(int id)
|
---|
193 | {
|
---|
194 | Q_D(QScriptDebuggerEvent);
|
---|
195 | d->attributes[BreakpointID] = id;
|
---|
196 | }
|
---|
197 |
|
---|
198 | QString QScriptDebuggerEvent::message() const
|
---|
199 | {
|
---|
200 | Q_D(const QScriptDebuggerEvent);
|
---|
201 | return d->attributes.value(Message).toString();
|
---|
202 | }
|
---|
203 |
|
---|
204 | void QScriptDebuggerEvent::setMessage(const QString &message)
|
---|
205 | {
|
---|
206 | Q_D(QScriptDebuggerEvent);
|
---|
207 | d->attributes[Message] = message;
|
---|
208 | }
|
---|
209 |
|
---|
210 | QScriptDebuggerValue QScriptDebuggerEvent::scriptValue() const
|
---|
211 | {
|
---|
212 | Q_D(const QScriptDebuggerEvent);
|
---|
213 | return qvariant_cast<QScriptDebuggerValue>(d->attributes[Value]);
|
---|
214 | }
|
---|
215 |
|
---|
216 | void QScriptDebuggerEvent::setScriptValue(const QScriptDebuggerValue &value)
|
---|
217 | {
|
---|
218 | Q_D(QScriptDebuggerEvent);
|
---|
219 | d->attributes[Value] = qVariantFromValue(value);
|
---|
220 | }
|
---|
221 |
|
---|
222 | void QScriptDebuggerEvent::setNestedEvaluate(bool nested)
|
---|
223 | {
|
---|
224 | Q_D(QScriptDebuggerEvent);
|
---|
225 | d->attributes[IsNestedEvaluate] = nested;
|
---|
226 | }
|
---|
227 |
|
---|
228 | bool QScriptDebuggerEvent::isNestedEvaluate() const
|
---|
229 | {
|
---|
230 | Q_D(const QScriptDebuggerEvent);
|
---|
231 | return d->attributes.value(IsNestedEvaluate).toBool();
|
---|
232 | }
|
---|
|
---|