util/qundostack.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5QUndoCommand::QUndoCommand(const QString &text, QUndoCommand *parent) -
6{ -
7 d = new QUndoCommandPrivate; -
8 if (parent != 0)
never evaluated: parent != 0
0
9 parent->d->child_list.append(this);
never executed: parent->d->child_list.append(this);
0
10 setText(text); -
11}
never executed: }
0
12QUndoCommand::QUndoCommand(QUndoCommand *parent) -
13{ -
14 d = new QUndoCommandPrivate; -
15 if (parent != 0)
evaluated: parent != 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:50
2-50
16 parent->d->child_list.append(this);
executed: parent->d->child_list.append(this);
Execution Count:2
2
17}
executed: }
Execution Count:52
52
18 -
19 -
20 -
21 -
22 -
23 -
24 -
25QUndoCommand::~QUndoCommand() -
26{ -
27 qDeleteAll(d->child_list); -
28 delete d; -
29}
executed: }
Execution Count:52
52
30int QUndoCommand::id() const -
31{ -
32 return -1;
executed: return -1;
Execution Count:15
15
33} -
34bool QUndoCommand::mergeWith(const QUndoCommand *command) -
35{ -
36 (void)command;; -
37 return false;
never executed: return false;
0
38} -
39void QUndoCommand::redo() -
40{ -
41 for (int i = 0; i < d->child_list.size(); ++i)
evaluated: i < d->child_list.size()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:5
5-10
42 d->child_list.at(i)->redo();
executed: d->child_list.at(i)->redo();
Execution Count:10
10
43}
executed: }
Execution Count:5
5
44void QUndoCommand::undo() -
45{ -
46 for (int i = d->child_list.size() - 1; i >= 0; --i)
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:7
7-14
47 d->child_list.at(i)->undo();
executed: d->child_list.at(i)->undo();
Execution Count:14
14
48}
executed: }
Execution Count:7
7
49QString QUndoCommand::text() const -
50{ -
51 return d->text;
executed: return d->text;
Execution Count:4
4
52} -
53QString QUndoCommand::actionText() const -
54{ -
55 return d->actionText;
executed: return d->actionText;
Execution Count:220
220
56} -
57void QUndoCommand::setText(const QString &text) -
58{ -
59 int cdpos = text.indexOf(QLatin1Char('\n')); -
60 if (cdpos > 0) {
evaluated: cdpos > 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:51
3-51
61 d->text = text.left(cdpos); -
62 d->actionText = text.mid(cdpos + 1); -
63 } else {
executed: }
Execution Count:3
3
64 d->text = text; -
65 d->actionText = text; -
66 }
executed: }
Execution Count:51
51
67} -
68int QUndoCommand::childCount() const -
69{ -
70 return d->child_list.count();
never executed: return d->child_list.count();
0
71} -
72const QUndoCommand *QUndoCommand::child(int index) const -
73{ -
74 if (index < 0 || index >= d->child_list.count())
never evaluated: index < 0
never evaluated: index >= d->child_list.count()
0
75 return 0;
never executed: return 0;
0
76 return d->child_list.at(index);
never executed: return d->child_list.at(index);
0
77} -
78QUndoAction::QUndoAction(const QString &prefix, QObject *parent) -
79 : QAction(parent) -
80{ -
81 m_prefix = prefix; -
82}
executed: }
Execution Count:20
20
83 -
84void QUndoAction::setPrefixedText(const QString &text) -
85{ -
86 if (m_defaultText.isEmpty()) {
evaluated: m_defaultText.isEmpty()
TRUEFALSE
yes
Evaluation Count:202
yes
Evaluation Count:10
10-202
87 QString s = m_prefix; -
88 if (!m_prefix.isEmpty() && !text.isEmpty())
partially evaluated: !m_prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:202
no
Evaluation Count:0
evaluated: !text.isEmpty()
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:101
0-202
89 s.append(QLatin1Char(' '));
executed: s.append(QLatin1Char(' '));
Execution Count:101
101
90 s.append(text); -
91 setText(s); -
92 } else {
executed: }
Execution Count:202
202
93 if (text.isEmpty())
evaluated: text.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
4-6
94 setText(m_defaultText);
executed: setText(m_defaultText);
Execution Count:6
6
95 else -
96 setText(m_prefix.arg(text));
executed: setText(m_prefix.arg(text));
Execution Count:4
4
97 } -
98} -
99 -
100void QUndoAction::setTextFormat(const QString &textFormat, const QString &defaultText) -
101{ -
102 m_prefix = textFormat; -
103 m_defaultText = defaultText; -
104}
executed: }
Execution Count:2
2
105void QUndoStackPrivate::setIndex(int idx, bool clean) -
106{ -
107 QUndoStack * const q = q_func(); -
108 -
109 bool was_clean = index == clean_index; -
110 -
111 if (idx != index) {
evaluated: idx != index
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:9
9-79
112 index = idx; -
113 q->indexChanged(index); -
114 q->canUndoChanged(q->canUndo()); -
115 q->undoTextChanged(q->undoText()); -
116 q->canRedoChanged(q->canRedo()); -
117 q->redoTextChanged(q->redoText()); -
118 }
executed: }
Execution Count:79
79
119 -
120 if (clean)
evaluated: clean
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:83
5-83
121 clean_index = index;
executed: clean_index = index;
Execution Count:5
5
122 -
123 bool is_clean = index == clean_index; -
124 if (is_clean != was_clean)
evaluated: is_clean != was_clean
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:48
40-48
125 q->cleanChanged(is_clean);
executed: q->cleanChanged(is_clean);
Execution Count:40
40
126}
executed: }
Execution Count:88
88
127bool QUndoStackPrivate::checkUndoLimit() -
128{ -
129 if (undo_limit <= 0 || !macro_stack.isEmpty() || undo_limit >= command_list.count())
evaluated: undo_limit <= 0
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:11
partially evaluated: !macro_stack.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
evaluated: undo_limit >= command_list.count()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:4
0-29
130 return false;
executed: return false;
Execution Count:36
36
131 -
132 int del_count = command_list.count() - undo_limit; -
133 -
134 for (int i = 0; i < del_count; ++i)
evaluated: i < del_count
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
135 delete command_list.takeFirst();
executed: delete command_list.takeFirst();
Execution Count:4
4
136 -
137 index -= del_count; -
138 if (clean_index != -1) {
evaluated: clean_index != -1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
139 if (clean_index < del_count)
evaluated: clean_index < del_count
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
140 clean_index = -1;
executed: clean_index = -1;
Execution Count:1
1
141 else -
142 clean_index -= del_count;
executed: clean_index -= del_count;
Execution Count:2
2
143 } -
144 -
145 return true;
executed: return true;
Execution Count:4
4
146} -
147QUndoStack::QUndoStack(QObject *parent) -
148 : QObject(*(new QUndoStackPrivate), parent) -
149{ -
150 -
151 if (QUndoGroup *group = qobject_cast<QUndoGroup*>(parent))
evaluated: QUndoGroup *group = qobject_cast<QUndoGroup*>(parent)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:12
8-12
152 group->addStack(this);
executed: group->addStack(this);
Execution Count:8
8
153 -
154}
executed: }
Execution Count:20
20
155QUndoStack::~QUndoStack() -
156{ -
157 -
158 QUndoStackPrivate * const d = d_func(); -
159 if (d->group != 0)
evaluated: d->group != 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:15
5-15
160 d->group->removeStack(this);
executed: d->group->removeStack(this);
Execution Count:5
5
161 -
162 clear(); -
163}
executed: }
Execution Count:20
20
164void QUndoStack::clear() -
165{ -
166 QUndoStackPrivate * const d = d_func(); -
167 -
168 if (d->command_list.isEmpty())
evaluated: d->command_list.isEmpty()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:11
11-12
169 return;
executed: return;
Execution Count:12
12
170 -
171 bool was_clean = isClean(); -
172 -
173 d->macro_stack.clear(); -
174 qDeleteAll(d->command_list); -
175 d->command_list.clear(); -
176 -
177 d->index = 0; -
178 d->clean_index = 0; -
179 -
180 indexChanged(0); -
181 canUndoChanged(false); -
182 undoTextChanged(QString()); -
183 canRedoChanged(false); -
184 redoTextChanged(QString()); -
185 -
186 if (!was_clean)
evaluated: !was_clean
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1
1-10
187 cleanChanged(true);
executed: cleanChanged(true);
Execution Count:10
10
188}
executed: }
Execution Count:11
11
189void QUndoStack::push(QUndoCommand *cmd) -
190{ -
191 QUndoStackPrivate * const d = d_func(); -
192 cmd->redo(); -
193 -
194 bool macro = !d->macro_stack.isEmpty(); -
195 -
196 QUndoCommand *cur = 0; -
197 if (macro) {
evaluated: macro
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:37
8-37
198 QUndoCommand *macro_cmd = d->macro_stack.last(); -
199 if (!macro_cmd->d->child_list.isEmpty())
evaluated: !macro_cmd->d->child_list.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
200 cur = macro_cmd->d->child_list.last();
executed: cur = macro_cmd->d->child_list.last();
Execution Count:4
4
201 } else {
executed: }
Execution Count:8
8
202 if (d->index > 0)
evaluated: d->index > 0
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:14
14-23
203 cur = d->command_list.at(d->index - 1);
executed: cur = d->command_list.at(d->index - 1);
Execution Count:23
23
204 while (d->index < d->command_list.size())
evaluated: d->index < d->command_list.size()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:37
11-37
205 delete d->command_list.takeLast();
executed: delete d->command_list.takeLast();
Execution Count:11
11
206 if (d->clean_index > d->index)
evaluated: d->clean_index > d->index
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:35
2-35
207 d->clean_index = -1;
executed: d->clean_index = -1;
Execution Count:2
2
208 }
executed: }
Execution Count:37
37
209 -
210 bool try_merge = cur != 0
evaluated: cur != 0
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:18
18-27
211 && cur->id() != -1
evaluated: cur->id() != -1
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:13
13-14
212 && cur->id() == cmd->id()
evaluated: cur->id() == cmd->id()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2
2-12
213 && (macro || d->index != d->clean_index);
evaluated: macro
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10
evaluated: d->index != d->clean_index
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2
2-10
214 -
215 if (try_merge && cur->mergeWith(cmd)) {
evaluated: try_merge
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:35
evaluated: cur->mergeWith(cmd)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
3-35
216 delete cmd; -
217 if (!macro) {
evaluated: !macro
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
218 indexChanged(d->index); -
219 canUndoChanged(canUndo()); -
220 undoTextChanged(undoText()); -
221 canRedoChanged(canRedo()); -
222 redoTextChanged(redoText()); -
223 }
executed: }
Execution Count:2
2
224 } else {
executed: }
Execution Count:3
3
225 if (macro) {
evaluated: macro
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:35
7-35
226 d->macro_stack.last()->d->child_list.append(cmd); -
227 } else {
executed: }
Execution Count:7
7
228 d->command_list.append(cmd); -
229 d->checkUndoLimit(); -
230 d->setIndex(d->index + 1, false); -
231 }
executed: }
Execution Count:35
35
232 } -
233} -
234void QUndoStack::setClean() -
235{ -
236 QUndoStackPrivate * const d = d_func(); -
237 if (!d->macro_stack.isEmpty()) {
evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
238 QMessageLogger("util/qundostack.cpp", 645, __PRETTY_FUNCTION__).warning("QUndoStack::setClean(): cannot set clean in the middle of a macro"); -
239 return;
executed: return;
Execution Count:1
1
240 } -
241 -
242 d->setIndex(d->index, true); -
243}
executed: }
Execution Count:5
5
244 -
245 -
246 -
247 -
248 -
249 -
250 -
251bool QUndoStack::isClean() const -
252{ -
253 const QUndoStackPrivate * const d = d_func(); -
254 if (!d->macro_stack.isEmpty())
evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:116
18-116
255 return false;
executed: return false;
Execution Count:18
18
256 return d->clean_index == d->index;
executed: return d->clean_index == d->index;
Execution Count:116
116
257} -
258int QUndoStack::cleanIndex() const -
259{ -
260 const QUndoStackPrivate * const d = d_func(); -
261 return d->clean_index;
executed: return d->clean_index;
Execution Count:11
11
262} -
263void QUndoStack::undo() -
264{ -
265 QUndoStackPrivate * const d = d_func(); -
266 if (d->index == 0)
evaluated: d->index == 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:25
5-25
267 return;
executed: return;
Execution Count:5
5
268 -
269 if (!d->macro_stack.isEmpty()) {
partially evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
270 QMessageLogger("util/qundostack.cpp", 700, __PRETTY_FUNCTION__).warning("QUndoStack::undo(): cannot undo in the middle of a macro"); -
271 return;
never executed: return;
0
272 } -
273 -
274 int idx = d->index - 1; -
275 d->command_list.at(idx)->undo(); -
276 d->setIndex(idx, false); -
277}
executed: }
Execution Count:25
25
278void QUndoStack::redo() -
279{ -
280 QUndoStackPrivate * const d = d_func(); -
281 if (d->index == d->command_list.size())
evaluated: d->index == d->command_list.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
282 return;
executed: return;
Execution Count:1
1
283 -
284 if (!d->macro_stack.isEmpty()) {
evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
285 QMessageLogger("util/qundostack.cpp", 726, __PRETTY_FUNCTION__).warning("QUndoStack::redo(): cannot redo in the middle of a macro"); -
286 return;
executed: return;
Execution Count:1
1
287 } -
288 -
289 d->command_list.at(d->index)->redo(); -
290 d->setIndex(d->index + 1, false); -
291}
executed: }
Execution Count:6
6
292int QUndoStack::count() const -
293{ -
294 const QUndoStackPrivate * const d = d_func(); -
295 return d->command_list.size();
executed: return d->command_list.size();
Execution Count:107
107
296} -
297int QUndoStack::index() const -
298{ -
299 const QUndoStackPrivate * const d = d_func(); -
300 return d->index;
executed: return d->index;
Execution Count:114
114
301} -
302void QUndoStack::setIndex(int idx) -
303{ -
304 QUndoStackPrivate * const d = d_func(); -
305 if (!d->macro_stack.isEmpty()) {
evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
306 QMessageLogger("util/qundostack.cpp", 773, __PRETTY_FUNCTION__).warning("QUndoStack::setIndex(): cannot set index in the middle of a macro"); -
307 return;
executed: return;
Execution Count:1
1
308 } -
309 -
310 if (idx < 0)
evaluated: idx < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:11
2-11
311 idx = 0;
executed: idx = 0;
Execution Count:2
2
312 else if (idx > d->command_list.size())
evaluated: idx > d->command_list.size()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:9
2-9
313 idx = d->command_list.size();
executed: idx = d->command_list.size();
Execution Count:2
2
314 -
315 int i = d->index; -
316 while (i < idx)
evaluated: i < idx
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:13
6-13
317 d->command_list.at(i++)->redo();
executed: d->command_list.at(i++)->redo();
Execution Count:6
6
318 while (i > idx)
evaluated: i > idx
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:13
9-13
319 d->command_list.at(--i)->undo();
executed: d->command_list.at(--i)->undo();
Execution Count:9
9
320 -
321 d->setIndex(idx, false); -
322}
executed: }
Execution Count:13
13
323bool QUndoStack::canUndo() const -
324{ -
325 const QUndoStackPrivate * const d = d_func(); -
326 if (!d->macro_stack.isEmpty())
evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:195
18-195
327 return false;
executed: return false;
Execution Count:18
18
328 return d->index > 0;
executed: return d->index > 0;
Execution Count:195
195
329} -
330bool QUndoStack::canRedo() const -
331{ -
332 const QUndoStackPrivate * const d = d_func(); -
333 if (!d->macro_stack.isEmpty())
evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:195
18-195
334 return false;
executed: return false;
Execution Count:18
18
335 return d->index < d->command_list.size();
executed: return d->index < d->command_list.size();
Execution Count:195
195
336} -
337 -
338 -
339 -
340 -
341 -
342 -
343 -
344QString QUndoStack::undoText() const -
345{ -
346 const QUndoStackPrivate * const d = d_func(); -
347 if (!d->macro_stack.isEmpty())
evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:195
18-195
348 return QString();
executed: return QString();
Execution Count:18
18
349 if (d->index > 0)
evaluated: d->index > 0
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:51
51-144
350 return d->command_list.at(d->index - 1)->actionText();
executed: return d->command_list.at(d->index - 1)->actionText();
Execution Count:144
144
351 return QString();
executed: return QString();
Execution Count:51
51
352} -
353 -
354 -
355 -
356 -
357 -
358 -
359 -
360QString QUndoStack::redoText() const -
361{ -
362 const QUndoStackPrivate * const d = d_func(); -
363 if (!d->macro_stack.isEmpty())
evaluated: !d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:195
18-195
364 return QString();
executed: return QString();
Execution Count:18
18
365 if (d->index < d->command_list.size())
evaluated: d->index < d->command_list.size()
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:122
73-122
366 return d->command_list.at(d->index)->actionText();
executed: return d->command_list.at(d->index)->actionText();
Execution Count:73
73
367 return QString();
executed: return QString();
Execution Count:122
122
368} -
369QAction *QUndoStack::createUndoAction(QObject *parent, const QString &prefix) const -
370{ -
371 QUndoAction *result = new QUndoAction(prefix, parent); -
372 if (prefix.isEmpty())
evaluated: prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-8
373 result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
executed: result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
Execution Count:1
1
374 -
375 result->setEnabled(canUndo()); -
376 result->setPrefixedText(undoText()); -
377 connect(this, "2""canUndoChanged(bool)", -
378 result, "1""setEnabled(bool)"); -
379 connect(this, "2""undoTextChanged(QString)", -
380 result, "1""setPrefixedText(QString)"); -
381 connect(result, "2""triggered()", this, "1""undo()"); -
382 return result;
executed: return result;
Execution Count:9
9
383} -
384QAction *QUndoStack::createRedoAction(QObject *parent, const QString &prefix) const -
385{ -
386 QUndoAction *result = new QUndoAction(prefix, parent); -
387 if (prefix.isEmpty())
evaluated: prefix.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-8
388 result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
executed: result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
Execution Count:1
1
389 -
390 result->setEnabled(canRedo()); -
391 result->setPrefixedText(redoText()); -
392 connect(this, "2""canRedoChanged(bool)", -
393 result, "1""setEnabled(bool)"); -
394 connect(this, "2""redoTextChanged(QString)", -
395 result, "1""setPrefixedText(QString)"); -
396 connect(result, "2""triggered()", this, "1""redo()"); -
397 return result;
executed: return result;
Execution Count:9
9
398} -
399void QUndoStack::beginMacro(const QString &text) -
400{ -
401 QUndoStackPrivate * const d = d_func(); -
402 QUndoCommand *cmd = new QUndoCommand(); -
403 cmd->setText(text); -
404 -
405 if (d->macro_stack.isEmpty()) {
evaluated: d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
406 while (d->index < d->command_list.size())
evaluated: d->index < d->command_list.size()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-4
407 delete d->command_list.takeLast();
executed: delete d->command_list.takeLast();
Execution Count:2
2
408 if (d->clean_index > d->index)
partially evaluated: d->clean_index > d->index
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
409 d->clean_index = -1;
never executed: d->clean_index = -1;
0
410 d->command_list.append(cmd); -
411 } else {
executed: }
Execution Count:4
4
412 d->macro_stack.last()->d->child_list.append(cmd); -
413 }
executed: }
Execution Count:1
1
414 d->macro_stack.append(cmd); -
415 -
416 if (d->macro_stack.count() == 1) {
evaluated: d->macro_stack.count() == 1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
417 canUndoChanged(false); -
418 undoTextChanged(QString()); -
419 canRedoChanged(false); -
420 redoTextChanged(QString()); -
421 }
executed: }
Execution Count:4
4
422}
executed: }
Execution Count:5
5
423void QUndoStack::endMacro() -
424{ -
425 QUndoStackPrivate * const d = d_func(); -
426 if (d->macro_stack.isEmpty()) {
partially evaluated: d->macro_stack.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
427 QMessageLogger("util/qundostack.cpp", 993, __PRETTY_FUNCTION__).warning("QUndoStack::endMacro(): no matching beginMacro()"); -
428 return;
never executed: return;
0
429 } -
430 -
431 d->macro_stack.removeLast(); -
432 -
433 if (d->macro_stack.isEmpty()) {
evaluated: d->macro_stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
434 d->checkUndoLimit(); -
435 d->setIndex(d->index + 1, false); -
436 }
executed: }
Execution Count:4
4
437}
executed: }
Execution Count:5
5
438const QUndoCommand *QUndoStack::command(int index) const -
439{ -
440 const QUndoStackPrivate * const d = d_func(); -
441 -
442 if (index < 0 || index >= d->command_list.count())
never evaluated: index < 0
never evaluated: index >= d->command_list.count()
0
443 return 0;
never executed: return 0;
0
444 return d->command_list.at(index);
never executed: return d->command_list.at(index);
0
445} -
446 -
447 -
448 -
449 -
450 -
451 -
452 -
453QString QUndoStack::text(int idx) const -
454{ -
455 const QUndoStackPrivate * const d = d_func(); -
456 -
457 if (idx < 0 || idx >= d->command_list.size())
partially evaluated: idx < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: idx >= d->command_list.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
458 return QString();
never executed: return QString();
0
459 return d->command_list.at(idx)->text();
executed: return d->command_list.at(idx)->text();
Execution Count:1
1
460} -
461void QUndoStack::setUndoLimit(int limit) -
462{ -
463 QUndoStackPrivate * const d = d_func(); -
464 -
465 if (!d->command_list.isEmpty()) {
partially evaluated: !d->command_list.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
466 QMessageLogger("util/qundostack.cpp", 1061, __PRETTY_FUNCTION__).warning("QUndoStack::setUndoLimit(): an undo limit can only be set when the stack is empty"); -
467 return;
never executed: return;
0
468 } -
469 -
470 if (limit == d->undo_limit)
partially evaluated: limit == d->undo_limit
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
471 return;
never executed: return;
0
472 d->undo_limit = limit; -
473 d->checkUndoLimit(); -
474}
executed: }
Execution Count:1
1
475 -
476int QUndoStack::undoLimit() const -
477{ -
478 const QUndoStackPrivate * const d = d_func(); -
479 -
480 return d->undo_limit;
executed: return d->undo_limit;
Execution Count:2
2
481} -
482void QUndoStack::setActive(bool active) -
483{ -
484 -
485 -
486 -
487 QUndoStackPrivate * const d = d_func(); -
488 -
489 if (d->group != 0) {
evaluated: d->group != 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1
1-8
490 if (active)
evaluated: active
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
491 d->group->setActiveStack(this);
executed: d->group->setActiveStack(this);
Execution Count:6
6
492 else if (d->group->activeStack() == this)
evaluated: d->group->activeStack() == this
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
493 d->group->setActiveStack(0);
executed: d->group->setActiveStack(0);
Execution Count:1
1
494 } -
495 -
496}
executed: }
Execution Count:9
9
497 -
498bool QUndoStack::isActive() const -
499{ -
500 -
501 -
502 -
503 const QUndoStackPrivate * const d = d_func(); -
504 return d->group == 0 || d->group->activeStack() == this;
executed: return d->group == 0 || d->group->activeStack() == this;
Execution Count:16
16
505 -
506} -
507 -
508 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial