OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / shared / qrceditor / undocommands_p.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef UNDO_COMMANDS_H
34 #define UNDO_COMMANDS_H
35
36 #include "resourceview.h"
37
38 #include <QtCore/QString>
39 #include <QtGui/QUndoCommand>
40
41 QT_BEGIN_NAMESPACE
42 class QModelIndex;
43 QT_END_NAMESPACE
44
45 namespace SharedTools {
46
47 /*!
48     \class ViewCommand
49
50     Provides a base for \l ResourceView-related commands.
51 */
52 class ViewCommand : public QUndoCommand
53 {
54 protected:
55     ResourceView *m_view;
56
57     ViewCommand(ResourceView *view);
58     virtual ~ViewCommand();
59 };
60
61 /*!
62     \class ModelIndexViewCommand
63
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.
66 */
67 class ModelIndexViewCommand : public ViewCommand
68 {
69     int m_prefixArrayIndex;
70     int m_fileArrayIndex;
71
72 protected:
73     ModelIndexViewCommand(ResourceView *view);
74     virtual ~ModelIndexViewCommand();
75     void storeIndex(const QModelIndex &index);
76     QModelIndex makeIndex() const;
77 };
78
79 /*!
80     \class ModifyPropertyCommand
81
82     Modifies the name/prefix/language property of a prefix/file node.
83 */
84 class ModifyPropertyCommand : public ModelIndexViewCommand
85 {
86     ResourceView::NodeProperty m_property;
87     QString m_before;
88     QString m_after;
89     int m_mergeId;
90
91 public:
92     ModifyPropertyCommand(ResourceView *view, const QModelIndex &nodeIndex,
93             ResourceView::NodeProperty property, const int mergeId, const QString &before,
94             const QString &after = QString());
95
96 private:
97     int id() const { return m_mergeId; }
98     bool mergeWith(const QUndoCommand * command);
99     void undo();
100     void redo();
101 };
102
103 /*!
104     \class RemoveEntryCommand
105
106     Removes a \l QModelIndex including all children from a \l ResourceView.
107 */
108 class RemoveEntryCommand : public ModelIndexViewCommand
109 {
110     EntryBackup *m_entry;
111     bool m_isExpanded;
112
113 public:
114     RemoveEntryCommand(ResourceView *view, const QModelIndex &index);
115     ~RemoveEntryCommand();
116
117 private:
118     void redo();
119     void undo();
120     void freeEntry();
121 };
122
123 /*!
124     \class AddFilesCommand
125
126     Adds a list of files to a given prefix node.
127 */
128 class AddFilesCommand : public ViewCommand
129 {
130     int m_prefixIndex;
131     int m_cursorFileIndex;
132     int m_firstFile;
133     int m_lastFile;
134     const QStringList m_fileNames;
135
136 public:
137     AddFilesCommand(ResourceView *view, int prefixIndex, int cursorFileIndex,
138             const QStringList &fileNames);
139
140 private:
141     void redo();
142     void undo();
143 };
144
145 /*!
146     \class AddEmptyPrefixCommand
147
148     Adds a new, empty prefix node.
149 */
150 class AddEmptyPrefixCommand : public ViewCommand
151 {
152     int m_prefixArrayIndex;
153
154 public:
155     AddEmptyPrefixCommand(ResourceView *view);
156
157 private:
158     void redo();
159     void undo();
160 };
161
162 } // namespace SharedTools
163
164 #endif // UNDO_COMMANDS_H