QElectroTech  0.70
templatecommands.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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 #include "templatecommands.h"
19 #include "templatevisualcell.h"
20 #include "templateview.h"
21 #include "titleblockcell.h"
22 #include "dimension.h"
23 #define TITLEBLOCK_DEFAULT_ROW_HEIGHT TitleBlockDimension(25)
24 #define TITLEBLOCK_DEFAULT_COL_WIDTH TitleBlockDimension(50)
25 
32  QUndoCommand(parent),
33  view_(nullptr),
34  modified_cell_(cell)
35 {
36 }
37 
42 }
43 
50 }
51 
57 bool ModifyTitleBlockCellCommand::mergeWith(const QUndoCommand *command) {
58  const ModifyTitleBlockCellCommand *other = static_cast<const ModifyTitleBlockCellCommand *>(command);
59  if (other) {
60  if (other -> modified_cell_ == modified_cell_) {
61  if (other -> new_values_.keys() == new_values_.keys()) {
62  new_values_ = other -> new_values_;
63  return(true);
64  }
65  }
66  }
67  return(false);
68 }
69 
74  if (!modified_cell_) return;
75  foreach (QString attribute, old_values_.keys()) {
76  modified_cell_ -> setAttribute(attribute, old_values_[attribute]);
77  }
78  if (view_) view_ -> refresh();
79 }
80 
85  if (!modified_cell_) return;
86  foreach (QString attribute, new_values_.keys()) {
87  modified_cell_ -> setAttribute(attribute, new_values_[attribute]);
88  }
89  if (view_) view_ -> refresh();
90 }
91 
96  return(modified_cell_);
97 }
98 
104  modified_cell_ = modified_cell;
105 }
106 
111  return(view_);
112 }
113 
119  view_ = view;
120 }
121 
126  old_values_.clear();
127  new_values_.clear();
128 }
129 
138 void ModifyTitleBlockCellCommand::addModification(const QString &attribute, const QVariant &value, bool is_old_value) {
139  if (is_old_value) {
140  // the provided value is the old one; therefore, the one we fetch is the new one
141  old_values_[attribute] = value;
142  if (modified_cell_) {
143  new_values_[attribute] = modified_cell_ -> attribute(attribute);
144  }
145  } else {
146  // the provided value is the new one; therefore, we fetch the old one
147  if (modified_cell_) {
148  old_values_[attribute] = modified_cell_ -> attribute(attribute);
149  }
150  new_values_[attribute] = value;
151  }
152 }
153 
160  QUndoCommand(parent),
161  tbtemplate_(tbtemplate),
162  view_(nullptr)
163 {
164 }
165 
170 }
171 
176  return(tbtemplate_);
177 }
178 
184  tbtemplate_ = tbtemplate;
185 }
186 
191  return(view_);
192 }
193 
199  view_ = view;
200 }
201 
206  if (!view_) return;
207  view_ -> refresh();
208 }
209 
214  if (!view_) return;
215  view_ -> updateLayout();
216 }
217 
226  if (!tbtemplate) return(nullptr);
227 
228  // create the command itself
229  ModifyTemplateGridCommand *add_row_command = new ModifyTemplateGridCommand(tbtemplate);
230  add_row_command -> setInsertion(true);
231  add_row_command -> setType(true);
232  add_row_command -> setCells(tbtemplate -> createRow());
233  add_row_command -> setDimension(TITLEBLOCK_DEFAULT_ROW_HEIGHT);
234  add_row_command -> setIndex(index);
235 
236  return(add_row_command);
237 }
238 
247  if (!tbtemplate) return(nullptr);
248 
249  // create the command itself
250  ModifyTemplateGridCommand *add_column_command = new ModifyTemplateGridCommand(tbtemplate);
251  add_column_command -> setInsertion(true);
252  add_column_command -> setType(false);
253  add_column_command -> setCells(tbtemplate -> createColumn());
254  add_column_command -> setDimension(TITLEBLOCK_DEFAULT_COL_WIDTH);
255  add_column_command -> setIndex(index);
256 
257  return(add_column_command);
258 }
259 
268  if (!tbtemplate) return(nullptr);
269 
270  // create the command itself
271  ModifyTemplateGridCommand *del_row_command = new ModifyTemplateGridCommand(tbtemplate);
272  del_row_command -> setInsertion(false);
273  del_row_command -> setType(true);
274  del_row_command -> setIndex(index);
275 
276  return(del_row_command);
277 }
278 
287  if (!tbtemplate) return(nullptr);
288 
289  // create the command itself
290  ModifyTemplateGridCommand *del_column_command = new ModifyTemplateGridCommand(tbtemplate);
291  del_column_command -> setInsertion(false);
292  del_column_command -> setType(false);
293  del_column_command -> setIndex(index);
294 
295  return(del_column_command);
296 }
297 
304  TitleBlockTemplateCommand(tbtemplate, parent),
305  index_(-1),
306  type_(true),
307  dimension_(TITLEBLOCK_DEFAULT_ROW_HEIGHT),
308  insertion_(true)
309 {
310  updateText();
311 }
312 
317 }
318 
323  return(index_);
324 }
325 
331  index_ = index;
332 }
333 
337 QList<TitleBlockCell *> ModifyTemplateGridCommand::cells() const {
338  return(cells_);
339 }
340 
345 void ModifyTemplateGridCommand::setCells(const QList<TitleBlockCell *> &cells) {
346  cells_ = cells;
347 }
348 
353  return dimension_;
354 }
355 
362 }
363 
368  return(type_);
369 }
370 
376  type_ = type;
377  updateText();
378 }
379 
384  return(insertion_);
385 }
386 
391  insertion_ = insertion;
392  updateText();
393 }
394 
399  apply(true);
400 }
401 
406  apply(false);
407 }
408 
413  if (type_) {
414  if (insertion_) {
415  setText(QObject::tr("Insertion d'une ligne", "label used in the title block template editor undo list"));
416  } else {
417  setText(QObject::tr("Suppression d'une ligne", "label used in the title block template editor undo list"));
418  }
419  } else {
420  if (insertion_) {
421  setText(QObject::tr("Insertion d'une colonne", "label used in the title block template editor undo list"));
422  } else {
423  setText(QObject::tr("Suppression d'une colonne", "label used in the title block template editor undo list"));
424  }
425  }
426 }
427 
428 /*
429  This method takes care of the actual job when undoing / redoing a
430  row/column insertion/removal.
431  @param true to undo the change, false to apply it.
432 */
434  if (!tbtemplate_ || index_ == -1) return;
435 
436  if (insertion_ ^ undo) {
437  if (type_) {
438  tbtemplate_ -> insertRow(dimension_.value, cells_, index_);
439  } else {
440  tbtemplate_ -> insertColumn(dimension_, cells_, index_);
441  }
442  } else {
443  if (type_) {
444  dimension_.value = tbtemplate_ -> rowDimension(index_);
445  cells_ = tbtemplate_ -> takeRow(index_);
446  } else {
447  dimension_ = tbtemplate_ -> columnDimension(index_);
448  cells_ = tbtemplate_ -> takeColumn(index_);
449  }
450  }
451 
452  // update the view, if any
453  if (view_) {
454  view_ -> updateLayout();
455  }
456 }
457 
464  TitleBlockTemplateCommand(tbtemplate, parent),
465  index_(-1),
466  type_(true),
467  before_(TitleBlockDimension(-1)),
468  after_(TitleBlockDimension(-1))
469 {
470 }
471 
476 }
477 
482  return(index_);
483 }
484 
490  index_ = index;
491 }
492 
497  return type_;
498 }
499 
505  type_ = type;
506  updateText();
507 }
508 
513  return(before_);
514 }
515 
520  before_ = dimension;
521 }
522 
527  return(after_);
528 }
529 
534  after_ = dimension;
535 }
536 
541  apply(before_);
542 }
543 
548  apply(after_);
549 }
550 
555  if (type_) {
556  setText(QObject::tr("Modification d'une ligne", "label used in the title block template editor undo list"));
557  } else {
558  setText(QObject::tr("Modification d'une colonne", "label used in the title block template editor undo list"));
559  }
560 }
561 
567  if (!tbtemplate_) return;
568  if (type_) {
569  tbtemplate_ -> setRowDimension(index_, dimension);
570  } else {
571  tbtemplate_ -> setColumnDimension(index_, dimension);
572  }
573  if (view_) {
574  if (type_) {
575  view_ -> rowsDimensionsChanged();
576  } else {
577  view_ -> columnsDimensionsChanged();
578  }
579  }
580 }
581 
589 MergeCellsCommand::MergeCellsCommand(const TitleBlockTemplateCellsSet &merged_cells, TitleBlockTemplate *tbtemplate, QUndoCommand *parent) :
590  TitleBlockTemplateCommand(tbtemplate, parent),
591  spanning_cell_(nullptr),
592  row_span_after_(-1),
593  col_span_after_(-1)
594 {
595  if (!canMerge(merged_cells, tbtemplate)) return;
596 
597  // the spanning cell is the top left cell
598  TitleBlockTemplateVisualCell *top_left_cell = merged_cells.topLeftCell();
599  if (!top_left_cell) return;
600  spanning_cell_ = top_left_cell -> cell();
601  if (!spanning_cell_) return;
602 
603  // store the spanner_cell attribute of each cell implied in the merge
604  foreach(TitleBlockCell *cell, merged_cells.cells()) {
605  spanner_cells_before_merge_.insert(cell, cell -> spanner_cell);
606  }
607 
608  // store the former values of the row_span and col_span attributes of the spanning cell
609  row_span_before_ = spanning_cell_ -> row_span;
610  col_span_before_ = spanning_cell_ -> col_span;
611  applied_row_span_before_ = spanning_cell_ -> applied_row_span;
612  applied_col_span_before_ = spanning_cell_ -> applied_col_span;
613  span_state_before_ = spanning_cell_ -> span_state;
614 
615  // calculate their new values after the merge operation
616  TitleBlockCell *bottom_right_cell = getBottomRightCell(merged_cells);
617  if (!bottom_right_cell) return;
618  row_span_after_ = bottom_right_cell -> num_row - spanning_cell_ -> num_row;
619  col_span_after_ = bottom_right_cell -> num_col - spanning_cell_ -> num_col;
620 
621  setText(
622  QString(
623  QObject::tr(
624  "Fusion de %1 cellules",
625  "label used in the title block template editor undo list; %1 is the number of merged cells"
626  )
627  ).arg(merged_cells.count())
628  );
629 }
630 
635 }
636 
643  Q_UNUSED(tbtemplate)
644 
645  // basic checks
646  if (!merged_cells.isRectangle()) return(false);
647  if (merged_cells.count() < 2) return(false);
648 
649  // the spanning cell is the top left cell
650  TitleBlockTemplateVisualCell *top_left_cell = merged_cells.topLeftCell();
651  if (!top_left_cell || !top_left_cell -> cell()) return(false);
652 
653  if (!getBottomRightCell(merged_cells)) return(false);
654 
655  return(true);
656 }
657 
662  // we consider having a non-zero spanning cell and positive spans makes a MergeCellsCommand valid
663  return(spanning_cell_ && row_span_after_ != -1 && col_span_after_ != -1);
664 }
665 
670  if (!isValid()) return;
671 
672  // restore the original spanning_cell attribute of all impacted cells
673  foreach (TitleBlockCell *cell, spanner_cells_before_merge_.keys()) {
674  cell -> spanner_cell = spanner_cells_before_merge_[cell];
675  }
676 
677  // restore the span-related attributes of the spanning cell
678  spanning_cell_ -> row_span = row_span_before_;
679  spanning_cell_ -> col_span = col_span_before_;
680  spanning_cell_ -> applied_row_span = applied_row_span_before_;
681  spanning_cell_ -> applied_col_span = applied_col_span_before_;
682  spanning_cell_ -> span_state = span_state_before_;
683 
684  if (view_) view_ -> updateLayout();
685 }
686 
691  if (!isValid()) return;
692 
693  // set the spanning_cell attributes of spanned cells to the spanning cell
694  foreach (TitleBlockCell *cell, spanner_cells_before_merge_.keys()) {
695  if (cell == spanning_cell_) continue;
696  cell -> spanner_cell = spanning_cell_;
697  }
698 
699  // set the new values of the row_span and col_span attributes
700  spanning_cell_ -> row_span = row_span_after_;
701  spanning_cell_ -> col_span = col_span_after_;
702  spanning_cell_ -> applied_row_span = row_span_after_;
703  spanning_cell_ -> applied_col_span = col_span_after_;
704  spanning_cell_ -> span_state = TitleBlockCell::Enabled;
705 
706  if (view_) view_ -> updateLayout();
707 }
708 
714  // first, we get the visual cell at the bottom right
715  TitleBlockTemplateVisualCell *bottom_right_cell = cells_set.bottomRightCell();
716  if (!bottom_right_cell) return(nullptr);
717 
718  // next, we get its logical cells: the painted one and the spanned ones (if any)
719  QSet<TitleBlockCell *> logical_cells = bottom_right_cell -> cells();
720  if (logical_cells.isEmpty()) return(nullptr);
721  if (logical_cells.count() == 1) return(logical_cells.toList().first());
722 
723  // we then look for the bottom right logical cell
724  int max_num_row = -1, max_num_col = -1;
725  TitleBlockCell *candidate = nullptr;
726  foreach(TitleBlockCell *cell, logical_cells) {
727  if (cell -> num_row > max_num_row) max_num_row = cell -> num_row;
728  if (cell -> num_col > max_num_col) max_num_col = cell -> num_col;
729  if (cell -> num_row == max_num_row && cell -> num_col == max_num_col) {
730  candidate = cell;
731  }
732  }
733  return(candidate);
734 }
735 
744 SplitCellsCommand::SplitCellsCommand(const TitleBlockTemplateCellsSet &splitted_cells, TitleBlockTemplate *tbtemplate, QUndoCommand *parent) :
745  TitleBlockTemplateCommand(tbtemplate, parent),
746  spanning_cell_(nullptr),
747  row_span_before_(-1),
748  col_span_before_(-1)
749 {
750  if (!canSplit(splitted_cells, tbtemplate)) return;
751 
752  // retrieve values necessary for the undo operation
753  spanning_cell_ = splitted_cells.first() -> cell();
754  spanned_cells_ = tbtemplate_ -> spannedCells(spanning_cell_);
755  row_span_before_ = spanning_cell_ -> row_span;
756  col_span_before_ = spanning_cell_ -> col_span;
759  span_state_before_ = spanning_cell_ -> span_state;
760 
761  setText(
762  QString(
763  QObject::tr(
764  "Séparation d'une cellule en %1",
765  "label used in the title block template editor undo list; %1 is the number of cells after the split"
766  )
767  ).arg(spanned_cells_.count() + 1)
768  );
769 }
770 
775 }
776 
783  Q_UNUSED(tbtemplate)
784 
785  // basic check: the command applies to a single visual cell only
786  if (splitted_cells.count() != 1) return(false);
787 
788  // fetch the spanning cell
789  TitleBlockCell *spanning_cell = splitted_cells.first() -> cell();
790  if (!spanning_cell) return(false);
791 
792  // ensure the cell spans over other cells and therefore can be splitted
793  if (!spanning_cell -> spans()) return(false);
794 
795  return(true);
796 }
797 
802  // we consider having a non-zero spanning cell and at least one spanned cell makes a SplitCellsCommand valid
803  return(spanning_cell_ && spanned_cells_.count());
804 }
805 
810  if (!isValid()) return;
811 
812  // the spanned cells are spanned again
813  foreach(TitleBlockCell *cell, spanned_cells_) {
814  cell -> spanner_cell = spanning_cell_;
815  }
816 
817  // the spanning cell span again
818  spanning_cell_ -> row_span = row_span_before_;
819  spanning_cell_ -> col_span = col_span_before_;
820  spanning_cell_ -> applied_row_span = applied_row_span_before_;
821  spanning_cell_ -> applied_col_span = applied_col_span_before_;
822  spanning_cell_ -> span_state = span_state_before_;
823 
824  if (view_) view_ -> updateLayout();
825 }
826 
831  if (!isValid()) return;
832 
833  // the spanned cells are not spanned anymore
834  foreach(TitleBlockCell *cell, spanned_cells_) {
835  cell -> spanner_cell = nullptr;
836  }
837 
838  // the spanning cell does not span anymore
839  spanning_cell_ -> row_span = 0;
840  spanning_cell_ -> col_span = 0;
841  tbtemplate_ -> checkCellSpan(spanning_cell_);
842 
843  if (view_) view_ -> updateLayout();
844 }
845 
846 
854 ChangeTemplateInformationsCommand::ChangeTemplateInformationsCommand(TitleBlockTemplate *tbt, const QString &old_info, const QString &new_info, QUndoCommand *parent) :
855  QUndoCommand(QObject::tr("modification des informations complémentaires", "undo caption"), parent),
856  tbtemplate_(tbt),
857  old_information_(old_info),
858  new_information_(new_info)
859 {
860 }
861 
866 }
867 
872  if (!tbtemplate_) return;
873  tbtemplate_ -> setInformation(old_information_);
874 }
875 
880  tbtemplate_ -> setInformation(new_information_);
881 }
882 
887  TitleBlockTemplateCommand(tb_template, parent)
888 {
889 }
890 
895 }
896 
901  foreach (TitleBlockCell *cell, cut_cells_.keys()) {
902  cell -> cell_type = cut_cells_.value(cell);
903  }
904  refreshView();
905 }
906 
911  foreach (TitleBlockCell *cell, cut_cells_.keys()) {
912  cell -> cell_type = TitleBlockCell::EmptyCell;
913  }
914  refreshView();
915 }
916 
917 void CutTemplateCellsCommand::setCutCells(const QList<TitleBlockCell *> &cells) {
918  foreach (TitleBlockCell *cell, cells) {
919  cut_cells_.insert(cell, cell -> cell_type);
920  }
921  updateText();
922 }
923 
928  setText(QObject::tr("Couper %n cellule(s)", "undo caption", cut_cells_.count()));
929 }
930 
931 
938  TitleBlockTemplateCommand(tb_template, parent)
939 {
940 }
941 
946 }
947 
952  setText(QObject::tr("Coller %n cellule(s)", "undo caption", erased_cells_.count()));
953 }
954 
959  bool span_management = erased_cells_.count() > 1;
960  foreach (TitleBlockCell *cell, erased_cells_.keys()) {
961  cell -> loadContentFromCell(erased_cells_.value(cell));
962  }
963  if (span_management) {
964  // restore all span parameters as they were before the paste operation.
965  tbtemplate_ -> setAllSpans(spans_before_);
966  tbtemplate_ -> applyCellSpans();
967  refreshLayout();
968  } else {
969  refreshView();
970  }
971 }
972 
977  // we only play with spans when pasting more than one cell.
978  bool span_management = erased_cells_.count() > 1;
979 
980  if (span_management) {
981  // When pasting several cells, we may modify the span parameters of existing,
982  // non-erased cells. The easiest way to ensure everything can be restored at its
983  // initial state consists in saving the span parameters of every cell.
984  if (spans_before_.isEmpty()) {
985  spans_before_ = tbtemplate_ -> getAllSpans();
986  }
987  }
988 
989  // copy data from each pasted cell into each erased cell
990  foreach (TitleBlockCell *cell, erased_cells_.keys()) {
991  if (span_management) {
992  // the erased cell may be spanned by another cell
993  if (TitleBlockCell *spanning_cell = cell -> spanner_cell) {
994  // for the moment, we simply cancel the whole spanning
995  tbtemplate_ -> forgetSpanning(spanning_cell);
996  }
997  }
998 
999  // copy non-spans data
1000  TitleBlockCell pasted_cell = pasted_cells_.value(cell);
1001  cell -> loadContentFromCell(pasted_cell);
1002 
1003  if (span_management) {
1004  // copy spans data
1005  if ((pasted_cell.row_span != cell -> row_span) || (pasted_cell.col_span != cell -> col_span)) {
1006  tbtemplate_ -> forgetSpanning(cell);
1007 
1008  // Note: the code below is similar to TitleBlockTemplate::checkCell() but is more aggressive (spans deletion).
1009  // set the new/pasted span parameters
1010  cell -> row_span = qBound(0, pasted_cell.row_span, tbtemplate_ -> rowsCount() - 1 - cell -> num_row);
1011  cell -> col_span = qBound(0, pasted_cell.col_span, tbtemplate_ -> columnsCount() - 1 - cell -> num_col);
1012 
1013  if (cell -> row_span || cell -> col_span) {
1014  // browse newly spanned cells...
1015  foreach (TitleBlockCell *spanned_cell, tbtemplate_ -> spannedCells(cell, true)) {
1016  // ... to ensure they are not already spanned by other cells
1017  if (spanned_cell -> spanner_cell && spanned_cell -> spanner_cell != cell) {
1018  // if so, simply cancel the whole spanning
1019  tbtemplate_ -> forgetSpanning(spanned_cell -> spanner_cell);
1020  }
1021  }
1022 
1023  // set the spanner_cell attribute of newly spanned cells
1024  tbtemplate_ -> applyCellSpan(cell);
1025  }
1026  }
1027  }
1028  }
1029  if (span_management) {
1030  refreshLayout();
1031  } else {
1032  refreshView();
1033  }
1034 }
1035 
1041  pasted_cells_.insert(cell, new_cell_content);
1042 }
1043 
1049  erased_cells_.insert(cell, former_cell_content);
1050  updateText();
1051 }
1052 
1059  addPastedCell(cell, after);
1060  addErasedCell(cell, before);
1061 }
int applied_col_span_before_
the applied_col_span attribute of the spanning cell before the merge
#define TITLEBLOCK_DEFAULT_ROW_HEIGHT
void setDimensionAfter(const TitleBlockDimension &)
QList< TitleBlockCell * > cells_
Cells composing the inserted/deleted row/column.
TitleBlockCell * spanning_cell_
the cell spanning over the other ones
void setDimension(const TitleBlockDimension &)
~SplitCellsCommand() override
TitleBlockTemplateCommand(TitleBlockTemplate *=nullptr, QUndoCommand *=nullptr)
ChangeTemplateInformationsCommand(TitleBlockTemplate *, const QString &, const QString &, QUndoCommand *=nullptr)
#define MODIFY_TITLE_BLOCK_CELL_COMMAND_ID
TitleBlockTemplate * tbtemplate_
Modified TitleBlock Template.
TitleBlockDimension after_
Size of the row/column after it is changed.
TitleBlockTemplate * titleBlockTemplate() const
QHash< TitleBlockCell *, TitleBlockCell::TemplateCellType > cut_cells_
Cut cells.
QString old_information_
Informations before they are modified.
void undo() override
int col_span_before_
the col_span attribute of the spanning cell before the merge
int row_span_before_
the row_span attribute of the spanning cell before the merge
void setCell(TitleBlockCell *)
QHash< TitleBlockCell *, TitleBlockCell > erased_cells_
Existing cells impacted by the paste operation.
QHash< TitleBlockCell *, TitleBlockCell > pasted_cells_
Pasted cells.
int span_state_before_
the span_state attribute of the spanning cell before splitting
void setView(TitleBlockTemplateView *)
TitleBlockCell * modified_cell_
modified cell
bool mergeWith(const QUndoCommand *) override
int value
Numeric value.
Definition: dimension.h:34
QHash< QString, QVariant > new_values_
values after the cell has been modified
int index_
Index of the inserted/deleted row/column.
virtual void addErasedCell(TitleBlockCell *, const TitleBlockCell &)
TitleBlockTemplateView * view() const
ModifyTitleBlockCellCommand(TitleBlockCell *, QUndoCommand *=nullptr)
static bool canMerge(const TitleBlockTemplateCellsSet &, TitleBlockTemplate *)
void setDimensionBefore(const TitleBlockDimension &)
int applied_col_span_before_
the applied_col_span attribute of the spanning cell before splitting
void setView(TitleBlockTemplateView *)
static bool canSplit(const TitleBlockTemplateCellsSet &splitted_cells, TitleBlockTemplate *tbtemplate)
int applied_row_span_before_
the applied_row_span attribute of the spanning cell before the merge
int row_span
number of extra rows spanned by this cell
the cell span parameters should be applied without restriction
QSet< TitleBlockCell * > cells(bool=true) const
virtual void setCutCells(const QList< TitleBlockCell *> &)
int applied_row_span_before_
the applied_row_span attribute of the spanning cell before splitting
TitleBlockTemplateView * view() const
TitleBlockDimension dimension() const
QHash< TitleBlockCell *, TitleBlockCell * > spanner_cells_before_merge_
CutTemplateCellsCommand(TitleBlockTemplate *, QUndoCommand *=nullptr)
QString new_information_
Informations after they were modified.
bool type_
true for a row, false for a column
TitleBlockDimension dimension_
width/height of the column/row, which interpretation depends on type_
QIcon tr
Definition: qeticons.cpp:204
QHash< QString, QVariant > old_values_
values before the cell is modified
TitleBlockTemplateVisualCell * topLeftCell() const
void redo() override
int span_state_before_
the span_state attribute of the spanning cell before the merge
int row_span_before_
the row_span attribute of the spanning cell before splitting
PasteTemplateCellsCommand(TitleBlockTemplate *, QUndoCommand *=nullptr)
~MergeCellsCommand() override
static TitleBlockCell * getBottomRightCell(const TitleBlockTemplateCellsSet &)
int row_span_after_
the row_span attribute of the spanning cell after the merge
void setCells(const QList< TitleBlockCell *> &)
static ModifyTemplateGridCommand * deleteRow(TitleBlockTemplate *, int=-1)
static ModifyTemplateGridCommand * addRow(TitleBlockTemplate *, int=-1)
void apply(const TitleBlockDimension &)
int col_span_after_
the col_span attribute of the spanning cell after the merge
MergeCellsCommand(const TitleBlockTemplateCellsSet &, TitleBlockTemplate *=nullptr, QUndoCommand *=nullptr)
void undo() override
static ModifyTemplateGridCommand * deleteColumn(TitleBlockTemplate *, int=-1)
ModifyTemplateGridCommand(TitleBlockTemplate *=nullptr, QUndoCommand *=nullptr)
static ModifyTemplateGridCommand * addColumn(TitleBlockTemplate *, int=-1)
QSet< TitleBlockCell * > spanned_cells_
the spanned cells
TitleBlockTemplateVisualCell * bottomRightCell() const
bool type_
true for a row, false for a column
void setTitleBlockTemplate(TitleBlockTemplate *)
virtual void addPastedCell(TitleBlockCell *, const TitleBlockCell &)
TitleBlockDimension before_
Size of the row/column before it is changed.
TitleBlockTemplate * tbtemplate_
Changed title block template.
#define TITLEBLOCK_DEFAULT_COL_WIDTH
virtual void addCell(TitleBlockCell *, const TitleBlockCell &, const TitleBlockCell &)
SplitCellsCommand(const TitleBlockTemplateCellsSet &, TitleBlockTemplate *=nullptr, QUndoCommand *=nullptr)
TitleBlockTemplateView * view_
This class may trigger a view update.
ModifyTemplateDimension(TitleBlockTemplate *=nullptr, QUndoCommand *=nullptr)
int col_span_before_
the col_span attribute of the spanning cell before splitting
TitleBlockTemplateView * view_
This class may trigger a view update.
TitleBlockDimension dimensionAfter() const
QList< TitleBlockCell * > cells() const
void redo() override
TitleBlockDimension dimensionBefore() const
int col_span
number of extra columns spanned by this cell
TitleBlockCell * spanning_cell_
the cell spanning over the other ones
int index_
Index of the resized row/column.
TitleBlockCell * cell() const
void addModification(const QString &, const QVariant &, bool=false)
QHash< TitleBlockCell *, QPair< int, int > > spans_before_
Spans before operation.