1 /* This file is part of the KDE project
2    Copyright 2004 Ariya Hidayat <ariya@kde.org>
3    Copyright 2004 Laurent Montel <montel@kde.org>
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9 
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 GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public License
16    along with this library; see the file COPYING.LIB.  If not, write to
17    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18    Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef CALLIGRA_SHEETS_SHEET_COMMANDS
22 #define CALLIGRA_SHEETS_SHEET_COMMANDS
23 
24 #include <QString>
25 #include <kundo2command.h>
26 
27 namespace Calligra
28 {
29 namespace Sheets
30 {
31 class Map;
32 class Sheet;
33 
34 /**
35  * \ingroup Commands
36  * \brief Renames a sheet.
37  */
38 class RenameSheetCommand : public KUndo2Command
39 {
40 public:
41     RenameSheetCommand(Sheet* sheet, const QString &name);
42 
43     void redo() override;
44     void undo() override;
45 
46 protected:
47     Sheet* sheet;
48     QString oldName;
49     QString newName;
50 };
51 
52 
53 /**
54  * \ingroup Commands
55  * \brief Hides a sheet.
56  */
57 class HideSheetCommand : public KUndo2Command
58 {
59 public:
60     explicit HideSheetCommand(Sheet* sheet);
61 
62     void redo() override;
63     void undo() override;
64 
65 protected:
66     Map* map;
67     QString sheetName;
68 };
69 
70 
71 /**
72  * \ingroup Commands
73  * \brief Shows a hidden sheet.
74  */
75 class ShowSheetCommand : public KUndo2Command
76 {
77 public:
78     explicit ShowSheetCommand(Sheet* sheet, KUndo2Command* parent = 0);
79 
80     void redo() override;
81     void undo() override;
82 
83 protected:
84     Map* map;
85     QString sheetName;
86 };
87 
88 
89 /**
90  * \ingroup Commands
91  * \brief Adds a sheet.
92  */
93 class AddSheetCommand : public KUndo2Command
94 {
95 public:
96     explicit AddSheetCommand(Sheet* sheet);
97 
98     void redo() override;
99     void undo() override;
100 
101 protected:
102     Sheet*  m_sheet;
103     bool    m_firstrun;
104 };
105 
106 
107 /**
108  * \ingroup Commands
109  * \brief Duplicates a sheet.
110  */
111 class DuplicateSheetCommand : public KUndo2Command
112 {
113 public:
114     explicit DuplicateSheetCommand();
115 
116     void setSheet(Sheet* sheet);
117 
118     void redo() override;
119     void undo() override;
120 
121 protected:
122     Sheet* m_oldSheet;
123     Sheet* m_newSheet;
124     bool m_firstrun;
125 };
126 
127 
128 /**
129  * \ingroup Commands
130  * \brief Removes a sheet.
131  */
132 class RemoveSheetCommand : public KUndo2Command
133 {
134 public:
135     explicit RemoveSheetCommand(Sheet* sheet);
136 
137     void redo() override;
138     void undo() override;
139 
140 protected:
141     Sheet* sheet;
142     Map* map;
143 };
144 
145 
146 /**
147  * \ingroup Commands
148  * \brief Changes sheet properties.
149  */
150 class SheetPropertiesCommand : public KUndo2Command
151 {
152 public:
153     explicit SheetPropertiesCommand(Sheet *sheet);
154     void setLayoutDirection(Qt::LayoutDirection direction);
155     void setAutoCalculationEnabled(bool b);
156     void setShowGrid(bool b);
157     void setShowPageOutline(bool b);
158     void setShowFormula(bool b);
159     void setHideZero(bool b);
160     void setShowFormulaIndicator(bool b);
161     void setShowCommentIndicator(bool b);
162     void setColumnAsNumber(bool b);
163     void setLcMode(bool b);
164     void setCapitalizeFirstLetter(bool b);
165 
166     void redo() override;
167     void undo() override;
168 
169 protected:
170     Sheet* sheet;
171     Map* map;
172     Qt::LayoutDirection oldDirection, newDirection;
173     bool oldAutoCalc, newAutoCalc;
174     bool oldShowGrid, newShowGrid;
175     bool oldShowPageOutline, newShowPageOutline;
176     bool oldShowFormula, newShowFormula;
177     bool oldHideZero, newHideZero;
178     bool oldShowFormulaIndicator, newShowFormulaIndicator;
179     bool oldShowCommentIndicator, newShowCommentIndicator;
180     bool oldColumnAsNumber, newColumnAsNumber;
181     bool oldLcMode, newLcMode;
182     bool oldCapitalizeFirstLetter, newCapitalizeFirstLetter;
183 };
184 
185 } // namespace Sheets
186 } // namespace Calligra
187 
188 #endif // CALLIGRA_SHEETS_SHEET_COMMANDS
189