|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the examples of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "scriptbreakpointmanager.h" |
|
43 |
|
44 ScriptBreakpointManager::ScriptBreakpointManager() |
|
45 { |
|
46 } |
|
47 |
|
48 ScriptBreakpointManager::~ScriptBreakpointManager() |
|
49 { |
|
50 } |
|
51 |
|
52 bool ScriptBreakpointManager::hasBreakpoints() const |
|
53 { |
|
54 return !breakpoints.isEmpty(); |
|
55 } |
|
56 |
|
57 int ScriptBreakpointManager::setBreakpoint(const QString &fileName, int lineNumber) |
|
58 { |
|
59 breakpoints.append(ScriptBreakpointInfo(fileName, lineNumber)); |
|
60 return breakpoints.size() - 1; |
|
61 } |
|
62 |
|
63 int ScriptBreakpointManager::setBreakpoint(const QString &functionName, const QString &fileName) |
|
64 { |
|
65 breakpoints.append(ScriptBreakpointInfo(functionName, fileName)); |
|
66 return breakpoints.size() - 1; |
|
67 } |
|
68 |
|
69 int ScriptBreakpointManager::setBreakpoint(const QScriptValue &function) |
|
70 { |
|
71 breakpoints.append(ScriptBreakpointInfo(function)); |
|
72 return breakpoints.size() - 1; |
|
73 } |
|
74 |
|
75 void ScriptBreakpointManager::removeBreakpoint(int id) |
|
76 { |
|
77 if (id >= 0 && id < breakpoints.size()) |
|
78 breakpoints[id] = ScriptBreakpointInfo(); |
|
79 } |
|
80 |
|
81 int ScriptBreakpointManager::findBreakpoint(const QString &fileName, int lineNumber) const |
|
82 { |
|
83 for (int i = 0; i < breakpoints.size(); ++i) { |
|
84 const ScriptBreakpointInfo &brk = breakpoints.at(i); |
|
85 if (brk.type != ScriptBreakpointInfo::File) |
|
86 continue; |
|
87 if (brk.fileName == fileName && brk.lineNumber == lineNumber) |
|
88 return i; |
|
89 } |
|
90 return -1; |
|
91 } |
|
92 |
|
93 int ScriptBreakpointManager::findBreakpoint(const QString &functionName, const QString &fileName) const |
|
94 { |
|
95 for (int i = 0; i < breakpoints.size(); ++i) { |
|
96 const ScriptBreakpointInfo &brk = breakpoints.at(i); |
|
97 if (brk.type != ScriptBreakpointInfo::FunctionName) |
|
98 continue; |
|
99 if (brk.functionName == functionName && brk.fileName == fileName) |
|
100 return i; |
|
101 } |
|
102 return -1; |
|
103 } |
|
104 |
|
105 int ScriptBreakpointManager::findBreakpoint(const QScriptValue &function) const |
|
106 { |
|
107 for (int i = 0; i < breakpoints.size(); ++i) { |
|
108 const ScriptBreakpointInfo &brk = breakpoints.at(i); |
|
109 if (brk.type != ScriptBreakpointInfo::Function) |
|
110 continue; |
|
111 if (brk.function.strictlyEquals(function)) |
|
112 return i; |
|
113 } |
|
114 return -1; |
|
115 } |
|
116 |
|
117 bool ScriptBreakpointManager::isBreakpointEnabled(int id) const |
|
118 { |
|
119 return breakpoints.value(id).enabled; |
|
120 } |
|
121 |
|
122 void ScriptBreakpointManager::setBreakpointEnabled(int id, bool enabled) |
|
123 { |
|
124 if (id >= 0 && id < breakpoints.size()) |
|
125 breakpoints[id].enabled = enabled; |
|
126 } |
|
127 |
|
128 QString ScriptBreakpointManager::breakpointCondition(int id) const |
|
129 { |
|
130 return breakpoints.value(id).condition; |
|
131 } |
|
132 |
|
133 void ScriptBreakpointManager::setBreakpointCondition(int id, const QString &expression) |
|
134 { |
|
135 if (id >= 0 && id < breakpoints.size()) |
|
136 breakpoints[id].condition = expression; |
|
137 } |
|
138 |
|
139 int ScriptBreakpointManager::breakpointIgnoreCount(int id) const |
|
140 { |
|
141 return breakpoints.value(id).ignoreCount; |
|
142 } |
|
143 |
|
144 void ScriptBreakpointManager::setBreakpointIgnoreCount(int id, int ignoreCount) |
|
145 { |
|
146 if (id >= 0 && id < breakpoints.size()) |
|
147 breakpoints[id].ignoreCount = ignoreCount; |
|
148 } |
|
149 |
|
150 bool ScriptBreakpointManager::isBreakpointSingleShot(int id) const |
|
151 { |
|
152 return breakpoints.value(id).singleShot; |
|
153 } |
|
154 |
|
155 void ScriptBreakpointManager::setBreakpointSingleShot(int id, bool singleShot) |
|
156 { |
|
157 if (id >= 0 && id < breakpoints.size()) |
|
158 breakpoints[id].singleShot = singleShot; |
|
159 } |