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 #ifndef TITLEBLOCK_CELL_H
19 #define TITLEBLOCK_CELL_H
20 #include "nameslist.h"
21 
22 /**
23 	This class is a container for the various parameters of a titleblock cell
24 	@see TitleBlockColumnLength
25 */
26 class TitleBlockCell {
27 	public:
28 	enum TemplateCellType {
29 		EmptyCell,
30 		TextCell,
31 		LogoCell
32 	};
33 	enum TemplateCellSpanState {
34 		Disabled,     ///< the cell span parameters should not applied at all
35 		Enabled,      ///< the cell span parameters should be applied without restriction
36 		Restricted    ///< the cell span parameters should be applied with some restrictions
37 	};
38 
39 	// Constructor, destructor
40 	public:
41 	TitleBlockCell();
42 	virtual ~TitleBlockCell();
43 
44 	// methods
45 	public:
46 	TemplateCellType type() const;
47 	int horizontalAlign() const;
48 	int verticalAlign() const;
49 	void setAttribute(const QString &, const QVariant &);
50 	QVariant attribute(const QString &);
51 	static QString attributeName(const QString &);
52 	bool spans() const;
53 	void loadContentFromCell(const TitleBlockCell &);
54 	void loadContentFromXml(const QDomElement &);
55 	void saveContentToXml(QDomElement &);
56 
57 
58 	// attributes
59 	public:
60 	TemplateCellType cell_type;        ///< Cell type: empty, text, logo?
61 	int num_row;                       ///< y coordinate of the cell within its parent title block template grid
62 	int num_col;                       ///< x coordinate of the cell within its parent title block template grid
63 	int row_span;                      ///< number of extra rows spanned by this cell
64 	int col_span;                      ///< number of extra columns spanned by this cell
65 	int span_state;                    ///< how should row_span and col_span be applied given other cells in the parent template
66 	int applied_row_span;              ///< Actually applied row span
67 	int applied_col_span;              ///< Actually applied column span
68 	TitleBlockCell *spanner_cell;      ///< Cell spanning this cell, if any
69 	QString value_name;                ///< name of the cell; not displayed when the title block template is rendered
70 	NamesList value;                   ///< Text displayed by the cell
71 	NamesList label;                   ///< Label displayed by the cell
72 	bool display_label;                ///< Whether to display the label or not
73 	int alignment;                     ///< Where the label+text should be displayed within the visual cell
74 	int font_size;                     ///< Font size the text should be rendered with
75 	bool hadjust;                      ///< Whether to reduce the font size if the text does not fit in the cell
76 	QString logo_reference;            ///< Logo displayed by this cell, it it is a logo cell
77 };
78 #endif
79