QElectroTech  0.70
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
TitleBlockTemplate Class Reference

#include <titleblocktemplate.h>

Public Member Functions

 TitleBlockTemplate (QObject *=nullptr)
 
 ~TitleBlockTemplate () override
 
TitleBlockCellcreateCell (const TitleBlockCell *=nullptr)
 
bool loadFromXmlFile (const QString &)
 
bool loadFromXmlElement (const QDomElement &)
 
bool saveToXmlFile (const QString &)
 
bool saveToXmlElement (QDomElement &) const
 
void exportCellToXml (TitleBlockCell *, QDomElement &) const
 
TitleBlockTemplateclone () const
 
QString name () const
 
QString information () const
 
void setInformation (const QString &)
 
int rowDimension (int)
 
void setRowDimension (int, const TitleBlockDimension &)
 
TitleBlockDimension columnDimension (int)
 
void setColumnDimension (int, const TitleBlockDimension &)
 
int columnsCount () const
 
int rowsCount () const
 
QList< int > columnsWidth (int) const
 
QList< int > rowsHeights () const
 
int columnTypeCount (QET::TitleBlockColumnLength)
 
int columnTypeTotal (QET::TitleBlockColumnLength)
 
int minimumWidth ()
 
int maximumWidth ()
 
int width (int)
 
int height () const
 
bool moveRow (int, int)
 
void addRow (int=-1)
 
bool insertRow (int, const QList< TitleBlockCell *> &, int=-1)
 
QList< TitleBlockCell * > takeRow (int)
 
QList< TitleBlockCell * > createRow ()
 
bool moveColumn (int, int)
 
void addColumn (int=-1)
 
bool insertColumn (const TitleBlockDimension &, const QList< TitleBlockCell *> &, int=-1)
 
QList< TitleBlockCell * > takeColumn (int)
 
QList< TitleBlockCell * > createColumn ()
 
TitleBlockCellcell (int, int) const
 
QSet< TitleBlockCell * > spannedCells (const TitleBlockCell *, bool=false) const
 
QHash< TitleBlockCell *, QPair< int, int > > getAllSpans () const
 
void setAllSpans (const QHash< TitleBlockCell *, QPair< int, int > > &)
 
bool addLogo (const QString &, QByteArray *, const QString &="svg", const QString &="xml")
 
bool addLogoFromFile (const QString &, const QString &=QString())
 
bool saveLogoToFile (const QString &, const QString &)
 
bool removeLogo (const QString &)
 
bool renameLogo (const QString &, const QString &)
 
void setLogoStorage (const QString &, const QString &)
 
QList< QString > logos () const
 
QString logoType (const QString &) const
 
QSvgRenderer * vectorLogo (const QString &) const
 
QPixmap bitmapLogo (const QString &) const
 
void render (QPainter &, const DiagramContext &, int) const
 
void renderDxf (QRectF &, const DiagramContext &, int, QString &, int) const
 
void renderCell (QPainter &, const TitleBlockCell &, const DiagramContext &, const QRect &) const
 
void applyCellSpans ()
 
void forgetSpanning ()
 
void forgetSpanning (TitleBlockCell *, bool=true)
 
bool checkCellSpan (TitleBlockCell *)
 
void applyCellSpan (TitleBlockCell *)
 
void applyRowColNums ()
 
void rowColsChanged ()
 
QStringList listOfVariables ()
 Get list of variables. More...
 

Static Public Member Functions

static QFont fontForCell (const TitleBlockCell &)
 

Protected Member Functions

void loadInformation (const QDomElement &)
 
bool loadLogos (const QDomElement &, bool=false)
 
bool loadLogo (const QDomElement &)
 
bool loadGrid (const QDomElement &)
 
bool loadCells (const QDomElement &)
 
void loadCell (const QDomElement &)
 
void saveInformation (QDomElement &) const
 
void saveLogos (QDomElement &) const
 
void saveLogo (const QString &, QDomElement &) const
 
void saveGrid (QDomElement &) const
 
void saveCells (QDomElement &) const
 
void saveCell (TitleBlockCell *, QDomElement &, bool=false) const
 
QList< TitleBlockCell * > createCellsList (int)
 

Private Member Functions

 TitleBlockTemplate (const TitleBlockTemplate &)
 
void parseRows (const QString &)
 
void parseColumns (const QString &)
 
bool checkCell (const QDomElement &, TitleBlockCell **=nullptr)
 
void flushCells ()
 
void initCells ()
 
int lengthRange (int, int, const QList< int > &) const
 
QString finalTextForCell (const TitleBlockCell &, const DiagramContext &) const
 
QString interpreteVariables (const QString &, const DiagramContext &) const
 
void renderTextCell (QPainter &, const QString &, const TitleBlockCell &, const QRectF &) const
 
void renderTextCellDxf (QString &, const QString &, const TitleBlockCell &, qreal, qreal, qreal, qreal, int) const
 

Private Attributes

QString name_
 name identifying the Title Block Template within its parent collection More...
 
QString information_
 
QHash< QString, QByteArray > data_logos_
 Logos raw data. More...
 
QHash< QString, QString > storage_logos_
 Logos applied storage type (e.g. "xml" or "base64") More...
 
QHash< QString, QString > type_logos_
 Logos types (e.g. "png", "jpeg", "svg") More...
 
QHash< QString, QSvgRenderer * > vector_logos_
 Rendered objects for vector logos. More...
 
QHash< QString, QPixmap > bitmap_logos_
 Pixmaps for bitmap logos. More...
 
QList< int > rows_heights_
 rows heights – simple integers More...
 
QList< TitleBlockDimensioncolumns_width_
 columns widths – More...
 
QList< TitleBlockCell * > registered_cells_
 Cells objects created rattached to this template, but not mandatorily used. More...
 
QList< QList< TitleBlockCell * > > cells_
 Cells grid. More...
 

Detailed Description

This class represents an title block template for an electric diagram. It can read from an XML document the layout of the table that graphically represents the title block, and can produce a graphical rendering of it from a diagram context (object embedding the informations of the diagram we want to represent the title block.

Definition at line 34 of file titleblocktemplate.h.

Constructor & Destructor Documentation

◆ TitleBlockTemplate() [1/2]

TitleBlockTemplate::TitleBlockTemplate ( QObject *  parent = nullptr)

Constructor

Parameters
parentparent QObject

Definition at line 30 of file titleblocktemplate.cpp.

Referenced by clone().

◆ ~TitleBlockTemplate()

TitleBlockTemplate::~TitleBlockTemplate ( )
override

Destructor

Definition at line 38 of file titleblocktemplate.cpp.

References loadLogos(), and registered_cells_.

◆ TitleBlockTemplate() [2/2]

TitleBlockTemplate::TitleBlockTemplate ( const TitleBlockTemplate )
private

Member Function Documentation

◆ addColumn()

void TitleBlockTemplate::addColumn ( int  i = -1)

Add a new 50px-wide column at the provided index.

Parameters
iIndex of the added column, -1 meaning "last position"

Definition at line 912 of file titleblocktemplate.cpp.

References QET::Absolute, createColumn(), and insertColumn().

◆ addLogo()

bool TitleBlockTemplate::addLogo ( const QString &  logo_name,
QByteArray *  logo_data,
const QString &  logo_type = "svg",
const QString &  logo_storage = "xml" 
)
Parameters
logo_nameLogo name to be added / replaced
logo_dataLogo data

Definition at line 1024 of file titleblocktemplate.cpp.

References bitmap_logos_, data_logos_, removeLogo(), storage_logos_, type_logos_, and vector_logos_.

Referenced by addLogoFromFile(), and loadLogo().

◆ addLogoFromFile()

bool TitleBlockTemplate::addLogoFromFile ( const QString &  filepath,
const QString &  name = QString() 
)
Parameters
filepathPath of the image file to add as a logo
nameName used to store the logo; if none is provided, the basename of the first argument is used.
Returns
true if the logo could be deleted, false otherwise

Definition at line 1072 of file titleblocktemplate.cpp.

References addLogo(), and name().

◆ addRow()

void TitleBlockTemplate::addRow ( int  i = -1)

Add a new 25px-wide row at the provided index.

Parameters
iIndex of the added row, -1 meaning "last position"

Definition at line 848 of file titleblocktemplate.cpp.

References createRow(), and insertRow().

◆ applyCellSpan()

void TitleBlockTemplate::applyCellSpan ( TitleBlockCell cell)

Ensure the spans of the provided cell are applied within the grid structure. Note: this function does not check whether the spans of the provided cell make sense.

Parameters
cellPotentially spanning cell

Definition at line 1584 of file titleblocktemplate.cpp.

References cell(), cells_, and TitleBlockCell::Disabled.

Referenced by applyCellSpans().

◆ applyCellSpans()

void TitleBlockTemplate::applyCellSpans ( )

Forget any previously applied span, then apply again all spans defined by existing cells.

Definition at line 1524 of file titleblocktemplate.cpp.

References applyCellSpan(), cells_, checkCellSpan(), columns_width_, forgetSpanning(), and rows_heights_.

Referenced by loadGrid(), and rowColsChanged().

◆ applyRowColNums()

void TitleBlockTemplate::applyRowColNums ( )

Ensure all cells have the right col+row numbers.

Definition at line 1605 of file titleblocktemplate.cpp.

References cells_, columns_width_, and rows_heights_.

Referenced by loadGrid(), and rowColsChanged().

◆ bitmapLogo()

QPixmap TitleBlockTemplate::bitmapLogo ( const QString &  logo_name) const
Parameters
logo_nameName of a logo embedded within this title block template.
Returns
the pixmap for the required bitmap logo, or a null pixmap if no such bitmap logo was found in this template.

Definition at line 1199 of file titleblocktemplate.cpp.

References bitmap_logos_.

◆ cell()

TitleBlockCell * TitleBlockTemplate::cell ( int  row,
int  col 
) const
Parameters
rowA row number (starting from 0)
colA column number (starting from 0)
Returns
the cell located at (row, col)

Definition at line 957 of file titleblocktemplate.cpp.

References cells_, columns_width_, and rows_heights_.

Referenced by applyCellSpan(), checkCellSpan(), exportCellToXml(), finalTextForCell(), fontForCell(), renderCell(), renderTextCell(), renderTextCellDxf(), saveCell(), setAllSpans(), and spannedCells().

◆ checkCell()

bool TitleBlockTemplate::checkCell ( const QDomElement &  xml_element,
TitleBlockCell **  titleblock_cell_ptr = nullptr 
)
private

Load the essential attributes of a cell: row and column indices and spans.

Parameters
xml_elementXML element representing a cell, i.e. either an titleblock logo or an titleblock field.
titleblock_cell_ptrPointer to a TitleBlockCell object pointer - if non-zero and if this method returns true, will be filled with the created TitleBlockCell
Returns
TRUE if the cell appears to be ok, FALSE otherwise

Definition at line 522 of file titleblocktemplate.cpp.

References QET::attributeIsAnInteger(), cells_, columns_width_, TitleBlockCell::EmptyCell, and rows_heights_.

Referenced by loadCell().

◆ checkCellSpan()

bool TitleBlockTemplate::checkCellSpan ( TitleBlockCell cell)

Check whether a given cell can be spanned according to its row_span and col_span attributes. the following attributes of cell are updated according to what is really possible: applied_col_span applied_row_span span_state

Parameters
cellCell we want to check
Returns
false if no check could be performed, true otherwise

Definition at line 1544 of file titleblocktemplate.cpp.

References cell(), cells_, columnsCount(), TitleBlockCell::Disabled, TitleBlockCell::EmptyCell, TitleBlockCell::Enabled, TitleBlockCell::Restricted, and rowsCount().

Referenced by applyCellSpans().

◆ clone()

TitleBlockTemplate * TitleBlockTemplate::clone ( ) const
Returns
a deep copy of the current title block template (i.e. title block cells are duplicated too and associated with their parent template).

Definition at line 169 of file titleblocktemplate.cpp.

References bitmap_logos_, cells_, columns_width_, createCell(), data_logos_, information_, name_, rows_heights_, storage_logos_, TitleBlockTemplate(), type_logos_, and vector_logos_.

◆ columnDimension()

TitleBlockDimension TitleBlockTemplate::columnDimension ( int  i)
Parameters
icolumn index
Returns
the width of the column at index i

Definition at line 635 of file titleblocktemplate.cpp.

References columns_width_.

◆ columnsCount()

int TitleBlockTemplate::columnsCount ( ) const
Returns
the number of columns in this template

Definition at line 658 of file titleblocktemplate.cpp.

References columns_width_.

Referenced by checkCellSpan().

◆ columnsWidth()

QList< int > TitleBlockTemplate::columnsWidth ( int  total_width) const
Parameters
total_widthThe total width of the titleblock to render
Returns
the list of the columns widths for this rendering

Definition at line 673 of file titleblocktemplate.cpp.

References QET::Absolute, columns_width_, QET::RelativeToRemainingLength, QET::RelativeToTotalLength, TitleBlockDimension::type, and TitleBlockDimension::value.

Referenced by render(), renderDxf(), and width().

◆ columnTypeCount()

int TitleBlockTemplate::columnTypeCount ( QET::TitleBlockColumnLength  type)
Parameters
acolumn type
Returns
the count of type columns

Definition at line 745 of file titleblocktemplate.cpp.

References columns_width_.

Referenced by maximumWidth().

◆ columnTypeTotal()

int TitleBlockTemplate::columnTypeTotal ( QET::TitleBlockColumnLength  type)
Parameters
acolumn type
Returns
the sum of values attached to type columns

Definition at line 759 of file titleblocktemplate.cpp.

References columns_width_.

Referenced by maximumWidth(), and minimumWidth().

◆ createCell()

TitleBlockCell * TitleBlockTemplate::createCell ( const TitleBlockCell existing_cell = nullptr)

Create a new cell and associate it with this template, which means that it will be deleted when this template is destroyed.

Parameters
existing_cell(optional) An existing cell that will be copied
Returns
A pointer to the newly created cell

Definition at line 49 of file titleblocktemplate.cpp.

References registered_cells_.

Referenced by clone(), and createCellsList().

◆ createCellsList()

QList< TitleBlockCell * > TitleBlockTemplate::createCellsList ( int  count)
protected
Parameters
countNumber of cells expected in the list
Returns
a list containing count newly created (and registered) cells
See also
createCell()

Definition at line 60 of file titleblocktemplate.cpp.

References createCell().

Referenced by createColumn(), and createRow().

◆ createColumn()

QList< TitleBlockCell * > TitleBlockTemplate::createColumn ( )
Returns
a new column that fits the current grid

Definition at line 948 of file titleblocktemplate.cpp.

References createCellsList(), and rows_heights_.

Referenced by addColumn(), and initCells().

◆ createRow()

QList< TitleBlockCell * > TitleBlockTemplate::createRow ( )
Returns
a new row that fits the current grid

Definition at line 888 of file titleblocktemplate.cpp.

References columns_width_, and createCellsList().

Referenced by addRow().

◆ exportCellToXml()

void TitleBlockTemplate::exportCellToXml ( TitleBlockCell cell,
QDomElement &  xml_element 
) const
Parameters
xml_elementParent XML element to be used when exporting cell
cellCell to export

Definition at line 161 of file titleblocktemplate.cpp.

References cell(), and saveCell().

◆ finalTextForCell()

QString TitleBlockTemplate::finalTextForCell ( const TitleBlockCell cell,
const DiagramContext diagram_context 
) const
private
Parameters
cellA cell from this template
diagram_contextDiagram context to use to generate the final text for the given cell
Returns
the final text that has to be drawn in the given cell

Definition at line 1343 of file titleblocktemplate.cpp.

References cell(), TitleBlockCell::display_label, interpreteVariables(), NamesList::isEmpty(), TitleBlockCell::label, NamesList::name(), QET::Icons::tr, and TitleBlockCell::value.

Referenced by renderCell(), and renderDxf().

◆ flushCells()

void TitleBlockTemplate::flushCells ( )
private

◆ fontForCell()

QFont TitleBlockTemplate::fontForCell ( const TitleBlockCell cell)
static
Parameters
cellAn existing cell
Returns
The font that should be used to render this cell according to its properties.

Definition at line 70 of file titleblocktemplate.cpp.

References cell(), QETApp::diagramTextsFont(), and TitleBlockCell::font_size.

Referenced by TitleBlockCell::attribute(), TitleBlockTemplateCellWidget::edit(), renderTextCell(), and renderTextCellDxf().

◆ forgetSpanning() [1/2]

void TitleBlockTemplate::forgetSpanning ( )

Set the spanner_cell attribute of every cell to 0.

Definition at line 1494 of file titleblocktemplate.cpp.

References cells_, columns_width_, and rows_heights_.

Referenced by applyCellSpans().

◆ forgetSpanning() [2/2]

void TitleBlockTemplate::forgetSpanning ( TitleBlockCell spanning_cell,
bool  modify_cell = true 
)

Set the spanner_cell attribute of every cell spanned by spanning_cell to 0.

Parameters
modify_cell(Optional, defaults to true) Whether to set row_span and col_span of spanning_cell to 0.

Definition at line 1506 of file titleblocktemplate.cpp.

References TitleBlockCell::Enabled, and spannedCells().

◆ getAllSpans()

QHash< TitleBlockCell *, QPair< int, int > > TitleBlockTemplate::getAllSpans ( ) const

Export the span parameters of all cell in the current grid.

Definition at line 994 of file titleblocktemplate.cpp.

References cells_, columns_width_, and rows_heights_.

◆ height()

int TitleBlockTemplate::height ( ) const
Returns
the total height of this template

Definition at line 819 of file titleblocktemplate.cpp.

References rows_heights_.

Referenced by render().

◆ information()

QString TitleBlockTemplate::information ( ) const
Returns
the information field attached to this template

Definition at line 596 of file titleblocktemplate.cpp.

References information_.

Referenced by saveInformation().

◆ initCells()

void TitleBlockTemplate::initCells ( )
private

Initialize the internal cells grid with the row and column counts. Note that this method does nothing if one of the internal lists columns_width_ and rows_heights_ is empty.

Definition at line 572 of file titleblocktemplate.cpp.

References cells_, columns_width_, createColumn(), registered_cells_, and rows_heights_.

Referenced by loadGrid().

◆ insertColumn()

bool TitleBlockTemplate::insertColumn ( const TitleBlockDimension dimension,
const QList< TitleBlockCell *> &  column,
int  i = -1 
)
Parameters
dimensionSize of the column to be added
columnColumn to be added
iIndex of the column after insertion, -1 meaning "last position"

Definition at line 921 of file titleblocktemplate.cpp.

References cells_, columns_width_, and rowColsChanged().

Referenced by addColumn().

◆ insertRow()

bool TitleBlockTemplate::insertRow ( int  dimension,
const QList< TitleBlockCell *> &  row,
int  i = -1 
)
Parameters
dimensionSize of the row to be added (always absolute, in pixels)
columnRow to be added
iIndex of the column after insertion, -1 meaning "last position"

Definition at line 857 of file titleblocktemplate.cpp.

References cells_, columns_width_, rowColsChanged(), and rows_heights_.

Referenced by addRow().

◆ interpreteVariables()

QString TitleBlockTemplate::interpreteVariables ( const QString &  string,
const DiagramContext diagram_context 
) const
private
Parameters
stringA text containing 0 to n variables, e.g. "%var" or "%{var}"
diagram_contextDiagram context to use to interprete variables
Returns
the provided string with variables replaced by the values from the diagram context

Definition at line 1363 of file titleblocktemplate.cpp.

References DiagramContext::DecreasingLength, and DiagramContext::keys().

Referenced by finalTextForCell().

◆ lengthRange()

int TitleBlockTemplate::lengthRange ( int  start,
int  end,
const QList< int > &  lengths_list 
) const
private
Returns
the width between two borders
Parameters
startstart border number
endend border number

Definition at line 1628 of file titleblocktemplate.cpp.

Referenced by render(), and renderDxf().

◆ listOfVariables()

QStringList TitleBlockTemplate::listOfVariables ( )

Get list of variables.

Returns
The list of string with variables

Definition at line 1376 of file titleblocktemplate.cpp.

References cells_, columns_width_, TitleBlockCell::EmptyCell, and rows_heights_.

◆ loadCell()

void TitleBlockTemplate::loadCell ( const QDomElement &  cell_element)
protected

Load a cell into this template.

Parameters
cell_elementXML element describing a cell within a title block template

Definition at line 402 of file titleblocktemplate.cpp.

References checkCell().

Referenced by loadCells().

◆ loadCells()

bool TitleBlockTemplate::loadCells ( const QDomElement &  xml_element)
protected

Analyze an XML element, looking for grid cells. The grid cells are checked and stored in this object.

Parameters
xml_elementXML element to analyze
Returns
systematically true

Definition at line 385 of file titleblocktemplate.cpp.

References loadCell().

Referenced by loadGrid().

◆ loadFromXmlElement()

bool TitleBlockTemplate::loadFromXmlElement ( const QDomElement &  xml_element)
Parameters
xml_elementAn XML document to read the template from.
Returns
true if the reading succeeds, false otherwise.

Definition at line 105 of file titleblocktemplate.cpp.

References loadGrid(), loadInformation(), loadLogos(), and name_.

Referenced by loadFromXmlFile().

◆ loadFromXmlFile()

bool TitleBlockTemplate::loadFromXmlFile ( const QString &  filepath)

Load a titleblock template from an XML file.

Parameters
filepathA file path to read the template from.
Returns
true if the reading succeeds, false otherwise.

Definition at line 79 of file titleblocktemplate.cpp.

References loadFromXmlElement().

◆ loadGrid()

bool TitleBlockTemplate::loadGrid ( const QDomElement &  xml_element)
protected

Import the grid from a given XML titleblock template.

Parameters
xml_elementAn XML element representing an titleblock template.
Returns
true if the reading succeeds, false otherwise.

Definition at line 305 of file titleblocktemplate.cpp.

References applyCellSpans(), applyRowColNums(), initCells(), loadCells(), parseColumns(), and parseRows().

Referenced by loadFromXmlElement().

◆ loadInformation()

void TitleBlockTemplate::loadInformation ( const QDomElement &  xml_element)
protected

Import text informations from a given XML title block template.

Definition at line 220 of file titleblocktemplate.cpp.

References setInformation().

Referenced by loadFromXmlElement().

◆ loadLogo()

bool TitleBlockTemplate::loadLogo ( const QDomElement &  xml_element)
protected

Import the logo from a given XML logo description.

Parameters
xml_elementAn XML element representing a logo within an titleblock template.
Returns
true if the reading succeeds, false otherwise.

Definition at line 267 of file titleblocktemplate.cpp.

References addLogo().

Referenced by loadLogos().

◆ loadLogos()

bool TitleBlockTemplate::loadLogos ( const QDomElement &  xml_element,
bool  reset = false 
)
protected

Import the logos from a given XML titleblock template.

Parameters
xml_elementAn XML element representing an titleblock template.
resettrue to delete all previously known logos before, false otherwise.
Returns
true if the reading succeeds, false otherwise.

Definition at line 235 of file titleblocktemplate.cpp.

References bitmap_logos_, data_logos_, loadLogo(), storage_logos_, and vector_logos_.

Referenced by loadFromXmlElement(), and ~TitleBlockTemplate().

◆ logos()

QList< QString > TitleBlockTemplate::logos ( ) const
Returns
The names of logos embedded within this title block template.

Definition at line 1166 of file titleblocktemplate.cpp.

References data_logos_.

◆ logoType()

QString TitleBlockTemplate::logoType ( const QString &  logo_name) const
Parameters
logo_nameName of a logo embedded within this title block template.
Returns
the kind of storage used for the required logo, or a null QString if no such logo was found in this template.

Definition at line 1175 of file titleblocktemplate.cpp.

References type_logos_.

◆ maximumWidth()

int TitleBlockTemplate::maximumWidth ( )
Returns
the maximum width for this template, or -1 if it does not have any.

Definition at line 795 of file titleblocktemplate.cpp.

References QET::Absolute, columns_width_, columnTypeCount(), and columnTypeTotal().

◆ minimumWidth()

int TitleBlockTemplate::minimumWidth ( )
Returns
the minimum width for this template

Definition at line 774 of file titleblocktemplate.cpp.

References QET::Absolute, columnTypeTotal(), and QET::RelativeToTotalLength.

◆ moveColumn()

bool TitleBlockTemplate::moveColumn ( int  from,
int  to 
)

Move the column at index "from" to index "to".

Parameters
fromSource index of the moved column
toTarget index of the moved column

Definition at line 898 of file titleblocktemplate.cpp.

References cells_, columns_width_, and rowColsChanged().

◆ moveRow()

bool TitleBlockTemplate::moveRow ( int  from,
int  to 
)

Move a row within this template.

Parameters
fromIndex of the moved row
toArrival index of the moved row

Definition at line 832 of file titleblocktemplate.cpp.

References cells_, columns_width_, rowColsChanged(), and rows_heights_.

◆ name()

QString TitleBlockTemplate::name ( ) const
Returns
the name of this template

Definition at line 589 of file titleblocktemplate.cpp.

References name_.

Referenced by addLogoFromFile().

◆ parseColumns()

void TitleBlockTemplate::parseColumns ( const QString &  cols_string)
private

Parse the columns widths

Parameters
cols_stringA string describing the columns widths of the titleblock

Definition at line 354 of file titleblocktemplate.cpp.

References QET::Absolute, columns_width_, QET::RelativeToRemainingLength, and QET::RelativeToTotalLength.

Referenced by loadGrid().

◆ parseRows()

void TitleBlockTemplate::parseRows ( const QString &  rows_string)
private

Parse the rows heights

Parameters
rows_stringA string describing the rows heights of the titleblock

Definition at line 332 of file titleblocktemplate.cpp.

References rows_heights_.

Referenced by loadGrid().

◆ removeLogo()

bool TitleBlockTemplate::removeLogo ( const QString &  logo_name)
Parameters
logo_nameName of the logo to remove
Returns
true if the logo could be deleted, false otherwise

TODO check existing cells using this logo.

Definition at line 1113 of file titleblocktemplate.cpp.

References bitmap_logos_, data_logos_, storage_logos_, and vector_logos_.

Referenced by addLogo().

◆ renameLogo()

bool TitleBlockTemplate::renameLogo ( const QString &  logo_name,
const QString &  new_name 
)

Rename the logo_name logo to new_name

Parameters
logo_nameName of the logo to be renamed
new_nameNew name of the renamed logo

TODO check existing cells using this logo.

Definition at line 1135 of file titleblocktemplate.cpp.

References bitmap_logos_, data_logos_, storage_logos_, and vector_logos_.

◆ render()

void TitleBlockTemplate::render ( QPainter &  painter,
const DiagramContext diagram_context,
int  titleblock_width 
) const

Render the titleblock.

Parameters
painterPainter to use to render the titleblock
diagram_contextDiagram context to use to generate the titleblock strings
titleblock_widthWidth of the titleblock to render

Definition at line 1212 of file titleblocktemplate.cpp.

References cells_, columns_width_, columnsWidth(), TitleBlockCell::Disabled, TitleBlockCell::EmptyCell, height(), lengthRange(), renderCell(), and rows_heights_.

Referenced by renderCell().

◆ renderCell()

void TitleBlockTemplate::renderCell ( QPainter &  painter,
const TitleBlockCell cell,
const DiagramContext diagram_context,
const QRect &  cell_rect 
) const

Render a titleblock cell.

Parameters
painterPainter to use to render the titleblock
diagram_contextDiagram context to use to generate the titleblock strings
rectRectangle the cell must be rendered into.

Definition at line 1304 of file titleblocktemplate.cpp.

References bitmap_logos_, cell(), finalTextForCell(), TitleBlockCell::logo_reference, TitleBlockCell::LogoCell, render(), renderTextCell(), TitleBlockCell::TextCell, TitleBlockCell::type(), and vector_logos_.

Referenced by render().

◆ renderDxf()

void TitleBlockTemplate::renderDxf ( QRectF &  title_block_rect,
const DiagramContext diagram_context,
int  titleblock_width,
QString &  file_path,
int  color 
) const

Render the titleblock in DXF.

Parameters
diagram_contextDiagram context to use to generate the titleblock strings
titleblock_widthWidth of the titleblock to render

Definition at line 1254 of file titleblocktemplate.cpp.

References cells_, columns_width_, columnsWidth(), TitleBlockCell::Disabled, Createdxf::drawRectangle(), TitleBlockCell::EmptyCell, finalTextForCell(), lengthRange(), renderTextCellDxf(), rows_heights_, Createdxf::sheetHeight, TitleBlockCell::TextCell, Createdxf::xScale, and Createdxf::yScale.

◆ renderTextCell()

void TitleBlockTemplate::renderTextCell ( QPainter &  painter,
const QString &  text,
const TitleBlockCell cell,
const QRectF &  cell_rect 
) const
private

This method uses a painter to render the text of a cell into the cell_rect rectangle. The alignment, font_size and other cell parameters are taken into account when rendering.

Parameters
painterQPainter used to render the text
textText to render
cellCell the rendered text is rattached to
cell_rectRectangle delimiting the cell area

Definition at line 1400 of file titleblocktemplate.cpp.

References TitleBlockCell::alignment, cell(), fontForCell(), and TitleBlockCell::hadjust.

Referenced by renderCell().

◆ renderTextCellDxf()

void TitleBlockTemplate::renderTextCellDxf ( QString &  file_path,
const QString &  text,
const TitleBlockCell cell,
qreal  x,
qreal  y,
qreal  w,
qreal  h,
int  color 
) const
private

◆ rowColsChanged()

void TitleBlockTemplate::rowColsChanged ( )

Take care of consistency and span-related problematics when adding/moving/deleting rows and columns.

Definition at line 1618 of file titleblocktemplate.cpp.

References applyCellSpans(), and applyRowColNums().

Referenced by insertColumn(), insertRow(), moveColumn(), moveRow(), takeColumn(), and takeRow().

◆ rowDimension()

int TitleBlockTemplate::rowDimension ( int  i)
Parameters
irow index
Returns
the height of the row at index i

Definition at line 611 of file titleblocktemplate.cpp.

References rows_heights_.

◆ rowsCount()

int TitleBlockTemplate::rowsCount ( ) const
Returns
the number of rows in this template

Definition at line 665 of file titleblocktemplate.cpp.

References rows_heights_.

Referenced by checkCellSpan().

◆ rowsHeights()

QList< int > TitleBlockTemplate::rowsHeights ( ) const
Returns
the heights of all the rows in this template

Definition at line 737 of file titleblocktemplate.cpp.

References rows_heights_.

◆ saveCell()

void TitleBlockTemplate::saveCell ( TitleBlockCell cell,
QDomElement &  xml_element,
bool  save_empty = false 
) const
protected

Export a specific cell as XML

Parameters
cellCell to be exported as XML
xml_elementXML element under which the <cell> element will be attached
save_emptyIf true, the cell will be saved even if it is an empty one

Definition at line 495 of file titleblocktemplate.cpp.

References cell(), and TitleBlockCell::EmptyCell.

Referenced by exportCellToXml(), and saveCells().

◆ saveCells()

void TitleBlockTemplate::saveCells ( QDomElement &  xml_element) const
protected

Export this template's cells as XML (without the grid-related information, usch as rows and cols)

Parameters
xml_elementXML element under which the <cell> elements will be attached

Definition at line 479 of file titleblocktemplate.cpp.

References cells_, columns_width_, TitleBlockCell::EmptyCell, rows_heights_, and saveCell().

Referenced by saveGrid().

◆ saveGrid()

void TitleBlockTemplate::saveGrid ( QDomElement &  xml_element) const
protected

Export this template's cells grid as XML

Parameters
xml_elementXML element under which the <grid> element will be attached

Definition at line 461 of file titleblocktemplate.cpp.

References columns_width_, rows_heights_, saveCells(), and TitleBlockDimension::toShortString().

Referenced by saveToXmlElement().

◆ saveInformation()

void TitleBlockTemplate::saveInformation ( QDomElement &  xml_element) const
protected

Export this template's extra information.

Parameters
xml_elementXML element under which extra informations will be attached

Definition at line 412 of file titleblocktemplate.cpp.

References information().

Referenced by saveToXmlElement().

◆ saveLogo()

void TitleBlockTemplate::saveLogo ( const QString &  logo_name,
QDomElement &  xml_element 
) const
protected

Export a specific logo as XML

Parameters
logo_nameName of the logo to be exported
xml_elementXML element in which the logo will be exported

Definition at line 439 of file titleblocktemplate.cpp.

References data_logos_, storage_logos_, and type_logos_.

Referenced by saveLogos().

◆ saveLogos()

void TitleBlockTemplate::saveLogos ( QDomElement &  xml_element) const
protected

Export this template's logos as XML

Parameters
xml_elementXML Element under which the <logos> element will be attached

Definition at line 424 of file titleblocktemplate.cpp.

References saveLogo(), and type_logos_.

Referenced by saveToXmlElement().

◆ saveLogoToFile()

bool TitleBlockTemplate::saveLogoToFile ( const QString &  logo_name,
const QString &  filepath 
)

Definition at line 1094 of file titleblocktemplate.cpp.

References data_logos_.

◆ saveToXmlElement()

bool TitleBlockTemplate::saveToXmlElement ( QDomElement &  xml_element) const

Save the title block template as XML.

Parameters
xml_elementThe XML element this title block template should be saved to.
Returns
true if the export succeeds, false otherwise

Definition at line 145 of file titleblocktemplate.cpp.

References name_, saveGrid(), saveInformation(), and saveLogos().

Referenced by saveToXmlFile().

◆ saveToXmlFile()

bool TitleBlockTemplate::saveToXmlFile ( const QString &  filepath)

Save the title block template into an XML file.

Parameters
filepathThe file path this title block template should be saved to.
Returns
true if the operation succeeds, false otherwise

Definition at line 127 of file titleblocktemplate.cpp.

References saveToXmlElement(), and QET::writeXmlFile().

◆ setAllSpans()

void TitleBlockTemplate::setAllSpans ( const QHash< TitleBlockCell *, QPair< int, int > > &  spans)

Restore a set of span parameters.

Definition at line 1013 of file titleblocktemplate.cpp.

References cell().

◆ setColumnDimension()

void TitleBlockTemplate::setColumnDimension ( int  i,
const TitleBlockDimension dimension 
)

Set the width of a column

Parameters
icolumn index
dimensionNew width of the column at index i

Definition at line 648 of file titleblocktemplate.cpp.

References columns_width_.

◆ setInformation()

void TitleBlockTemplate::setInformation ( const QString &  info)
Parameters
infoinformation to be attached to this template

Definition at line 603 of file titleblocktemplate.cpp.

References information_.

Referenced by loadInformation().

◆ setLogoStorage()

void TitleBlockTemplate::setLogoStorage ( const QString &  logo_name,
const QString &  storage 
)

Set the kind of storage for the logo_name logo.

Parameters
logo_nameName of the logo which kind of storage is to be changed
storageThe kind of storage to use for the logo, e.g. "xml" or "base64".

Definition at line 1157 of file titleblocktemplate.cpp.

References storage_logos_.

◆ setRowDimension()

void TitleBlockTemplate::setRowDimension ( int  i,
const TitleBlockDimension dimension 
)

Set the height of a row

Parameters
irow index
dimensionNew height of the row at index i

Definition at line 624 of file titleblocktemplate.cpp.

References rows_heights_, and TitleBlockDimension::value.

◆ spannedCells()

QSet< TitleBlockCell * > TitleBlockTemplate::spannedCells ( const TitleBlockCell given_cell,
bool  ignore_span_state = false 
) const
Parameters
cellA cell belonging to this title block template
ignore_span_state(Optional, defaults to false) If true, will consider cells theoretically spanned (i.e. row_span and col_span attributes). Otherwise, will take span_state attribute into account.
Returns
the set of cells spanned by the provided cell Note the returned set does not include the spanning, provided cell

Definition at line 972 of file titleblocktemplate.cpp.

References cell(), and TitleBlockCell::Disabled.

Referenced by forgetSpanning().

◆ takeColumn()

QList< TitleBlockCell * > TitleBlockTemplate::takeColumn ( int  i)

Removes the column at index i

Parameters
iIndex of the column to be removed
Returns
the removed column

Definition at line 934 of file titleblocktemplate.cpp.

References cells_, columns_width_, and rowColsChanged().

◆ takeRow()

QList< TitleBlockCell * > TitleBlockTemplate::takeRow ( int  i)

Removes the row at index i

Parameters
iIndex of the column to be removed
Returns
the removed column

Definition at line 873 of file titleblocktemplate.cpp.

References cells_, columns_width_, rowColsChanged(), and rows_heights_.

◆ vectorLogo()

QSvgRenderer * TitleBlockTemplate::vectorLogo ( const QString &  logo_name) const
Parameters
logo_nameName of a vector logo embedded within this title block template.
Returns
the rendering object for the required vector logo, or 0 if no such vector logo was found in this template.

Definition at line 1187 of file titleblocktemplate.cpp.

References vector_logos_.

◆ width()

int TitleBlockTemplate::width ( int  total_width)
Returns
the total effective width of this template
Parameters
total_widthThe total width initially planned for the rendering

Definition at line 808 of file titleblocktemplate.cpp.

References columnsWidth().

Member Data Documentation

◆ bitmap_logos_

QHash<QString, QPixmap> TitleBlockTemplate::bitmap_logos_
private

Pixmaps for bitmap logos.

Definition at line 147 of file titleblocktemplate.h.

Referenced by addLogo(), bitmapLogo(), clone(), loadLogos(), removeLogo(), renameLogo(), and renderCell().

◆ cells_

QList< QList<TitleBlockCell *> > TitleBlockTemplate::cells_
private

◆ columns_width_

QList<TitleBlockDimension> TitleBlockTemplate::columns_width_
private

◆ data_logos_

QHash<QString, QByteArray > TitleBlockTemplate::data_logos_
private

Logos raw data.

Definition at line 143 of file titleblocktemplate.h.

Referenced by addLogo(), clone(), loadLogos(), logos(), removeLogo(), renameLogo(), saveLogo(), and saveLogoToFile().

◆ information_

QString TitleBlockTemplate::information_
private

Definition at line 141 of file titleblocktemplate.h.

Referenced by clone(), information(), and setInformation().

◆ name_

QString TitleBlockTemplate::name_
private

name identifying the Title Block Template within its parent collection

Definition at line 140 of file titleblocktemplate.h.

Referenced by clone(), loadFromXmlElement(), name(), and saveToXmlElement().

◆ registered_cells_

QList<TitleBlockCell *> TitleBlockTemplate::registered_cells_
private

Cells objects created rattached to this template, but not mandatorily used.

Definition at line 151 of file titleblocktemplate.h.

Referenced by createCell(), initCells(), and ~TitleBlockTemplate().

◆ rows_heights_

QList<int> TitleBlockTemplate::rows_heights_
private

◆ storage_logos_

QHash<QString, QString> TitleBlockTemplate::storage_logos_
private

Logos applied storage type (e.g. "xml" or "base64")

Definition at line 144 of file titleblocktemplate.h.

Referenced by addLogo(), clone(), loadLogos(), removeLogo(), renameLogo(), saveLogo(), and setLogoStorage().

◆ type_logos_

QHash<QString, QString> TitleBlockTemplate::type_logos_
private

Logos types (e.g. "png", "jpeg", "svg")

Definition at line 145 of file titleblocktemplate.h.

Referenced by addLogo(), clone(), logoType(), saveLogo(), and saveLogos().

◆ vector_logos_

QHash<QString, QSvgRenderer *> TitleBlockTemplate::vector_logos_
private

Rendered objects for vector logos.

Definition at line 146 of file titleblocktemplate.h.

Referenced by addLogo(), clone(), loadLogos(), removeLogo(), renameLogo(), renderCell(), and vectorLogo().


The documentation for this class was generated from the following files: