2
* Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com>
3
* Copyright (c) 2014 Mohit Goyal <mohit.bits2011@gmail.com>
5
* This library is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License as published by
7
* the Free Software Foundation; either version 2.1 of the License, or
8
* (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
/****************************************************************************
21
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
22
** All rights reserved.
23
** Contact: Nokia Corporation (qt-info@nokia.com)
25
** This file is part of the QtGui module of the Qt Toolkit.
27
** $QT_BEGIN_LICENSE:LGPL$
28
** No Commercial Usage
29
** This file contains pre-release code and may not be distributed.
30
** You may use this file in accordance with the terms and conditions
31
** contained in the Technology Preview License Agreement accompanying
34
** GNU Lesser General Public License Usage
35
** Alternatively, this file may be used under the terms of the GNU Lesser
36
** General Public License version 2.1 as published by the Free Software
37
** Foundation and appearing in the file LICENSE.LGPL included in the
38
** packaging of this file. Please review the following information to
39
** ensure the GNU Lesser General Public License version 2.1 requirements
40
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
42
** In addition, as a special exception, Nokia gives you certain additional
43
** rights. These rights are described in the Nokia Qt LGPL Exception
44
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
46
** If you have questions regarding the use of this file, please contact
47
** Nokia at qt-info@nokia.com.
58
****************************************************************************/
71
#include "kexiundo_export.h"
74
class KUndo2CommandPrivate;
76
class KActionCollection;
78
#ifndef QT_NO_UNDOCOMMAND
80
#include "kundo2magicstring.h"
81
#include "kundo2commandextradata.h"
84
class KEXIUNDO_EXPORT KUndo2Command
86
KUndo2CommandPrivate *d;
89
explicit KUndo2Command(KUndo2Command *parent = 0);
90
explicit KUndo2Command(const KUndo2MagicString &text, KUndo2Command *parent = 0);
91
virtual ~KUndo2Command();
96
QString actionText() const;
97
KUndo2MagicString text() const;
98
void setText(const KUndo2MagicString &text);
100
virtual int id() const;
101
virtual int timedId();
102
virtual void setTimedID(int timedID);
103
virtual bool mergeWith(const KUndo2Command *other);
104
virtual bool timedMergeWith(KUndo2Command *other);
106
int childCount() const;
107
const KUndo2Command *child(int index) const;
110
virtual void setTime();
111
virtual QTime time();
112
virtual void setEndTime();
113
virtual QTime endTime();
115
virtual QVector<KUndo2Command*> mergeCommandsVector();
116
virtual bool isMerged();
117
virtual void undoMergedCommands();
118
virtual void redoMergedCommands();
121
* \return user-defined object associated with the command
123
* \see setExtraData()
125
KUndo2CommandExtraData* extraData() const;
128
* The user can assign an arbitrary object associated with the
129
* command. The \p data object is owned by the command. If you assign
130
* the object twice, the first one will be destroyed.
132
void setExtraData(KUndo2CommandExtraData *data);
135
Q_DISABLE_COPY(KUndo2Command)
136
friend class KUndo2QStack;
142
QTime m_timeOfCreation;
143
QTime m_endOfCommand;
144
QVector<KUndo2Command*> m_mergeCommandsVector;
147
#endif // QT_NO_UNDOCOMMAND
149
#ifndef QT_NO_UNDOSTACK
151
class KEXIUNDO_EXPORT KUndo2QStack : public QObject
154
// Q_DECLARE_PRIVATE(KUndo2QStack)
155
Q_PROPERTY(bool active READ isActive WRITE setActive)
156
Q_PROPERTY(int undoLimit READ undoLimit WRITE setUndoLimit)
159
explicit KUndo2QStack(QObject *parent = 0);
160
virtual ~KUndo2QStack();
163
bool push(KUndo2Command *cmd);
165
bool canUndo() const;
166
bool canRedo() const;
167
QString undoText() const;
168
QString redoText() const;
172
QString actionText(int idx) const;
173
QString text(int idx) const;
176
QAction *createUndoAction(QObject *parent) const;
177
QAction *createRedoAction(QObject *parent) const;
178
#endif // QT_NO_ACTION
180
bool isActive() const;
181
bool isClean() const;
182
int cleanIndex() const;
184
void beginMacro(const KUndo2MagicString &text);
187
void setUndoLimit(int limit);
188
int undoLimit() const;
190
const KUndo2Command *command(int index) const;
192
void setUseCumulativeUndoRedo(bool value);
193
bool useCumulativeUndoRedo();
194
void setTimeT1(double value);
196
void setTimeT2(double value);
199
void setStrokesN(int value);
204
virtual void setIndex(int idx);
207
void setActive(bool active = true);
209
void purgeRedoState();
212
void indexChanged(int idx);
213
void cleanChanged(bool clean);
214
void canUndoChanged(bool canUndo);
215
void canRedoChanged(bool canRedo);
216
void undoTextChanged(const QString &undoActionText);
217
void redoTextChanged(const QString &redoActionText);
220
virtual void notifySetIndexChangedOneCommand();
223
// from QUndoStackPrivate
224
QList<KUndo2Command*> m_command_list;
225
QList<KUndo2Command*> m_macro_stack;
228
KUndo2Group *m_group;
230
bool m_useCumulativeUndoRedo;
234
int m_lastMergedSetCount;
235
int m_lastMergedIndex;
237
// also from QUndoStackPrivate
238
void setIndex(int idx, bool clean);
239
bool checkUndoLimit();
241
Q_DISABLE_COPY(KUndo2QStack)
242
friend class KUndo2Group;
245
class KEXIUNDO_EXPORT KUndo2Stack : public KUndo2QStack
249
explicit KUndo2Stack(QObject *parent = 0);
251
// functions from KUndoStack
252
QAction* createRedoAction(KActionCollection* actionCollection, const QString& actionName = QString());
253
QAction* createUndoAction(KActionCollection* actionCollection, const QString& actionName = QString());
256
#endif // QT_NO_UNDOSTACK
258
#endif // KUNDO2STACK_H