1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef UNDO_COMMANDS_H
34 #define UNDO_COMMANDS_H
36 #include "resourceview.h"
38 #include <QtCore/QString>
39 #include <QtGui/QUndoCommand>
45 namespace SharedTools {
50 Provides a base for \l ResourceView-related commands.
52 class ViewCommand : public QUndoCommand
57 ViewCommand(ResourceView *view);
58 virtual ~ViewCommand();
62 \class ModelIndexViewCommand
64 Provides a mean to store/restore a \l QModelIndex as it cannot
65 be stored safely in most cases. This is an abstract class.
67 class ModelIndexViewCommand : public ViewCommand
69 int m_prefixArrayIndex;
73 ModelIndexViewCommand(ResourceView *view);
74 virtual ~ModelIndexViewCommand();
75 void storeIndex(const QModelIndex &index);
76 QModelIndex makeIndex() const;
80 \class ModifyPropertyCommand
82 Modifies the name/prefix/language property of a prefix/file node.
84 class ModifyPropertyCommand : public ModelIndexViewCommand
86 ResourceView::NodeProperty m_property;
92 ModifyPropertyCommand(ResourceView *view, const QModelIndex &nodeIndex,
93 ResourceView::NodeProperty property, const int mergeId, const QString &before,
94 const QString &after = QString());
97 int id() const { return m_mergeId; }
98 bool mergeWith(const QUndoCommand * command);
104 \class RemoveEntryCommand
106 Removes a \l QModelIndex including all children from a \l ResourceView.
108 class RemoveEntryCommand : public ModelIndexViewCommand
110 EntryBackup *m_entry;
114 RemoveEntryCommand(ResourceView *view, const QModelIndex &index);
115 ~RemoveEntryCommand();
124 \class AddFilesCommand
126 Adds a list of files to a given prefix node.
128 class AddFilesCommand : public ViewCommand
131 int m_cursorFileIndex;
134 const QStringList m_fileNames;
137 AddFilesCommand(ResourceView *view, int prefixIndex, int cursorFileIndex,
138 const QStringList &fileNames);
146 \class AddEmptyPrefixCommand
148 Adds a new, empty prefix node.
150 class AddEmptyPrefixCommand : public ViewCommand
152 int m_prefixArrayIndex;
155 AddEmptyPrefixCommand(ResourceView *view);
162 } // namespace SharedTools
164 #endif // UNDO_COMMANDS_H