QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
templatecommands.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech 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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef TITLEBLOCK_SLASH_TEMPLATE_COMMANDS_H
19#define TITLEBLOCK_SLASH_TEMPLATE_COMMANDS_H
20#define MODIFY_TITLE_BLOCK_CELL_COMMAND_ID 6378
21#include "../titleblockcell.h"
22#include "dimension.h"
23#include "templatecellsset.h"
24
25#include <QUndoCommand>
26#include <QtCore>
29
34class ModifyTitleBlockCellCommand : public QUndoCommand {
35 // constructor, destructor
36 public:
37 ModifyTitleBlockCellCommand(TitleBlockCell *, QUndoCommand * = nullptr);
39 private:
41
42 // methods
43 public:
44 int id() const override;
45 bool mergeWith(const QUndoCommand *) override;
46 void undo() override;
47 void redo() override;
48 TitleBlockCell *cell() const;
49 void setCell(TitleBlockCell *);
52 void clear();
53 void addModification(const QString &, const QVariant &, bool = false);
54
55 // attributes
56 private:
59 QHash<QString, QVariant> old_values_;
60 QHash<QString, QVariant> new_values_;
61};
62
67class TitleBlockTemplateCommand : public QUndoCommand {
68 // Constructors, destructor
69 public:
70 TitleBlockTemplateCommand(TitleBlockTemplate * = nullptr, QUndoCommand * = nullptr);
72 private:
74
75 // methods
76 public:
81 void refreshView();
82 void refreshLayout();
83
84 // attributes
85 protected:
88};
89
95 // static factory methods
96 public:
101
102 // Constructors, destructor
103 public:
104 ModifyTemplateGridCommand(TitleBlockTemplate * = nullptr, QUndoCommand * = nullptr);
106 private:
108
109 // methods
110 public:
111 int index() const;
112 void setIndex(int);
113 QList<TitleBlockCell *> cells() const;
114 void setCells(const QList<TitleBlockCell *> &);
116 void setDimension(const TitleBlockDimension &);
117 int type() const;
118 void setType(bool);
119 bool isInsertion() const;
120 void setInsertion(bool);
121 void undo() override;
122 void redo() override;
123
124 private:
125 void updateText();
126 void apply(bool = false);
127
128 // attributes
129 private:
130 int index_;
131 QList<TitleBlockCell *> cells_;
132 bool type_;
135};
136
142 // Constructor, destructor
143 public:
144 ModifyTemplateDimension(TitleBlockTemplate * = nullptr, QUndoCommand * = nullptr);
145 ~ModifyTemplateDimension() override;
146 private:
148
149 // methods
150 public:
151 int index() const;
152 void setIndex(int);
153 int type() const;
154 void setType(bool);
159 void undo() override;
160 void redo() override;
161
162 private:
163 void updateText();
164 void apply(const TitleBlockDimension &);
165
166 // attributes
167 private:
168 int index_;
169 bool type_;
172};
173
174
179 // Constructor, destructor
180 public:
181 MergeCellsCommand(const TitleBlockTemplateCellsSet &, TitleBlockTemplate * = nullptr, QUndoCommand * = nullptr);
182 ~MergeCellsCommand() override;
183
184 // methods
185 public:
187 bool isValid() const;
188 void undo() override;
189 void redo() override;
190 private:
192
193 // attributes
194 private:
199 QHash<TitleBlockCell *, TitleBlockCell *> spanner_cells_before_merge_;
207};
208
213 // Constructor, destructor
214 public:
215 SplitCellsCommand(const TitleBlockTemplateCellsSet &, TitleBlockTemplate * = nullptr, QUndoCommand * = nullptr);
216 ~SplitCellsCommand() override;
217
218 // methods
219 public:
220 static bool canSplit(const TitleBlockTemplateCellsSet &splitted_cells, TitleBlockTemplate *tbtemplate);
221 bool isValid() const;
222 void undo() override;
223 void redo() override;
224
225 // attributes
226 private:
228 QSet<TitleBlockCell *> spanned_cells_;
234};
235
240class ChangeTemplateInformationsCommand : public QUndoCommand {
241 // constructors, destructor
242 public:
243 ChangeTemplateInformationsCommand(TitleBlockTemplate *, const QString &, const QString &, QUndoCommand * = nullptr);
245 private:
247
248 // methods
249 public:
250 void undo() override;
251 void redo() override;
252
253 // attributes
254 private:
261};
262
267 // constructors, destructor
268 public:
269 CutTemplateCellsCommand(TitleBlockTemplate *, QUndoCommand * = nullptr);
270 ~CutTemplateCellsCommand() override;
271 private:
273
274 // methods
275 public:
276 void undo() override;
277 void redo() override;
278 virtual void setCutCells(const QList<TitleBlockCell *> &);
279 protected:
280 virtual void updateText();
281
282 // attributes
283 public:
285 QHash<TitleBlockCell *, TitleBlockCell::TemplateCellType> cut_cells_;
286};
287
292 // constructors, destructor
293 public:
294 PasteTemplateCellsCommand(TitleBlockTemplate *, QUndoCommand * = nullptr);
296 private:
298
299 // methods
300 public:
301 void undo() override;
302 void redo() override;
303 virtual void addPastedCell(TitleBlockCell *, const TitleBlockCell &);
304 virtual void addErasedCell(TitleBlockCell *, const TitleBlockCell &);
305 virtual void addCell(TitleBlockCell *, const TitleBlockCell &, const TitleBlockCell &);
306 protected:
307 virtual void updateText();
308
309 // attributes
310 public:
312 QHash<TitleBlockCell *, QPair<int, int> > spans_before_;
314 QHash<TitleBlockCell *, TitleBlockCell> pasted_cells_;
316 QHash<TitleBlockCell *, TitleBlockCell> erased_cells_;
317};
318#endif
Definition templatecommands.h:240
QString old_information_
Informations before they are modified.
Definition templatecommands.h:258
~ChangeTemplateInformationsCommand() override
Definition templatecommands.cpp:903
TitleBlockTemplate * tbtemplate_
Changed title block template.
Definition templatecommands.h:256
void redo() override
Definition templatecommands.cpp:919
void undo() override
Definition templatecommands.cpp:910
ChangeTemplateInformationsCommand(const ChangeTemplateInformationsCommand &)
QString new_information_
Informations after they were modified.
Definition templatecommands.h:260
Definition templatecommands.h:266
virtual void setCutCells(const QList< TitleBlockCell * > &)
Definition templatecommands.cpp:961
void redo() override
Definition templatecommands.cpp:953
virtual void updateText()
Definition templatecommands.cpp:971
CutTemplateCellsCommand(const CutTemplateCellsCommand &)
void undo() override
Definition templatecommands.cpp:942
QHash< TitleBlockCell *, TitleBlockCell::TemplateCellType > cut_cells_
Cut cells.
Definition templatecommands.h:285
~CutTemplateCellsCommand() override
Definition templatecommands.cpp:935
Definition templatecommands.h:178
QHash< TitleBlockCell *, TitleBlockCell * > spanner_cells_before_merge_
Definition templatecommands.h:199
int col_span_after_
the col_span attribute of the spanning cell after the merge
Definition templatecommands.h:206
static bool canMerge(const TitleBlockTemplateCellsSet &, TitleBlockTemplate *)
Definition templatecommands.cpp:673
int span_state_before_
the span_state attribute of the spanning cell before the merge
Definition templatecommands.h:204
int applied_row_span_before_
the applied_row_span attribute of the spanning cell before the merge
Definition templatecommands.h:202
TitleBlockCell * spanning_cell_
the cell spanning over the other ones
Definition templatecommands.h:196
~MergeCellsCommand() override
Definition templatecommands.cpp:664
int applied_col_span_before_
the applied_col_span attribute of the spanning cell before the merge
Definition templatecommands.h:203
void redo() override
Definition templatecommands.cpp:723
static TitleBlockCell * getBottomRightCell(const TitleBlockTemplateCellsSet &)
Definition templatecommands.cpp:747
void undo() override
Definition templatecommands.cpp:701
int row_span_after_
the row_span attribute of the spanning cell after the merge
Definition templatecommands.h:205
int col_span_before_
the col_span attribute of the spanning cell before the merge
Definition templatecommands.h:201
bool isValid() const
Definition templatecommands.cpp:692
int row_span_before_
the row_span attribute of the spanning cell before the merge
Definition templatecommands.h:200
Definition templatecommands.h:141
TitleBlockDimension before_
Size of the row/column before it is changed.
Definition templatecommands.h:170
~ModifyTemplateDimension() override
Definition templatecommands.cpp:497
void apply(const TitleBlockDimension &)
Definition templatecommands.cpp:596
int type() const
Definition templatecommands.cpp:520
void setType(bool)
Definition templatecommands.cpp:529
TitleBlockDimension dimensionAfter() const
Definition templatecommands.cpp:552
void redo() override
Definition templatecommands.cpp:575
int index() const
Definition templatecommands.cpp:504
void undo() override
Definition templatecommands.cpp:567
void updateText()
Definition templatecommands.cpp:583
ModifyTemplateDimension(const ModifyTemplateDimension &)
void setIndex(int)
Definition templatecommands.cpp:513
int index_
Index of the resized row/column.
Definition templatecommands.h:168
TitleBlockDimension after_
Size of the row/column after it is changed.
Definition templatecommands.h:171
void setDimensionBefore(const TitleBlockDimension &)
Definition templatecommands.cpp:545
bool type_
true for a row, false for a column
Definition templatecommands.h:169
TitleBlockDimension dimensionBefore() const
Definition templatecommands.cpp:537
void setDimensionAfter(const TitleBlockDimension &)
Definition templatecommands.cpp:560
Definition templatecommands.h:94
void setInsertion(bool)
Definition templatecommands.cpp:409
TitleBlockDimension dimension_
width/height of the column/row, which interpretation depends on type_
Definition templatecommands.h:133
void setIndex(int)
Definition templatecommands.cpp:345
static ModifyTemplateGridCommand * deleteColumn(TitleBlockTemplate *, int=-1)
Definition templatecommands.cpp:299
QList< TitleBlockCell * > cells() const
Definition templatecommands.cpp:352
static ModifyTemplateGridCommand * addRow(TitleBlockTemplate *, int=-1)
Definition templatecommands.cpp:238
void redo() override
Definition templatecommands.cpp:425
TitleBlockDimension dimension() const
Definition templatecommands.cpp:368
ModifyTemplateGridCommand(const ModifyTemplateGridCommand &)
static ModifyTemplateGridCommand * addColumn(TitleBlockTemplate *, int=-1)
Definition templatecommands.cpp:259
void undo() override
Definition templatecommands.cpp:417
void setCells(const QList< TitleBlockCell * > &)
Definition templatecommands.cpp:361
int index() const
Definition templatecommands.cpp:336
QList< TitleBlockCell * > cells_
Cells composing the inserted/deleted row/column.
Definition templatecommands.h:131
void setDimension(const TitleBlockDimension &)
Definition templatecommands.cpp:377
bool insertion_
Definition templatecommands.h:134
void apply(bool=false)
Definition templatecommands.cpp:455
void setType(bool)
Definition templatecommands.cpp:393
int type() const
Definition templatecommands.cpp:384
int index_
Index of the inserted/deleted row/column.
Definition templatecommands.h:130
bool type_
true for a row, false for a column
Definition templatecommands.h:132
static ModifyTemplateGridCommand * deleteRow(TitleBlockTemplate *, int=-1)
Definition templatecommands.cpp:280
bool isInsertion() const
Definition templatecommands.cpp:401
void updateText()
Definition templatecommands.cpp:433
~ModifyTemplateGridCommand() override
Definition templatecommands.cpp:329
Definition templatecommands.h:34
void addModification(const QString &, const QVariant &, bool=false)
Definition templatecommands.cpp:146
ModifyTitleBlockCellCommand(const ModifyTitleBlockCellCommand &)
void redo() override
Definition templatecommands.cpp:88
void setCell(TitleBlockCell *)
Definition templatecommands.cpp:109
bool mergeWith(const QUndoCommand *) override
Definition templatecommands.cpp:60
void clear()
Definition templatecommands.cpp:132
TitleBlockTemplateView * view() const
Definition templatecommands.cpp:116
TitleBlockTemplateView * view_
This class may trigger a view update.
Definition templatecommands.h:57
~ModifyTitleBlockCellCommand() override
Definition templatecommands.cpp:42
TitleBlockCell * cell() const
Definition templatecommands.cpp:100
QHash< QString, QVariant > new_values_
values after the cell has been modified
Definition templatecommands.h:60
TitleBlockCell * modified_cell_
modified cell
Definition templatecommands.h:58
void setView(TitleBlockTemplateView *)
Definition templatecommands.cpp:125
void undo() override
Definition templatecommands.cpp:76
QHash< QString, QVariant > old_values_
values before the cell is modified
Definition templatecommands.h:59
int id() const override
Definition templatecommands.cpp:50
Definition templatecommands.h:291
~PasteTemplateCellsCommand() override
Definition templatecommands.cpp:990
void redo() override
Definition templatecommands.cpp:1024
PasteTemplateCellsCommand(const PasteTemplateCellsCommand &)
void undo() override
Definition templatecommands.cpp:1005
QHash< TitleBlockCell *, TitleBlockCell > pasted_cells_
Pasted cells.
Definition templatecommands.h:314
QHash< TitleBlockCell *, TitleBlockCell > erased_cells_
Existing cells impacted by the paste operation.
Definition templatecommands.h:316
QHash< TitleBlockCell *, QPair< int, int > > spans_before_
Spans before operation.
Definition templatecommands.h:312
virtual void updateText()
Definition templatecommands.cpp:997
virtual void addCell(TitleBlockCell *, const TitleBlockCell &, const TitleBlockCell &)
Definition templatecommands.cpp:1107
virtual void addErasedCell(TitleBlockCell *, const TitleBlockCell &)
Definition templatecommands.cpp:1097
virtual void addPastedCell(TitleBlockCell *, const TitleBlockCell &)
Definition templatecommands.cpp:1089
Definition templatecommands.h:212
int span_state_before_
the span_state attribute of the spanning cell before splitting
Definition templatecommands.h:233
void undo() override
Definition templatecommands.cpp:845
QSet< TitleBlockCell * > spanned_cells_
the spanned cells
Definition templatecommands.h:228
TitleBlockCell * spanning_cell_
the cell spanning over the other ones
Definition templatecommands.h:227
int applied_row_span_before_
the applied_row_span attribute of the spanning cell before splitting
Definition templatecommands.h:231
static bool canSplit(const TitleBlockTemplateCellsSet &splitted_cells, TitleBlockTemplate *tbtemplate)
Definition templatecommands.cpp:817
void redo() override
Definition templatecommands.cpp:867
bool isValid() const
Definition templatecommands.cpp:836
~SplitCellsCommand() override
Definition templatecommands.cpp:808
int applied_col_span_before_
the applied_col_span attribute of the spanning cell before splitting
Definition templatecommands.h:232
int col_span_before_
the col_span attribute of the spanning cell before splitting
Definition templatecommands.h:230
int row_span_before_
the row_span attribute of the spanning cell before splitting
Definition templatecommands.h:229
Definition titleblockcell.h:26
Definition templatecellsset.h:28
Definition templatecommands.h:67
void setView(TitleBlockTemplateView *)
Definition templatecommands.cpp:209
TitleBlockTemplate * tbtemplate_
Modified TitleBlock Template.
Definition templatecommands.h:86
void refreshView()
Definition templatecommands.cpp:216
void refreshLayout()
Definition templatecommands.cpp:225
TitleBlockTemplateView * view_
This class may trigger a view update.
Definition templatecommands.h:87
TitleBlockTemplateCommand(const TitleBlockTemplateCommand &)
void setTitleBlockTemplate(TitleBlockTemplate *)
Definition templatecommands.cpp:193
TitleBlockTemplate * titleBlockTemplate() const
Definition templatecommands.cpp:184
TitleBlockTemplateView * view() const
Definition templatecommands.cpp:200
~TitleBlockTemplateCommand() override
Definition templatecommands.cpp:177
The TitleBlockTemplate class This class represents an title block template for an electric diagram....
Definition titleblocktemplate.h:37
Definition templateview.h:33
Definition dimension.h:26