| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/util/qundogroup.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | class 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; | - | ||||||
| 9 | public: | - | ||||||
| 10 | QUndoGroupPrivate() : active(0) {} never executed: end of block | 0 | ||||||
| 11 | - | |||||||
| 12 | QUndoStack *active; | - | ||||||
| 13 | QList<QUndoStack*> stack_list; | - | ||||||
| 14 | }; | - | ||||||
| 15 | QUndoGroup::QUndoGroup(QObject *parent) | - | ||||||
| 16 | : QObject(*new QUndoGroupPrivate(), parent) | - | ||||||
| 17 | { | - | ||||||
| 18 | } never executed: end of block | 0 | ||||||
| 19 | - | |||||||
| 20 | - | |||||||
| 21 | - | |||||||
| 22 | - | |||||||
| 23 | QUndoGroup::~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
| 0 | ||||||
| 30 | (*it)->d_func()->group = 0; | - | ||||||
| 31 | ++it; | - | ||||||
| 32 | } never executed: end of block | 0 | ||||||
| 33 | } never executed: end of block | 0 | ||||||
| 34 | void QUndoGroup::addStack(QUndoStack *stack) | - | ||||||
| 35 | { | - | ||||||
| 36 | QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 37 | - | |||||||
| 38 | if (d->stack_list.contains(stack)
| 0 | ||||||
| 39 | return; never executed: return; | 0 | ||||||
| 40 | d->stack_list.append(stack); | - | ||||||
| 41 | - | |||||||
| 42 | if (QUndoGroup *other = stack->d_func()->group
| 0 | ||||||
| 43 | other->removeStack(stack); never executed: other->removeStack(stack); | 0 | ||||||
| 44 | stack->d_func()->group = this; | - | ||||||
| 45 | } never executed: end of block | 0 | ||||||
| 46 | void QUndoGroup::removeStack(QUndoStack *stack) | - | ||||||
| 47 | { | - | ||||||
| 48 | QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 49 | - | |||||||
| 50 | if (d->stack_list.removeAll(stack) == 0
| 0 | ||||||
| 51 | return; never executed: return; | 0 | ||||||
| 52 | if (stack == d->active
| 0 | ||||||
| 53 | setActiveStack(0); never executed: setActiveStack(0); | 0 | ||||||
| 54 | stack->d_func()->group = 0; | - | ||||||
| 55 | } never executed: end of block | 0 | ||||||
| 56 | - | |||||||
| 57 | - | |||||||
| 58 | - | |||||||
| 59 | - | |||||||
| 60 | - | |||||||
| 61 | - | |||||||
| 62 | - | |||||||
| 63 | QList<QUndoStack*> QUndoGroup::stacks() const | - | ||||||
| 64 | { | - | ||||||
| 65 | const QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 66 | return never executed: d->stack_list;return d->stack_list;never executed: return d->stack_list; | 0 | ||||||
| 67 | } | - | ||||||
| 68 | void QUndoGroup::setActiveStack(QUndoStack *stack) | - | ||||||
| 69 | { | - | ||||||
| 70 | QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 71 | if (d->active == stack
| 0 | ||||||
| 72 | return; never executed: return; | 0 | ||||||
| 73 | - | |||||||
| 74 | if (d->active != 0
| 0 | ||||||
| 75 | disconnect(d->active, qFlagLocation("2""canUndoChanged(bool)" "\0" __FILE__ ":" "196"), | - | ||||||
| 76 | this, qFlagLocation("2""canUndoChanged(bool)" "\0" __FILE__ ":" "197")); | - | ||||||
| 77 | disconnect(d->active, qFlagLocation("2""undoTextChanged(QString)" "\0" __FILE__ ":" "198"), | - | ||||||
| 78 | this, qFlagLocation("2""undoTextChanged(QString)" "\0" __FILE__ ":" "199")); | - | ||||||
| 79 | disconnect(d->active, qFlagLocation("2""canRedoChanged(bool)" "\0" __FILE__ ":" "200"), | - | ||||||
| 80 | this, qFlagLocation("2""canRedoChanged(bool)" "\0" __FILE__ ":" "201")); | - | ||||||
| 81 | disconnect(d->active, qFlagLocation("2""redoTextChanged(QString)" "\0" __FILE__ ":" "202"), | - | ||||||
| 82 | this, qFlagLocation("2""redoTextChanged(QString)" "\0" __FILE__ ":" "203")); | - | ||||||
| 83 | disconnect(d->active, qFlagLocation("2""indexChanged(int)" "\0" __FILE__ ":" "204"), | - | ||||||
| 84 | this, qFlagLocation("2""indexChanged(int)" "\0" __FILE__ ":" "205")); | - | ||||||
| 85 | disconnect(d->active, qFlagLocation("2""cleanChanged(bool)" "\0" __FILE__ ":" "206"), | - | ||||||
| 86 | this, qFlagLocation("2""cleanChanged(bool)" "\0" __FILE__ ":" "207")); | - | ||||||
| 87 | } never executed: end of block | 0 | ||||||
| 88 | - | |||||||
| 89 | d->active = stack; | - | ||||||
| 90 | - | |||||||
| 91 | if (d->active == 0
| 0 | ||||||
| 92 | canUndoChanged(false); | - | ||||||
| 93 | undoTextChanged(QString()); | - | ||||||
| 94 | canRedoChanged(false); | - | ||||||
| 95 | redoTextChanged(QString()); | - | ||||||
| 96 | cleanChanged(true); | - | ||||||
| 97 | indexChanged(0); | - | ||||||
| 98 | } never executed: else {end of block | 0 | ||||||
| 99 | connect(d->active, qFlagLocation("2""canUndoChanged(bool)" "\0" __FILE__ ":" "220"), | - | ||||||
| 100 | this, qFlagLocation("2""canUndoChanged(bool)" "\0" __FILE__ ":" "221")); | - | ||||||
| 101 | connect(d->active, qFlagLocation("2""undoTextChanged(QString)" "\0" __FILE__ ":" "222"), | - | ||||||
| 102 | this, qFlagLocation("2""undoTextChanged(QString)" "\0" __FILE__ ":" "223")); | - | ||||||
| 103 | connect(d->active, qFlagLocation("2""canRedoChanged(bool)" "\0" __FILE__ ":" "224"), | - | ||||||
| 104 | this, qFlagLocation("2""canRedoChanged(bool)" "\0" __FILE__ ":" "225")); | - | ||||||
| 105 | connect(d->active, qFlagLocation("2""redoTextChanged(QString)" "\0" __FILE__ ":" "226"), | - | ||||||
| 106 | this, qFlagLocation("2""redoTextChanged(QString)" "\0" __FILE__ ":" "227")); | - | ||||||
| 107 | connect(d->active, qFlagLocation("2""indexChanged(int)" "\0" __FILE__ ":" "228"), | - | ||||||
| 108 | this, qFlagLocation("2""indexChanged(int)" "\0" __FILE__ ":" "229")); | - | ||||||
| 109 | connect(d->active, qFlagLocation("2""cleanChanged(bool)" "\0" __FILE__ ":" "230"), | - | ||||||
| 110 | this, qFlagLocation("2""cleanChanged(bool)" "\0" __FILE__ ":" "231")); | - | ||||||
| 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 | } never executed: end of block | 0 | ||||||
| 118 | - | |||||||
| 119 | activeStackChanged(d->active); | - | ||||||
| 120 | } never executed: end of block | 0 | ||||||
| 121 | QUndoStack *QUndoGroup::activeStack() const | - | ||||||
| 122 | { | - | ||||||
| 123 | const QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 124 | return never executed: d->active;return d->active;never executed: return d->active; | 0 | ||||||
| 125 | } | - | ||||||
| 126 | void QUndoGroup::undo() | - | ||||||
| 127 | { | - | ||||||
| 128 | QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 129 | if (d->active != 0
| 0 | ||||||
| 130 | d->active->undo(); never executed: d->active->undo(); | 0 | ||||||
| 131 | } never executed: end of block | 0 | ||||||
| 132 | void QUndoGroup::redo() | - | ||||||
| 133 | { | - | ||||||
| 134 | QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 135 | if (d->active != 0
| 0 | ||||||
| 136 | d->active->redo(); never executed: d->active->redo(); | 0 | ||||||
| 137 | } never executed: end of block | 0 | ||||||
| 138 | bool QUndoGroup::canUndo() const | - | ||||||
| 139 | { | - | ||||||
| 140 | const QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 141 | return never executed: d->active != 0 && d->active->canUndo();return d->active != 0 && d->active->canUndo();never executed: return d->active != 0 && d->active->canUndo(); | 0 | ||||||
| 142 | } | - | ||||||
| 143 | bool QUndoGroup::canRedo() const | - | ||||||
| 144 | { | - | ||||||
| 145 | const QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 146 | return never executed: d->active != 0 && d->active->canRedo();return d->active != 0 && d->active->canRedo();never executed: return d->active != 0 && d->active->canRedo(); | 0 | ||||||
| 147 | } | - | ||||||
| 148 | QString QUndoGroup::undoText() const | - | ||||||
| 149 | { | - | ||||||
| 150 | const QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 151 | return never executed: d->active == 0 ? QString() : d->active->undoText();return d->active == 0 ? QString() : d->active->undoText();never executed: return d->active == 0 ? QString() : d->active->undoText(); | 0 | ||||||
| 152 | } | - | ||||||
| 153 | QString QUndoGroup::redoText() const | - | ||||||
| 154 | { | - | ||||||
| 155 | const QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 156 | return never executed: d->active == 0 ? QString() : d->active->redoText();return d->active == 0 ? QString() : d->active->redoText();never executed: return d->active == 0 ? QString() : d->active->redoText(); | 0 | ||||||
| 157 | } | - | ||||||
| 158 | bool QUndoGroup::isClean() const | - | ||||||
| 159 | { | - | ||||||
| 160 | const QUndoGroupPrivate * const d = d_func(); | - | ||||||
| 161 | return never executed: d->active == 0 || d->active->isClean();return d->active == 0 || d->active->isClean();never executed: return d->active == 0 || d->active->isClean(); | 0 | ||||||
| 162 | } | - | ||||||
| 163 | QAction *QUndoGroup::createUndoAction(QObject *parent, const QString &prefix) const | - | ||||||
| 164 | { | - | ||||||
| 165 | QUndoAction *result = new QUndoAction(prefix, parent); | - | ||||||
| 166 | if (prefix.isEmpty()
| 0 | ||||||
| 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, qFlagLocation("2""canUndoChanged(bool)" "\0" __FILE__ ":" "391"), | - | ||||||
| 172 | result, qFlagLocation("1""setEnabled(bool)" "\0" __FILE__ ":" "392")); | - | ||||||
| 173 | connect(this, qFlagLocation("2""undoTextChanged(QString)" "\0" __FILE__ ":" "393"), | - | ||||||
| 174 | result, qFlagLocation("1""setPrefixedText(QString)" "\0" __FILE__ ":" "394")); | - | ||||||
| 175 | connect(result, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "395"), this, qFlagLocation("1""undo()" "\0" __FILE__ ":" "395")); | - | ||||||
| 176 | return never executed: result;return result;never executed: return result; | 0 | ||||||
| 177 | } | - | ||||||
| 178 | QAction *QUndoGroup::createRedoAction(QObject *parent, const QString &prefix) const | - | ||||||
| 179 | { | - | ||||||
| 180 | QUndoAction *result = new QUndoAction(prefix, parent); | - | ||||||
| 181 | if (prefix.isEmpty()
| 0 | ||||||
| 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, qFlagLocation("2""canRedoChanged(bool)" "\0" __FILE__ ":" "422"), | - | ||||||
| 187 | result, qFlagLocation("1""setEnabled(bool)" "\0" __FILE__ ":" "423")); | - | ||||||
| 188 | connect(this, qFlagLocation("2""redoTextChanged(QString)" "\0" __FILE__ ":" "424"), | - | ||||||
| 189 | result, qFlagLocation("1""setPrefixedText(QString)" "\0" __FILE__ ":" "425")); | - | ||||||
| 190 | connect(result, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "426"), this, qFlagLocation("1""redo()" "\0" __FILE__ ":" "426")); | - | ||||||
| 191 | return never executed: result;return result;never executed: return result; | 0 | ||||||
| 192 | } | - | ||||||
| 193 | - | |||||||
| 194 | - | |||||||
| Switch to Source code | Preprocessed file |