util/qundogroup.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6class QUndoGroupPrivate : public QObjectPrivate -
7{ -
8 inline QUndoGroup* q_func() { return static_cast<QUndoGroup *>(q_ptr); } inline const QUndoGroup* q_func() const { return static_cast<const QUndoGroup *>(q_ptr); } friend class QUndoGroup; -
9public: -
10 QUndoGroupPrivate() : active(0) {}
executed: }
Execution Count:5
5
11 -
12 QUndoStack *active; -
13 QList<QUndoStack*> stack_list; -
14}; -
15QUndoGroup::QUndoGroup(QObject *parent) -
16 : QObject(*new QUndoGroupPrivate(), parent) -
17{ -
18}
executed: }
Execution Count:5
5
19 -
20 -
21 -
22 -
23QUndoGroup::~QUndoGroup() -
24{ -
25 -
26 QUndoGroupPrivate * const d = d_func(); -
27 QList<QUndoStack *>::iterator it = d->stack_list.begin(); -
28 QList<QUndoStack *>::iterator end = d->stack_list.end(); -
29 while (it != end) {
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
30 (*it)->d_func()->group = 0; -
31 ++it; -
32 }
executed: }
Execution Count:2
2
33}
executed: }
Execution Count:5
5
34void QUndoGroup::addStack(QUndoStack *stack) -
35{ -
36 QUndoGroupPrivate * const d = d_func(); -
37 -
38 if (d->stack_list.contains(stack))
evaluated: d->stack_list.contains(stack)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
1-11
39 return;
executed: return;
Execution Count:1
1
40 d->stack_list.append(stack); -
41 -
42 if (QUndoGroup *other = stack->d_func()->group)
partially evaluated: QUndoGroup *other = stack->d_func()->group
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
43 other->removeStack(stack);
never executed: other->removeStack(stack);
0
44 stack->d_func()->group = this; -
45}
executed: }
Execution Count:11
11
46void QUndoGroup::removeStack(QUndoStack *stack) -
47{ -
48 QUndoGroupPrivate * const d = d_func(); -
49 -
50 if (d->stack_list.removeAll(stack) == 0)
evaluated: d->stack_list.removeAll(stack) == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:9
2-9
51 return;
executed: return;
Execution Count:2
2
52 if (stack == d->active)
evaluated: stack == d->active
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5
4-5
53 setActiveStack(0);
executed: setActiveStack(0);
Execution Count:4
4
54 stack->d_func()->group = 0; -
55}
executed: }
Execution Count:9
9
56 -
57 -
58 -
59 -
60 -
61 -
62 -
63QList<QUndoStack*> QUndoGroup::stacks() const -
64{ -
65 const QUndoGroupPrivate * const d = d_func(); -
66 return d->stack_list;
executed: return d->stack_list;
Execution Count:12
12
67} -
68void QUndoGroup::setActiveStack(QUndoStack *stack) -
69{ -
70 QUndoGroupPrivate * const d = d_func(); -
71 if (d->active == stack)
partially evaluated: d->active == stack
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
72 return;
never executed: return;
0
73 -
74 if (d->active != 0) {
evaluated: d->active != 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:5
5-7
75 disconnect(d->active, "2""canUndoChanged(bool)", -
76 this, "2""canUndoChanged(bool)"); -
77 disconnect(d->active, "2""undoTextChanged(QString)", -
78 this, "2""undoTextChanged(QString)"); -
79 disconnect(d->active, "2""canRedoChanged(bool)", -
80 this, "2""canRedoChanged(bool)"); -
81 disconnect(d->active, "2""redoTextChanged(QString)", -
82 this, "2""redoTextChanged(QString)"); -
83 disconnect(d->active, "2""indexChanged(int)", -
84 this, "2""indexChanged(int)"); -
85 disconnect(d->active, "2""cleanChanged(bool)", -
86 this, "2""cleanChanged(bool)"); -
87 }
executed: }
Execution Count:7
7
88 -
89 d->active = stack; -
90 -
91 if (d->active == 0) {
evaluated: d->active == 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:7
5-7
92 canUndoChanged(false); -
93 undoTextChanged(QString()); -
94 canRedoChanged(false); -
95 redoTextChanged(QString()); -
96 cleanChanged(true); -
97 indexChanged(0); -
98 } else {
executed: }
Execution Count:5
5
99 connect(d->active, "2""canUndoChanged(bool)", -
100 this, "2""canUndoChanged(bool)"); -
101 connect(d->active, "2""undoTextChanged(QString)", -
102 this, "2""undoTextChanged(QString)"); -
103 connect(d->active, "2""canRedoChanged(bool)", -
104 this, "2""canRedoChanged(bool)"); -
105 connect(d->active, "2""redoTextChanged(QString)", -
106 this, "2""redoTextChanged(QString)"); -
107 connect(d->active, "2""indexChanged(int)", -
108 this, "2""indexChanged(int)"); -
109 connect(d->active, "2""cleanChanged(bool)", -
110 this, "2""cleanChanged(bool)"); -
111 canUndoChanged(d->active->canUndo()); -
112 undoTextChanged(d->active->undoText()); -
113 canRedoChanged(d->active->canRedo()); -
114 redoTextChanged(d->active->redoText()); -
115 cleanChanged(d->active->isClean()); -
116 indexChanged(d->active->index()); -
117 }
executed: }
Execution Count:7
7
118 -
119 activeStackChanged(d->active); -
120}
executed: }
Execution Count:12
12
121QUndoStack *QUndoGroup::activeStack() const -
122{ -
123 const QUndoGroupPrivate * const d = d_func(); -
124 return d->active;
executed: return d->active;
Execution Count:46
46
125} -
126void QUndoGroup::undo() -
127{ -
128 QUndoGroupPrivate * const d = d_func(); -
129 if (d->active != 0)
evaluated: d->active != 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
130 d->active->undo();
executed: d->active->undo();
Execution Count:1
1
131}
executed: }
Execution Count:2
2
132void QUndoGroup::redo() -
133{ -
134 QUndoGroupPrivate * const d = d_func(); -
135 if (d->active != 0)
evaluated: d->active != 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
136 d->active->redo();
executed: d->active->redo();
Execution Count:1
1
137}
executed: }
Execution Count:2
2
138bool QUndoGroup::canUndo() const -
139{ -
140 const QUndoGroupPrivate * const d = d_func(); -
141 return d->active != 0 && d->active->canUndo();
executed: return d->active != 0 && d->active->canUndo();
Execution Count:18
18
142} -
143bool QUndoGroup::canRedo() const -
144{ -
145 const QUndoGroupPrivate * const d = d_func(); -
146 return d->active != 0 && d->active->canRedo();
executed: return d->active != 0 && d->active->canRedo();
Execution Count:18
18
147} -
148QString QUndoGroup::undoText() const -
149{ -
150 const QUndoGroupPrivate * const d = d_func(); -
151 return d->active == 0 ? QString() : d->active->undoText();
executed: return d->active == 0 ? QString() : d->active->undoText();
Execution Count:18
18
152} -
153QString QUndoGroup::redoText() const -
154{ -
155 const QUndoGroupPrivate * const d = d_func(); -
156 return d->active == 0 ? QString() : d->active->redoText();
executed: return d->active == 0 ? QString() : d->active->redoText();
Execution Count:18
18
157} -
158bool QUndoGroup::isClean() const -
159{ -
160 const QUndoGroupPrivate * const d = d_func(); -
161 return d->active == 0 || d->active->isClean();
executed: return d->active == 0 || d->active->isClean();
Execution Count:17
17
162} -
163QAction *QUndoGroup::createUndoAction(QObject *parent, const QString &prefix) const -
164{ -
165 QUndoAction *result = new QUndoAction(prefix, parent); -
166 if (prefix.isEmpty())
partially evaluated: prefix.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
167 result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
never executed: result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
0
168 -
169 result->setEnabled(canUndo()); -
170 result->setPrefixedText(undoText()); -
171 connect(this, "2""canUndoChanged(bool)", -
172 result, "1""setEnabled(bool)"); -
173 connect(this, "2""undoTextChanged(QString)", -
174 result, "1""setPrefixedText(QString)"); -
175 connect(result, "2""triggered()", this, "1""undo()"); -
176 return result;
executed: return result;
Execution Count:1
1
177} -
178QAction *QUndoGroup::createRedoAction(QObject *parent, const QString &prefix) const -
179{ -
180 QUndoAction *result = new QUndoAction(prefix, parent); -
181 if (prefix.isEmpty())
partially evaluated: prefix.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
182 result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
never executed: result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
0
183 -
184 result->setEnabled(canRedo()); -
185 result->setPrefixedText(redoText()); -
186 connect(this, "2""canRedoChanged(bool)", -
187 result, "1""setEnabled(bool)"); -
188 connect(this, "2""redoTextChanged(QString)", -
189 result, "1""setPrefixedText(QString)"); -
190 connect(result, "2""triggered()", this, "1""redo()"); -
191 return result;
executed: return result;
Execution Count:1
1
192} -
193 -
194 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial