QElectroTech
0.70
|
#include <templateview.h>
Public Slots | |
void | setTitleBlockTemplate (TitleBlockTemplate *) |
void | selectionChanged () |
void | zoomIn () |
void | zoomOut () |
void | zoomFit () |
void | zoomReset () |
QList< TitleBlockCell * > | cut () |
QList< TitleBlockCell * > | copy () |
bool | mayPaste () |
QList< TitleBlockCell > | pastedCells () |
void | paste () |
void | addColumnAtEnd () |
void | addRowAtEnd () |
void | addColumnBefore () |
void | addRowBefore () |
void | addColumnAfter () |
void | addRowAfter () |
void | editColumn (HelperCell *=nullptr) |
void | editRow (HelperCell *=nullptr) |
void | deleteColumn () |
void | deleteRow () |
void | mergeSelectedCells () |
void | splitSelectedCell () |
void | refresh () |
void | changePreviewWidth () |
void | setPreviewWidth (int) |
void | updateLayout () |
void | rowsDimensionsChanged () |
void | columnsDimensionsChanged () |
void | updateDisplayedMinMaxWidth () |
void | setReadOnly (bool) |
Signals | |
void | selectedCellsChanged (QList< TitleBlockCell *>) |
void | gridModificationRequested (TitleBlockTemplateCommand *) |
void | previewWidthChanged (int, int) |
Public Member Functions | |
TitleBlockTemplateView (QWidget *=nullptr) | |
TitleBlockTemplateView (QGraphicsScene *, QWidget *=nullptr) | |
~TitleBlockTemplateView () override | |
TitleBlockTemplate * | titleBlockTemplate () const |
virtual QList< TitleBlockCell * > | selectedCells () const |
virtual TitleBlockTemplateCellsSet | selectedCellsSet () const |
virtual TitleBlockTemplateCellsSet | cells (const QRectF &) const |
virtual void | analyzeSelectedCells (bool *, bool *, int *) |
virtual QSizeF | templateSize () const |
virtual qreal | templateWidth () const |
virtual qreal | templateHeight () const |
Protected Slots | |
virtual void | applyColumnsWidths (bool=true) |
virtual void | applyRowsHeights (bool=true) |
virtual void | updateRowsHelperCells () |
virtual void | updateColumnsHelperCells () |
Protected Member Functions | |
void | drawBackground (QPainter *, const QRectF &) override |
virtual void | addCells () |
virtual void | loadTemplate (TitleBlockTemplate *) |
virtual void | init () |
void | wheelEvent (QWheelEvent *) override |
virtual qreal | zoomFactor () const |
virtual void | fillWithEmptyCells () |
bool | event (QEvent *) override |
virtual void | normalizeCells (QList< TitleBlockCell > &, int x=0, int y=0) const |
Private Slots | |
void | updateLastContextMenuCell (HelperCell *) |
void | adjustSceneRect () |
Private Member Functions | |
TitleBlockTemplateView (const TitleBlockTemplateView &) | |
QList< QAction * > | rowsActions () const |
QList< QAction * > | columnsActions () const |
void | updateTotalWidthLabel () |
void | requestGridModification (TitleBlockTemplateCommand *) |
int | lastContextMenuCellIndex () const |
int | indexOf (QGraphicsLayoutItem *) |
void | removeItem (QGraphicsLayoutItem *) |
TitleBlockTemplateCellsSet | makeCellsSetFromGraphicsItems (const QList< QGraphicsItem *> &) const |
QString | makePrettyToolTip (const QString &) |
Private Attributes | |
TitleBlockTemplate * | tbtemplate_ |
QGraphicsGridLayout * | tbgrid_ |
QGraphicsWidget * | form_ |
int | preview_width_ |
SplittedHelperCell * | total_width_helper_cell_ |
HelperCell * | extra_cells_width_helper_cell_ |
QAction * | add_column_before_ |
QAction * | add_row_before_ |
QAction * | add_column_after_ |
QAction * | add_row_after_ |
QAction * | edit_column_dim_ |
QAction * | edit_row_dim_ |
QAction * | delete_column_ |
QAction * | delete_row_ |
QAction * | change_preview_width_ |
HelperCell * | last_context_menu_cell_ |
int | apply_columns_widths_count_ |
int | apply_rows_heights_count_ |
bool | first_activation_ |
Boolean used to detect the first display of this widget. More... | |
bool | read_only_ |
Boolean stating whether this view allows template edition. More... | |
This QGraphicsView subclass is used in the title block template editor to offer a graphical preview of the template being edited, but also to handle cell selection and various actions.
Definition at line 32 of file templateview.h.
TitleBlockTemplateView::TitleBlockTemplateView | ( | QWidget * | parent = nullptr | ) |
Constructor
parent | Parent QWidget. |
Definition at line 40 of file templateview.cpp.
References init().
TitleBlockTemplateView::TitleBlockTemplateView | ( | QGraphicsScene * | scene, |
QWidget * | parent = nullptr |
||
) |
Constructor
parent | Parent QWidget. |
Definition at line 58 of file templateview.cpp.
References init().
|
override |
Destructor
Definition at line 74 of file templateview.cpp.
|
private |
|
protectedvirtual |
Add the cells (both helper cells and regular visual cells) to the scene to get a visual representation of the edited title block template.
Definition at line 695 of file templateview.cpp.
References QET::Absolute, change_preview_width_, changePreviewWidth(), COL_OFFSET, columnsActions(), TitleBlockCell::Disabled, editColumn(), editRow(), extra_cells_width_helper_cell_, QET::Horizontal, ROW_OFFSET, rowsActions(), tbgrid_, tbtemplate_, TitleBlockDimension::toString(), total_width_helper_cell_, QET::Icons::tr, TitleBlockDimension::type, updateLastContextMenuCell(), updateTotalWidthLabel(), and QET::Vertical.
Referenced by loadTemplate().
|
slot |
Add a column right after the last index selected when calling the context menu.
Definition at line 302 of file templateview.cpp.
References ModifyTemplateGridCommand::addColumn(), lastContextMenuCellIndex(), read_only_, requestGridModification(), and tbtemplate_.
Referenced by init().
|
slot |
Add a column right after the last one.
Definition at line 263 of file templateview.cpp.
References ModifyTemplateGridCommand::addColumn(), read_only_, requestGridModification(), and tbtemplate_.
|
slot |
Add a column right before the last index selected when calling the context menu.
Definition at line 280 of file templateview.cpp.
References ModifyTemplateGridCommand::addColumn(), lastContextMenuCellIndex(), read_only_, requestGridModification(), and tbtemplate_.
Referenced by init().
|
slot |
Add a row right after the last index selected when calling the context menu.
Definition at line 313 of file templateview.cpp.
References ModifyTemplateGridCommand::addRow(), lastContextMenuCellIndex(), read_only_, requestGridModification(), and tbtemplate_.
Referenced by init().
|
slot |
Add a row right after the last one.
Definition at line 271 of file templateview.cpp.
References ModifyTemplateGridCommand::addRow(), read_only_, requestGridModification(), and tbtemplate_.
|
slot |
Add a row right before the last index selected when calling the context menu.
Definition at line 291 of file templateview.cpp.
References ModifyTemplateGridCommand::addRow(), lastContextMenuCellIndex(), read_only_, requestGridModification(), and tbtemplate_.
Referenced by init().
|
privateslot |
Adjusts the bounding rect of the scene.
Definition at line 1094 of file templateview.cpp.
References templateSize().
Referenced by loadTemplate(), zoomFit(), and zoomReset().
|
virtual |
can_merge | If non-zero, will be changed to reflect whether selected cells may be merged |
can_merge | If non-zero, will be changed to reflect whether selected cells may be splitted |
count | If non-zero, will be changed to reflect the number of selected cells |
Definition at line 451 of file templateview.cpp.
References MergeCellsCommand::canMerge(), SplitCellsCommand::canSplit(), selectedCellsSet(), and tbtemplate_.
|
protectedvirtualslot |
Apply the columns widths currently specified by the edited title block template.
animate | true to animate the change, false otherwise. |
Definition at line 566 of file templateview.cpp.
References apply_columns_widths_count_, COL_OFFSET, DEFAULT_ROWS_HELPER_CELLS_WIDTH, extra_cells_width_helper_cell_, form_, preview_width_, removeItem(), ROW_OFFSET, tbgrid_, tbtemplate_, total_width_helper_cell_, QET::Icons::tr, updateColumnsHelperCells(), and updateDisplayedMinMaxWidth().
Referenced by columnsDimensionsChanged(), loadTemplate(), and setPreviewWidth().
|
protectedvirtualslot |
Apply the rows heights currently specified by the edited title block template.
animate | true to animate the change, false otherwise. |
Definition at line 631 of file templateview.cpp.
References apply_rows_heights_count_, DEFAULT_COLS_HELPER_CELLS_HEIGHT, DEFAULT_PREVIEW_HELPER_CELL_HEIGHT, form_, ROW_OFFSET, tbgrid_, tbtemplate_, and updateRowsHelperCells().
Referenced by loadTemplate(), and rowsDimensionsChanged().
|
virtual |
rect | Rectangle in the coordinates of the QGraphicsWidget representing the title block template. |
Definition at line 440 of file templateview.cpp.
References form_, and makeCellsSetFromGraphicsItems().
Referenced by normalizeCells(), and selectedCells().
|
slot |
Ask the user a new width for the preview
Definition at line 782 of file templateview.cpp.
References TitleBlockDimensionWidget::label(), preview_width_, setPreviewWidth(), TitleBlockDimensionWidget::setValue(), QET::Icons::tr, TitleBlockDimension::value, and TitleBlockDimensionWidget::value().
Referenced by addCells(), and init().
|
private |
Definition at line 891 of file templateview.cpp.
References add_column_after_, add_column_before_, delete_column_, and edit_column_dim_.
Referenced by addCells().
|
slot |
Update the displayed layout. Call this function when the dimensions of columns changed.
Definition at line 917 of file templateview.cpp.
References applyColumnsWidths().
|
slot |
Export currently selected cells to the clipboard.
Definition at line 154 of file templateview.cpp.
References selectedCells(), and tbtemplate_.
Referenced by cut().
|
slot |
Export currently selected cells to the clipboard before setting them as empty.
Definition at line 138 of file templateview.cpp.
References copy(), requestGridModification(), and tbtemplate_.
|
slot |
Remove the column at the last index selected when calling the context menu.
Definition at line 375 of file templateview.cpp.
References ModifyTemplateGridCommand::deleteColumn(), lastContextMenuCellIndex(), requestGridModification(), and tbtemplate_.
Referenced by init().
|
slot |
Remove the row at the last index selected when calling the context menu.
Definition at line 384 of file templateview.cpp.
References ModifyTemplateGridCommand::deleteRow(), lastContextMenuCellIndex(), requestGridModification(), and tbtemplate_.
Referenced by init().
|
overrideprotected |
Reimplement the way the background is drawn to render the title block template.
Definition at line 416 of file templateview.cpp.
References tbtemplate_.
|
slot |
Edit the width of a column.
cell | (optional) HelperCell of the column to be modified. If 0, this method uses the last index selected when calling the context menu. |
Definition at line 325 of file templateview.cpp.
References TitleBlockDimensionWidget::label(), lastContextMenuCellIndex(), read_only_, requestGridModification(), TitleBlockDimensionWidget::setReadOnly(), TitleBlockDimensionWidget::setValue(), tbtemplate_, QET::Icons::tr, and TitleBlockDimensionWidget::value().
Referenced by addCells(), and init().
|
slot |
Edit the height of a row.
cell | (optional) HelperCell of the row to be modified. If 0, this method uses the last index selected when calling the context menu. |
Definition at line 351 of file templateview.cpp.
References TitleBlockDimensionWidget::label(), lastContextMenuCellIndex(), read_only_, requestGridModification(), TitleBlockDimensionWidget::setReadOnly(), TitleBlockDimensionWidget::setValue(), tbtemplate_, QET::Icons::tr, and TitleBlockDimensionWidget::value().
Referenced by addCells(), and init().
|
overrideprotected |
event | Object describing the received event |
Definition at line 816 of file templateview.cpp.
References first_activation_, and zoomFit().
|
protectedvirtual |
Fill the layout with empty cells where needed.
Definition at line 795 of file templateview.cpp.
References COL_OFFSET, ROW_OFFSET, tbgrid_, and tbtemplate_.
Referenced by loadTemplate().
|
signal |
Referenced by requestGridModification().
|
private |
item | an item supposed to be contained in the grid layout. |
Definition at line 1029 of file templateview.cpp.
References tbgrid_.
Referenced by removeItem().
|
protectedvirtual |
Initialize this view (actions, signals/slots connections, etc.)
Definition at line 534 of file templateview.cpp.
References add_column_after_, add_column_before_, add_row_after_, add_row_before_, addColumnAfter(), addColumnBefore(), addRowAfter(), addRowBefore(), change_preview_width_, changePreviewWidth(), delete_column_, delete_row_, deleteColumn(), deleteRow(), edit_column_dim_, edit_row_dim_, editColumn(), editRow(), QET::Icons::EditTableDeleteColumn, QET::Icons::EditTableDeleteRow, QET::Icons::EditTableInsertColumnLeft, QET::Icons::EditTableInsertColumnRight, QET::Icons::EditTableInsertRowAbove, QET::Icons::EditTableInsertRowUnder, selectionChanged(), and QET::Icons::tr.
Referenced by TitleBlockTemplateView().
|
private |
Definition at line 1018 of file templateview.cpp.
References last_context_menu_cell_.
Referenced by addColumnAfter(), addColumnBefore(), addRowAfter(), addRowBefore(), deleteColumn(), deleteRow(), editColumn(), and editRow().
|
protectedvirtual |
Load the tbt title block template. If a different template was previously loaded, it is deleted.
Definition at line 848 of file templateview.cpp.
References addCells(), adjustSceneRect(), applyColumnsWidths(), applyRowsHeights(), fillWithEmptyCells(), form_, removeItem(), tbgrid_, and tbtemplate_.
Referenced by setTitleBlockTemplate(), and updateLayout().
|
private |
a | list of QGraphicsItem |
Definition at line 1057 of file templateview.cpp.
Referenced by cells(), and selectedCellsSet().
|
private |
Definition at line 1073 of file templateview.cpp.
Referenced by updateDisplayedMinMaxWidth().
|
slot |
Definition at line 178 of file templateview.cpp.
|
slot |
Merge the selected cells.
Definition at line 393 of file templateview.cpp.
References requestGridModification(), selectedCellsSet(), and tbtemplate_.
|
protectedvirtual |
Given a cells list, change their position so the top left one is at row x and column y.
cells | Cells list |
Definition at line 828 of file templateview.cpp.
References cells().
Referenced by paste().
|
slot |
Import the cells described in the clipboard.
Definition at line 236 of file templateview.cpp.
References normalizeCells(), TitleBlockCell::num_col, TitleBlockCell::num_row, pastedCells(), requestGridModification(), selectedCellsSet(), tbtemplate_, and TitleBlockTemplateCellsSet::topLeftCell().
|
slot |
Definition at line 187 of file templateview.cpp.
References QET::attributeIsAnInteger(), TitleBlockCell::col_span, TitleBlockCell::loadContentFromXml(), TitleBlockCell::num_col, TitleBlockCell::num_row, and TitleBlockCell::row_span.
Referenced by paste().
|
signal |
Referenced by setPreviewWidth().
|
slot |
Refresh the regular cells.
Definition at line 763 of file templateview.cpp.
References COL_OFFSET, ROW_OFFSET, tbgrid_, and tbtemplate_.
|
private |
Removes an item from the grid layout
item | an item supposed to be contained in the grid layout. |
Definition at line 1040 of file templateview.cpp.
References indexOf(), and tbgrid_.
Referenced by applyColumnsWidths(), and loadTemplate().
|
private |
Emit the gridModificationRequested() signal with command after having set its view component.
command | A command object modifying the rendered title block template. |
Definition at line 1008 of file templateview.cpp.
References gridModificationRequested().
Referenced by addColumnAfter(), addColumnAtEnd(), addColumnBefore(), addRowAfter(), addRowAtEnd(), addRowBefore(), cut(), deleteColumn(), deleteRow(), editColumn(), editRow(), mergeSelectedCells(), paste(), and splitSelectedCell().
|
private |
Definition at line 884 of file templateview.cpp.
References add_row_after_, add_row_before_, delete_row_, and edit_row_dim_.
Referenced by addCells().
|
slot |
Update the displayed layout. Call this function when the dimensions of rows changed.
Definition at line 909 of file templateview.cpp.
References applyRowsHeights().
|
virtual |
Definition at line 424 of file templateview.cpp.
References cells(), and selectedCellsSet().
Referenced by copy(), and selectionChanged().
|
signal |
Referenced by selectionChanged().
|
virtual |
Definition at line 431 of file templateview.cpp.
References makeCellsSetFromGraphicsItems().
Referenced by analyzeSelectedCells(), mergeSelectedCells(), paste(), selectedCells(), and splitSelectedCell().
|
slot |
Emits the selectedCellsChanged() signal with the currently selected cells.
Definition at line 96 of file templateview.cpp.
References selectedCells(), and selectedCellsChanged().
Referenced by init().
|
slot |
Set the new preview width to width
width | new preview width |
Definition at line 976 of file templateview.cpp.
References applyColumnsWidths(), form_, preview_width_, previewWidthChanged(), tbgrid_, and updateTotalWidthLabel().
Referenced by changePreviewWidth().
|
slot |
read_only | whether this view should be read only. |
Definition at line 960 of file templateview.cpp.
References add_column_after_, add_column_before_, add_row_after_, add_row_before_, delete_column_, delete_row_, and read_only_.
|
slot |
tbtemplate | Title block template to be rendered by this view. If set to zero, the View will render nothing. |
Definition at line 81 of file templateview.cpp.
References loadTemplate(), and zoomFit().
|
slot |
Split the selected cell.
Definition at line 404 of file templateview.cpp.
References requestGridModification(), selectedCellsSet(), and tbtemplate_.
|
virtual |
Definition at line 497 of file templateview.cpp.
References DEFAULT_COLS_HELPER_CELLS_HEIGHT, DEFAULT_PREVIEW_HELPER_CELL_HEIGHT, and tbtemplate_.
Referenced by templateSize().
|
virtual |
Definition at line 477 of file templateview.cpp.
References templateHeight(), and templateWidth().
Referenced by adjustSceneRect().
|
virtual |
Definition at line 484 of file templateview.cpp.
References DEFAULT_ROWS_HELPER_CELLS_WIDTH, preview_width_, and tbtemplate_.
Referenced by templateSize().
TitleBlockTemplate * TitleBlockTemplateView::titleBlockTemplate | ( | ) | const |
Definition at line 89 of file templateview.cpp.
References tbtemplate_.
|
protectedvirtualslot |
Update the content (type and value) of columns helper cells.
Definition at line 679 of file templateview.cpp.
References COL_OFFSET, tbgrid_, tbtemplate_, TitleBlockDimension::toString(), and TitleBlockDimension::type.
Referenced by applyColumnsWidths().
|
slot |
Update the tooltip that displays the minimum and/or maximum width of the template.
Definition at line 925 of file templateview.cpp.
References makePrettyToolTip(), tbtemplate_, total_width_helper_cell_, and QET::Icons::tr.
Referenced by applyColumnsWidths().
|
privateslot |
Stores last_context_menu_cell as being the last helper cell the context menu was triggered on.
Definition at line 1087 of file templateview.cpp.
References last_context_menu_cell_.
Referenced by addCells().
|
slot |
Update the displayed layout. Call this function to refresh the display after the rendered title block template has been "deeply" modified, e.g. rows/columns have been added/modified or cells were merged/splitted.
Definition at line 900 of file templateview.cpp.
References loadTemplate(), and tbtemplate_.
|
protectedvirtualslot |
Update the content (type and value) of rows helper cells.
Definition at line 664 of file templateview.cpp.
References QET::Absolute, ROW_OFFSET, tbgrid_, tbtemplate_, and QET::Icons::tr.
Referenced by applyRowsHeights().
|
private |
Update the label of the helper cell that indicates the preview width.
Definition at line 992 of file templateview.cpp.
References preview_width_, total_width_helper_cell_, and QET::Icons::tr.
Referenced by addCells(), and setPreviewWidth().
|
overrideprotected |
Handles mouse wheel-related actions
e | QWheelEvent describing the wheel event |
Definition at line 511 of file templateview.cpp.
|
protectedvirtual |
|
slot |
Fit the rendered title block template in this view.
Definition at line 120 of file templateview.cpp.
References adjustSceneRect().
Referenced by event(), and setTitleBlockTemplate().
|
slot |
Zoom in by zoomFactor().
Definition at line 104 of file templateview.cpp.
References zoomFactor().
Referenced by wheelEvent().
|
slot |
Zoom out by zoomFactor().
Definition at line 112 of file templateview.cpp.
References zoomFactor().
Referenced by wheelEvent().
|
slot |
Reset the zoom level.
Definition at line 128 of file templateview.cpp.
References adjustSceneRect().
|
private |
Definition at line 133 of file templateview.h.
Referenced by columnsActions(), init(), and setReadOnly().
|
private |
Definition at line 132 of file templateview.h.
Referenced by columnsActions(), init(), and setReadOnly().
|
private |
Definition at line 133 of file templateview.h.
Referenced by init(), rowsActions(), and setReadOnly().
|
private |
Definition at line 132 of file templateview.h.
Referenced by init(), rowsActions(), and setReadOnly().
|
private |
Definition at line 138 of file templateview.h.
Referenced by applyColumnsWidths().
|
private |
Definition at line 139 of file templateview.h.
Referenced by applyRowsHeights().
|
private |
Definition at line 136 of file templateview.h.
Referenced by addCells(), and init().
|
private |
Definition at line 135 of file templateview.h.
Referenced by columnsActions(), init(), and setReadOnly().
|
private |
Definition at line 135 of file templateview.h.
Referenced by init(), rowsActions(), and setReadOnly().
|
private |
Definition at line 134 of file templateview.h.
Referenced by columnsActions(), and init().
|
private |
Definition at line 134 of file templateview.h.
Referenced by init(), and rowsActions().
|
private |
Definition at line 131 of file templateview.h.
Referenced by addCells(), and applyColumnsWidths().
|
private |
Boolean used to detect the first display of this widget.
Definition at line 140 of file templateview.h.
Referenced by event().
|
private |
Definition at line 128 of file templateview.h.
Referenced by applyColumnsWidths(), applyRowsHeights(), cells(), loadTemplate(), and setPreviewWidth().
|
private |
Definition at line 137 of file templateview.h.
Referenced by lastContextMenuCellIndex(), and updateLastContextMenuCell().
|
private |
Definition at line 129 of file templateview.h.
Referenced by applyColumnsWidths(), changePreviewWidth(), setPreviewWidth(), templateWidth(), and updateTotalWidthLabel().
|
private |
Boolean stating whether this view allows template edition.
Definition at line 141 of file templateview.h.
Referenced by addColumnAfter(), addColumnAtEnd(), addColumnBefore(), addRowAfter(), addRowAtEnd(), addRowBefore(), editColumn(), editRow(), and setReadOnly().
|
private |
Definition at line 127 of file templateview.h.
Referenced by addCells(), applyColumnsWidths(), applyRowsHeights(), fillWithEmptyCells(), indexOf(), loadTemplate(), refresh(), removeItem(), setPreviewWidth(), updateColumnsHelperCells(), and updateRowsHelperCells().
|
private |
Definition at line 126 of file templateview.h.
Referenced by addCells(), addColumnAfter(), addColumnAtEnd(), addColumnBefore(), addRowAfter(), addRowAtEnd(), addRowBefore(), analyzeSelectedCells(), applyColumnsWidths(), applyRowsHeights(), copy(), cut(), deleteColumn(), deleteRow(), drawBackground(), editColumn(), editRow(), fillWithEmptyCells(), loadTemplate(), mergeSelectedCells(), paste(), refresh(), splitSelectedCell(), templateHeight(), templateWidth(), titleBlockTemplate(), updateColumnsHelperCells(), updateDisplayedMinMaxWidth(), updateLayout(), and updateRowsHelperCells().
|
private |
Definition at line 130 of file templateview.h.
Referenced by addCells(), applyColumnsWidths(), updateDisplayedMinMaxWidth(), and updateTotalWidthLabel().