| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/util/qundogroup.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qundogroup.h" | - | ||||||||||||
| 35 | #include "qundostack.h" | - | ||||||||||||
| 36 | #include "qundostack_p.h" | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | #ifndef QT_NO_UNDOGROUP | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | class QUndoGroupPrivate : public QObjectPrivate | - | ||||||||||||
| 43 | { | - | ||||||||||||
| 44 | Q_DECLARE_PUBLIC(QUndoGroup) | - | ||||||||||||
| 45 | public: | - | ||||||||||||
| 46 | QUndoGroupPrivate() : active(0) {} never executed: end of block | 0 | ||||||||||||
| 47 | - | |||||||||||||
| 48 | QUndoStack *active; | - | ||||||||||||
| 49 | QList<QUndoStack*> stack_list; | - | ||||||||||||
| 50 | }; | - | ||||||||||||
| 51 | - | |||||||||||||
| 52 | /*! | - | ||||||||||||
| 53 | \class QUndoGroup | - | ||||||||||||
| 54 | \brief The QUndoGroup class is a group of QUndoStack objects. | - | ||||||||||||
| 55 | \since 4.2 | - | ||||||||||||
| 56 | \inmodule QtWidgets | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | For an overview of the Qt's undo framework, see the | - | ||||||||||||
| 59 | \l{qundo.html}{overview}. | - | ||||||||||||
| 60 | - | |||||||||||||
| 61 | An application often has multiple undo stacks, one for each opened document. At the | - | ||||||||||||
| 62 | same time, an application usually has one undo action and one redo action, which | - | ||||||||||||
| 63 | triggers undo or redo in the active document. | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | QUndoGroup is a group of QUndoStack objects, one of which may be active. It has | - | ||||||||||||
| 66 | an undo() and redo() slot, which calls QUndoStack::undo() and QUndoStack::redo() | - | ||||||||||||
| 67 | for the active stack. It also has the functions createUndoAction() and createRedoAction(). | - | ||||||||||||
| 68 | The actions returned by these functions behave in the same way as those returned by | - | ||||||||||||
| 69 | QUndoStack::createUndoAction() and QUndoStack::createRedoAction() of the active | - | ||||||||||||
| 70 | stack. | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | Stacks are added to a group with addStack() and removed with removeStack(). A stack | - | ||||||||||||
| 73 | is implicitly added to a group when it is created with the group as its parent | - | ||||||||||||
| 74 | QObject. | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | It is the programmer's responsibility to specify which stack is active by | - | ||||||||||||
| 77 | calling QUndoStack::setActive(), usually when the associated document window receives focus. | - | ||||||||||||
| 78 | The active stack may also be set with setActiveStack(), and is returned by activeStack(). | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | When a stack is added to a group using addStack(), the group does not take ownership | - | ||||||||||||
| 81 | of the stack. This means the stack has to be deleted separately from the group. When | - | ||||||||||||
| 82 | a stack is deleted, it is automatically removed from a group. A stack may belong to | - | ||||||||||||
| 83 | only one group. Adding it to another group will cause it to be removed from the previous | - | ||||||||||||
| 84 | group. | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | A QUndoGroup is also useful in conjunction with QUndoView. If a QUndoView is | - | ||||||||||||
| 87 | set to watch a group using QUndoView::setGroup(), it will update itself to display | - | ||||||||||||
| 88 | the active stack. | - | ||||||||||||
| 89 | */ | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | /*! | - | ||||||||||||
| 92 | Creates an empty QUndoGroup object with parent \a parent. | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | \sa addStack() | - | ||||||||||||
| 95 | */ | - | ||||||||||||
| 96 | - | |||||||||||||
| 97 | QUndoGroup::QUndoGroup(QObject *parent) | - | ||||||||||||
| 98 | : QObject(*new QUndoGroupPrivate(), parent) | - | ||||||||||||
| 99 | { | - | ||||||||||||
| 100 | } never executed: end of block | 0 | ||||||||||||
| 101 | - | |||||||||||||
| 102 | /*! | - | ||||||||||||
| 103 | Destroys the QUndoGroup. | - | ||||||||||||
| 104 | */ | - | ||||||||||||
| 105 | QUndoGroup::~QUndoGroup() | - | ||||||||||||
| 106 | { | - | ||||||||||||
| 107 | // Ensure all QUndoStacks no longer refer to this group. | - | ||||||||||||
| 108 | Q_D(QUndoGroup); | - | ||||||||||||
| 109 | QList<QUndoStack *>::iterator it = d->stack_list.begin(); | - | ||||||||||||
| 110 | QList<QUndoStack *>::iterator end = d->stack_list.end(); | - | ||||||||||||
| 111 | while (it != end) {
| 0 | ||||||||||||
| 112 | (*it)->d_func()->group = 0; | - | ||||||||||||
| 113 | ++it; | - | ||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||
| 115 | } never executed: end of block | 0 | ||||||||||||
| 116 | - | |||||||||||||
| 117 | /*! | - | ||||||||||||
| 118 | Adds \a stack to this group. The group does not take ownership of the stack. Another | - | ||||||||||||
| 119 | way of adding a stack to a group is by specifying the group as the stack's parent | - | ||||||||||||
| 120 | QObject in QUndoStack::QUndoStack(). In this case, the stack is deleted when the | - | ||||||||||||
| 121 | group is deleted, in the usual manner of QObjects. | - | ||||||||||||
| 122 | - | |||||||||||||
| 123 | \sa removeStack(), stacks(), QUndoStack::QUndoStack() | - | ||||||||||||
| 124 | */ | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | void QUndoGroup::addStack(QUndoStack *stack) | - | ||||||||||||
| 127 | { | - | ||||||||||||
| 128 | Q_D(QUndoGroup); | - | ||||||||||||
| 129 | - | |||||||||||||
| 130 | if (d->stack_list.contains(stack))
| 0 | ||||||||||||
| 131 | return; never executed: return; | 0 | ||||||||||||
| 132 | d->stack_list.append(stack); | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | if (QUndoGroup *other = stack->d_func()->group)
| 0 | ||||||||||||
| 135 | other->removeStack(stack); never executed: other->removeStack(stack); | 0 | ||||||||||||
| 136 | stack->d_func()->group = this; | - | ||||||||||||
| 137 | } never executed: end of block | 0 | ||||||||||||
| 138 | - | |||||||||||||
| 139 | /*! | - | ||||||||||||
| 140 | Removes \a stack from this group. If the stack was the active stack in the group, | - | ||||||||||||
| 141 | the active stack becomes 0. | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | \sa addStack(), stacks(), QUndoStack::~QUndoStack() | - | ||||||||||||
| 144 | */ | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | void QUndoGroup::removeStack(QUndoStack *stack) | - | ||||||||||||
| 147 | { | - | ||||||||||||
| 148 | Q_D(QUndoGroup); | - | ||||||||||||
| 149 | - | |||||||||||||
| 150 | if (d->stack_list.removeAll(stack) == 0)
| 0 | ||||||||||||
| 151 | return; never executed: return; | 0 | ||||||||||||
| 152 | if (stack == d->active)
| 0 | ||||||||||||
| 153 | setActiveStack(0); never executed: setActiveStack(0); | 0 | ||||||||||||
| 154 | stack->d_func()->group = 0; | - | ||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||
| 156 | - | |||||||||||||
| 157 | /*! | - | ||||||||||||
| 158 | Returns a list of stacks in this group. | - | ||||||||||||
| 159 | - | |||||||||||||
| 160 | \sa addStack(), removeStack() | - | ||||||||||||
| 161 | */ | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 | QList<QUndoStack*> QUndoGroup::stacks() const | - | ||||||||||||
| 164 | { | - | ||||||||||||
| 165 | Q_D(const QUndoGroup); | - | ||||||||||||
| 166 | return d->stack_list; never executed: return d->stack_list; | 0 | ||||||||||||
| 167 | } | - | ||||||||||||
| 168 | - | |||||||||||||
| 169 | /*! | - | ||||||||||||
| 170 | Sets the active stack of this group to \a stack. | - | ||||||||||||
| 171 | - | |||||||||||||
| 172 | If the stack is not a member of this group, this function does nothing. | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | Synonymous with calling QUndoStack::setActive() on \a stack. | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | The actions returned by createUndoAction() and createRedoAction() will now behave | - | ||||||||||||
| 177 | in the same way as those returned by \a stack's QUndoStack::createUndoAction() | - | ||||||||||||
| 178 | and QUndoStack::createRedoAction(). | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | \sa QUndoStack::setActive(), activeStack() | - | ||||||||||||
| 181 | */ | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | void QUndoGroup::setActiveStack(QUndoStack *stack) | - | ||||||||||||
| 184 | { | - | ||||||||||||
| 185 | Q_D(QUndoGroup); | - | ||||||||||||
| 186 | if (d->active == stack)
| 0 | ||||||||||||
| 187 | return; never executed: return; | 0 | ||||||||||||
| 188 | - | |||||||||||||
| 189 | if (d->active != 0) {
| 0 | ||||||||||||
| 190 | disconnect(d->active, SIGNAL(canUndoChanged(bool)), | - | ||||||||||||
| 191 | this, SIGNAL(canUndoChanged(bool))); | - | ||||||||||||
| 192 | disconnect(d->active, SIGNAL(undoTextChanged(QString)), | - | ||||||||||||
| 193 | this, SIGNAL(undoTextChanged(QString))); | - | ||||||||||||
| 194 | disconnect(d->active, SIGNAL(canRedoChanged(bool)), | - | ||||||||||||
| 195 | this, SIGNAL(canRedoChanged(bool))); | - | ||||||||||||
| 196 | disconnect(d->active, SIGNAL(redoTextChanged(QString)), | - | ||||||||||||
| 197 | this, SIGNAL(redoTextChanged(QString))); | - | ||||||||||||
| 198 | disconnect(d->active, SIGNAL(indexChanged(int)), | - | ||||||||||||
| 199 | this, SIGNAL(indexChanged(int))); | - | ||||||||||||
| 200 | disconnect(d->active, SIGNAL(cleanChanged(bool)), | - | ||||||||||||
| 201 | this, SIGNAL(cleanChanged(bool))); | - | ||||||||||||
| 202 | } never executed: end of block | 0 | ||||||||||||
| 203 | - | |||||||||||||
| 204 | d->active = stack; | - | ||||||||||||
| 205 | - | |||||||||||||
| 206 | if (d->active == 0) {
| 0 | ||||||||||||
| 207 | emit canUndoChanged(false); | - | ||||||||||||
| 208 | emit undoTextChanged(QString()); | - | ||||||||||||
| 209 | emit canRedoChanged(false); | - | ||||||||||||
| 210 | emit redoTextChanged(QString()); | - | ||||||||||||
| 211 | emit cleanChanged(true); | - | ||||||||||||
| 212 | emit indexChanged(0); | - | ||||||||||||
| 213 | } else { never executed: end of block | 0 | ||||||||||||
| 214 | connect(d->active, SIGNAL(canUndoChanged(bool)), | - | ||||||||||||
| 215 | this, SIGNAL(canUndoChanged(bool))); | - | ||||||||||||
| 216 | connect(d->active, SIGNAL(undoTextChanged(QString)), | - | ||||||||||||
| 217 | this, SIGNAL(undoTextChanged(QString))); | - | ||||||||||||
| 218 | connect(d->active, SIGNAL(canRedoChanged(bool)), | - | ||||||||||||
| 219 | this, SIGNAL(canRedoChanged(bool))); | - | ||||||||||||
| 220 | connect(d->active, SIGNAL(redoTextChanged(QString)), | - | ||||||||||||
| 221 | this, SIGNAL(redoTextChanged(QString))); | - | ||||||||||||
| 222 | connect(d->active, SIGNAL(indexChanged(int)), | - | ||||||||||||
| 223 | this, SIGNAL(indexChanged(int))); | - | ||||||||||||
| 224 | connect(d->active, SIGNAL(cleanChanged(bool)), | - | ||||||||||||
| 225 | this, SIGNAL(cleanChanged(bool))); | - | ||||||||||||
| 226 | emit canUndoChanged(d->active->canUndo()); | - | ||||||||||||
| 227 | emit undoTextChanged(d->active->undoText()); | - | ||||||||||||
| 228 | emit canRedoChanged(d->active->canRedo()); | - | ||||||||||||
| 229 | emit redoTextChanged(d->active->redoText()); | - | ||||||||||||
| 230 | emit cleanChanged(d->active->isClean()); | - | ||||||||||||
| 231 | emit indexChanged(d->active->index()); | - | ||||||||||||
| 232 | } never executed: end of block | 0 | ||||||||||||
| 233 | - | |||||||||||||
| 234 | emit activeStackChanged(d->active); | - | ||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||
| 236 | - | |||||||||||||
| 237 | /*! | - | ||||||||||||
| 238 | Returns the active stack of this group. | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | If none of the stacks are active, or if the group is empty, this function | - | ||||||||||||
| 241 | returns 0. | - | ||||||||||||
| 242 | - | |||||||||||||
| 243 | \sa setActiveStack(), QUndoStack::setActive() | - | ||||||||||||
| 244 | */ | - | ||||||||||||
| 245 | - | |||||||||||||
| 246 | QUndoStack *QUndoGroup::activeStack() const | - | ||||||||||||
| 247 | { | - | ||||||||||||
| 248 | Q_D(const QUndoGroup); | - | ||||||||||||
| 249 | return d->active; never executed: return d->active; | 0 | ||||||||||||
| 250 | } | - | ||||||||||||
| 251 | - | |||||||||||||
| 252 | /*! | - | ||||||||||||
| 253 | Calls QUndoStack::undo() on the active stack. | - | ||||||||||||
| 254 | - | |||||||||||||
| 255 | If none of the stacks are active, or if the group is empty, this function | - | ||||||||||||
| 256 | does nothing. | - | ||||||||||||
| 257 | - | |||||||||||||
| 258 | \sa redo(), canUndo(), setActiveStack() | - | ||||||||||||
| 259 | */ | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | void QUndoGroup::undo() | - | ||||||||||||
| 262 | { | - | ||||||||||||
| 263 | Q_D(QUndoGroup); | - | ||||||||||||
| 264 | if (d->active != 0)
| 0 | ||||||||||||
| 265 | d->active->undo(); never executed: d->active->undo(); | 0 | ||||||||||||
| 266 | } never executed: end of block | 0 | ||||||||||||
| 267 | - | |||||||||||||
| 268 | /*! | - | ||||||||||||
| 269 | Calls QUndoStack::redo() on the active stack. | - | ||||||||||||
| 270 | - | |||||||||||||
| 271 | If none of the stacks are active, or if the group is empty, this function | - | ||||||||||||
| 272 | does nothing. | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | \sa undo(), canRedo(), setActiveStack() | - | ||||||||||||
| 275 | */ | - | ||||||||||||
| 276 | - | |||||||||||||
| 277 | - | |||||||||||||
| 278 | void QUndoGroup::redo() | - | ||||||||||||
| 279 | { | - | ||||||||||||
| 280 | Q_D(QUndoGroup); | - | ||||||||||||
| 281 | if (d->active != 0)
| 0 | ||||||||||||
| 282 | d->active->redo(); never executed: d->active->redo(); | 0 | ||||||||||||
| 283 | } never executed: end of block | 0 | ||||||||||||
| 284 | - | |||||||||||||
| 285 | /*! | - | ||||||||||||
| 286 | Returns the value of the active stack's QUndoStack::canUndo(). | - | ||||||||||||
| 287 | - | |||||||||||||
| 288 | If none of the stacks are active, or if the group is empty, this function | - | ||||||||||||
| 289 | returns \c false. | - | ||||||||||||
| 290 | - | |||||||||||||
| 291 | \sa canRedo(), setActiveStack() | - | ||||||||||||
| 292 | */ | - | ||||||||||||
| 293 | - | |||||||||||||
| 294 | bool QUndoGroup::canUndo() const | - | ||||||||||||
| 295 | { | - | ||||||||||||
| 296 | Q_D(const QUndoGroup); | - | ||||||||||||
| 297 | return d->active != 0 && d->active->canUndo(); never executed: return d->active != 0 && d->active->canUndo();
| 0 | ||||||||||||
| 298 | } | - | ||||||||||||
| 299 | - | |||||||||||||
| 300 | /*! | - | ||||||||||||
| 301 | Returns the value of the active stack's QUndoStack::canRedo(). | - | ||||||||||||
| 302 | - | |||||||||||||
| 303 | If none of the stacks are active, or if the group is empty, this function | - | ||||||||||||
| 304 | returns \c false. | - | ||||||||||||
| 305 | - | |||||||||||||
| 306 | \sa canUndo(), setActiveStack() | - | ||||||||||||
| 307 | */ | - | ||||||||||||
| 308 | - | |||||||||||||
| 309 | bool QUndoGroup::canRedo() const | - | ||||||||||||
| 310 | { | - | ||||||||||||
| 311 | Q_D(const QUndoGroup); | - | ||||||||||||
| 312 | return d->active != 0 && d->active->canRedo(); never executed: return d->active != 0 && d->active->canRedo();
| 0 | ||||||||||||
| 313 | } | - | ||||||||||||
| 314 | - | |||||||||||||
| 315 | /*! | - | ||||||||||||
| 316 | Returns the value of the active stack's QUndoStack::undoText(). | - | ||||||||||||
| 317 | - | |||||||||||||
| 318 | If none of the stacks are active, or if the group is empty, this function | - | ||||||||||||
| 319 | returns an empty string. | - | ||||||||||||
| 320 | - | |||||||||||||
| 321 | \sa redoText(), setActiveStack() | - | ||||||||||||
| 322 | */ | - | ||||||||||||
| 323 | - | |||||||||||||
| 324 | QString QUndoGroup::undoText() const | - | ||||||||||||
| 325 | { | - | ||||||||||||
| 326 | Q_D(const QUndoGroup); | - | ||||||||||||
| 327 | return d->active == 0 ? QString() : d->active->undoText(); never executed: return d->active == 0 ? QString() : d->active->undoText();
| 0 | ||||||||||||
| 328 | } | - | ||||||||||||
| 329 | - | |||||||||||||
| 330 | /*! | - | ||||||||||||
| 331 | Returns the value of the active stack's QUndoStack::redoText(). | - | ||||||||||||
| 332 | - | |||||||||||||
| 333 | If none of the stacks are active, or if the group is empty, this function | - | ||||||||||||
| 334 | returns an empty string. | - | ||||||||||||
| 335 | - | |||||||||||||
| 336 | \sa undoText(), setActiveStack() | - | ||||||||||||
| 337 | */ | - | ||||||||||||
| 338 | - | |||||||||||||
| 339 | QString QUndoGroup::redoText() const | - | ||||||||||||
| 340 | { | - | ||||||||||||
| 341 | Q_D(const QUndoGroup); | - | ||||||||||||
| 342 | return d->active == 0 ? QString() : d->active->redoText(); never executed: return d->active == 0 ? QString() : d->active->redoText();
| 0 | ||||||||||||
| 343 | } | - | ||||||||||||
| 344 | - | |||||||||||||
| 345 | /*! | - | ||||||||||||
| 346 | Returns the value of the active stack's QUndoStack::isClean(). | - | ||||||||||||
| 347 | - | |||||||||||||
| 348 | If none of the stacks are active, or if the group is empty, this function | - | ||||||||||||
| 349 | returns \c true. | - | ||||||||||||
| 350 | - | |||||||||||||
| 351 | \sa setActiveStack() | - | ||||||||||||
| 352 | */ | - | ||||||||||||
| 353 | - | |||||||||||||
| 354 | bool QUndoGroup::isClean() const | - | ||||||||||||
| 355 | { | - | ||||||||||||
| 356 | Q_D(const QUndoGroup); | - | ||||||||||||
| 357 | return d->active == 0 || d->active->isClean(); never executed: return d->active == 0 || d->active->isClean();
| 0 | ||||||||||||
| 358 | } | - | ||||||||||||
| 359 | - | |||||||||||||
| 360 | #ifndef QT_NO_ACTION | - | ||||||||||||
| 361 | - | |||||||||||||
| 362 | /*! | - | ||||||||||||
| 363 | Creates an undo QAction object with parent \a parent. | - | ||||||||||||
| 364 | - | |||||||||||||
| 365 | Triggering this action will cause a call to QUndoStack::undo() on the active stack. | - | ||||||||||||
| 366 | The text of this action will always be the text of the command which will be undone | - | ||||||||||||
| 367 | in the next call to undo(), prefixed by \a prefix. If there is no command available | - | ||||||||||||
| 368 | for undo, if the group is empty or if none of the stacks are active, this action will | - | ||||||||||||
| 369 | be disabled. | - | ||||||||||||
| 370 | - | |||||||||||||
| 371 | If \a prefix is empty, the default template "Undo %1" is used instead of prefix. | - | ||||||||||||
| 372 | Before Qt 4.8, the prefix "Undo" was used by default. | - | ||||||||||||
| 373 | - | |||||||||||||
| 374 | \sa createRedoAction(), canUndo(), QUndoCommand::text() | - | ||||||||||||
| 375 | */ | - | ||||||||||||
| 376 | - | |||||||||||||
| 377 | QAction *QUndoGroup::createUndoAction(QObject *parent, const QString &prefix) const | - | ||||||||||||
| 378 | { | - | ||||||||||||
| 379 | QUndoAction *result = new QUndoAction(prefix, parent); | - | ||||||||||||
| 380 | if (prefix.isEmpty())
| 0 | ||||||||||||
| 381 | 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 | ||||||||||||
| 382 | - | |||||||||||||
| 383 | result->setEnabled(canUndo()); | - | ||||||||||||
| 384 | result->setPrefixedText(undoText()); | - | ||||||||||||
| 385 | connect(this, SIGNAL(canUndoChanged(bool)), | - | ||||||||||||
| 386 | result, SLOT(setEnabled(bool))); | - | ||||||||||||
| 387 | connect(this, SIGNAL(undoTextChanged(QString)), | - | ||||||||||||
| 388 | result, SLOT(setPrefixedText(QString))); | - | ||||||||||||
| 389 | connect(result, SIGNAL(triggered()), this, SLOT(undo())); | - | ||||||||||||
| 390 | return result; never executed: return result; | 0 | ||||||||||||
| 391 | } | - | ||||||||||||
| 392 | - | |||||||||||||
| 393 | /*! | - | ||||||||||||
| 394 | Creates an redo QAction object with parent \a parent. | - | ||||||||||||
| 395 | - | |||||||||||||
| 396 | Triggering this action will cause a call to QUndoStack::redo() on the active stack. | - | ||||||||||||
| 397 | The text of this action will always be the text of the command which will be redone | - | ||||||||||||
| 398 | in the next call to redo(), prefixed by \a prefix. If there is no command available | - | ||||||||||||
| 399 | for redo, if the group is empty or if none of the stacks are active, this action will | - | ||||||||||||
| 400 | be disabled. | - | ||||||||||||
| 401 | - | |||||||||||||
| 402 | If \a prefix is empty, the default template "Redo %1" is used instead of prefix. | - | ||||||||||||
| 403 | Before Qt 4.8, the prefix "Redo" was used by default. | - | ||||||||||||
| 404 | - | |||||||||||||
| 405 | \sa createUndoAction(), canRedo(), QUndoCommand::text() | - | ||||||||||||
| 406 | */ | - | ||||||||||||
| 407 | - | |||||||||||||
| 408 | QAction *QUndoGroup::createRedoAction(QObject *parent, const QString &prefix) const | - | ||||||||||||
| 409 | { | - | ||||||||||||
| 410 | QUndoAction *result = new QUndoAction(prefix, parent); | - | ||||||||||||
| 411 | if (prefix.isEmpty())
| 0 | ||||||||||||
| 412 | 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 | ||||||||||||
| 413 | - | |||||||||||||
| 414 | result->setEnabled(canRedo()); | - | ||||||||||||
| 415 | result->setPrefixedText(redoText()); | - | ||||||||||||
| 416 | connect(this, SIGNAL(canRedoChanged(bool)), | - | ||||||||||||
| 417 | result, SLOT(setEnabled(bool))); | - | ||||||||||||
| 418 | connect(this, SIGNAL(redoTextChanged(QString)), | - | ||||||||||||
| 419 | result, SLOT(setPrefixedText(QString))); | - | ||||||||||||
| 420 | connect(result, SIGNAL(triggered()), this, SLOT(redo())); | - | ||||||||||||
| 421 | return result; never executed: return result; | 0 | ||||||||||||
| 422 | } | - | ||||||||||||
| 423 | - | |||||||||||||
| 424 | #endif // QT_NO_ACTION | - | ||||||||||||
| 425 | - | |||||||||||||
| 426 | /*! \fn void QUndoGroup::activeStackChanged(QUndoStack *stack) | - | ||||||||||||
| 427 | - | |||||||||||||
| 428 | This signal is emitted whenever the active stack of the group changes. This can happen | - | ||||||||||||
| 429 | when setActiveStack() or QUndoStack::setActive() is called, or when the active stack | - | ||||||||||||
| 430 | is removed form the group. \a stack is the new active stack. If no stack is active, | - | ||||||||||||
| 431 | \a stack is 0. | - | ||||||||||||
| 432 | - | |||||||||||||
| 433 | \sa setActiveStack(), QUndoStack::setActive() | - | ||||||||||||
| 434 | */ | - | ||||||||||||
| 435 | - | |||||||||||||
| 436 | /*! \fn void QUndoGroup::indexChanged(int idx) | - | ||||||||||||
| 437 | - | |||||||||||||
| 438 | This signal is emitted whenever the active stack emits QUndoStack::indexChanged() | - | ||||||||||||
| 439 | or the active stack changes. | - | ||||||||||||
| 440 | - | |||||||||||||
| 441 | \a idx is the new current index, or 0 if the active stack is 0. | - | ||||||||||||
| 442 | - | |||||||||||||
| 443 | \sa QUndoStack::indexChanged(), setActiveStack() | - | ||||||||||||
| 444 | */ | - | ||||||||||||
| 445 | - | |||||||||||||
| 446 | /*! \fn void QUndoGroup::cleanChanged(bool clean) | - | ||||||||||||
| 447 | - | |||||||||||||
| 448 | This signal is emitted whenever the active stack emits QUndoStack::cleanChanged() | - | ||||||||||||
| 449 | or the active stack changes. | - | ||||||||||||
| 450 | - | |||||||||||||
| 451 | \a clean is the new state, or true if the active stack is 0. | - | ||||||||||||
| 452 | - | |||||||||||||
| 453 | \sa QUndoStack::cleanChanged(), setActiveStack() | - | ||||||||||||
| 454 | */ | - | ||||||||||||
| 455 | - | |||||||||||||
| 456 | /*! \fn void QUndoGroup::canUndoChanged(bool canUndo) | - | ||||||||||||
| 457 | - | |||||||||||||
| 458 | This signal is emitted whenever the active stack emits QUndoStack::canUndoChanged() | - | ||||||||||||
| 459 | or the active stack changes. | - | ||||||||||||
| 460 | - | |||||||||||||
| 461 | \a canUndo is the new state, or false if the active stack is 0. | - | ||||||||||||
| 462 | - | |||||||||||||
| 463 | \sa QUndoStack::canUndoChanged(), setActiveStack() | - | ||||||||||||
| 464 | */ | - | ||||||||||||
| 465 | - | |||||||||||||
| 466 | /*! \fn void QUndoGroup::canRedoChanged(bool canRedo) | - | ||||||||||||
| 467 | - | |||||||||||||
| 468 | This signal is emitted whenever the active stack emits QUndoStack::canRedoChanged() | - | ||||||||||||
| 469 | or the active stack changes. | - | ||||||||||||
| 470 | - | |||||||||||||
| 471 | \a canRedo is the new state, or false if the active stack is 0. | - | ||||||||||||
| 472 | - | |||||||||||||
| 473 | \sa QUndoStack::canRedoChanged(), setActiveStack() | - | ||||||||||||
| 474 | */ | - | ||||||||||||
| 475 | - | |||||||||||||
| 476 | /*! \fn void QUndoGroup::undoTextChanged(const QString &undoText) | - | ||||||||||||
| 477 | - | |||||||||||||
| 478 | This signal is emitted whenever the active stack emits QUndoStack::undoTextChanged() | - | ||||||||||||
| 479 | or the active stack changes. | - | ||||||||||||
| 480 | - | |||||||||||||
| 481 | \a undoText is the new state, or an empty string if the active stack is 0. | - | ||||||||||||
| 482 | - | |||||||||||||
| 483 | \sa QUndoStack::undoTextChanged(), setActiveStack() | - | ||||||||||||
| 484 | */ | - | ||||||||||||
| 485 | - | |||||||||||||
| 486 | /*! \fn void QUndoGroup::redoTextChanged(const QString &redoText) | - | ||||||||||||
| 487 | - | |||||||||||||
| 488 | This signal is emitted whenever the active stack emits QUndoStack::redoTextChanged() | - | ||||||||||||
| 489 | or the active stack changes. | - | ||||||||||||
| 490 | - | |||||||||||||
| 491 | \a redoText is the new state, or an empty string if the active stack is 0. | - | ||||||||||||
| 492 | - | |||||||||||||
| 493 | \sa QUndoStack::redoTextChanged(), setActiveStack() | - | ||||||||||||
| 494 | */ | - | ||||||||||||
| 495 | - | |||||||||||||
| 496 | QT_END_NAMESPACE | - | ||||||||||||
| 497 | - | |||||||||||||
| 498 | #include "moc_qundogroup.cpp" | - | ||||||||||||
| 499 | - | |||||||||||||
| 500 | #endif // QT_NO_UNDOGROUP | - | ||||||||||||
| Source code | Switch to Preprocessed file |