mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Changed every occurence in the code of the "inset" term to "title block".
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1132 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -180,7 +180,7 @@
|
|||||||
<file>ico/oxygen-icons/48x48/apps/qelectrotech.png</file>
|
<file>ico/oxygen-icons/48x48/apps/qelectrotech.png</file>
|
||||||
<file>ico/oxygen-icons/64x64/apps/qelectrotech.png</file>
|
<file>ico/oxygen-icons/64x64/apps/qelectrotech.png</file>
|
||||||
<file>ico/splash.png</file>
|
<file>ico/splash.png</file>
|
||||||
<file>insets/default.inset</file>
|
<file>titleblocks/default.titleblock</file>
|
||||||
<file>LICENSE</file>
|
<file>LICENSE</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "borderpropertieswidget.h"
|
#include "borderpropertieswidget.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "borderinset.h"
|
#include "bordertitleblock.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -99,11 +99,11 @@ void BorderPropertiesWidget::build() {
|
|||||||
QLabel *ds1 = new QLabel(tr("Colonnes :"));
|
QLabel *ds1 = new QLabel(tr("Colonnes :"));
|
||||||
|
|
||||||
columns_count = new QSpinBox(diagram_size_box);
|
columns_count = new QSpinBox(diagram_size_box);
|
||||||
columns_count -> setMinimum(BorderInset::minNbColumns());
|
columns_count -> setMinimum(BorderTitleBlock::minNbColumns());
|
||||||
columns_count -> setMaximum(10000); // valeur arbitraire
|
columns_count -> setMaximum(10000); // valeur arbitraire
|
||||||
|
|
||||||
columns_width = new QSpinBox(diagram_size_box);
|
columns_width = new QSpinBox(diagram_size_box);
|
||||||
columns_width -> setMinimum(qRound(BorderInset::minColumnsWidth()));
|
columns_width -> setMinimum(qRound(BorderTitleBlock::minColumnsWidth()));
|
||||||
columns_width -> setSingleStep(10);
|
columns_width -> setSingleStep(10);
|
||||||
columns_width -> setPrefix(tr("\327", "multiplication symbol"));
|
columns_width -> setPrefix(tr("\327", "multiplication symbol"));
|
||||||
columns_width -> setSuffix(tr("px", "unit for cols width"));
|
columns_width -> setSuffix(tr("px", "unit for cols width"));
|
||||||
@@ -114,11 +114,11 @@ void BorderPropertiesWidget::build() {
|
|||||||
QLabel *ds2 = new QLabel(tr("Lignes :"));
|
QLabel *ds2 = new QLabel(tr("Lignes :"));
|
||||||
|
|
||||||
rows_count = new QSpinBox(diagram_size_box);
|
rows_count = new QSpinBox(diagram_size_box);
|
||||||
rows_count -> setMinimum(BorderInset::minNbRows());
|
rows_count -> setMinimum(BorderTitleBlock::minNbRows());
|
||||||
rows_count -> setMaximum(10000); // valeur arbitraire
|
rows_count -> setMaximum(10000); // valeur arbitraire
|
||||||
|
|
||||||
rows_height = new QSpinBox(diagram_size_box);
|
rows_height = new QSpinBox(diagram_size_box);
|
||||||
rows_height -> setMinimum(qRound(BorderInset::minRowsHeight()));
|
rows_height -> setMinimum(qRound(BorderTitleBlock::minRowsHeight()));
|
||||||
rows_height -> setSingleStep(10);
|
rows_height -> setSingleStep(10);
|
||||||
rows_height -> setPrefix(tr("\327", "multiplication symbol"));
|
rows_height -> setPrefix(tr("\327", "multiplication symbol"));
|
||||||
rows_height -> setSuffix(tr("px", "unit for rows height"));
|
rows_height -> setSuffix(tr("px", "unit for rows height"));
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class QSpinBox;
|
|||||||
/**
|
/**
|
||||||
Cette classe represente un widget permettant d'editer les dimensions et les
|
Cette classe represente un widget permettant d'editer les dimensions et les
|
||||||
options d'affichage d'un schema, cartouche non inclus.
|
options d'affichage d'un schema, cartouche non inclus.
|
||||||
@see InsetPropertiesWidget
|
@see TitleBlockPropertiesWidget
|
||||||
*/
|
*/
|
||||||
class BorderPropertiesWidget : public QWidget {
|
class BorderPropertiesWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "insettemplate.h"
|
#include "titleblocktemplate.h"
|
||||||
#include "insettemplaterenderer.h"
|
#include "titleblocktemplaterenderer.h"
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
#include "borderinset.h"
|
#include "bordertitleblock.h"
|
||||||
#include "diagramposition.h"
|
#include "diagramposition.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
@@ -27,22 +27,22 @@
|
|||||||
/**
|
/**
|
||||||
Constructeur simple : construit une bordure en recuperant les dimensions
|
Constructeur simple : construit une bordure en recuperant les dimensions
|
||||||
dans la configuration de l'application.
|
dans la configuration de l'application.
|
||||||
@param parent QObject parent de ce BorderInset
|
@param parent QObject parent de ce BorderTitleBlock
|
||||||
*/
|
*/
|
||||||
BorderInset::BorderInset(QObject *parent) :
|
BorderTitleBlock::BorderTitleBlock(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
// at first, the internal inset template renderer uses the default inset template
|
// at first, the internal titleblock template renderer uses the default titleblock template
|
||||||
inset_template_renderer = new InsetTemplateRenderer(this);
|
titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
|
||||||
inset_template_renderer -> setInsetTemplate(QETApp::defaultInsetTemplate());
|
titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
|
||||||
|
|
||||||
// dimensions par defaut du schema
|
// dimensions par defaut du schema
|
||||||
importBorder(BorderProperties());
|
importBorder(BorderProperties());
|
||||||
|
|
||||||
// contenu par defaut du cartouche
|
// contenu par defaut du cartouche
|
||||||
importInset(InsetProperties());
|
importTitleBlock(TitleBlockProperties());
|
||||||
|
|
||||||
display_inset = true;
|
display_titleblock = true;
|
||||||
display_border = true;
|
display_border = true;
|
||||||
setFolioData(1, 1);
|
setFolioData(1, 1);
|
||||||
updateRectangles();
|
updateRectangles();
|
||||||
@@ -51,49 +51,49 @@ BorderInset::BorderInset(QObject *parent) :
|
|||||||
/**
|
/**
|
||||||
Destructeur - ne fait rien
|
Destructeur - ne fait rien
|
||||||
*/
|
*/
|
||||||
BorderInset::~BorderInset() {
|
BorderTitleBlock::~BorderTitleBlock() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return la hauteur du cartouche
|
@return la hauteur du cartouche
|
||||||
*/
|
*/
|
||||||
qreal BorderInset::insetHeight() const {
|
qreal BorderTitleBlock::titleBlockHeight() const {
|
||||||
return(inset_template_renderer -> height());
|
return(titleblock_template_renderer -> height());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le nombre minimum de colonnes qu'un schema doit comporter
|
@return Le nombre minimum de colonnes qu'un schema doit comporter
|
||||||
*/
|
*/
|
||||||
int BorderInset::minNbColumns() {
|
int BorderTitleBlock::minNbColumns() {
|
||||||
return(3);
|
return(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return la largeur minimale d'une colonne de schema
|
@return la largeur minimale d'une colonne de schema
|
||||||
*/
|
*/
|
||||||
qreal BorderInset::minColumnsWidth() {
|
qreal BorderTitleBlock::minColumnsWidth() {
|
||||||
return(5.0);
|
return(5.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le nombre minimum de lignes qu'un schema doit comporter
|
@return Le nombre minimum de lignes qu'un schema doit comporter
|
||||||
*/
|
*/
|
||||||
int BorderInset::minNbRows() {
|
int BorderTitleBlock::minNbRows() {
|
||||||
return(2);
|
return(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return la hauteur minimale d'une ligne de schema
|
@return la hauteur minimale d'une ligne de schema
|
||||||
*/
|
*/
|
||||||
qreal BorderInset::minRowsHeight() {
|
qreal BorderTitleBlock::minRowsHeight() {
|
||||||
return(5.0);
|
return(5.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return les proprietes du cartouches
|
@return les proprietes du cartouches
|
||||||
*/
|
*/
|
||||||
InsetProperties BorderInset::exportInset() {
|
TitleBlockProperties BorderTitleBlock::exportTitleBlock() {
|
||||||
InsetProperties ip;
|
TitleBlockProperties ip;
|
||||||
ip.author = bi_author;
|
ip.author = bi_author;
|
||||||
ip.date = bi_date;
|
ip.date = bi_date;
|
||||||
ip.title = bi_title;
|
ip.title = bi_title;
|
||||||
@@ -105,20 +105,20 @@ InsetProperties BorderInset::exportInset() {
|
|||||||
/**
|
/**
|
||||||
@param ip les nouvelles proprietes du cartouche
|
@param ip les nouvelles proprietes du cartouche
|
||||||
*/
|
*/
|
||||||
void BorderInset::importInset(const InsetProperties &ip) {
|
void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
|
||||||
bi_author = ip.author;
|
bi_author = ip.author;
|
||||||
bi_date = ip.date;
|
bi_date = ip.date;
|
||||||
setTitle(ip.title);
|
setTitle(ip.title);
|
||||||
bi_folio = ip.folio;
|
bi_folio = ip.folio;
|
||||||
bi_filename = ip.filename;
|
bi_filename = ip.filename;
|
||||||
updateDiagramContextForInset();
|
updateDiagramContextForTitleBlock();
|
||||||
emit(needFolioData());
|
emit(needFolioData());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return les proprietes de la bordure
|
@return les proprietes de la bordure
|
||||||
*/
|
*/
|
||||||
BorderProperties BorderInset::exportBorder() {
|
BorderProperties BorderTitleBlock::exportBorder() {
|
||||||
BorderProperties bp;
|
BorderProperties bp;
|
||||||
bp.columns_count = nbColumns();
|
bp.columns_count = nbColumns();
|
||||||
bp.columns_width = columnsWidth();
|
bp.columns_width = columnsWidth();
|
||||||
@@ -134,7 +134,7 @@ BorderProperties BorderInset::exportBorder() {
|
|||||||
/**
|
/**
|
||||||
@param bp les nouvelles proprietes de la bordure
|
@param bp les nouvelles proprietes de la bordure
|
||||||
*/
|
*/
|
||||||
void BorderInset::importBorder(const BorderProperties &bp) {
|
void BorderTitleBlock::importBorder(const BorderProperties &bp) {
|
||||||
setColumnsHeaderHeight(bp.columns_header_height);
|
setColumnsHeaderHeight(bp.columns_header_height);
|
||||||
setNbColumns(bp.columns_count);
|
setNbColumns(bp.columns_count);
|
||||||
setColumnsWidth(bp.columns_width);
|
setColumnsWidth(bp.columns_width);
|
||||||
@@ -146,34 +146,34 @@ void BorderInset::importBorder(const BorderProperties &bp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the inset template used to render the inset
|
@return the titleblock template used to render the titleblock
|
||||||
@see InsetTemplateRenderer::insetTemplate()
|
@see TitleBlockTemplateRenderer::titleBlockTemplate()
|
||||||
*/
|
*/
|
||||||
const InsetTemplate *BorderInset::insetTemplate() {
|
const TitleBlockTemplate *BorderTitleBlock::titleBlockTemplate() {
|
||||||
return(inset_template_renderer -> insetTemplate());
|
return(titleblock_template_renderer -> titleBlockTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param inset_template The new inset template to use to render the inset
|
@param titleblock_template The new titleblock template to use to render the titleblock
|
||||||
@see InsetTemplateRenderer::setInsetTemplate()
|
@see TitleBlockTemplateRenderer::setTitleBlockTemplate()
|
||||||
*/
|
*/
|
||||||
void BorderInset::setInsetTemplate(const InsetTemplate *inset_template) {
|
void BorderTitleBlock::setTitleBlockTemplate(const TitleBlockTemplate *titleblock_template) {
|
||||||
inset_template_renderer -> setInsetTemplate(inset_template);
|
titleblock_template_renderer -> setTitleBlockTemplate(titleblock_template);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param di true pour afficher le cartouche, false sinon
|
@param di true pour afficher le cartouche, false sinon
|
||||||
*/
|
*/
|
||||||
void BorderInset::displayInset(bool di) {
|
void BorderTitleBlock::displayTitleBlock(bool di) {
|
||||||
bool change = (di != display_inset);
|
bool change = (di != display_titleblock);
|
||||||
display_inset = di;
|
display_titleblock = di;
|
||||||
if (change) emit(displayChanged());
|
if (change) emit(displayChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param dc true pour afficher les entetes des colonnes, false sinon
|
@param dc true pour afficher les entetes des colonnes, false sinon
|
||||||
*/
|
*/
|
||||||
void BorderInset::displayColumns(bool dc) {
|
void BorderTitleBlock::displayColumns(bool dc) {
|
||||||
bool change = (dc != display_columns);
|
bool change = (dc != display_columns);
|
||||||
display_columns = dc;
|
display_columns = dc;
|
||||||
if (change) emit(displayChanged());
|
if (change) emit(displayChanged());
|
||||||
@@ -182,7 +182,7 @@ void BorderInset::displayColumns(bool dc) {
|
|||||||
/**
|
/**
|
||||||
@param dr true pour afficher les entetes des lignes, false sinon
|
@param dr true pour afficher les entetes des lignes, false sinon
|
||||||
*/
|
*/
|
||||||
void BorderInset::displayRows(bool dr) {
|
void BorderTitleBlock::displayRows(bool dr) {
|
||||||
bool change = (dr != display_rows);
|
bool change = (dr != display_rows);
|
||||||
display_rows = dr;
|
display_rows = dr;
|
||||||
if (change) emit(displayChanged());
|
if (change) emit(displayChanged());
|
||||||
@@ -193,7 +193,7 @@ void BorderInset::displayRows(bool dr) {
|
|||||||
Note : si l'affichage de la bordure est ainsi desactivee, les lignes et
|
Note : si l'affichage de la bordure est ainsi desactivee, les lignes et
|
||||||
colonnes ne seront pas dessinees.
|
colonnes ne seront pas dessinees.
|
||||||
*/
|
*/
|
||||||
void BorderInset::displayBorder(bool db) {
|
void BorderTitleBlock::displayBorder(bool db) {
|
||||||
bool change = (db != display_border);
|
bool change = (db != display_border);
|
||||||
display_border = db;
|
display_border = db;
|
||||||
if (change) emit(displayChanged());
|
if (change) emit(displayChanged());
|
||||||
@@ -203,14 +203,14 @@ void BorderInset::displayBorder(bool db) {
|
|||||||
Methode recalculant les rectangles composant le cadre et le cartouche en
|
Methode recalculant les rectangles composant le cadre et le cartouche en
|
||||||
fonction des attributs de taille
|
fonction des attributs de taille
|
||||||
*/
|
*/
|
||||||
void BorderInset::updateRectangles() {
|
void BorderTitleBlock::updateRectangles() {
|
||||||
// rectangle delimitant le schema
|
// rectangle delimitant le schema
|
||||||
QRectF previous_diagram = diagram;
|
QRectF previous_diagram = diagram;
|
||||||
diagram = QRectF(0, 0, diagramWidth(), diagramHeight());
|
diagram = QRectF(0, 0, diagramWidth(), diagramHeight());
|
||||||
if (diagram != previous_diagram) emit(borderChanged(previous_diagram, diagram));
|
if (diagram != previous_diagram) emit(borderChanged(previous_diagram, diagram));
|
||||||
|
|
||||||
// rectangles relatifs au cartouche
|
// rectangles relatifs au cartouche
|
||||||
inset = QRectF(diagram.bottomLeft().x(), diagram.bottomLeft().y(), insetWidth(), insetHeight());
|
titleblock = QRectF(diagram.bottomLeft().x(), diagram.bottomLeft().y(), titleBlockWidth(), titleBlockHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,10 +219,10 @@ void BorderInset::updateRectangles() {
|
|||||||
@param x Abscisse du cadre
|
@param x Abscisse du cadre
|
||||||
@param y Ordonnee du cadre
|
@param y Ordonnee du cadre
|
||||||
*/
|
*/
|
||||||
void BorderInset::draw(QPainter *qp, qreal x, qreal y) {
|
void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) {
|
||||||
// translate tous les rectangles
|
// translate tous les rectangles
|
||||||
diagram .translate(x, y);
|
diagram .translate(x, y);
|
||||||
inset .translate(x, y);
|
titleblock .translate(x, y);
|
||||||
|
|
||||||
// prepare le QPainter
|
// prepare le QPainter
|
||||||
qp -> save();
|
qp -> save();
|
||||||
@@ -276,24 +276,24 @@ void BorderInset::draw(QPainter *qp, qreal x, qreal y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the inset, using the InsetTemplate object
|
// render the titleblock, using the TitleBlockTemplate object
|
||||||
if (display_inset) {
|
if (display_titleblock) {
|
||||||
qp -> translate(inset.topLeft());
|
qp -> translate(titleblock.topLeft());
|
||||||
inset_template_renderer -> render(qp, inset.width());
|
titleblock_template_renderer -> render(qp, titleblock.width());
|
||||||
qp -> translate(-inset.topLeft());
|
qp -> translate(-titleblock.topLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
qp -> restore();
|
qp -> restore();
|
||||||
|
|
||||||
// annule la translation des rectangles
|
// annule la translation des rectangles
|
||||||
diagram .translate(-x, -y);
|
diagram .translate(-x, -y);
|
||||||
inset .translate(-x, -y);
|
titleblock .translate(-x, -y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ajoute une colonne.
|
Ajoute une colonne.
|
||||||
*/
|
*/
|
||||||
void BorderInset::addColumn() {
|
void BorderTitleBlock::addColumn() {
|
||||||
setNbColumns(nbColumns() + 1);
|
setNbColumns(nbColumns() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,14 +301,14 @@ void BorderInset::addColumn() {
|
|||||||
Enleve une colonne sans passer sous le minimum requis.
|
Enleve une colonne sans passer sous le minimum requis.
|
||||||
@see minNbColumns()
|
@see minNbColumns()
|
||||||
*/
|
*/
|
||||||
void BorderInset::removeColumn() {
|
void BorderTitleBlock::removeColumn() {
|
||||||
setNbColumns(nbColumns() - 1);
|
setNbColumns(nbColumns() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ajoute une ligne.
|
Ajoute une ligne.
|
||||||
*/
|
*/
|
||||||
void BorderInset::addRow() {
|
void BorderTitleBlock::addRow() {
|
||||||
setNbRows(nbRows() + 1);
|
setNbRows(nbRows() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ void BorderInset::addRow() {
|
|||||||
Enleve une ligne sans passer sous le minimum requis.
|
Enleve une ligne sans passer sous le minimum requis.
|
||||||
@see minNbRows()
|
@see minNbRows()
|
||||||
*/
|
*/
|
||||||
void BorderInset::removeRow() {
|
void BorderTitleBlock::removeRow() {
|
||||||
setNbRows(nbRows() - 1);
|
setNbRows(nbRows() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,10 +327,10 @@ void BorderInset::removeRow() {
|
|||||||
@param nb_c nouveau nombre de colonnes
|
@param nb_c nouveau nombre de colonnes
|
||||||
@see minNbColumns()
|
@see minNbColumns()
|
||||||
*/
|
*/
|
||||||
void BorderInset::setNbColumns(int nb_c) {
|
void BorderTitleBlock::setNbColumns(int nb_c) {
|
||||||
if (nb_c == nbColumns()) return;
|
if (nb_c == nbColumns()) return;
|
||||||
nb_columns = qMax(minNbColumns(), nb_c);
|
nb_columns = qMax(minNbColumns(), nb_c);
|
||||||
setInsetWidth(diagramWidth());
|
setTitleBlockWidth(diagramWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,10 +340,10 @@ void BorderInset::setNbColumns(int nb_c) {
|
|||||||
@param new_cw nouvelle largeur des colonnes
|
@param new_cw nouvelle largeur des colonnes
|
||||||
@see minColumnsWidth()
|
@see minColumnsWidth()
|
||||||
*/
|
*/
|
||||||
void BorderInset::setColumnsWidth(const qreal &new_cw) {
|
void BorderTitleBlock::setColumnsWidth(const qreal &new_cw) {
|
||||||
if (new_cw == columnsWidth()) return;
|
if (new_cw == columnsWidth()) return;
|
||||||
columns_width = qMax(minColumnsWidth(), new_cw);
|
columns_width = qMax(minColumnsWidth(), new_cw);
|
||||||
setInsetWidth(diagramWidth());
|
setTitleBlockWidth(diagramWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -351,7 +351,7 @@ void BorderInset::setColumnsWidth(const qreal &new_cw) {
|
|||||||
doit rester comprise entre 5 et 50 px.
|
doit rester comprise entre 5 et 50 px.
|
||||||
@param new_chh nouvelle hauteur des en-tetes de colonnes
|
@param new_chh nouvelle hauteur des en-tetes de colonnes
|
||||||
*/
|
*/
|
||||||
void BorderInset::setColumnsHeaderHeight(const qreal &new_chh) {
|
void BorderTitleBlock::setColumnsHeaderHeight(const qreal &new_chh) {
|
||||||
columns_header_height = qBound(qreal(5.0), new_chh, qreal(50.0));
|
columns_header_height = qBound(qreal(5.0), new_chh, qreal(50.0));
|
||||||
updateRectangles();
|
updateRectangles();
|
||||||
}
|
}
|
||||||
@@ -363,10 +363,10 @@ void BorderInset::setColumnsHeaderHeight(const qreal &new_chh) {
|
|||||||
@param nb_r nouveau nombre de lignes
|
@param nb_r nouveau nombre de lignes
|
||||||
@see minNbRows()
|
@see minNbRows()
|
||||||
*/
|
*/
|
||||||
void BorderInset::setNbRows(int nb_r) {
|
void BorderTitleBlock::setNbRows(int nb_r) {
|
||||||
if (nb_r == nbRows()) return;
|
if (nb_r == nbRows()) return;
|
||||||
nb_rows = qMax(minNbRows(), nb_r);
|
nb_rows = qMax(minNbRows(), nb_r);
|
||||||
setInsetWidth(diagramWidth());
|
setTitleBlockWidth(diagramWidth());
|
||||||
updateRectangles();
|
updateRectangles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ void BorderInset::setNbRows(int nb_r) {
|
|||||||
@param new_rh nouvelle hauteur des lignes
|
@param new_rh nouvelle hauteur des lignes
|
||||||
@see minRowsHeight()
|
@see minRowsHeight()
|
||||||
*/
|
*/
|
||||||
void BorderInset::setRowsHeight(const qreal &new_rh) {
|
void BorderTitleBlock::setRowsHeight(const qreal &new_rh) {
|
||||||
if (new_rh == rowsHeight()) return;
|
if (new_rh == rowsHeight()) return;
|
||||||
rows_height = qMax(minRowsHeight(), new_rh);
|
rows_height = qMax(minRowsHeight(), new_rh);
|
||||||
updateRectangles();
|
updateRectangles();
|
||||||
@@ -388,7 +388,7 @@ void BorderInset::setRowsHeight(const qreal &new_rh) {
|
|||||||
doit rester comprise entre 5 et 50 px.
|
doit rester comprise entre 5 et 50 px.
|
||||||
@param new_rhw nouvelle largeur des en-tetes des lignes
|
@param new_rhw nouvelle largeur des en-tetes des lignes
|
||||||
*/
|
*/
|
||||||
void BorderInset::setRowsHeaderWidth(const qreal &new_rhw) {
|
void BorderTitleBlock::setRowsHeaderWidth(const qreal &new_rhw) {
|
||||||
rows_header_width = qBound(qreal(5.0), new_rhw, qreal(50.0));
|
rows_header_width = qBound(qreal(5.0), new_rhw, qreal(50.0));
|
||||||
updateRectangles();
|
updateRectangles();
|
||||||
}
|
}
|
||||||
@@ -397,7 +397,7 @@ void BorderInset::setRowsHeaderWidth(const qreal &new_rhw) {
|
|||||||
Cette methode essaye de se rapprocher le plus possible de la hauteur donnee
|
Cette methode essaye de se rapprocher le plus possible de la hauteur donnee
|
||||||
en parametre en modifiant le nombre de lignes en cours.
|
en parametre en modifiant le nombre de lignes en cours.
|
||||||
*/
|
*/
|
||||||
void BorderInset::setDiagramHeight(const qreal &height) {
|
void BorderTitleBlock::setDiagramHeight(const qreal &height) {
|
||||||
// taille des lignes a utiliser = rows_height
|
// taille des lignes a utiliser = rows_height
|
||||||
setNbRows(qRound(ceil(height / rows_height)));
|
setNbRows(qRound(ceil(height / rows_height)));
|
||||||
}
|
}
|
||||||
@@ -406,8 +406,8 @@ void BorderInset::setDiagramHeight(const qreal &height) {
|
|||||||
Change la largeur du cartouche. Cette largeur sera restreinte a celle du
|
Change la largeur du cartouche. Cette largeur sera restreinte a celle du
|
||||||
schema.
|
schema.
|
||||||
*/
|
*/
|
||||||
void BorderInset::setInsetWidth(const qreal &new_iw) {
|
void BorderTitleBlock::setTitleBlockWidth(const qreal &new_iw) {
|
||||||
inset_width = qMin(diagramWidth(), new_iw);
|
titleblock_width = qMin(diagramWidth(), new_iw);
|
||||||
updateRectangles();
|
updateRectangles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,8 +416,8 @@ void BorderInset::setInsetWidth(const qreal &new_iw) {
|
|||||||
Ajuste la largeur du cartouche de facon a ce que celui-ci soit aussi large
|
Ajuste la largeur du cartouche de facon a ce que celui-ci soit aussi large
|
||||||
que le schema
|
que le schema
|
||||||
*/
|
*/
|
||||||
void BorderInset::adjustInsetToColumns() {
|
void BorderTitleBlock::adjustTitleBlockToColumns() {
|
||||||
setInsetWidth(diagramWidth());
|
setTitleBlockWidth(diagramWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -425,7 +425,7 @@ void BorderInset::adjustInsetToColumns() {
|
|||||||
dans la grille (ex : B2)
|
dans la grille (ex : B2)
|
||||||
@return la position dans la grille correspondant a pos
|
@return la position dans la grille correspondant a pos
|
||||||
*/
|
*/
|
||||||
DiagramPosition BorderInset::convertPosition(const QPointF &pos) {
|
DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos) {
|
||||||
// recupere le rectangle quadrille par les en-tetes
|
// recupere le rectangle quadrille par les en-tetes
|
||||||
QRectF grid_rect(
|
QRectF grid_rect(
|
||||||
rowsHeaderWidth(),
|
rowsHeaderWidth(),
|
||||||
@@ -451,10 +451,10 @@ DiagramPosition BorderInset::convertPosition(const QPointF &pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Update the informations given to the inset template by regenerating a
|
Update the informations given to the titleblock template by regenerating a
|
||||||
DiagramContext object.
|
DiagramContext object.
|
||||||
*/
|
*/
|
||||||
void BorderInset::updateDiagramContextForInset() {
|
void BorderTitleBlock::updateDiagramContextForTitleBlock() {
|
||||||
DiagramContext context;
|
DiagramContext context;
|
||||||
context.addValue("author", bi_author);
|
context.addValue("author", bi_author);
|
||||||
context.addValue("date", bi_date.toString("dd/MM/yyyy"));
|
context.addValue("date", bi_date.toString("dd/MM/yyyy"));
|
||||||
@@ -464,10 +464,10 @@ void BorderInset::updateDiagramContextForInset() {
|
|||||||
context.addValue("folio-id", folio_index_);
|
context.addValue("folio-id", folio_index_);
|
||||||
context.addValue("folio-total", folio_total_);
|
context.addValue("folio-total", folio_total_);
|
||||||
|
|
||||||
inset_template_renderer -> setContext(context);
|
titleblock_template_renderer -> setContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BorderInset::incrementLetters(const QString &string) {
|
QString BorderTitleBlock::incrementLetters(const QString &string) {
|
||||||
if (string.isEmpty()) {
|
if (string.isEmpty()) {
|
||||||
return("A");
|
return("A");
|
||||||
} else {
|
} else {
|
||||||
@@ -488,7 +488,7 @@ QString BorderInset::incrementLetters(const QString &string) {
|
|||||||
@param index numero du schema (de 1 a total)
|
@param index numero du schema (de 1 a total)
|
||||||
@param total nombre total de schemas dans le projet
|
@param total nombre total de schemas dans le projet
|
||||||
*/
|
*/
|
||||||
void BorderInset::setFolioData(int index, int total) {
|
void BorderTitleBlock::setFolioData(int index, int total) {
|
||||||
if (index < 1 || total < 1 || index > total) return;
|
if (index < 1 || total < 1 || index > total) return;
|
||||||
|
|
||||||
// memorise les informations
|
// memorise les informations
|
||||||
@@ -500,5 +500,5 @@ void BorderInset::setFolioData(int index, int total) {
|
|||||||
bi_final_folio.replace("%id", QString::number(folio_index_));
|
bi_final_folio.replace("%id", QString::number(folio_index_));
|
||||||
bi_final_folio.replace("%total", QString::number(folio_total_));
|
bi_final_folio.replace("%total", QString::number(folio_total_));
|
||||||
|
|
||||||
updateDiagramContextForInset();
|
updateDiagramContextForTitleBlock();
|
||||||
}
|
}
|
||||||
@@ -15,31 +15,31 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef BORDERINSET_H
|
#ifndef BORDERTITLEBLOCK_H
|
||||||
#define BORDERINSET_H
|
#define BORDERTITLEBLOCK_H
|
||||||
#include "insetproperties.h"
|
#include "titleblockproperties.h"
|
||||||
#include "borderproperties.h"
|
#include "borderproperties.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class DiagramPosition;
|
class DiagramPosition;
|
||||||
class InsetTemplate;
|
class TitleBlockTemplate;
|
||||||
class InsetTemplateRenderer;
|
class TitleBlockTemplateRenderer;
|
||||||
/**
|
/**
|
||||||
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
||||||
schema electrique.
|
schema electrique.
|
||||||
*/
|
*/
|
||||||
class BorderInset : public QObject {
|
class BorderTitleBlock : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
BorderInset(QObject * = 0);
|
BorderTitleBlock(QObject * = 0);
|
||||||
virtual ~BorderInset();
|
virtual ~BorderTitleBlock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BorderInset(const BorderInset &);
|
BorderTitleBlock(const BorderTitleBlock &);
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
@@ -79,14 +79,14 @@ class BorderInset : public QObject {
|
|||||||
|
|
||||||
// cartouche
|
// cartouche
|
||||||
/// @return la largeur du cartouche
|
/// @return la largeur du cartouche
|
||||||
qreal insetWidth() const { return(inset_width); }
|
qreal titleBlockWidth() const { return(titleblock_width); }
|
||||||
qreal insetHeight() const;
|
qreal titleBlockHeight() const;
|
||||||
|
|
||||||
// cadre avec le cartouche
|
// cadre avec le cartouche
|
||||||
/// @return la hauteur de la bordure
|
/// @return la hauteur de la bordure
|
||||||
qreal borderWidth() const { return(diagramWidth()); }
|
qreal borderWidth() const { return(diagramWidth()); }
|
||||||
/// @return la hauteur de la bordure
|
/// @return la hauteur de la bordure
|
||||||
qreal borderHeight() const { return(diagramHeight() + insetHeight()); }
|
qreal borderHeight() const { return(diagramHeight() + titleBlockHeight()); }
|
||||||
|
|
||||||
// methodes d'acces en lecture aux informations du cartouche
|
// methodes d'acces en lecture aux informations du cartouche
|
||||||
/// @return le champ "Auteur" du cartouche
|
/// @return le champ "Auteur" du cartouche
|
||||||
@@ -102,7 +102,7 @@ class BorderInset : public QObject {
|
|||||||
|
|
||||||
// methodes d'acces en lecture aux options
|
// methodes d'acces en lecture aux options
|
||||||
/// @return true si le cartouche est affiche, false sinon
|
/// @return true si le cartouche est affiche, false sinon
|
||||||
bool insetIsDisplayed() const { return(display_inset); }
|
bool titleBlockIsDisplayed() const { return(display_titleblock); }
|
||||||
/// @return true si les entetes des colonnes sont affiches, false sinon
|
/// @return true si les entetes des colonnes sont affiches, false sinon
|
||||||
bool columnsAreDisplayed() const { return(display_columns); }
|
bool columnsAreDisplayed() const { return(display_columns); }
|
||||||
/// @return true si les entetes des lignes sont affiches, false sinon
|
/// @return true si les entetes des lignes sont affiches, false sinon
|
||||||
@@ -122,8 +122,8 @@ class BorderInset : public QObject {
|
|||||||
void setColumnsHeaderHeight(const qreal &);
|
void setColumnsHeaderHeight(const qreal &);
|
||||||
void setRowsHeaderWidth (const qreal &);
|
void setRowsHeaderWidth (const qreal &);
|
||||||
void setDiagramHeight (const qreal &);
|
void setDiagramHeight (const qreal &);
|
||||||
void setInsetWidth (const qreal &);
|
void setTitleBlockWidth (const qreal &);
|
||||||
void adjustInsetToColumns ();
|
void adjustTitleBlockToColumns ();
|
||||||
|
|
||||||
DiagramPosition convertPosition(const QPointF &);
|
DiagramPosition convertPosition(const QPointF &);
|
||||||
|
|
||||||
@@ -145,23 +145,23 @@ class BorderInset : public QObject {
|
|||||||
/// @param filename le nouveau contenu du champ "Fichier"
|
/// @param filename le nouveau contenu du champ "Fichier"
|
||||||
void setFileName (const QString &filename) { bi_filename = filename; }
|
void setFileName (const QString &filename) { bi_filename = filename; }
|
||||||
|
|
||||||
InsetProperties exportInset();
|
TitleBlockProperties exportTitleBlock();
|
||||||
void importInset(const InsetProperties &);
|
void importTitleBlock(const TitleBlockProperties &);
|
||||||
BorderProperties exportBorder();
|
BorderProperties exportBorder();
|
||||||
void importBorder(const BorderProperties &);
|
void importBorder(const BorderProperties &);
|
||||||
|
|
||||||
const InsetTemplate *insetTemplate();
|
const TitleBlockTemplate *titleBlockTemplate();
|
||||||
void setInsetTemplate(const InsetTemplate *);
|
void setTitleBlockTemplate(const TitleBlockTemplate *);
|
||||||
|
|
||||||
// methodes d'acces en ecriture aux options
|
// methodes d'acces en ecriture aux options
|
||||||
void displayInset(bool);
|
void displayTitleBlock(bool);
|
||||||
void displayColumns(bool);
|
void displayColumns(bool);
|
||||||
void displayRows(bool);
|
void displayRows(bool);
|
||||||
void displayBorder(bool);
|
void displayBorder(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateRectangles();
|
void updateRectangles();
|
||||||
void updateDiagramContextForInset();
|
void updateDiagramContextForTitleBlock();
|
||||||
QString incrementLetters(const QString &);
|
QString incrementLetters(const QString &);
|
||||||
|
|
||||||
// signaux
|
// signaux
|
||||||
@@ -212,18 +212,18 @@ class BorderInset : public QObject {
|
|||||||
qreal rows_header_width;
|
qreal rows_header_width;
|
||||||
|
|
||||||
// dimensions du cartouche
|
// dimensions du cartouche
|
||||||
qreal inset_width;
|
qreal titleblock_width;
|
||||||
qreal inset_height;
|
qreal titleblock_height;
|
||||||
|
|
||||||
// rectangles utilises pour le dessin
|
// rectangles utilises pour le dessin
|
||||||
QRectF diagram;
|
QRectF diagram;
|
||||||
QRectF inset;
|
QRectF titleblock;
|
||||||
|
|
||||||
// booleens pour les options de dessin
|
// booleens pour les options de dessin
|
||||||
bool display_inset;
|
bool display_titleblock;
|
||||||
bool display_columns;
|
bool display_columns;
|
||||||
bool display_rows;
|
bool display_rows;
|
||||||
bool display_border;
|
bool display_border;
|
||||||
InsetTemplateRenderer *inset_template_renderer;
|
TitleBlockTemplateRenderer *titleblock_template_renderer;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -18,10 +18,10 @@
|
|||||||
#include "configpages.h"
|
#include "configpages.h"
|
||||||
#include "borderpropertieswidget.h"
|
#include "borderpropertieswidget.h"
|
||||||
#include "conductorpropertieswidget.h"
|
#include "conductorpropertieswidget.h"
|
||||||
#include "insetpropertieswidget.h"
|
#include "titleblockpropertieswidget.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "qetdiagrameditor.h"
|
#include "qetdiagrameditor.h"
|
||||||
#include "borderinset.h"
|
#include "bordertitleblock.h"
|
||||||
#include "qeticons.h"
|
#include "qeticons.h"
|
||||||
#include "exportpropertieswidget.h"
|
#include "exportpropertieswidget.h"
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) {
|
|||||||
bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties());
|
bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties());
|
||||||
|
|
||||||
// proprietes par defaut d'un cartouche
|
// proprietes par defaut d'un cartouche
|
||||||
ipw = new InsetPropertiesWidget(QETDiagramEditor::defaultInsetProperties(), true);
|
ipw = new TitleBlockPropertiesWidget(QETDiagramEditor::defaultTitleBlockProperties(), true);
|
||||||
|
|
||||||
// proprietes par defaut des conducteurs
|
// proprietes par defaut des conducteurs
|
||||||
cpw = new ConductorPropertiesWidget(QETDiagramEditor::defaultConductorProperties());
|
cpw = new ConductorPropertiesWidget(QETDiagramEditor::defaultConductorProperties());
|
||||||
@@ -77,7 +77,7 @@ void NewDiagramPage::applyConf() {
|
|||||||
bpw -> borderProperties().toSettings(settings, "diagrameditor/default");
|
bpw -> borderProperties().toSettings(settings, "diagrameditor/default");
|
||||||
|
|
||||||
// proprietes du cartouche
|
// proprietes du cartouche
|
||||||
ipw-> insetProperties().toSettings(settings, "diagrameditor/default");
|
ipw-> titleBlockProperties().toSettings(settings, "diagrameditor/default");
|
||||||
|
|
||||||
// proprietes par defaut des conducteurs
|
// proprietes par defaut des conducteurs
|
||||||
cpw -> conductorProperties().toSettings(settings, "diagrameditor/defaultconductor");
|
cpw -> conductorProperties().toSettings(settings, "diagrameditor/defaultconductor");
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
class BorderPropertiesWidget;
|
class BorderPropertiesWidget;
|
||||||
class ConductorPropertiesWidget;
|
class ConductorPropertiesWidget;
|
||||||
class InsetPropertiesWidget;
|
class TitleBlockPropertiesWidget;
|
||||||
class ExportPropertiesWidget;
|
class ExportPropertiesWidget;
|
||||||
/**
|
/**
|
||||||
Cette classe abstraite contient les methodes que toutes les pages de
|
Cette classe abstraite contient les methodes que toutes les pages de
|
||||||
@@ -65,7 +65,7 @@ class NewDiagramPage : public ConfigPage {
|
|||||||
// attributs
|
// attributs
|
||||||
public:
|
public:
|
||||||
BorderPropertiesWidget *bpw; ///< Widget d'edition des dimensions du schema
|
BorderPropertiesWidget *bpw; ///< Widget d'edition des dimensions du schema
|
||||||
InsetPropertiesWidget *ipw; ///< Widget d'edition des proprietes par defaut du cartouche
|
TitleBlockPropertiesWidget *ipw; ///< Widget d'edition des proprietes par defaut du cartouche
|
||||||
ConductorPropertiesWidget *cpw; ///< Widget d'edition des proprietes par defaut des conducteurs
|
ConductorPropertiesWidget *cpw; ///< Widget d'edition des proprietes par defaut des conducteurs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
p -> drawPoints(points);
|
p -> drawPoints(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_border) border_and_inset.draw(p, margin, margin);
|
if (use_border) border_and_titleblock.draw(p, margin, margin);
|
||||||
p -> restore();
|
p -> restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,8 +190,8 @@ bool Diagram::toPaintDevice(QPaintDevice &pix, int width, int height, Qt::Aspect
|
|||||||
source_area = QRectF(
|
source_area = QRectF(
|
||||||
0.0,
|
0.0,
|
||||||
0.0,
|
0.0,
|
||||||
border_and_inset.borderWidth () + 2.0 * margin,
|
border_and_titleblock.borderWidth () + 2.0 * margin,
|
||||||
border_and_inset.borderHeight() + 2.0 * margin
|
border_and_titleblock.borderHeight() + 2.0 * margin
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,8 +233,8 @@ QSize Diagram::imageSize() const {
|
|||||||
image_width = items_rect.width();
|
image_width = items_rect.width();
|
||||||
image_height = items_rect.height();
|
image_height = items_rect.height();
|
||||||
} else {
|
} else {
|
||||||
image_width = border_and_inset.borderWidth();
|
image_width = border_and_titleblock.borderWidth();
|
||||||
image_height = border_and_inset.borderHeight();
|
image_height = border_and_titleblock.borderHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
image_width += 2.0 * margin;
|
image_width += 2.0 * margin;
|
||||||
@@ -267,21 +267,21 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
|
|
||||||
// proprietes du schema
|
// proprietes du schema
|
||||||
if (whole_content) {
|
if (whole_content) {
|
||||||
if (!border_and_inset.author().isNull()) racine.setAttribute("author", border_and_inset.author());
|
if (!border_and_titleblock.author().isNull()) racine.setAttribute("author", border_and_titleblock.author());
|
||||||
if (!border_and_inset.date().isNull()) racine.setAttribute("date", border_and_inset.date().toString("yyyyMMdd"));
|
if (!border_and_titleblock.date().isNull()) racine.setAttribute("date", border_and_titleblock.date().toString("yyyyMMdd"));
|
||||||
if (!border_and_inset.title().isNull()) racine.setAttribute("title", border_and_inset.title());
|
if (!border_and_titleblock.title().isNull()) racine.setAttribute("title", border_and_titleblock.title());
|
||||||
if (!border_and_inset.fileName().isNull()) racine.setAttribute("filename", border_and_inset.fileName());
|
if (!border_and_titleblock.fileName().isNull()) racine.setAttribute("filename", border_and_titleblock.fileName());
|
||||||
if (!border_and_inset.folio().isNull()) racine.setAttribute("folio", border_and_inset.folio());
|
if (!border_and_titleblock.folio().isNull()) racine.setAttribute("folio", border_and_titleblock.folio());
|
||||||
racine.setAttribute("cols", border_and_inset.nbColumns());
|
racine.setAttribute("cols", border_and_titleblock.nbColumns());
|
||||||
racine.setAttribute("colsize", QString("%1").arg(border_and_inset.columnsWidth()));
|
racine.setAttribute("colsize", QString("%1").arg(border_and_titleblock.columnsWidth()));
|
||||||
racine.setAttribute("rows", border_and_inset.nbRows());
|
racine.setAttribute("rows", border_and_titleblock.nbRows());
|
||||||
racine.setAttribute("rowsize", QString("%1").arg(border_and_inset.rowsHeight()));
|
racine.setAttribute("rowsize", QString("%1").arg(border_and_titleblock.rowsHeight()));
|
||||||
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
||||||
racine.setAttribute("height", QString("%1").arg(border_and_inset.diagramHeight()));
|
racine.setAttribute("height", QString("%1").arg(border_and_titleblock.diagramHeight()));
|
||||||
racine.setAttribute("displaycols", border_and_inset.columnsAreDisplayed() ? "true" : "false");
|
racine.setAttribute("displaycols", border_and_titleblock.columnsAreDisplayed() ? "true" : "false");
|
||||||
racine.setAttribute("displayrows", border_and_inset.rowsAreDisplayed() ? "true" : "false");
|
racine.setAttribute("displayrows", border_and_titleblock.rowsAreDisplayed() ? "true" : "false");
|
||||||
if (!inset_template_name_.isEmpty()) {
|
if (!titleblock_template_name_.isEmpty()) {
|
||||||
racine.setAttribute("insettemplate", inset_template_name_);
|
racine.setAttribute("titleblocktemplate", titleblock_template_name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// type de conducteur par defaut
|
// type de conducteur par defaut
|
||||||
@@ -417,49 +417,49 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
|
|
||||||
// lecture des attributs de ce schema
|
// lecture des attributs de ce schema
|
||||||
if (consider_informations) {
|
if (consider_informations) {
|
||||||
border_and_inset.setAuthor(root.attribute("author"));
|
border_and_titleblock.setAuthor(root.attribute("author"));
|
||||||
border_and_inset.setTitle(root.attribute("title"));
|
border_and_titleblock.setTitle(root.attribute("title"));
|
||||||
border_and_inset.setDate(QDate::fromString(root.attribute("date"), "yyyyMMdd"));
|
border_and_titleblock.setDate(QDate::fromString(root.attribute("date"), "yyyyMMdd"));
|
||||||
border_and_inset.setFileName(root.attribute("filename"));
|
border_and_titleblock.setFileName(root.attribute("filename"));
|
||||||
border_and_inset.setFolio(root.attribute("folio"));
|
border_and_titleblock.setFolio(root.attribute("folio"));
|
||||||
if (root.hasAttribute("insettemplate") && project_) {
|
if (root.hasAttribute("titleblocktemplate") && project_) {
|
||||||
QString inset_template_name = root.attribute("insettemplate");
|
QString titleblock_template_name = root.attribute("titleblocktemplate");
|
||||||
const InsetTemplate *inset_template = project_ -> getTemplateByName(inset_template_name);
|
const TitleBlockTemplate *titleblock_template = project_ -> getTemplateByName(titleblock_template_name);
|
||||||
if (inset_template) {
|
if (titleblock_template) {
|
||||||
inset_template_name_ = inset_template_name;
|
titleblock_template_name_ = titleblock_template_name;
|
||||||
border_and_inset.setInsetTemplate(inset_template);
|
border_and_titleblock.setTitleBlockTemplate(titleblock_template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
// nombre de colonnes
|
// nombre de colonnes
|
||||||
int nb_cols = root.attribute("cols").toInt(&ok);
|
int nb_cols = root.attribute("cols").toInt(&ok);
|
||||||
if (ok) border_and_inset.setNbColumns(nb_cols);
|
if (ok) border_and_titleblock.setNbColumns(nb_cols);
|
||||||
|
|
||||||
// taille des colonnes
|
// taille des colonnes
|
||||||
double col_size = root.attribute("colsize").toDouble(&ok);
|
double col_size = root.attribute("colsize").toDouble(&ok);
|
||||||
if (ok) border_and_inset.setColumnsWidth(col_size);
|
if (ok) border_and_titleblock.setColumnsWidth(col_size);
|
||||||
|
|
||||||
// retrocompatibilite : les schemas enregistres avec la 0.1 ont un attribut "height"
|
// retrocompatibilite : les schemas enregistres avec la 0.1 ont un attribut "height"
|
||||||
if (root.hasAttribute("rows") && root.hasAttribute("rowsize")) {
|
if (root.hasAttribute("rows") && root.hasAttribute("rowsize")) {
|
||||||
// nombre de lignes
|
// nombre de lignes
|
||||||
int nb_rows = root.attribute("rows").toInt(&ok);
|
int nb_rows = root.attribute("rows").toInt(&ok);
|
||||||
if (ok) border_and_inset.setNbRows(nb_rows);
|
if (ok) border_and_titleblock.setNbRows(nb_rows);
|
||||||
|
|
||||||
// taille des lignes
|
// taille des lignes
|
||||||
double row_size = root.attribute("rowsize").toDouble(&ok);
|
double row_size = root.attribute("rowsize").toDouble(&ok);
|
||||||
if (ok) border_and_inset.setRowsHeight(row_size);
|
if (ok) border_and_titleblock.setRowsHeight(row_size);
|
||||||
} else {
|
} else {
|
||||||
// hauteur du schema
|
// hauteur du schema
|
||||||
double height = root.attribute("height").toDouble(&ok);
|
double height = root.attribute("height").toDouble(&ok);
|
||||||
if (ok) border_and_inset.setDiagramHeight(height);
|
if (ok) border_and_titleblock.setDiagramHeight(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// affichage des lignes et colonnes
|
// affichage des lignes et colonnes
|
||||||
border_and_inset.displayColumns(root.attribute("displaycols") != "false");
|
border_and_titleblock.displayColumns(root.attribute("displaycols") != "false");
|
||||||
border_and_inset.displayRows(root.attribute("displayrows") != "false");
|
border_and_titleblock.displayRows(root.attribute("displayrows") != "false");
|
||||||
|
|
||||||
border_and_inset.adjustInsetToColumns();
|
border_and_titleblock.adjustTitleBlockToColumns();
|
||||||
|
|
||||||
// repere le permier element "defaultconductor"
|
// repere le permier element "defaultconductor"
|
||||||
for (QDomNode node = root.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
for (QDomNode node = root.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
||||||
@@ -806,8 +806,8 @@ QRectF Diagram::border() const {
|
|||||||
QRectF(
|
QRectF(
|
||||||
margin,
|
margin,
|
||||||
margin,
|
margin,
|
||||||
border_and_inset.borderWidth(),
|
border_and_titleblock.borderWidth(),
|
||||||
border_and_inset.borderHeight()
|
border_and_titleblock.borderHeight()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -816,7 +816,7 @@ QRectF Diagram::border() const {
|
|||||||
@return le titre du cartouche
|
@return le titre du cartouche
|
||||||
*/
|
*/
|
||||||
QString Diagram::title() const {
|
QString Diagram::title() const {
|
||||||
return(border_and_inset.title());
|
return(border_and_titleblock.title());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -912,8 +912,8 @@ ExportProperties Diagram::applyProperties(const ExportProperties &new_properties
|
|||||||
// exporte les options de rendu en cours
|
// exporte les options de rendu en cours
|
||||||
ExportProperties old_properties;
|
ExportProperties old_properties;
|
||||||
old_properties.draw_grid = displayGrid();
|
old_properties.draw_grid = displayGrid();
|
||||||
old_properties.draw_border = border_and_inset.borderIsDisplayed();
|
old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
|
||||||
old_properties.draw_inset = border_and_inset.insetIsDisplayed();
|
old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
|
||||||
old_properties.draw_terminals = drawTerminals();
|
old_properties.draw_terminals = drawTerminals();
|
||||||
old_properties.draw_colored_conductors = drawColoredConductors();
|
old_properties.draw_colored_conductors = drawColoredConductors();
|
||||||
old_properties.exported_area = useBorder() ? QET::BorderArea : QET::ElementsArea;
|
old_properties.exported_area = useBorder() ? QET::BorderArea : QET::ElementsArea;
|
||||||
@@ -923,8 +923,8 @@ ExportProperties Diagram::applyProperties(const ExportProperties &new_properties
|
|||||||
setDrawTerminals (new_properties.draw_terminals);
|
setDrawTerminals (new_properties.draw_terminals);
|
||||||
setDrawColoredConductors (new_properties.draw_colored_conductors);
|
setDrawColoredConductors (new_properties.draw_colored_conductors);
|
||||||
setDisplayGrid (new_properties.draw_grid);
|
setDisplayGrid (new_properties.draw_grid);
|
||||||
border_and_inset.displayBorder(new_properties.draw_border);
|
border_and_titleblock.displayBorder(new_properties.draw_border);
|
||||||
border_and_inset.displayInset (new_properties.draw_inset);
|
border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
|
||||||
|
|
||||||
// retourne les anciennes options de rendu
|
// retourne les anciennes options de rendu
|
||||||
return(old_properties);
|
return(old_properties);
|
||||||
@@ -939,8 +939,8 @@ DiagramPosition Diagram::convertPosition(const QPointF &pos) {
|
|||||||
// decale la position pour prendre en compte les marges en haut a gauche du schema
|
// decale la position pour prendre en compte les marges en haut a gauche du schema
|
||||||
QPointF final_pos = pos - QPointF(margin, margin);
|
QPointF final_pos = pos - QPointF(margin, margin);
|
||||||
|
|
||||||
// delegue le calcul au BorderInset
|
// delegue le calcul au BorderTitleBlock
|
||||||
DiagramPosition diagram_position = border_and_inset.convertPosition(final_pos);
|
DiagramPosition diagram_position = border_and_titleblock.convertPosition(final_pos);
|
||||||
|
|
||||||
// embarque la position cartesienne
|
// embarque la position cartesienne
|
||||||
diagram_position.setPosition(pos);
|
diagram_position.setPosition(pos);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#define DIAGRAM_H
|
#define DIAGRAM_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include "borderinset.h"
|
#include "bordertitleblock.h"
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
#include "exportproperties.h"
|
#include "exportproperties.h"
|
||||||
#include "qgimanager.h"
|
#include "qgimanager.h"
|
||||||
@@ -57,14 +57,14 @@ class Diagram : public QGraphicsScene {
|
|||||||
/**
|
/**
|
||||||
Represente les options possibles pour l'affichage du schema :
|
Represente les options possibles pour l'affichage du schema :
|
||||||
* EmptyBorder : N'afficher que la bordure
|
* EmptyBorder : N'afficher que la bordure
|
||||||
* Inset : Afficher le cartouche
|
* TitleBlock : Afficher le cartouche
|
||||||
* Columns : Afficher les colonnes
|
* Columns : Afficher les colonnes
|
||||||
*/
|
*/
|
||||||
enum BorderOptions { EmptyBorder, Inset, Columns };
|
enum BorderOptions { EmptyBorder, TitleBlock, Columns };
|
||||||
/// Proprietes par defaut des nouveaux conducteurs
|
/// Proprietes par defaut des nouveaux conducteurs
|
||||||
ConductorProperties defaultConductorProperties;
|
ConductorProperties defaultConductorProperties;
|
||||||
/// Dimensions et cartouches du schema
|
/// Dimensions et cartouches du schema
|
||||||
BorderInset border_and_inset;
|
BorderTitleBlock border_and_titleblock;
|
||||||
/// taille de la grille en abscisse
|
/// taille de la grille en abscisse
|
||||||
static const int xGrid;
|
static const int xGrid;
|
||||||
/// taille de la grille en ordonnee
|
/// taille de la grille en ordonnee
|
||||||
@@ -85,7 +85,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
QDomDocument xml_document;
|
QDomDocument xml_document;
|
||||||
QETProject *project_;
|
QETProject *project_;
|
||||||
bool read_only_;
|
bool read_only_;
|
||||||
QString inset_template_name_;
|
QString titleblock_template_name_;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
protected:
|
protected:
|
||||||
@@ -249,9 +249,9 @@ inline bool Diagram::useBorder() {
|
|||||||
@see BorderOptions
|
@see BorderOptions
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setBorderOptions(Diagram::BorderOptions bo) {
|
inline void Diagram::setBorderOptions(Diagram::BorderOptions bo) {
|
||||||
border_and_inset.displayBorder(!(bo & EmptyBorder));
|
border_and_titleblock.displayBorder(!(bo & EmptyBorder));
|
||||||
border_and_inset.displayColumns(bo & Columns);
|
border_and_titleblock.displayColumns(bo & Columns);
|
||||||
border_and_inset.displayInset(bo & Inset);
|
border_and_titleblock.displayTitleBlock(bo & TitleBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -261,8 +261,8 @@ inline void Diagram::setBorderOptions(Diagram::BorderOptions bo) {
|
|||||||
*/
|
*/
|
||||||
inline Diagram::BorderOptions Diagram::borderOptions() {
|
inline Diagram::BorderOptions Diagram::borderOptions() {
|
||||||
BorderOptions retour = EmptyBorder;
|
BorderOptions retour = EmptyBorder;
|
||||||
if (border_and_inset.insetIsDisplayed()) retour = (BorderOptions)(retour|Inset);
|
if (border_and_titleblock.titleBlockIsDisplayed()) retour = (BorderOptions)(retour|TitleBlock);
|
||||||
if (border_and_inset.columnsAreDisplayed()) retour = (BorderOptions)(retour|Columns);
|
if (border_and_titleblock.columnsAreDisplayed()) retour = (BorderOptions)(retour|Columns);
|
||||||
return(retour);
|
return(retour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -828,32 +828,32 @@ void ResetConductorCommand::redo() {
|
|||||||
@param new_ip Nouvelles proprietes du cartouche
|
@param new_ip Nouvelles proprietes du cartouche
|
||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
ChangeInsetCommand::ChangeInsetCommand(
|
ChangeTitleBlockCommand::ChangeTitleBlockCommand(
|
||||||
Diagram *d,
|
Diagram *d,
|
||||||
const InsetProperties &old_ip,
|
const TitleBlockProperties &old_ip,
|
||||||
const InsetProperties &new_ip,
|
const TitleBlockProperties &new_ip,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modifier le cartouche", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modifier le cartouche", "undo caption"), parent),
|
||||||
diagram(d),
|
diagram(d),
|
||||||
old_inset(old_ip),
|
old_titleblock(old_ip),
|
||||||
new_inset(new_ip)
|
new_titleblock(new_ip)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
ChangeInsetCommand::~ChangeInsetCommand() {
|
ChangeTitleBlockCommand::~ChangeTitleBlockCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Annule la modification de cartouche
|
/// Annule la modification de cartouche
|
||||||
void ChangeInsetCommand::undo() {
|
void ChangeTitleBlockCommand::undo() {
|
||||||
diagram -> border_and_inset.importInset(old_inset);
|
diagram -> border_and_titleblock.importTitleBlock(old_titleblock);
|
||||||
diagram -> invalidate(diagram -> border());
|
diagram -> invalidate(diagram -> border());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait la modification de cartouche
|
/// Refait la modification de cartouche
|
||||||
void ChangeInsetCommand::redo() {
|
void ChangeTitleBlockCommand::redo() {
|
||||||
diagram -> border_and_inset.importInset(new_inset);
|
diagram -> border_and_titleblock.importTitleBlock(new_titleblock);
|
||||||
diagram -> invalidate(diagram -> border());
|
diagram -> invalidate(diagram -> border());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,12 +878,12 @@ ChangeBorderCommand::~ChangeBorderCommand() {
|
|||||||
|
|
||||||
/// Annule les changements apportes au schema
|
/// Annule les changements apportes au schema
|
||||||
void ChangeBorderCommand::undo() {
|
void ChangeBorderCommand::undo() {
|
||||||
diagram -> border_and_inset.importBorder(old_properties);
|
diagram -> border_and_titleblock.importBorder(old_properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait les changements apportes au schema
|
/// Refait les changements apportes au schema
|
||||||
void ChangeBorderCommand::redo() {
|
void ChangeBorderCommand::redo() {
|
||||||
diagram -> border_and_inset.importBorder(new_properties);
|
diagram -> border_and_titleblock.importBorder(new_properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
#include "diagramcontent.h"
|
#include "diagramcontent.h"
|
||||||
#include "insetproperties.h"
|
#include "titleblockproperties.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class DiagramTextItem;
|
class DiagramTextItem;
|
||||||
@@ -419,13 +419,13 @@ class ResetConductorCommand : public QUndoCommand {
|
|||||||
/**
|
/**
|
||||||
Cette classe represente l'action de modifier les informations du cartouche d'un schema
|
Cette classe represente l'action de modifier les informations du cartouche d'un schema
|
||||||
*/
|
*/
|
||||||
class ChangeInsetCommand : public QUndoCommand {
|
class ChangeTitleBlockCommand : public QUndoCommand {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ChangeInsetCommand(Diagram *, const InsetProperties &, const InsetProperties &, QUndoCommand * = 0);
|
ChangeTitleBlockCommand(Diagram *, const TitleBlockProperties &, const TitleBlockProperties &, QUndoCommand * = 0);
|
||||||
virtual ~ChangeInsetCommand();
|
virtual ~ChangeTitleBlockCommand();
|
||||||
private:
|
private:
|
||||||
ChangeInsetCommand(const ChangeInsetCommand &);
|
ChangeTitleBlockCommand(const ChangeTitleBlockCommand &);
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
@@ -437,9 +437,9 @@ class ChangeInsetCommand : public QUndoCommand {
|
|||||||
/// schema modifie
|
/// schema modifie
|
||||||
Diagram *diagram;
|
Diagram *diagram;
|
||||||
/// proprietes avant changement
|
/// proprietes avant changement
|
||||||
InsetProperties old_inset;
|
TitleBlockProperties old_titleblock;
|
||||||
/// proprietes apres changement
|
/// proprietes apres changement
|
||||||
InsetProperties new_inset;
|
TitleBlockProperties new_titleblock;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
/**
|
/**
|
||||||
This class represents a diagram context, i.e. the data (a list of key/value
|
This class represents a diagram context, i.e. the data (a list of key/value
|
||||||
pairs) of a diagram at a given time. It is notably used by inset templates
|
pairs) of a diagram at a given time. It is notably used by titleblock templates
|
||||||
to fetch the informations they need to do their rendering.
|
to fetch the informations they need to do their rendering.
|
||||||
*/
|
*/
|
||||||
class DiagramContext {
|
class DiagramContext {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "conductortextitem.h"
|
#include "conductortextitem.h"
|
||||||
#include "elementtextitem.h"
|
#include "elementtextitem.h"
|
||||||
#include "independenttextitem.h"
|
#include "independenttextitem.h"
|
||||||
#include "insetpropertieswidget.h"
|
#include "titleblockpropertieswidget.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "borderpropertieswidget.h"
|
#include "borderpropertieswidget.h"
|
||||||
@@ -67,9 +67,9 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(pare
|
|||||||
|
|
||||||
connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
|
connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
|
||||||
connect(scene, SIGNAL(readOnlyChanged(bool)), this, SLOT(applyReadOnly()));
|
connect(scene, SIGNAL(readOnlyChanged(bool)), this, SLOT(applyReadOnly()));
|
||||||
connect(&(scene -> border_and_inset), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
|
connect(&(scene -> border_and_titleblock), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
|
||||||
connect(&(scene -> border_and_inset), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect()));
|
connect(&(scene -> border_and_titleblock), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect()));
|
||||||
connect(&(scene -> border_and_inset), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
connect(&(scene -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
||||||
connect(&(scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(updateWindowTitle()));
|
connect(&(scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(updateWindowTitle()));
|
||||||
|
|
||||||
connect(this, SIGNAL(aboutToAddElement()), this, SLOT(addDroppedElement()), Qt::QueuedConnection);
|
connect(this, SIGNAL(aboutToAddElement()), this, SLOT(addDroppedElement()), Qt::QueuedConnection);
|
||||||
@@ -412,8 +412,8 @@ void DiagramView::editDiagramProperties() {
|
|||||||
bool diagram_is_read_only = scene -> isReadOnly();
|
bool diagram_is_read_only = scene -> isReadOnly();
|
||||||
|
|
||||||
// recupere le cartouche et les dimensions du schema
|
// recupere le cartouche et les dimensions du schema
|
||||||
InsetProperties inset = scene -> border_and_inset.exportInset();
|
TitleBlockProperties titleblock = scene -> border_and_titleblock.exportTitleBlock();
|
||||||
BorderProperties border = scene -> border_and_inset.exportBorder();
|
BorderProperties border = scene -> border_and_titleblock.exportBorder();
|
||||||
|
|
||||||
// construit le dialogue
|
// construit le dialogue
|
||||||
QDialog popup(diagramEditor());
|
QDialog popup(diagramEditor());
|
||||||
@@ -426,8 +426,8 @@ void DiagramView::editDiagramProperties() {
|
|||||||
|
|
||||||
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup);
|
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup);
|
||||||
border_infos -> setReadOnly(diagram_is_read_only);
|
border_infos -> setReadOnly(diagram_is_read_only);
|
||||||
InsetPropertiesWidget *inset_infos = new InsetPropertiesWidget(inset, false, &popup);
|
TitleBlockPropertiesWidget *titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, &popup);
|
||||||
inset_infos -> setReadOnly(diagram_is_read_only);
|
titleblock_infos -> setReadOnly(diagram_is_read_only);
|
||||||
|
|
||||||
// boutons
|
// boutons
|
||||||
QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
@@ -437,16 +437,16 @@ void DiagramView::editDiagramProperties() {
|
|||||||
// ajout dans une disposition verticale
|
// ajout dans une disposition verticale
|
||||||
QVBoxLayout layout_v(&popup);
|
QVBoxLayout layout_v(&popup);
|
||||||
layout_v.addWidget(border_infos);
|
layout_v.addWidget(border_infos);
|
||||||
layout_v.addWidget(inset_infos);
|
layout_v.addWidget(titleblock_infos);
|
||||||
layout_v.addStretch();
|
layout_v.addStretch();
|
||||||
layout_v.addWidget(&boutons);
|
layout_v.addWidget(&boutons);
|
||||||
// si le dialogue est accepte
|
// si le dialogue est accepte
|
||||||
if (popup.exec() == QDialog::Accepted && !diagram_is_read_only) {
|
if (popup.exec() == QDialog::Accepted && !diagram_is_read_only) {
|
||||||
InsetProperties new_inset = inset_infos -> insetProperties();
|
TitleBlockProperties new_titleblock = titleblock_infos -> titleBlockProperties();
|
||||||
BorderProperties new_border = border_infos -> borderProperties();
|
BorderProperties new_border = border_infos -> borderProperties();
|
||||||
// s'il y a des modifications au cartouche
|
// s'il y a des modifications au cartouche
|
||||||
if (new_inset != inset) {
|
if (new_titleblock != titleblock) {
|
||||||
scene -> undoStack().push(new ChangeInsetCommand(scene, inset, new_inset));
|
scene -> undoStack().push(new ChangeTitleBlockCommand(scene, titleblock, new_titleblock));
|
||||||
}
|
}
|
||||||
|
|
||||||
// s'il y a des modifications aux dimensions du schema
|
// s'il y a des modifications aux dimensions du schema
|
||||||
@@ -501,8 +501,8 @@ bool DiagramView::hasDeletableItems() {
|
|||||||
*/
|
*/
|
||||||
void DiagramView::addColumn() {
|
void DiagramView::addColumn() {
|
||||||
if (scene -> isReadOnly()) return;
|
if (scene -> isReadOnly()) return;
|
||||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
BorderProperties old_bp = scene -> border_and_titleblock.exportBorder();
|
||||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
BorderProperties new_bp = scene -> border_and_titleblock.exportBorder();
|
||||||
new_bp.columns_count += 1;
|
new_bp.columns_count += 1;
|
||||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||||
}
|
}
|
||||||
@@ -512,8 +512,8 @@ void DiagramView::addColumn() {
|
|||||||
*/
|
*/
|
||||||
void DiagramView::removeColumn() {
|
void DiagramView::removeColumn() {
|
||||||
if (scene -> isReadOnly()) return;
|
if (scene -> isReadOnly()) return;
|
||||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
BorderProperties old_bp = scene -> border_and_titleblock.exportBorder();
|
||||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
BorderProperties new_bp = scene -> border_and_titleblock.exportBorder();
|
||||||
new_bp.columns_count -= 1;
|
new_bp.columns_count -= 1;
|
||||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||||
}
|
}
|
||||||
@@ -523,8 +523,8 @@ void DiagramView::removeColumn() {
|
|||||||
*/
|
*/
|
||||||
void DiagramView::addRow() {
|
void DiagramView::addRow() {
|
||||||
if (scene -> isReadOnly()) return;
|
if (scene -> isReadOnly()) return;
|
||||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
BorderProperties old_bp = scene -> border_and_titleblock.exportBorder();
|
||||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
BorderProperties new_bp = scene -> border_and_titleblock.exportBorder();
|
||||||
new_bp.rows_count += 1;
|
new_bp.rows_count += 1;
|
||||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||||
}
|
}
|
||||||
@@ -534,8 +534,8 @@ void DiagramView::addRow() {
|
|||||||
*/
|
*/
|
||||||
void DiagramView::removeRow() {
|
void DiagramView::removeRow() {
|
||||||
if (scene -> isReadOnly()) return;
|
if (scene -> isReadOnly()) return;
|
||||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
BorderProperties old_bp = scene -> border_and_titleblock.exportBorder();
|
||||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
BorderProperties new_bp = scene -> border_and_titleblock.exportBorder();
|
||||||
new_bp.rows_count -= 1;
|
new_bp.rows_count -= 1;
|
||||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||||
}
|
}
|
||||||
@@ -987,14 +987,14 @@ QETDiagramEditor *DiagramView::diagramEditor() const {
|
|||||||
Gere les double-clics sur le schema
|
Gere les double-clics sur le schema
|
||||||
*/
|
*/
|
||||||
void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||||
BorderInset &bi = scene -> border_and_inset;
|
BorderTitleBlock &bi = scene -> border_and_titleblock;
|
||||||
|
|
||||||
// recupere le rectangle corespondant au cartouche
|
// recupere le rectangle corespondant au cartouche
|
||||||
QRectF inset_rect(
|
QRectF titleblock_rect(
|
||||||
Diagram::margin,
|
Diagram::margin,
|
||||||
Diagram::margin + bi.diagramHeight(),
|
Diagram::margin + bi.diagramHeight(),
|
||||||
bi.insetWidth(),
|
bi.titleBlockWidth(),
|
||||||
bi.insetHeight()
|
bi.titleBlockHeight()
|
||||||
);
|
);
|
||||||
|
|
||||||
// recupere le rectangle correspondant aux en-tetes des colonnes
|
// recupere le rectangle correspondant aux en-tetes des colonnes
|
||||||
@@ -1025,7 +1025,7 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
|||||||
} else {
|
} else {
|
||||||
QGraphicsView::mouseDoubleClickEvent(e);
|
QGraphicsView::mouseDoubleClickEvent(e);
|
||||||
}
|
}
|
||||||
} else if (inset_rect.contains(click_pos) || columns_rect.contains(click_pos) || rows_rect.contains(click_pos)) {
|
} else if (titleblock_rect.contains(click_pos) || columns_rect.contains(click_pos) || rows_rect.contains(click_pos)) {
|
||||||
// edite les proprietes du schema
|
// edite les proprietes du schema
|
||||||
editDiagramProperties();
|
editDiagramProperties();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ ExportProperties::ExportProperties() :
|
|||||||
format("PNG"),
|
format("PNG"),
|
||||||
draw_grid(false),
|
draw_grid(false),
|
||||||
draw_border(true),
|
draw_border(true),
|
||||||
draw_inset(true),
|
draw_titleblock(true),
|
||||||
draw_terminals(false),
|
draw_terminals(false),
|
||||||
draw_colored_conductors(true),
|
draw_colored_conductors(true),
|
||||||
exported_area(QET::BorderArea)
|
exported_area(QET::BorderArea)
|
||||||
@@ -54,7 +54,7 @@ void ExportProperties::toSettings(QSettings &settings, const QString &prefix) co
|
|||||||
settings.setValue(prefix + "format", format);
|
settings.setValue(prefix + "format", format);
|
||||||
settings.setValue(prefix + "drawgrid", draw_grid);
|
settings.setValue(prefix + "drawgrid", draw_grid);
|
||||||
settings.setValue(prefix + "drawborder", draw_border);
|
settings.setValue(prefix + "drawborder", draw_border);
|
||||||
settings.setValue(prefix + "drawinset", draw_inset);
|
settings.setValue(prefix + "drawtitleblock", draw_titleblock);
|
||||||
settings.setValue(prefix + "drawterminals", draw_terminals);
|
settings.setValue(prefix + "drawterminals", draw_terminals);
|
||||||
settings.setValue(prefix + "drawcoloredconductors", draw_colored_conductors);
|
settings.setValue(prefix + "drawcoloredconductors", draw_colored_conductors);
|
||||||
settings.setValue(prefix + "area", QET::diagramAreaToString(exported_area));
|
settings.setValue(prefix + "area", QET::diagramAreaToString(exported_area));
|
||||||
@@ -74,7 +74,7 @@ void ExportProperties::fromSettings(QSettings &settings, const QString &prefix)
|
|||||||
|
|
||||||
draw_grid = settings.value(prefix + "drawgrid", false).toBool();
|
draw_grid = settings.value(prefix + "drawgrid", false).toBool();
|
||||||
draw_border = settings.value(prefix + "drawborder", true ).toBool();
|
draw_border = settings.value(prefix + "drawborder", true ).toBool();
|
||||||
draw_inset = settings.value(prefix + "drawinset", true ).toBool();
|
draw_titleblock = settings.value(prefix + "drawtitleblock", true ).toBool();
|
||||||
draw_terminals = settings.value(prefix + "drawterminals", false).toBool();
|
draw_terminals = settings.value(prefix + "drawterminals", false).toBool();
|
||||||
draw_colored_conductors = settings.value(prefix + "drawcoloredconductors", true ).toBool();
|
draw_colored_conductors = settings.value(prefix + "drawcoloredconductors", true ).toBool();
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ExportProperties {
|
|||||||
QString format; ///< Quel format d'image faut-il utiliser ?
|
QString format; ///< Quel format d'image faut-il utiliser ?
|
||||||
bool draw_grid; ///< Faut-il dessiner la grille ?
|
bool draw_grid; ///< Faut-il dessiner la grille ?
|
||||||
bool draw_border; ///< Faut-il dessiner le cadre ?
|
bool draw_border; ///< Faut-il dessiner le cadre ?
|
||||||
bool draw_inset; ///< Faut-il dessiner le cartouche ?
|
bool draw_titleblock; ///< Faut-il dessiner le cartouche ?
|
||||||
bool draw_terminals; ///< Faut-il dessiner les bornes ?
|
bool draw_terminals; ///< Faut-il dessiner les bornes ?
|
||||||
bool draw_colored_conductors; ///< Faut-il respecter les couleurs des conducteurs ?
|
bool draw_colored_conductors; ///< Faut-il respecter les couleurs des conducteurs ?
|
||||||
QET::DiagramArea exported_area; ///< Zone du schema a exporter
|
QET::DiagramArea exported_area; ///< Zone du schema a exporter
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ ExportProperties ExportPropertiesWidget::exportProperties() const {
|
|||||||
export_properties.format = format -> itemData(format -> currentIndex()).toString();
|
export_properties.format = format -> itemData(format -> currentIndex()).toString();
|
||||||
export_properties.draw_grid = draw_grid -> isChecked();
|
export_properties.draw_grid = draw_grid -> isChecked();
|
||||||
export_properties.draw_border = draw_border -> isChecked();
|
export_properties.draw_border = draw_border -> isChecked();
|
||||||
export_properties.draw_inset = draw_inset -> isChecked();
|
export_properties.draw_titleblock = draw_titleblock -> isChecked();
|
||||||
export_properties.draw_terminals = draw_terminals -> isChecked();
|
export_properties.draw_terminals = draw_terminals -> isChecked();
|
||||||
export_properties.draw_colored_conductors = draw_colored_conductors -> isChecked();
|
export_properties.draw_colored_conductors = draw_colored_conductors -> isChecked();
|
||||||
export_properties.exported_area = export_border -> isChecked() ? QET::BorderArea : QET::ElementsArea;
|
export_properties.exported_area = export_border -> isChecked() ? QET::BorderArea : QET::ElementsArea;
|
||||||
@@ -70,7 +70,7 @@ void ExportPropertiesWidget::setExportProperties(const ExportProperties &export_
|
|||||||
|
|
||||||
draw_grid -> setChecked(export_properties.draw_grid);
|
draw_grid -> setChecked(export_properties.draw_grid);
|
||||||
draw_border -> setChecked(export_properties.draw_border);
|
draw_border -> setChecked(export_properties.draw_border);
|
||||||
draw_inset -> setChecked(export_properties.draw_inset);
|
draw_titleblock -> setChecked(export_properties.draw_titleblock);
|
||||||
draw_terminals -> setChecked(export_properties.draw_terminals);
|
draw_terminals -> setChecked(export_properties.draw_terminals);
|
||||||
draw_colored_conductors -> setChecked(export_properties.draw_colored_conductors);
|
draw_colored_conductors -> setChecked(export_properties.draw_colored_conductors);
|
||||||
|
|
||||||
@@ -169,8 +169,8 @@ void ExportPropertiesWidget::build() {
|
|||||||
optionshlayout -> addWidget(draw_border, 1, 0);
|
optionshlayout -> addWidget(draw_border, 1, 0);
|
||||||
|
|
||||||
// dessiner le cartouche
|
// dessiner le cartouche
|
||||||
draw_inset = new QCheckBox(tr("Dessiner le cartouche"), groupbox_options);
|
draw_titleblock = new QCheckBox(tr("Dessiner le cartouche"), groupbox_options);
|
||||||
optionshlayout -> addWidget(draw_inset, 2, 0);
|
optionshlayout -> addWidget(draw_titleblock, 2, 0);
|
||||||
|
|
||||||
// dessiner les bornes
|
// dessiner les bornes
|
||||||
draw_terminals = new QCheckBox(tr("Dessiner les bornes"), groupbox_options);
|
draw_terminals = new QCheckBox(tr("Dessiner les bornes"), groupbox_options);
|
||||||
@@ -190,8 +190,8 @@ void ExportPropertiesWidget::build() {
|
|||||||
setTabOrder(format, export_border);
|
setTabOrder(format, export_border);
|
||||||
setTabOrder(export_border, draw_border);
|
setTabOrder(export_border, draw_border);
|
||||||
setTabOrder(draw_border, draw_grid);
|
setTabOrder(draw_border, draw_grid);
|
||||||
setTabOrder(draw_grid, draw_inset);
|
setTabOrder(draw_grid, draw_titleblock);
|
||||||
setTabOrder(draw_inset, draw_terminals);
|
setTabOrder(draw_titleblock, draw_terminals);
|
||||||
setTabOrder(draw_terminals, draw_colored_conductors);
|
setTabOrder(draw_terminals, draw_colored_conductors);
|
||||||
|
|
||||||
// connexion du bouton permettant le choix du repertoire
|
// connexion du bouton permettant le choix du repertoire
|
||||||
@@ -202,7 +202,7 @@ void ExportPropertiesWidget::build() {
|
|||||||
connect(exported_content_choices, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(exportedAreaChanged()));
|
connect(exported_content_choices, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(exportedAreaChanged()));
|
||||||
connect(draw_grid, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
connect(draw_grid, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
||||||
connect(draw_border, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
connect(draw_border, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
||||||
connect(draw_inset, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
connect(draw_titleblock, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
||||||
connect(draw_terminals, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
connect(draw_terminals, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
||||||
connect(draw_colored_conductors, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
connect(draw_colored_conductors, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class ExportPropertiesWidget : public QWidget {
|
|||||||
QComboBox *format;
|
QComboBox *format;
|
||||||
QCheckBox *draw_grid;
|
QCheckBox *draw_grid;
|
||||||
QCheckBox *draw_border;
|
QCheckBox *draw_border;
|
||||||
QCheckBox *draw_inset;
|
QCheckBox *draw_titleblock;
|
||||||
QCheckBox *draw_terminals;
|
QCheckBox *draw_terminals;
|
||||||
QCheckBox *draw_colored_conductors;
|
QCheckBox *draw_colored_conductors;
|
||||||
QRadioButton *export_border;
|
QRadioButton *export_border;
|
||||||
|
|||||||
@@ -53,17 +53,17 @@ HotspotEditor::HotspotEditor(QWidget *parent) :
|
|||||||
sb_hotspot_y -> setSingleStep(10);
|
sb_hotspot_y -> setSingleStep(10);
|
||||||
|
|
||||||
diagram_scene = new Diagram();
|
diagram_scene = new Diagram();
|
||||||
diagram_scene -> border_and_inset.setColumnsWidth(50.0);
|
diagram_scene -> border_and_titleblock.setColumnsWidth(50.0);
|
||||||
diagram_scene -> border_and_inset.setNbColumns(3);
|
diagram_scene -> border_and_titleblock.setNbColumns(3);
|
||||||
diagram_scene -> border_and_inset.setRowsHeight(60.0);
|
diagram_scene -> border_and_titleblock.setRowsHeight(60.0);
|
||||||
diagram_scene -> border_and_inset.setNbRows(2);
|
diagram_scene -> border_and_titleblock.setNbRows(2);
|
||||||
diagram_scene -> border_and_inset.displayRows(false);
|
diagram_scene -> border_and_titleblock.displayRows(false);
|
||||||
diagram_scene -> border_and_inset.displayInset(false);
|
diagram_scene -> border_and_titleblock.displayTitleBlock(false);
|
||||||
|
|
||||||
diagram_view = new QGraphicsView(diagram_scene);
|
diagram_view = new QGraphicsView(diagram_scene);
|
||||||
diagram_view -> setMinimumSize(
|
diagram_view -> setMinimumSize(
|
||||||
qRound(diagram_scene -> border_and_inset.diagramWidth() + (3 * Diagram::margin)),
|
qRound(diagram_scene -> border_and_titleblock.diagramWidth() + (3 * Diagram::margin)),
|
||||||
qRound(diagram_scene -> border_and_inset.diagramHeight() + (3 * Diagram::margin))
|
qRound(diagram_scene -> border_and_titleblock.diagramHeight() + (3 * Diagram::margin))
|
||||||
);
|
);
|
||||||
diagram_view -> setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
diagram_view -> setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
diagram_view -> setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
diagram_view -> setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
|
|||||||
@@ -1,177 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2006-2010 Xavier Guerrin
|
|
||||||
This file is part of QElectroTech.
|
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "insetpropertieswidget.h"
|
|
||||||
#include "qetapp.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructeur
|
|
||||||
@param inset InsetProperties a afficher
|
|
||||||
@param current true pour afficher l'option "Date courante"
|
|
||||||
@param parent QWidget parent
|
|
||||||
*/
|
|
||||||
InsetPropertiesWidget::InsetPropertiesWidget(const InsetProperties &inset, bool current, QWidget *parent) : QWidget(parent), display_current_date(false) {
|
|
||||||
|
|
||||||
QVBoxLayout *this_layout = new QVBoxLayout(this);
|
|
||||||
this_layout -> setContentsMargins(0, 0, 0, 0);
|
|
||||||
QGroupBox *inset_infos = new QGroupBox(tr("Informations du cartouche"), this);
|
|
||||||
inset_infos -> setMinimumSize(300, 330);
|
|
||||||
this_layout -> addWidget(inset_infos);
|
|
||||||
|
|
||||||
inset_title = new QLineEdit(this);
|
|
||||||
inset_author = new QLineEdit(this);
|
|
||||||
|
|
||||||
QButtonGroup *date_policy_group = new QButtonGroup(this);
|
|
||||||
inset_no_date = new QRadioButton(tr("Pas de date"), this);
|
|
||||||
inset_current_date = new QRadioButton(tr("Date courante"), this);
|
|
||||||
inset_fixed_date = new QRadioButton(tr("Date fixe : "), this);
|
|
||||||
date_policy_group -> addButton(inset_no_date);
|
|
||||||
date_policy_group -> addButton(inset_current_date);
|
|
||||||
date_policy_group -> addButton(inset_fixed_date);
|
|
||||||
inset_date = new QDateEdit(QDate::currentDate(), this);
|
|
||||||
inset_date -> setEnabled(inset_fixed_date -> isChecked());
|
|
||||||
inset_current_date -> setVisible(display_current_date);
|
|
||||||
connect(inset_fixed_date, SIGNAL(toggled(bool)), inset_date, SLOT(setEnabled(bool)));
|
|
||||||
inset_date -> setCalendarPopup(true);
|
|
||||||
|
|
||||||
QGridLayout *layout_date = new QGridLayout();
|
|
||||||
layout_date -> addWidget(inset_no_date, 0, 0);
|
|
||||||
layout_date -> addWidget(inset_current_date, 1, 0);
|
|
||||||
layout_date -> addWidget(inset_fixed_date, 2, 0);
|
|
||||||
layout_date -> addWidget(inset_date, 2, 1);
|
|
||||||
layout_date -> setColumnStretch(0, 1);
|
|
||||||
layout_date -> setColumnStretch(1, 500);
|
|
||||||
|
|
||||||
inset_filename = new QLineEdit(this);
|
|
||||||
inset_folio = new QLineEdit(this);
|
|
||||||
QLabel *folio_tip = new QLabel(
|
|
||||||
tr(
|
|
||||||
"Les variables suivantes sont utilisables dans le champ Folio :\n"
|
|
||||||
" - %id : num\351ro du sch\351ma courant dans le projet\n"
|
|
||||||
" - %total : nombre total de sch\351mas dans le projet"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
folio_tip -> setWordWrap(true);
|
|
||||||
|
|
||||||
QGridLayout *layout_champs = new QGridLayout(inset_infos);
|
|
||||||
|
|
||||||
layout_champs -> addWidget(new QLabel(tr("Titre : ")), 0, 0);
|
|
||||||
layout_champs -> addWidget(inset_title, 0, 1);
|
|
||||||
layout_champs -> addWidget(new QLabel(tr("Auteur : ")), 1, 0);
|
|
||||||
layout_champs -> addWidget(inset_author, 1, 1);
|
|
||||||
layout_champs -> addWidget(new QLabel(tr("Date : ")), 2, 0, Qt::AlignTop);
|
|
||||||
layout_champs -> addLayout(layout_date, 2, 1);
|
|
||||||
layout_champs -> addWidget(new QLabel(tr("Fichier : ")), 3, 0);
|
|
||||||
layout_champs -> addWidget(inset_filename, 3, 1);
|
|
||||||
layout_champs -> addWidget(new QLabel(tr("Folio : ")), 4, 0);
|
|
||||||
layout_champs -> addWidget(inset_folio, 4, 1);
|
|
||||||
layout_champs -> addWidget(folio_tip, 5, 1, Qt::AlignTop);
|
|
||||||
layout_champs -> setRowStretch(5, 500);
|
|
||||||
|
|
||||||
inset_current_date -> setVisible(display_current_date = current);
|
|
||||||
setInsetProperties(inset);
|
|
||||||
setLayout(this_layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destructeur
|
|
||||||
InsetPropertiesWidget::~InsetPropertiesWidget() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return Les proprietes affichees par le widget
|
|
||||||
*/
|
|
||||||
InsetProperties InsetPropertiesWidget::insetProperties() const {
|
|
||||||
InsetProperties prop;
|
|
||||||
prop.title = inset_title -> text();
|
|
||||||
prop.author = inset_author -> text();
|
|
||||||
prop.filename = inset_filename -> text();
|
|
||||||
prop.folio = inset_folio -> text();
|
|
||||||
if (inset_no_date -> isChecked()) {
|
|
||||||
prop.useDate = InsetProperties::UseDateValue;
|
|
||||||
prop.date = QDate();
|
|
||||||
} else if (inset_fixed_date -> isChecked()) {
|
|
||||||
prop.useDate = InsetProperties::UseDateValue;
|
|
||||||
prop.date = inset_date -> date();
|
|
||||||
} else if (display_current_date && inset_current_date -> isChecked()) {
|
|
||||||
prop.useDate = InsetProperties::CurrentDate;
|
|
||||||
prop.date = QDate::currentDate();
|
|
||||||
}
|
|
||||||
return(prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Specifie les proprietes que le widget doit afficher
|
|
||||||
@param inset nouvelles proprietes affichees par le widget
|
|
||||||
*/
|
|
||||||
void InsetPropertiesWidget::setInsetProperties(const InsetProperties &inset) {
|
|
||||||
inset_title -> setText(inset.title);
|
|
||||||
inset_author -> setText(inset.author);
|
|
||||||
inset_filename -> setText(inset.filename);
|
|
||||||
inset_folio -> setText(inset.folio);
|
|
||||||
if (display_current_date) {
|
|
||||||
if (inset.useDate == InsetProperties::CurrentDate) {
|
|
||||||
inset_current_date -> setChecked(true);
|
|
||||||
} else {
|
|
||||||
if (inset.date.isNull()) {
|
|
||||||
inset_no_date -> setChecked(true);
|
|
||||||
} else {
|
|
||||||
inset_fixed_date -> setChecked(true);
|
|
||||||
inset_date -> setDate(inset.date);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (inset.useDate == InsetProperties::CurrentDate) {
|
|
||||||
inset_fixed_date -> setChecked(true);
|
|
||||||
inset_date -> setDate(QDate::currentDate());
|
|
||||||
} else {
|
|
||||||
if (inset.date.isNull()) {
|
|
||||||
inset_no_date -> setChecked(true);
|
|
||||||
} else {
|
|
||||||
inset_fixed_date -> setChecked(true);
|
|
||||||
inset_date -> setDate(inset.date);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return true si le widget affiche la proposition "Date courante", false sinon
|
|
||||||
*/
|
|
||||||
bool InsetPropertiesWidget::displayCurrentDate() const {
|
|
||||||
return(display_current_date);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return true si ce widget est en lecture seule, false sinon
|
|
||||||
*/
|
|
||||||
bool InsetPropertiesWidget::isReadOnly() const {
|
|
||||||
return(inset_title -> isReadOnly());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param ro true pour passer ce widget en lecture seule, false sinon
|
|
||||||
*/
|
|
||||||
void InsetPropertiesWidget::setReadOnly(bool ro) {
|
|
||||||
inset_title -> setReadOnly(ro);
|
|
||||||
inset_author -> setReadOnly(ro);
|
|
||||||
inset_date -> setReadOnly(ro);
|
|
||||||
inset_filename -> setReadOnly(ro);
|
|
||||||
inset_folio -> setReadOnly(ro);
|
|
||||||
inset_no_date -> setDisabled(ro);
|
|
||||||
inset_current_date -> setDisabled(ro);
|
|
||||||
inset_fixed_date -> setDisabled(ro);
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
#include "insettemplaterenderer.h"
|
|
||||||
#include "insettemplate.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
@param parnet Parent QObject of this renderer
|
|
||||||
*/
|
|
||||||
InsetTemplateRenderer::InsetTemplateRenderer(QObject *parent) :
|
|
||||||
QObject(parent),
|
|
||||||
inset_template_(0),
|
|
||||||
last_known_inset_width_(-1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Destructor
|
|
||||||
*/
|
|
||||||
InsetTemplateRenderer::~InsetTemplateRenderer() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return the inset template used for the rendering
|
|
||||||
*/
|
|
||||||
const InsetTemplate *InsetTemplateRenderer::insetTemplate() const {
|
|
||||||
return(inset_template_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param inset_template Inset template to render.
|
|
||||||
*/
|
|
||||||
void InsetTemplateRenderer::setInsetTemplate(const InsetTemplate *inset_template) {
|
|
||||||
if (inset_template != inset_template_) {
|
|
||||||
inset_template_ = inset_template;
|
|
||||||
invalidateRenderedTemplate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param context Diagram Context to use when rendering the inset
|
|
||||||
*/
|
|
||||||
void InsetTemplateRenderer::setContext(const DiagramContext &context) {
|
|
||||||
context_ = context;
|
|
||||||
invalidateRenderedTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return the height of the rendered template, or -1 if no template has been
|
|
||||||
set for this renderer.
|
|
||||||
@see InsetTemplate::height()
|
|
||||||
*/
|
|
||||||
int InsetTemplateRenderer::height() const {
|
|
||||||
if (!inset_template_) return(-1);
|
|
||||||
return(inset_template_ -> height());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Render the inset.
|
|
||||||
@param provided_painter QPainter to use to render the inset.
|
|
||||||
@param inset_width The total width of the inset to render
|
|
||||||
*/
|
|
||||||
void InsetTemplateRenderer::render(QPainter *provided_painter, int inset_width) {
|
|
||||||
if (!inset_template_) return;
|
|
||||||
|
|
||||||
// Do we really need to calculate all this again?
|
|
||||||
if (inset_width != last_known_inset_width_ || rendered_template_.isNull()) {
|
|
||||||
renderToQPicture(inset_width);
|
|
||||||
}
|
|
||||||
|
|
||||||
provided_painter -> save();
|
|
||||||
rendered_template_.play(provided_painter);
|
|
||||||
provided_painter -> restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Renders the inset to the internal QPicture
|
|
||||||
@param inset_width Width of the inset to render
|
|
||||||
*/
|
|
||||||
void InsetTemplateRenderer::renderToQPicture(int inset_width) {
|
|
||||||
if (!inset_template_) return;
|
|
||||||
|
|
||||||
// we render the template on our internal QPicture
|
|
||||||
QPainter painter(&rendered_template_);
|
|
||||||
|
|
||||||
inset_template_ -> render(painter, context_, inset_width);
|
|
||||||
|
|
||||||
// memorize the last known width
|
|
||||||
last_known_inset_width_ = inset_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Invalidates the previous rendering of the template by resetting the internal
|
|
||||||
QPicture.
|
|
||||||
*/
|
|
||||||
void InsetTemplateRenderer::invalidateRenderedTemplate() {
|
|
||||||
rendered_template_ = QPicture();
|
|
||||||
}
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "qetelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
#include "interactivemoveelementshandler.h"
|
#include "interactivemoveelementshandler.h"
|
||||||
#include "borderpropertieswidget.h"
|
#include "borderpropertieswidget.h"
|
||||||
#include "insetpropertieswidget.h"
|
#include "titleblockpropertieswidget.h"
|
||||||
#include "conductorpropertieswidget.h"
|
#include "conductorpropertieswidget.h"
|
||||||
#include "qeticons.h"
|
#include "qeticons.h"
|
||||||
#include "qetmessagebox.h"
|
#include "qetmessagebox.h"
|
||||||
@@ -424,7 +424,7 @@ void ProjectView::editProjectProperties() {
|
|||||||
bpw -> setReadOnly(project_is_read_only);
|
bpw -> setReadOnly(project_is_read_only);
|
||||||
|
|
||||||
// proprietes par defaut d'un cartouche
|
// proprietes par defaut d'un cartouche
|
||||||
InsetPropertiesWidget *ipw = new InsetPropertiesWidget(project_ -> defaultInsetProperties(), true);
|
TitleBlockPropertiesWidget *ipw = new TitleBlockPropertiesWidget(project_ -> defaultTitleBlockProperties(), true);
|
||||||
ipw -> setReadOnly(project_is_read_only);
|
ipw -> setReadOnly(project_is_read_only);
|
||||||
|
|
||||||
// proprietes par defaut des conducteurs
|
// proprietes par defaut des conducteurs
|
||||||
@@ -469,7 +469,7 @@ void ProjectView::editProjectProperties() {
|
|||||||
if (properties_dialog.exec() == QDialog::Accepted && !project_is_read_only) {
|
if (properties_dialog.exec() == QDialog::Accepted && !project_is_read_only) {
|
||||||
project_ -> setTitle(title_field -> text());
|
project_ -> setTitle(title_field -> text());
|
||||||
project_ -> setDefaultBorderProperties(bpw -> borderProperties());
|
project_ -> setDefaultBorderProperties(bpw -> borderProperties());
|
||||||
project_ -> setDefaultInsetProperties(ipw -> insetProperties());
|
project_ -> setDefaultTitleBlockProperties(ipw -> titleBlockProperties());
|
||||||
project_ -> setDefaultConductorProperties(cpw -> conductorProperties());
|
project_ -> setDefaultConductorProperties(cpw -> conductorProperties());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -517,11 +517,11 @@ bool QET::compareCanonicalFilePaths(const QString &first, const QString &second)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param icl an InsetColumnLength object
|
@param icl an TitleBlockColumnLength object
|
||||||
@see InsetColumnLength
|
@see TitleBlockColumnLength
|
||||||
@return a string describing the type of this InsetColumnLength object
|
@return a string describing the type of this TitleBlockColumnLength object
|
||||||
*/
|
*/
|
||||||
QString QET::insetColumnLengthToString(const InsetColumnLength &icl) {
|
QString QET::titleBlockColumnLengthToString(const TitleBlockColumnLength &icl) {
|
||||||
QString type_str;
|
QString type_str;
|
||||||
if (icl== Absolute) type_str = "absolute";
|
if (icl== Absolute) type_str = "absolute";
|
||||||
else if (icl == RelativeToTotalLength) type_str = "relative to total";
|
else if (icl == RelativeToTotalLength) type_str = "relative to total";
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace QET {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// enum used to specify the type of a length
|
/// enum used to specify the type of a length
|
||||||
enum InsetColumnLength {
|
enum TitleBlockColumnLength {
|
||||||
Absolute, ///< the length is absolute and should be applied as is
|
Absolute, ///< the length is absolute and should be applied as is
|
||||||
RelativeToTotalLength, ///< the length is just a fraction of the total available length
|
RelativeToTotalLength, ///< the length is just a fraction of the total available length
|
||||||
RelativeToRemainingLength ///< the length is just a fraction of the length that is still available when other types of lengths have been removed
|
RelativeToRemainingLength ///< the length is just a fraction of the length that is still available when other types of lengths have been removed
|
||||||
@@ -132,6 +132,6 @@ namespace QET {
|
|||||||
QString pointerString(void *);
|
QString pointerString(void *);
|
||||||
qreal correctAngle(const qreal &);
|
qreal correctAngle(const qreal &);
|
||||||
bool compareCanonicalFilePaths(const QString &, const QString &);
|
bool compareCanonicalFilePaths(const QString &, const QString &);
|
||||||
QString insetColumnLengthToString(const InsetColumnLength &);
|
QString titleBlockColumnLengthToString(const TitleBlockColumnLength &);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "qetelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
#include "elementscollectionitem.h"
|
#include "elementscollectionitem.h"
|
||||||
#include "fileelementscollection.h"
|
#include "fileelementscollection.h"
|
||||||
#include "insettemplate.h"
|
#include "titleblocktemplate.h"
|
||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "qtextorientationspinboxwidget.h"
|
#include "qtextorientationspinboxwidget.h"
|
||||||
#include "recentfiles.h"
|
#include "recentfiles.h"
|
||||||
@@ -46,7 +46,7 @@ uint QETApp::next_project_id = 0;
|
|||||||
RecentFiles *QETApp::projects_recent_files_ = 0;
|
RecentFiles *QETApp::projects_recent_files_ = 0;
|
||||||
RecentFiles *QETApp::elements_recent_files_ = 0;
|
RecentFiles *QETApp::elements_recent_files_ = 0;
|
||||||
AboutQET *QETApp::about_dialog_ = 0;
|
AboutQET *QETApp::about_dialog_ = 0;
|
||||||
InsetTemplate *QETApp::default_inset_template_ = 0;
|
TitleBlockTemplate *QETApp::default_titleblock_template_ = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -531,16 +531,16 @@ QTextOrientationSpinBoxWidget *QETApp::createTextOrientationSpinBoxWidget() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the default inset template for diagrams
|
@return the default titleblock template for diagrams
|
||||||
*/
|
*/
|
||||||
InsetTemplate *QETApp::defaultInsetTemplate() {
|
TitleBlockTemplate *QETApp::defaultTitleBlockTemplate() {
|
||||||
if (!QETApp::default_inset_template_) {
|
if (!QETApp::default_titleblock_template_) {
|
||||||
InsetTemplate *inset_template = new InsetTemplate(QETApp::instance());
|
TitleBlockTemplate *titleblock_template = new TitleBlockTemplate(QETApp::instance());
|
||||||
if (inset_template -> loadFromXmlFile(":/insets/default.inset")) {
|
if (titleblock_template -> loadFromXmlFile(":/titleblocks/default.titleblock")) {
|
||||||
QETApp::default_inset_template_ = inset_template;
|
QETApp::default_titleblock_template_ = titleblock_template;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(default_inset_template_);
|
return(default_titleblock_template_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ElementsCollectionItem;
|
|||||||
class FileElementsCollection;
|
class FileElementsCollection;
|
||||||
class ElementsCategory;
|
class ElementsCategory;
|
||||||
class ElementDefinition;
|
class ElementDefinition;
|
||||||
class InsetTemplate;
|
class TitleBlockTemplate;
|
||||||
class QETProject;
|
class QETProject;
|
||||||
class QTextOrientationSpinBoxWidget;
|
class QTextOrientationSpinBoxWidget;
|
||||||
class RecentFiles;
|
class RecentFiles;
|
||||||
@@ -99,7 +99,7 @@ class QETApp : public QETSingleApplication {
|
|||||||
static QList<QETElementEditor *> elementEditors();
|
static QList<QETElementEditor *> elementEditors();
|
||||||
static QList<QETElementEditor *> elementEditors(QETProject *);
|
static QList<QETElementEditor *> elementEditors(QETProject *);
|
||||||
static QTextOrientationSpinBoxWidget *createTextOrientationSpinBoxWidget();
|
static QTextOrientationSpinBoxWidget *createTextOrientationSpinBoxWidget();
|
||||||
static InsetTemplate *defaultInsetTemplate();
|
static TitleBlockTemplate *defaultTitleBlockTemplate();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifdef Q_OS_DARWIN
|
#ifdef Q_OS_DARWIN
|
||||||
@@ -142,7 +142,7 @@ class QETApp : public QETSingleApplication {
|
|||||||
static RecentFiles *projects_recent_files_;
|
static RecentFiles *projects_recent_files_;
|
||||||
static RecentFiles *elements_recent_files_;
|
static RecentFiles *elements_recent_files_;
|
||||||
static AboutQET *about_dialog_;
|
static AboutQET *about_dialog_;
|
||||||
static InsetTemplate *default_inset_template_;
|
static TitleBlockTemplate *default_titleblock_template_;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void systray(QSystemTrayIcon::ActivationReason);
|
void systray(QSystemTrayIcon::ActivationReason);
|
||||||
|
|||||||
@@ -660,7 +660,7 @@ bool QETDiagramEditor::newProject() {
|
|||||||
// transmet les proprietes par defaut des nouveaux schemas
|
// transmet les proprietes par defaut des nouveaux schemas
|
||||||
new_project -> setDefaultBorderProperties(defaultBorderProperties());
|
new_project -> setDefaultBorderProperties(defaultBorderProperties());
|
||||||
new_project -> setDefaultConductorProperties(defaultConductorProperties());
|
new_project -> setDefaultConductorProperties(defaultConductorProperties());
|
||||||
new_project -> setDefaultInsetProperties(defaultInsetProperties());
|
new_project -> setDefaultTitleBlockProperties(defaultTitleBlockProperties());
|
||||||
|
|
||||||
// ajoute un schema au projet
|
// ajoute un schema au projet
|
||||||
new_project -> addNewDiagram();
|
new_project -> addNewDiagram();
|
||||||
@@ -1780,11 +1780,11 @@ void QETDiagramEditor::editElementInEditor(const ElementsLocation &location) {
|
|||||||
/**
|
/**
|
||||||
@return Les proprietes par defaut pour le cartouche d'un schema
|
@return Les proprietes par defaut pour le cartouche d'un schema
|
||||||
*/
|
*/
|
||||||
InsetProperties QETDiagramEditor::defaultInsetProperties() {
|
TitleBlockProperties QETDiagramEditor::defaultTitleBlockProperties() {
|
||||||
// accede a la configuration de l'application
|
// accede a la configuration de l'application
|
||||||
QSettings &settings = QETApp::settings();
|
QSettings &settings = QETApp::settings();
|
||||||
|
|
||||||
InsetProperties def;
|
TitleBlockProperties def;
|
||||||
// lit le cartouche par defaut dans la configuration
|
// lit le cartouche par defaut dans la configuration
|
||||||
def.fromSettings(settings, "diagrameditor/default");
|
def.fromSettings(settings, "diagrameditor/default");
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "borderproperties.h"
|
#include "borderproperties.h"
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
#include "insetproperties.h"
|
#include "titleblockproperties.h"
|
||||||
#include "exportproperties.h"
|
#include "exportproperties.h"
|
||||||
class QETProject;
|
class QETProject;
|
||||||
class ProjectView;
|
class ProjectView;
|
||||||
@@ -56,7 +56,7 @@ class QETDiagramEditor : public QMainWindow {
|
|||||||
QList<DiagramView *> projectViews() const;
|
QList<DiagramView *> projectViews() const;
|
||||||
QList<QString> editedFiles() const;
|
QList<QString> editedFiles() const;
|
||||||
ProjectView *viewForFile(const QString &) const;
|
ProjectView *viewForFile(const QString &) const;
|
||||||
static InsetProperties defaultInsetProperties();
|
static TitleBlockProperties defaultTitleBlockProperties();
|
||||||
static BorderProperties defaultBorderProperties();
|
static BorderProperties defaultBorderProperties();
|
||||||
static ConductorProperties defaultConductorProperties();
|
static ConductorProperties defaultConductorProperties();
|
||||||
static ExportProperties defaultExportProperties();
|
static ExportProperties defaultExportProperties();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "integrationmoveelementshandler.h"
|
#include "integrationmoveelementshandler.h"
|
||||||
#include "basicmoveelementshandler.h"
|
#include "basicmoveelementshandler.h"
|
||||||
#include "qetmessagebox.h"
|
#include "qetmessagebox.h"
|
||||||
#include "insettemplate.h"
|
#include "titleblocktemplate.h"
|
||||||
|
|
||||||
QString QETProject::integration_category_name = "import";
|
QString QETProject::integration_category_name = "import";
|
||||||
|
|
||||||
@@ -268,10 +268,10 @@ void QETProject::setTitle(const QString &title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the list of the inset templates embedded within this project
|
@return the list of the titleblock templates embedded within this project
|
||||||
*/
|
*/
|
||||||
QList<QString> QETProject::embeddedInsetTemplates() const {
|
QList<QString> QETProject::embeddedTitleBlockTemplates() const {
|
||||||
return(inset_templates_xml_.keys());
|
return(titleblock_templates_xml_.keys());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,22 +279,22 @@ QList<QString> QETProject::embeddedInsetTemplates() const {
|
|||||||
@return the requested template, or 0 if there is no vltaid template of this
|
@return the requested template, or 0 if there is no vltaid template of this
|
||||||
name within the project
|
name within the project
|
||||||
*/
|
*/
|
||||||
const InsetTemplate *QETProject::getTemplateByName(const QString &template_name) {
|
const TitleBlockTemplate *QETProject::getTemplateByName(const QString &template_name) {
|
||||||
// Do we have already loaded this template?
|
// Do we have already loaded this template?
|
||||||
if (inset_templates_.contains(template_name)) {
|
if (titleblock_templates_.contains(template_name)) {
|
||||||
return(inset_templates_[template_name]);
|
return(titleblock_templates_[template_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No? Do we even know of it?
|
// No? Do we even know of it?
|
||||||
if (!inset_templates_xml_.contains(template_name)) {
|
if (!titleblock_templates_xml_.contains(template_name)) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, we have its XML description, we have to generate an InsetTemplate object
|
// Ok, we have its XML description, we have to generate an TitleBlockTemplate object
|
||||||
InsetTemplate *inset_template = new InsetTemplate(this);
|
TitleBlockTemplate *titleblock_template = new TitleBlockTemplate(this);
|
||||||
if (inset_template -> loadFromXmlElement(inset_templates_xml_[template_name])) {
|
if (titleblock_template -> loadFromXmlElement(titleblock_templates_xml_[template_name])) {
|
||||||
inset_templates_.insert(template_name, inset_template);
|
titleblock_templates_.insert(template_name, titleblock_template);
|
||||||
return(inset_template);
|
return(titleblock_template);
|
||||||
} else {
|
} else {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -303,11 +303,11 @@ const InsetTemplate *QETProject::getTemplateByName(const QString &template_name)
|
|||||||
/**
|
/**
|
||||||
@param template_name Name of the requested template
|
@param template_name Name of the requested template
|
||||||
@return the XML description of the requested template, or a null QDomElement
|
@return the XML description of the requested template, or a null QDomElement
|
||||||
if the project does not have such an inset template
|
if the project does not have such an titleblock template
|
||||||
*/
|
*/
|
||||||
QDomElement QETProject::getTemplateXmlDescriptionByName(const QString &template_name) {
|
QDomElement QETProject::getTemplateXmlDescriptionByName(const QString &template_name) {
|
||||||
if (inset_templates_xml_.contains(template_name)) {
|
if (titleblock_templates_xml_.contains(template_name)) {
|
||||||
return(inset_templates_xml_[template_name]);
|
return(titleblock_templates_xml_[template_name]);
|
||||||
}
|
}
|
||||||
return(QDomElement());
|
return(QDomElement());
|
||||||
}
|
}
|
||||||
@@ -333,17 +333,17 @@ void QETProject::setDefaultBorderProperties(const BorderProperties &border) {
|
|||||||
@return le cartouche par defaut utilise lors de la creation d'un
|
@return le cartouche par defaut utilise lors de la creation d'un
|
||||||
nouveau schema dans ce projet.
|
nouveau schema dans ce projet.
|
||||||
*/
|
*/
|
||||||
InsetProperties QETProject::defaultInsetProperties() const {
|
TitleBlockProperties QETProject::defaultTitleBlockProperties() const {
|
||||||
return(default_inset_properties_);
|
return(default_titleblock_properties_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de specifier le cartouche par defaut utilise lors de la creation
|
Permet de specifier le cartouche par defaut utilise lors de la creation
|
||||||
d'un nouveau schema dans ce projet.
|
d'un nouveau schema dans ce projet.
|
||||||
@param inset Cartouche d'un schema
|
@param titleblock Cartouche d'un schema
|
||||||
*/
|
*/
|
||||||
void QETProject::setDefaultInsetProperties(const InsetProperties &inset) {
|
void QETProject::setDefaultTitleBlockProperties(const TitleBlockProperties &titleblock) {
|
||||||
default_inset_properties_ = inset;
|
default_titleblock_properties_ = titleblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -373,14 +373,14 @@ QDomDocument QETProject::toXml() {
|
|||||||
project_root.setAttribute("title", project_title_);
|
project_root.setAttribute("title", project_title_);
|
||||||
xml_doc.appendChild(project_root);
|
xml_doc.appendChild(project_root);
|
||||||
|
|
||||||
// inset templates, if any
|
// titleblock templates, if any
|
||||||
if (inset_templates_xml_.count()) {
|
if (titleblock_templates_xml_.count()) {
|
||||||
qDebug() << qPrintable(QString("QETProject::toXml() : exporting %1 inset templates").arg(inset_templates_xml_.count()));
|
qDebug() << qPrintable(QString("QETProject::toXml() : exporting %1 titleblock templates").arg(titleblock_templates_xml_.count()));
|
||||||
QDomElement insettemplates_elmt = xml_doc.createElement("insettemplates");
|
QDomElement titleblocktemplates_elmt = xml_doc.createElement("titleblocktemplates");
|
||||||
foreach (QDomElement e, inset_templates_xml_) {
|
foreach (QDomElement e, titleblock_templates_xml_) {
|
||||||
insettemplates_elmt.appendChild(e);
|
titleblocktemplates_elmt.appendChild(e);
|
||||||
}
|
}
|
||||||
project_root.appendChild(insettemplates_elmt);
|
project_root.appendChild(titleblocktemplates_elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// proprietes pour les nouveaux schemas
|
// proprietes pour les nouveaux schemas
|
||||||
@@ -696,8 +696,8 @@ Diagram *QETProject::addNewDiagram() {
|
|||||||
Diagram *diagram = new Diagram();
|
Diagram *diagram = new Diagram();
|
||||||
|
|
||||||
// lui transmet les parametres par defaut
|
// lui transmet les parametres par defaut
|
||||||
diagram -> border_and_inset.importBorder(defaultBorderProperties());
|
diagram -> border_and_titleblock.importBorder(defaultBorderProperties());
|
||||||
diagram -> border_and_inset.importInset(defaultInsetProperties());
|
diagram -> border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
|
||||||
diagram -> defaultConductorProperties = defaultConductorProperties();
|
diagram -> defaultConductorProperties = defaultConductorProperties();
|
||||||
|
|
||||||
addDiagram(diagram);
|
addDiagram(diagram);
|
||||||
@@ -790,7 +790,7 @@ void QETProject::readProjectXml() {
|
|||||||
// charge les proprietes par defaut pour les nouveaux schemas
|
// charge les proprietes par defaut pour les nouveaux schemas
|
||||||
readDefaultPropertiesXml();
|
readDefaultPropertiesXml();
|
||||||
|
|
||||||
// load the embedded inset templates
|
// load the embedded titleblock templates
|
||||||
readEmbeddedTemplatesXml();
|
readEmbeddedTemplatesXml();
|
||||||
|
|
||||||
// charge la collection embarquee
|
// charge la collection embarquee
|
||||||
@@ -839,17 +839,17 @@ void QETProject::readDiagramsXml() {
|
|||||||
Loads the embedded template from the XML description of the project
|
Loads the embedded template from the XML description of the project
|
||||||
*/
|
*/
|
||||||
void QETProject::readEmbeddedTemplatesXml() {
|
void QETProject::readEmbeddedTemplatesXml() {
|
||||||
foreach (QDomElement e, QET::findInDomElement(document_root_.documentElement(), "insettemplates", "insettemplate")) {
|
foreach (QDomElement e, QET::findInDomElement(document_root_.documentElement(), "titleblocktemplates", "titleblocktemplate")) {
|
||||||
// each inset template must have a name
|
// each titleblock template must have a name
|
||||||
if (!e.hasAttribute("name")) continue;
|
if (!e.hasAttribute("name")) continue;
|
||||||
QString inset_template_name = e.attribute("name");
|
QString titleblock_template_name = e.attribute("name");
|
||||||
|
|
||||||
// if several templates have the same name, we keep the first one encountered
|
// if several templates have the same name, we keep the first one encountered
|
||||||
if (inset_templates_xml_.contains(inset_template_name)) continue;
|
if (titleblock_templates_xml_.contains(titleblock_template_name)) continue;
|
||||||
|
|
||||||
// we simply store the XML element describing the inset template,
|
// we simply store the XML element describing the titleblock template,
|
||||||
// without any further analysis for the moment
|
// without any further analysis for the moment
|
||||||
inset_templates_xml_.insert(inset_template_name, e);
|
titleblock_templates_xml_.insert(titleblock_template_name, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -893,11 +893,11 @@ void QETProject::readDefaultPropertiesXml() {
|
|||||||
|
|
||||||
// par defaut, les valeurs sont celles de la configuration QElectroTech
|
// par defaut, les valeurs sont celles de la configuration QElectroTech
|
||||||
default_border_properties_ = QETDiagramEditor::defaultBorderProperties();
|
default_border_properties_ = QETDiagramEditor::defaultBorderProperties();
|
||||||
default_inset_properties_ = QETDiagramEditor::defaultInsetProperties();
|
default_titleblock_properties_ = QETDiagramEditor::defaultTitleBlockProperties();
|
||||||
default_conductor_properties_ = QETDiagramEditor::defaultConductorProperties();
|
default_conductor_properties_ = QETDiagramEditor::defaultConductorProperties();
|
||||||
|
|
||||||
// lecture des valeurs indiquees dans le projet
|
// lecture des valeurs indiquees dans le projet
|
||||||
QDomElement border_elmt, inset_elmt, conductors_elmt;
|
QDomElement border_elmt, titleblock_elmt, conductors_elmt;
|
||||||
|
|
||||||
// recherche des elements XML concernant les dimensions, le cartouche et les conducteurs
|
// recherche des elements XML concernant les dimensions, le cartouche et les conducteurs
|
||||||
for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling()) {
|
for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling()) {
|
||||||
@@ -906,7 +906,7 @@ void QETProject::readDefaultPropertiesXml() {
|
|||||||
if (child_elmt.tagName() == "border") {
|
if (child_elmt.tagName() == "border") {
|
||||||
border_elmt = child_elmt;
|
border_elmt = child_elmt;
|
||||||
} else if (child_elmt.tagName() == "inset") {
|
} else if (child_elmt.tagName() == "inset") {
|
||||||
inset_elmt = child_elmt;
|
titleblock_elmt = child_elmt;
|
||||||
} else if (child_elmt.tagName() == "conductors") {
|
} else if (child_elmt.tagName() == "conductors") {
|
||||||
conductors_elmt = child_elmt;
|
conductors_elmt = child_elmt;
|
||||||
}
|
}
|
||||||
@@ -914,7 +914,7 @@ void QETProject::readDefaultPropertiesXml() {
|
|||||||
|
|
||||||
// dimensions, cartouche, et conducteurs
|
// dimensions, cartouche, et conducteurs
|
||||||
if (!border_elmt.isNull()) default_border_properties_.fromXml(border_elmt);
|
if (!border_elmt.isNull()) default_border_properties_.fromXml(border_elmt);
|
||||||
if (!inset_elmt.isNull()) default_inset_properties_.fromXml(inset_elmt);
|
if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt);
|
||||||
if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt);
|
if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -935,9 +935,9 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
|
|||||||
xml_element.appendChild(border_elmt);
|
xml_element.appendChild(border_elmt);
|
||||||
|
|
||||||
// exporte le contenu du cartouche
|
// exporte le contenu du cartouche
|
||||||
QDomElement inset_elmt = xml_document.createElement("inset");
|
QDomElement titleblock_elmt = xml_document.createElement("inset");
|
||||||
default_inset_properties_.toXml(inset_elmt);
|
default_titleblock_properties_.toXml(titleblock_elmt);
|
||||||
xml_element.appendChild(inset_elmt);
|
xml_element.appendChild(titleblock_elmt);
|
||||||
|
|
||||||
// exporte le type de conducteur par defaut
|
// exporte le type de conducteur par defaut
|
||||||
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
||||||
@@ -958,7 +958,7 @@ void QETProject::addDiagram(Diagram *diagram) {
|
|||||||
// si le schema est ecrit, alors il faut reecrire le fichier projet
|
// si le schema est ecrit, alors il faut reecrire le fichier projet
|
||||||
connect(diagram, SIGNAL(written()), this, SLOT(componentWritten()));
|
connect(diagram, SIGNAL(written()), this, SLOT(componentWritten()));
|
||||||
connect(
|
connect(
|
||||||
&(diagram -> border_and_inset),
|
&(diagram -> border_and_titleblock),
|
||||||
SIGNAL(needFolioData()),
|
SIGNAL(needFolioData()),
|
||||||
this,
|
this,
|
||||||
SLOT(updateDiagramsFolioData())
|
SLOT(updateDiagramsFolioData())
|
||||||
@@ -1059,7 +1059,7 @@ bool QETProject::projectWasModified() {
|
|||||||
void QETProject::updateDiagramsFolioData() {
|
void QETProject::updateDiagramsFolioData() {
|
||||||
int total_folio = diagrams_.count();
|
int total_folio = diagrams_.count();
|
||||||
for (int i = 0 ; i < total_folio ; ++ i) {
|
for (int i = 0 ; i < total_folio ; ++ i) {
|
||||||
diagrams_[i] -> border_and_inset.setFolioData(i + 1, total_folio);
|
diagrams_[i] -> border_and_titleblock.setFolioData(i + 1, total_folio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,13 +23,13 @@
|
|||||||
#include "elementslocation.h"
|
#include "elementslocation.h"
|
||||||
#include "borderproperties.h"
|
#include "borderproperties.h"
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
#include "insetproperties.h"
|
#include "titleblockproperties.h"
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class ElementsCollection;
|
class ElementsCollection;
|
||||||
class ElementsCategory;
|
class ElementsCategory;
|
||||||
class ElementDefinition;
|
class ElementDefinition;
|
||||||
class ElementsLocation;
|
class ElementsLocation;
|
||||||
class InsetTemplate;
|
class TitleBlockTemplate;
|
||||||
class XmlElementsCollection;
|
class XmlElementsCollection;
|
||||||
class MoveElementsHandler;
|
class MoveElementsHandler;
|
||||||
/**
|
/**
|
||||||
@@ -80,13 +80,13 @@ class QETProject : public QObject {
|
|||||||
QString title() const;
|
QString title() const;
|
||||||
qreal declaredQElectroTechVersion();
|
qreal declaredQElectroTechVersion();
|
||||||
void setTitle(const QString &);
|
void setTitle(const QString &);
|
||||||
QList<QString> embeddedInsetTemplates() const;
|
QList<QString> embeddedTitleBlockTemplates() const;
|
||||||
const InsetTemplate *getTemplateByName(const QString &template_name);
|
const TitleBlockTemplate *getTemplateByName(const QString &template_name);
|
||||||
QDomElement getTemplateXmlDescriptionByName(const QString &);
|
QDomElement getTemplateXmlDescriptionByName(const QString &);
|
||||||
BorderProperties defaultBorderProperties() const;
|
BorderProperties defaultBorderProperties() const;
|
||||||
void setDefaultBorderProperties(const BorderProperties &);
|
void setDefaultBorderProperties(const BorderProperties &);
|
||||||
InsetProperties defaultInsetProperties() const;
|
TitleBlockProperties defaultTitleBlockProperties() const;
|
||||||
void setDefaultInsetProperties(const InsetProperties &);
|
void setDefaultTitleBlockProperties(const TitleBlockProperties &);
|
||||||
ConductorProperties defaultConductorProperties() const;
|
ConductorProperties defaultConductorProperties() const;
|
||||||
void setDefaultConductorProperties(const ConductorProperties &);
|
void setDefaultConductorProperties(const ConductorProperties &);
|
||||||
QDomDocument toXml();
|
QDomDocument toXml();
|
||||||
@@ -162,10 +162,10 @@ class QETProject : public QObject {
|
|||||||
/// Proprietes par defaut des conducteurs pour les nouveaux schemas dans ce projet
|
/// Proprietes par defaut des conducteurs pour les nouveaux schemas dans ce projet
|
||||||
ConductorProperties default_conductor_properties_;
|
ConductorProperties default_conductor_properties_;
|
||||||
/// Proprietes par defaut du cartouche pour les nouveaux schemas dans ce projet
|
/// Proprietes par defaut du cartouche pour les nouveaux schemas dans ce projet
|
||||||
InsetProperties default_inset_properties_;
|
TitleBlockProperties default_titleblock_properties_;
|
||||||
/// XML descriptions of embedded inset templates
|
/// XML descriptions of embedded titleblock templates
|
||||||
QHash<QString, QDomElement> inset_templates_xml_;
|
QHash<QString, QDomElement> titleblock_templates_xml_;
|
||||||
/// Already parsed embedded inset templates
|
/// Already parsed embedded titleblock templates
|
||||||
QHash<QString, InsetTemplate *> inset_templates_;
|
QHash<QString, TitleBlockTemplate *> titleblock_templates_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,22 +15,22 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef INSET_CELL_H
|
#ifndef TITLEBLOCK_CELL_H
|
||||||
#define INSET_CELL_H
|
#define TITLEBLOCK_CELL_H
|
||||||
/**
|
/**
|
||||||
This class is a container for the various parameters of an inset cell
|
This class is a container for the various parameters of an titleblock cell
|
||||||
@see InsetColumnLength
|
@see TitleBlockColumnLength
|
||||||
*/
|
*/
|
||||||
class InsetCell {
|
class TitleBlockCell {
|
||||||
public:
|
public:
|
||||||
InsetCell();
|
TitleBlockCell();
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
bool is_null;
|
bool is_null;
|
||||||
int num_row;
|
int num_row;
|
||||||
int num_col;
|
int num_col;
|
||||||
int row_span;
|
int row_span;
|
||||||
int col_span;
|
int col_span;
|
||||||
InsetCell *spanner_cell;
|
TitleBlockCell *spanner_cell;
|
||||||
QString value_name;
|
QString value_name;
|
||||||
QString value;
|
QString value;
|
||||||
QString label;
|
QString label;
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "insetproperties.h"
|
#include "titleblockproperties.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur. Initialise un objet InsetProperties avec tous les champs
|
Constructeur. Initialise un objet TitleBlockProperties avec tous les champs
|
||||||
vides (date vide + useDate a UseDateValue).
|
vides (date vide + useDate a UseDateValue).
|
||||||
*/
|
*/
|
||||||
InsetProperties::InsetProperties() :
|
TitleBlockProperties::TitleBlockProperties() :
|
||||||
date(),
|
date(),
|
||||||
useDate(UseDateValue)
|
useDate(UseDateValue)
|
||||||
{
|
{
|
||||||
@@ -30,14 +30,14 @@ InsetProperties::InsetProperties() :
|
|||||||
/**
|
/**
|
||||||
Destructeur
|
Destructeur
|
||||||
*/
|
*/
|
||||||
InsetProperties::~InsetProperties() {
|
TitleBlockProperties::~TitleBlockProperties() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param ip autre conteneur InsetProperties
|
@param ip autre conteneur TitleBlockProperties
|
||||||
@return true si ip et ce conteneur sont identiques, false sinon
|
@return true si ip et ce conteneur sont identiques, false sinon
|
||||||
*/
|
*/
|
||||||
bool InsetProperties::operator==(const InsetProperties &ip) {
|
bool TitleBlockProperties::operator==(const TitleBlockProperties &ip) {
|
||||||
return(
|
return(
|
||||||
ip.title == title &&\
|
ip.title == title &&\
|
||||||
ip.author == author &&\
|
ip.author == author &&\
|
||||||
@@ -48,10 +48,10 @@ bool InsetProperties::operator==(const InsetProperties &ip) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param ip autre conteneur InsetProperties
|
@param ip autre conteneur TitleBlockProperties
|
||||||
@return false si ip et ce conteneur sont identiques, true sinon
|
@return false si ip et ce conteneur sont identiques, true sinon
|
||||||
*/
|
*/
|
||||||
bool InsetProperties::operator!=(const InsetProperties &ip) {
|
bool TitleBlockProperties::operator!=(const TitleBlockProperties &ip) {
|
||||||
return(!(*this == ip));
|
return(!(*this == ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ bool InsetProperties::operator!=(const InsetProperties &ip) {
|
|||||||
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
|
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
|
||||||
@param e Element XML auquel seront ajoutes des attributs
|
@param e Element XML auquel seront ajoutes des attributs
|
||||||
*/
|
*/
|
||||||
void InsetProperties::toXml(QDomElement &e) const {
|
void TitleBlockProperties::toXml(QDomElement &e) const {
|
||||||
e.setAttribute("author", author);
|
e.setAttribute("author", author);
|
||||||
e.setAttribute("title", title);
|
e.setAttribute("title", title);
|
||||||
e.setAttribute("filename", filename);
|
e.setAttribute("filename", filename);
|
||||||
@@ -72,7 +72,7 @@ void InsetProperties::toXml(QDomElement &e) const {
|
|||||||
Importe le cartouche a partir des attributs XML de l'element e
|
Importe le cartouche a partir des attributs XML de l'element e
|
||||||
@param e Element XML dont les attributs seront lus
|
@param e Element XML dont les attributs seront lus
|
||||||
*/
|
*/
|
||||||
void InsetProperties::fromXml(QDomElement &e) {
|
void TitleBlockProperties::fromXml(QDomElement &e) {
|
||||||
if (e.hasAttribute("author")) author = e.attribute("author");
|
if (e.hasAttribute("author")) author = e.attribute("author");
|
||||||
if (e.hasAttribute("title")) title = e.attribute("title");
|
if (e.hasAttribute("title")) title = e.attribute("title");
|
||||||
if (e.hasAttribute("filename")) filename = e.attribute("filename");
|
if (e.hasAttribute("filename")) filename = e.attribute("filename");
|
||||||
@@ -85,7 +85,7 @@ void InsetProperties::fromXml(QDomElement &e) {
|
|||||||
@param settings Parametres a ecrire
|
@param settings Parametres a ecrire
|
||||||
@param prefix prefixe a ajouter devant les noms des parametres
|
@param prefix prefixe a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void InsetProperties::toSettings(QSettings &settings, const QString &prefix) const {
|
void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix) const {
|
||||||
settings.setValue(prefix + "title", title);
|
settings.setValue(prefix + "title", title);
|
||||||
settings.setValue(prefix + "author", author);
|
settings.setValue(prefix + "author", author);
|
||||||
settings.setValue(prefix + "filename", filename);
|
settings.setValue(prefix + "filename", filename);
|
||||||
@@ -98,7 +98,7 @@ void InsetProperties::toSettings(QSettings &settings, const QString &prefix) con
|
|||||||
@param settings Parametres a lire
|
@param settings Parametres a lire
|
||||||
@param prefix prefixe a ajouter devant les noms des parametres
|
@param prefix prefixe a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void InsetProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
void TitleBlockProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
||||||
title = settings.value(prefix + "title").toString();
|
title = settings.value(prefix + "title").toString();
|
||||||
author = settings.value(prefix + "author").toString();
|
author = settings.value(prefix + "author").toString();
|
||||||
filename = settings.value(prefix + "filename").toString();
|
filename = settings.value(prefix + "filename").toString();
|
||||||
@@ -109,7 +109,7 @@ void InsetProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
|||||||
/**
|
/**
|
||||||
@return La date a utiliser
|
@return La date a utiliser
|
||||||
*/
|
*/
|
||||||
QDate InsetProperties::finalDate() const {
|
QDate TitleBlockProperties::finalDate() const {
|
||||||
if (useDate == UseDateValue) {
|
if (useDate == UseDateValue) {
|
||||||
return(date);
|
return(date);
|
||||||
} else {
|
} else {
|
||||||
@@ -124,7 +124,7 @@ QDate InsetProperties::finalDate() const {
|
|||||||
* now pour afficher la date courante (a la creation du schema)
|
* now pour afficher la date courante (a la creation du schema)
|
||||||
* une date au format yyyyMMdd pour utiliser une date fixe
|
* une date au format yyyyMMdd pour utiliser une date fixe
|
||||||
*/
|
*/
|
||||||
QString InsetProperties::exportDate() const {
|
QString TitleBlockProperties::exportDate() const {
|
||||||
QString date_setting_value;
|
QString date_setting_value;
|
||||||
if (useDate == UseDateValue) {
|
if (useDate == UseDateValue) {
|
||||||
if (date.isNull()) date_setting_value = "null";
|
if (date.isNull()) date_setting_value = "null";
|
||||||
@@ -140,7 +140,7 @@ QString InsetProperties::exportDate() const {
|
|||||||
@param date_string Chaine de caracteres a analyser
|
@param date_string Chaine de caracteres a analyser
|
||||||
@see exportDate
|
@see exportDate
|
||||||
*/
|
*/
|
||||||
void InsetProperties::setDateFromString(const QString &date_string) {
|
void TitleBlockProperties::setDateFromString(const QString &date_string) {
|
||||||
if (date_string == "now") {
|
if (date_string == "now") {
|
||||||
date = QDate::currentDate();
|
date = QDate::currentDate();
|
||||||
useDate = CurrentDate;
|
useDate = CurrentDate;
|
||||||
@@ -15,26 +15,26 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef INSET_PROPERTIES_H
|
#ifndef TITLEBLOCK_PROPERTIES_H
|
||||||
#define INSET_PROPERTIES_H
|
#define TITLEBLOCK_PROPERTIES_H
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
/**
|
/**
|
||||||
Cette classe est un conteneur pour les proprietes d'un cartouche de schema
|
Cette classe est un conteneur pour les proprietes d'un cartouche de schema
|
||||||
: titre, auteur, date, nom de fichier et folio
|
: titre, auteur, date, nom de fichier et folio
|
||||||
*/
|
*/
|
||||||
class InsetProperties {
|
class TitleBlockProperties {
|
||||||
public:
|
public:
|
||||||
InsetProperties();
|
TitleBlockProperties();
|
||||||
virtual ~InsetProperties();
|
virtual ~TitleBlockProperties();
|
||||||
/// Specifie comment gerer la date
|
/// Specifie comment gerer la date
|
||||||
enum DateManagement {
|
enum DateManagement {
|
||||||
UseDateValue, ///< utilise l'attribut date
|
UseDateValue, ///< utilise l'attribut date
|
||||||
CurrentDate ///< utilise la date courante
|
CurrentDate ///< utilise la date courante
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const InsetProperties &);
|
bool operator==(const TitleBlockProperties &);
|
||||||
bool operator!=(const InsetProperties &);
|
bool operator!=(const TitleBlockProperties &);
|
||||||
|
|
||||||
void toXml(QDomElement &) const;
|
void toXml(QDomElement &) const;
|
||||||
void fromXml(QDomElement &);
|
void fromXml(QDomElement &);
|
||||||
177
sources/titleblockpropertieswidget.cpp
Normal file
177
sources/titleblockpropertieswidget.cpp
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2010 Xavier Guerrin
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "titleblockpropertieswidget.h"
|
||||||
|
#include "qetapp.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructeur
|
||||||
|
@param titleblock TitleBlockProperties a afficher
|
||||||
|
@param current true pour afficher l'option "Date courante"
|
||||||
|
@param parent QWidget parent
|
||||||
|
*/
|
||||||
|
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current, QWidget *parent) : QWidget(parent), display_current_date(false) {
|
||||||
|
|
||||||
|
QVBoxLayout *this_layout = new QVBoxLayout(this);
|
||||||
|
this_layout -> setContentsMargins(0, 0, 0, 0);
|
||||||
|
QGroupBox *titleblock_infos = new QGroupBox(tr("Informations du cartouche"), this);
|
||||||
|
titleblock_infos -> setMinimumSize(300, 330);
|
||||||
|
this_layout -> addWidget(titleblock_infos);
|
||||||
|
|
||||||
|
titleblock_title = new QLineEdit(this);
|
||||||
|
titleblock_author = new QLineEdit(this);
|
||||||
|
|
||||||
|
QButtonGroup *date_policy_group = new QButtonGroup(this);
|
||||||
|
titleblock_no_date = new QRadioButton(tr("Pas de date"), this);
|
||||||
|
titleblock_current_date = new QRadioButton(tr("Date courante"), this);
|
||||||
|
titleblock_fixed_date = new QRadioButton(tr("Date fixe : "), this);
|
||||||
|
date_policy_group -> addButton(titleblock_no_date);
|
||||||
|
date_policy_group -> addButton(titleblock_current_date);
|
||||||
|
date_policy_group -> addButton(titleblock_fixed_date);
|
||||||
|
titleblock_date = new QDateEdit(QDate::currentDate(), this);
|
||||||
|
titleblock_date -> setEnabled(titleblock_fixed_date -> isChecked());
|
||||||
|
titleblock_current_date -> setVisible(display_current_date);
|
||||||
|
connect(titleblock_fixed_date, SIGNAL(toggled(bool)), titleblock_date, SLOT(setEnabled(bool)));
|
||||||
|
titleblock_date -> setCalendarPopup(true);
|
||||||
|
|
||||||
|
QGridLayout *layout_date = new QGridLayout();
|
||||||
|
layout_date -> addWidget(titleblock_no_date, 0, 0);
|
||||||
|
layout_date -> addWidget(titleblock_current_date, 1, 0);
|
||||||
|
layout_date -> addWidget(titleblock_fixed_date, 2, 0);
|
||||||
|
layout_date -> addWidget(titleblock_date, 2, 1);
|
||||||
|
layout_date -> setColumnStretch(0, 1);
|
||||||
|
layout_date -> setColumnStretch(1, 500);
|
||||||
|
|
||||||
|
titleblock_filename = new QLineEdit(this);
|
||||||
|
titleblock_folio = new QLineEdit(this);
|
||||||
|
QLabel *folio_tip = new QLabel(
|
||||||
|
tr(
|
||||||
|
"Les variables suivantes sont utilisables dans le champ Folio :\n"
|
||||||
|
" - %id : num\351ro du sch\351ma courant dans le projet\n"
|
||||||
|
" - %total : nombre total de sch\351mas dans le projet"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
folio_tip -> setWordWrap(true);
|
||||||
|
|
||||||
|
QGridLayout *layout_champs = new QGridLayout(titleblock_infos);
|
||||||
|
|
||||||
|
layout_champs -> addWidget(new QLabel(tr("Titre : ")), 0, 0);
|
||||||
|
layout_champs -> addWidget(titleblock_title, 0, 1);
|
||||||
|
layout_champs -> addWidget(new QLabel(tr("Auteur : ")), 1, 0);
|
||||||
|
layout_champs -> addWidget(titleblock_author, 1, 1);
|
||||||
|
layout_champs -> addWidget(new QLabel(tr("Date : ")), 2, 0, Qt::AlignTop);
|
||||||
|
layout_champs -> addLayout(layout_date, 2, 1);
|
||||||
|
layout_champs -> addWidget(new QLabel(tr("Fichier : ")), 3, 0);
|
||||||
|
layout_champs -> addWidget(titleblock_filename, 3, 1);
|
||||||
|
layout_champs -> addWidget(new QLabel(tr("Folio : ")), 4, 0);
|
||||||
|
layout_champs -> addWidget(titleblock_folio, 4, 1);
|
||||||
|
layout_champs -> addWidget(folio_tip, 5, 1, Qt::AlignTop);
|
||||||
|
layout_champs -> setRowStretch(5, 500);
|
||||||
|
|
||||||
|
titleblock_current_date -> setVisible(display_current_date = current);
|
||||||
|
setTitleBlockProperties(titleblock);
|
||||||
|
setLayout(this_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destructeur
|
||||||
|
TitleBlockPropertiesWidget::~TitleBlockPropertiesWidget() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return Les proprietes affichees par le widget
|
||||||
|
*/
|
||||||
|
TitleBlockProperties TitleBlockPropertiesWidget::titleBlockProperties() const {
|
||||||
|
TitleBlockProperties prop;
|
||||||
|
prop.title = titleblock_title -> text();
|
||||||
|
prop.author = titleblock_author -> text();
|
||||||
|
prop.filename = titleblock_filename -> text();
|
||||||
|
prop.folio = titleblock_folio -> text();
|
||||||
|
if (titleblock_no_date -> isChecked()) {
|
||||||
|
prop.useDate = TitleBlockProperties::UseDateValue;
|
||||||
|
prop.date = QDate();
|
||||||
|
} else if (titleblock_fixed_date -> isChecked()) {
|
||||||
|
prop.useDate = TitleBlockProperties::UseDateValue;
|
||||||
|
prop.date = titleblock_date -> date();
|
||||||
|
} else if (display_current_date && titleblock_current_date -> isChecked()) {
|
||||||
|
prop.useDate = TitleBlockProperties::CurrentDate;
|
||||||
|
prop.date = QDate::currentDate();
|
||||||
|
}
|
||||||
|
return(prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Specifie les proprietes que le widget doit afficher
|
||||||
|
@param titleblock nouvelles proprietes affichees par le widget
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setTitleBlockProperties(const TitleBlockProperties &titleblock) {
|
||||||
|
titleblock_title -> setText(titleblock.title);
|
||||||
|
titleblock_author -> setText(titleblock.author);
|
||||||
|
titleblock_filename -> setText(titleblock.filename);
|
||||||
|
titleblock_folio -> setText(titleblock.folio);
|
||||||
|
if (display_current_date) {
|
||||||
|
if (titleblock.useDate == TitleBlockProperties::CurrentDate) {
|
||||||
|
titleblock_current_date -> setChecked(true);
|
||||||
|
} else {
|
||||||
|
if (titleblock.date.isNull()) {
|
||||||
|
titleblock_no_date -> setChecked(true);
|
||||||
|
} else {
|
||||||
|
titleblock_fixed_date -> setChecked(true);
|
||||||
|
titleblock_date -> setDate(titleblock.date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (titleblock.useDate == TitleBlockProperties::CurrentDate) {
|
||||||
|
titleblock_fixed_date -> setChecked(true);
|
||||||
|
titleblock_date -> setDate(QDate::currentDate());
|
||||||
|
} else {
|
||||||
|
if (titleblock.date.isNull()) {
|
||||||
|
titleblock_no_date -> setChecked(true);
|
||||||
|
} else {
|
||||||
|
titleblock_fixed_date -> setChecked(true);
|
||||||
|
titleblock_date -> setDate(titleblock.date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return true si le widget affiche la proposition "Date courante", false sinon
|
||||||
|
*/
|
||||||
|
bool TitleBlockPropertiesWidget::displayCurrentDate() const {
|
||||||
|
return(display_current_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return true si ce widget est en lecture seule, false sinon
|
||||||
|
*/
|
||||||
|
bool TitleBlockPropertiesWidget::isReadOnly() const {
|
||||||
|
return(titleblock_title -> isReadOnly());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param ro true pour passer ce widget en lecture seule, false sinon
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setReadOnly(bool ro) {
|
||||||
|
titleblock_title -> setReadOnly(ro);
|
||||||
|
titleblock_author -> setReadOnly(ro);
|
||||||
|
titleblock_date -> setReadOnly(ro);
|
||||||
|
titleblock_filename -> setReadOnly(ro);
|
||||||
|
titleblock_folio -> setReadOnly(ro);
|
||||||
|
titleblock_no_date -> setDisabled(ro);
|
||||||
|
titleblock_current_date -> setDisabled(ro);
|
||||||
|
titleblock_fixed_date -> setDisabled(ro);
|
||||||
|
}
|
||||||
@@ -15,41 +15,41 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef INSET_PROPERTIES_WIDGET_H
|
#ifndef TITLEBLOCK_PROPERTIES_WIDGET_H
|
||||||
#define INSET_PROPERTIES_WIDGET_H
|
#define TITLEBLOCK_PROPERTIES_WIDGET_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "insetproperties.h"
|
#include "titleblockproperties.h"
|
||||||
/**
|
/**
|
||||||
Ce widget permet d'editer un objet InsetProperties, c'est-a-dire les
|
Ce widget permet d'editer un objet TitleBlockProperties, c'est-a-dire les
|
||||||
valeurs affichees par le cartouche d'un schema.
|
valeurs affichees par le cartouche d'un schema.
|
||||||
*/
|
*/
|
||||||
class InsetPropertiesWidget : public QWidget {
|
class TitleBlockPropertiesWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
InsetPropertiesWidget(const InsetProperties &inset = InsetProperties(), bool = false, QWidget * = 0);
|
TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock = TitleBlockProperties(), bool = false, QWidget * = 0);
|
||||||
virtual ~InsetPropertiesWidget();
|
virtual ~TitleBlockPropertiesWidget();
|
||||||
private:
|
private:
|
||||||
InsetPropertiesWidget(const InsetPropertiesWidget &);
|
TitleBlockPropertiesWidget(const TitleBlockPropertiesWidget &);
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
InsetProperties insetProperties() const;
|
TitleBlockProperties titleBlockProperties() const;
|
||||||
void setInsetProperties(const InsetProperties &);
|
void setTitleBlockProperties(const TitleBlockProperties &);
|
||||||
bool displayCurrentDate() const;
|
bool displayCurrentDate() const;
|
||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
void setReadOnly(bool);
|
void setReadOnly(bool);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
QLineEdit *inset_title;
|
QLineEdit *titleblock_title;
|
||||||
QLineEdit *inset_author;
|
QLineEdit *titleblock_author;
|
||||||
QDateEdit *inset_date;
|
QDateEdit *titleblock_date;
|
||||||
QLineEdit *inset_filename;
|
QLineEdit *titleblock_filename;
|
||||||
QLineEdit *inset_folio;
|
QLineEdit *titleblock_folio;
|
||||||
QRadioButton *inset_no_date;
|
QRadioButton *titleblock_no_date;
|
||||||
QRadioButton *inset_current_date;
|
QRadioButton *titleblock_current_date;
|
||||||
QRadioButton *inset_fixed_date;
|
QRadioButton *titleblock_fixed_date;
|
||||||
bool display_current_date;
|
bool display_current_date;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "insettemplate.h"
|
#include "titleblocktemplate.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
Constructor
|
Constructor
|
||||||
@param parent parent QObject
|
@param parent parent QObject
|
||||||
*/
|
*/
|
||||||
InsetTemplate::InsetTemplate(QObject *parent) :
|
TitleBlockTemplate::TitleBlockTemplate(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ InsetTemplate::InsetTemplate(QObject *parent) :
|
|||||||
/**
|
/**
|
||||||
Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
InsetTemplate::~InsetTemplate() {
|
TitleBlockTemplate::~TitleBlockTemplate() {
|
||||||
loadLogos(QDomElement(), true);
|
loadLogos(QDomElement(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ InsetTemplate::~InsetTemplate() {
|
|||||||
@param filepath A file path to read the template from.
|
@param filepath A file path to read the template from.
|
||||||
@return true if the reading succeeds, false otherwise.
|
@return true if the reading succeeds, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool InsetTemplate::loadFromXmlFile(const QString &filepath) {
|
bool TitleBlockTemplate::loadFromXmlFile(const QString &filepath) {
|
||||||
// opens the file
|
// opens the file
|
||||||
QFile template_file(filepath);
|
QFile template_file(filepath);
|
||||||
if (!template_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!template_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
@@ -51,7 +51,7 @@ bool InsetTemplate::loadFromXmlFile(const QString &filepath) {
|
|||||||
if (!xml_parsing) {
|
if (!xml_parsing) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << filepath << "opened";
|
qDebug() << Q_FUNC_INFO << filepath << "opened";
|
||||||
#endif
|
#endif
|
||||||
return(loadFromXmlElement(xml_description_.documentElement()));
|
return(loadFromXmlElement(xml_description_.documentElement()));
|
||||||
@@ -61,9 +61,9 @@ bool InsetTemplate::loadFromXmlFile(const QString &filepath) {
|
|||||||
@param xml_element An XML document to read the template from.
|
@param xml_element An XML document to read the template from.
|
||||||
@return true if the reading succeeds, false otherwise.
|
@return true if the reading succeeds, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool InsetTemplate::loadFromXmlElement(const QDomElement &xml_element) {
|
bool TitleBlockTemplate::loadFromXmlElement(const QDomElement &xml_element) {
|
||||||
// we expect the XML element to be an <insettemplate>
|
// we expect the XML element to be an <titleblocktemplate>
|
||||||
if (xml_element.tagName() != "insettemplate") {
|
if (xml_element.tagName() != "titleblocktemplate") {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,13 +73,13 @@ bool InsetTemplate::loadFromXmlElement(const QDomElement &xml_element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Imports the logos from a given XML inset template.
|
Imports the logos from a given XML titleblock template.
|
||||||
@param xml_element An XML element representing an inset template.
|
@param xml_element An XML element representing an titleblock template.
|
||||||
@param reset true to delete all previously known logos before, false
|
@param reset true to delete all previously known logos before, false
|
||||||
otherwise.
|
otherwise.
|
||||||
@return true if the reading succeeds, false otherwise.
|
@return true if the reading succeeds, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool InsetTemplate::loadLogos(const QDomElement &xml_element, bool reset) {
|
bool TitleBlockTemplate::loadLogos(const QDomElement &xml_element, bool reset) {
|
||||||
if (reset) {
|
if (reset) {
|
||||||
qDeleteAll(vector_logos_.begin(), vector_logos_.end());
|
qDeleteAll(vector_logos_.begin(), vector_logos_.end());
|
||||||
vector_logos_.clear();
|
vector_logos_.clear();
|
||||||
@@ -103,11 +103,11 @@ bool InsetTemplate::loadLogos(const QDomElement &xml_element, bool reset) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Imports the logo from a given XML logo description.
|
Imports the logo from a given XML logo description.
|
||||||
@param xml_element An XML element representing a logo within an inset
|
@param xml_element An XML element representing a logo within an titleblock
|
||||||
template.
|
template.
|
||||||
@return true if the reading succeeds, false otherwise.
|
@return true if the reading succeeds, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool InsetTemplate::loadLogo(const QDomElement &xml_element) {
|
bool TitleBlockTemplate::loadLogo(const QDomElement &xml_element) {
|
||||||
// we require a name
|
// we require a name
|
||||||
if (!xml_element.hasAttribute("name")) {
|
if (!xml_element.hasAttribute("name")) {
|
||||||
return(false);
|
return(false);
|
||||||
@@ -161,11 +161,11 @@ bool InsetTemplate::loadLogo(const QDomElement &xml_element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Imports the grid from a given XML inset template.
|
Imports the grid from a given XML titleblock template.
|
||||||
@param xml_element An XML element representing an inset template.
|
@param xml_element An XML element representing an titleblock template.
|
||||||
@return true if the reading succeeds, false otherwise.
|
@return true if the reading succeeds, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool InsetTemplate::loadGrid(const QDomElement &xml_element) {
|
bool TitleBlockTemplate::loadGrid(const QDomElement &xml_element) {
|
||||||
// we parse the first available "grid" XML element
|
// we parse the first available "grid" XML element
|
||||||
QDomElement grid_element;
|
QDomElement grid_element;
|
||||||
for (QDomNode n = xml_element.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
|
for (QDomNode n = xml_element.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
|
||||||
@@ -187,9 +187,9 @@ bool InsetTemplate::loadGrid(const QDomElement &xml_element) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Parses the rows heights
|
Parses the rows heights
|
||||||
@param rows_string A string describing the rows heights of the inset
|
@param rows_string A string describing the rows heights of the titleblock
|
||||||
*/
|
*/
|
||||||
void InsetTemplate::parseRows(const QString &rows_string) {
|
void TitleBlockTemplate::parseRows(const QString &rows_string) {
|
||||||
rows_heights_.clear();
|
rows_heights_.clear();
|
||||||
// parse the rows attribute: we expect a serie of absolute heights
|
// parse the rows attribute: we expect a serie of absolute heights
|
||||||
QRegExp row_size_format("^([0-9]+)(?:px)?$", Qt::CaseInsensitive);
|
QRegExp row_size_format("^([0-9]+)(?:px)?$", Qt::CaseInsensitive);
|
||||||
@@ -202,16 +202,16 @@ void InsetTemplate::parseRows(const QString &rows_string) {
|
|||||||
if (conv_ok) rows_heights_ << row_size;
|
if (conv_ok) rows_heights_ << row_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << "Rows heights:" << rows_heights_;
|
qDebug() << Q_FUNC_INFO << "Rows heights:" << rows_heights_;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Parses the columns widths
|
Parses the columns widths
|
||||||
@param cols_string A string describing the columns widths of the inset
|
@param cols_string A string describing the columns widths of the titleblock
|
||||||
*/
|
*/
|
||||||
void InsetTemplate::parseColumns(const QString &cols_string) {
|
void TitleBlockTemplate::parseColumns(const QString &cols_string) {
|
||||||
columns_width_.clear();
|
columns_width_.clear();
|
||||||
// parse the cols attribute: we expect a serie of absolute or relative widths
|
// parse the cols attribute: we expect a serie of absolute or relative widths
|
||||||
QRegExp abs_col_size_format("^([0-9]+)(?:px)?$", Qt::CaseInsensitive);
|
QRegExp abs_col_size_format("^([0-9]+)(?:px)?$", Qt::CaseInsensitive);
|
||||||
@@ -222,16 +222,16 @@ void InsetTemplate::parseColumns(const QString &cols_string) {
|
|||||||
foreach (QString cols_description, cols_descriptions) {
|
foreach (QString cols_description, cols_descriptions) {
|
||||||
if (abs_col_size_format.exactMatch(cols_description)) {
|
if (abs_col_size_format.exactMatch(cols_description)) {
|
||||||
int col_size = abs_col_size_format.capturedTexts().at(1).toInt(&conv_ok);
|
int col_size = abs_col_size_format.capturedTexts().at(1).toInt(&conv_ok);
|
||||||
if (conv_ok) columns_width_ << InsetColDimension(col_size, QET::Absolute);
|
if (conv_ok) columns_width_ << TitleBlockColDimension(col_size, QET::Absolute);
|
||||||
} else if (rel_col_size_format.exactMatch(cols_description)) {
|
} else if (rel_col_size_format.exactMatch(cols_description)) {
|
||||||
int col_size = rel_col_size_format.capturedTexts().at(2).toInt(&conv_ok);
|
int col_size = rel_col_size_format.capturedTexts().at(2).toInt(&conv_ok);
|
||||||
QET::InsetColumnLength col_type = rel_col_size_format.capturedTexts().at(1) == "t" ? QET::RelativeToTotalLength : QET::RelativeToRemainingLength;
|
QET::TitleBlockColumnLength col_type = rel_col_size_format.capturedTexts().at(1) == "t" ? QET::RelativeToTotalLength : QET::RelativeToRemainingLength;
|
||||||
if (conv_ok) columns_width_ << InsetColDimension(col_size, col_type );
|
if (conv_ok) columns_width_ << TitleBlockColDimension(col_size, col_type );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
foreach (InsetColDimension icd, columns_width_) {
|
foreach (TitleBlockColDimension icd, columns_width_) {
|
||||||
qDebug() << Q_FUNC_INFO << QString("%1 [%2]").arg(icd.value).arg(QET::insetColumnLengthToString(icd.type));
|
qDebug() << Q_FUNC_INFO << QString("%1 [%2]").arg(icd.value).arg(QET::titleBlockColumnLengthToString(icd.type));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ void InsetTemplate::parseColumns(const QString &cols_string) {
|
|||||||
and stored in this object.
|
and stored in this object.
|
||||||
@param xml_element XML element to analyze
|
@param xml_element XML element to analyze
|
||||||
*/
|
*/
|
||||||
bool InsetTemplate::loadCells(const QDomElement &xml_element) {
|
bool TitleBlockTemplate::loadCells(const QDomElement &xml_element) {
|
||||||
initCells();
|
initCells();
|
||||||
// we are interested by the "logo" and "field" elements
|
// we are interested by the "logo" and "field" elements
|
||||||
QDomElement grid_element;
|
QDomElement grid_element;
|
||||||
@@ -249,7 +249,7 @@ bool InsetTemplate::loadCells(const QDomElement &xml_element) {
|
|||||||
if (!n.isElement()) continue;
|
if (!n.isElement()) continue;
|
||||||
QDomElement cell_element = n.toElement();
|
QDomElement cell_element = n.toElement();
|
||||||
if (cell_element.tagName() == "field" || cell_element.tagName() == "logo") {
|
if (cell_element.tagName() == "field" || cell_element.tagName() == "logo") {
|
||||||
InsetCell *loaded_cell;
|
TitleBlockCell *loaded_cell;
|
||||||
if (!checkCell(cell_element, &loaded_cell)) continue;
|
if (!checkCell(cell_element, &loaded_cell)) continue;
|
||||||
|
|
||||||
if (cell_element.tagName() == "logo") {
|
if (cell_element.tagName() == "logo") {
|
||||||
@@ -290,16 +290,16 @@ bool InsetTemplate::loadCells(const QDomElement &xml_element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param xml_element XML element representing a cell, i.e. either an inset
|
@param xml_element XML element representing a cell, i.e. either an titleblock
|
||||||
logo or an inset field.
|
logo or an titleblock field.
|
||||||
@param inset_cell_ptr Pointer to an InsetCell object pointer - if non-zero and if
|
@param titleblock_cell_ptr Pointer to an TitleBlockCell object pointer - if non-zero and if
|
||||||
this method returns true, will be filled with the created InsetCell
|
this method returns true, will be filled with the created TitleBlockCell
|
||||||
@return TRUE if the cell appears to be ok, FALSE otherwise
|
@return TRUE if the cell appears to be ok, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
bool InsetTemplate::checkCell(const QDomElement &xml_element, InsetCell **inset_cell_ptr) {
|
bool TitleBlockTemplate::checkCell(const QDomElement &xml_element, TitleBlockCell **titleblock_cell_ptr) {
|
||||||
int col_count = columns_width_.count(), row_count = rows_heights_.count();
|
int col_count = columns_width_.count(), row_count = rows_heights_.count();
|
||||||
|
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << "begin" << row_count << col_count;
|
qDebug() << Q_FUNC_INFO << "begin" << row_count << col_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -318,10 +318,10 @@ bool InsetTemplate::checkCell(const QDomElement &xml_element, InsetCell **inset_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check whether the target cell can be used or not
|
// check whether the target cell can be used or not
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << "cell access" << col_num << row_num;
|
qDebug() << Q_FUNC_INFO << "cell access" << col_num << row_num;
|
||||||
#endif
|
#endif
|
||||||
InsetCell *cell_ptr = &(cells_[col_num][row_num]);
|
TitleBlockCell *cell_ptr = &(cells_[col_num][row_num]);
|
||||||
if (!cell_ptr -> is_null || cell_ptr -> spanner_cell) {
|
if (!cell_ptr -> is_null || cell_ptr -> spanner_cell) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@@ -342,10 +342,10 @@ bool InsetTemplate::checkCell(const QDomElement &xml_element, InsetCell **inset_
|
|||||||
for (int i = col_num ; i <= col_num + col_span ; ++ i) {
|
for (int i = col_num ; i <= col_num + col_span ; ++ i) {
|
||||||
for (int j = row_num ; j <= row_num + row_span ; ++ j) {
|
for (int j = row_num ; j <= row_num + row_span ; ++ j) {
|
||||||
if (i == col_num && j == row_num) continue;
|
if (i == col_num && j == row_num) continue;
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << "span check" << i << j;
|
qDebug() << Q_FUNC_INFO << "span check" << i << j;
|
||||||
#endif
|
#endif
|
||||||
InsetCell *current_cell = &(cells_[i][j]);
|
TitleBlockCell *current_cell = &(cells_[i][j]);
|
||||||
if (!current_cell -> is_null || current_cell -> spanner_cell) {
|
if (!current_cell -> is_null || current_cell -> spanner_cell) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ bool InsetTemplate::checkCell(const QDomElement &xml_element, InsetCell **inset_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// at this point, the cell is ok - we fill the adequate cells in the matrix
|
// at this point, the cell is ok - we fill the adequate cells in the matrix
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << "cell writing";
|
qDebug() << Q_FUNC_INFO << "cell writing";
|
||||||
#endif
|
#endif
|
||||||
cell_ptr -> num_row = row_num;
|
cell_ptr -> num_row = row_num;
|
||||||
@@ -362,16 +362,16 @@ bool InsetTemplate::checkCell(const QDomElement &xml_element, InsetCell **inset_
|
|||||||
if (has_row_span) cell_ptr -> row_span = row_span;
|
if (has_row_span) cell_ptr -> row_span = row_span;
|
||||||
if (has_col_span) cell_ptr -> col_span = col_span;
|
if (has_col_span) cell_ptr -> col_span = col_span;
|
||||||
cell_ptr -> is_null = false;
|
cell_ptr -> is_null = false;
|
||||||
if (inset_cell_ptr) *inset_cell_ptr = cell_ptr;
|
if (titleblock_cell_ptr) *titleblock_cell_ptr = cell_ptr;
|
||||||
|
|
||||||
if (has_row_span || has_col_span) {
|
if (has_row_span || has_col_span) {
|
||||||
for (int i = col_num ; i <= col_num + col_span ; ++ i) {
|
for (int i = col_num ; i <= col_num + col_span ; ++ i) {
|
||||||
for (int j = row_num ; j <= row_num + row_span ; ++ j) {
|
for (int j = row_num ; j <= row_num + row_span ; ++ j) {
|
||||||
if (i == col_num && j == row_num) continue;
|
if (i == col_num && j == row_num) continue;
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << "span cells writing" << i << j;
|
qDebug() << Q_FUNC_INFO << "span cells writing" << i << j;
|
||||||
#endif
|
#endif
|
||||||
InsetCell *current_cell = &(cells_[i][j]);
|
TitleBlockCell *current_cell = &(cells_[i][j]);
|
||||||
current_cell -> num_row = j;
|
current_cell -> num_row = j;
|
||||||
current_cell -> num_col = i;
|
current_cell -> num_col = i;
|
||||||
current_cell -> is_null = false;
|
current_cell -> is_null = false;
|
||||||
@@ -388,7 +388,7 @@ bool InsetTemplate::checkCell(const QDomElement &xml_element, InsetCell **inset_
|
|||||||
Note that this method does nothing if one of the internal lists
|
Note that this method does nothing if one of the internal lists
|
||||||
columns_width_ and rows_heights_ is empty.
|
columns_width_ and rows_heights_ is empty.
|
||||||
*/
|
*/
|
||||||
void InsetTemplate::initCells() {
|
void TitleBlockTemplate::initCells() {
|
||||||
if (columns_width_.count() < 1 || rows_heights_.count() < 1) return;
|
if (columns_width_.count() < 1 || rows_heights_.count() < 1) return;
|
||||||
|
|
||||||
cells_.resize(columns_width_.count());
|
cells_.resize(columns_width_.count());
|
||||||
@@ -397,20 +397,20 @@ void InsetTemplate::initCells() {
|
|||||||
cells_[i].resize(row_count);
|
cells_[i].resize(row_count);
|
||||||
// ensure every cell is a null cell
|
// ensure every cell is a null cell
|
||||||
for (int j = 0 ; j < row_count ; ++ j) {
|
for (int j = 0 ; j < row_count ; ++ j) {
|
||||||
cells_[i][j] = InsetCell();
|
cells_[i][j] = TitleBlockCell();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef INSET_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << toString();
|
qDebug() << Q_FUNC_INFO << toString();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return A string representing the inset template
|
@return A string representing the titleblock template
|
||||||
@see InsetCell::toString()
|
@see TitleBlockCell::toString()
|
||||||
*/
|
*/
|
||||||
QString InsetTemplate::toString() const {
|
QString TitleBlockTemplate::toString() const {
|
||||||
QString str = "\n";
|
QString str = "\n";
|
||||||
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
||||||
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
||||||
@@ -422,10 +422,10 @@ QString InsetTemplate::toString() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param total_width The total width of the inset to render
|
@param total_width The total width of the titleblock to render
|
||||||
@return the list of the columns widths for this rendering
|
@return the list of the columns widths for this rendering
|
||||||
*/
|
*/
|
||||||
QList<int> InsetTemplate::columnsWidth(int total_width) const {
|
QList<int> TitleBlockTemplate::columnsWidth(int total_width) const {
|
||||||
if (total_width < 0) return(QList<int>());
|
if (total_width < 0) return(QList<int>());
|
||||||
|
|
||||||
// we first iter to determine the absolute and total-width-related widths
|
// we first iter to determine the absolute and total-width-related widths
|
||||||
@@ -433,7 +433,7 @@ QList<int> InsetTemplate::columnsWidth(int total_width) const {
|
|||||||
int abs_widths_sum = 0;
|
int abs_widths_sum = 0;
|
||||||
|
|
||||||
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
||||||
InsetColDimension icd = columns_width_.at(i);
|
TitleBlockColDimension icd = columns_width_.at(i);
|
||||||
if (icd.type == QET::Absolute) {
|
if (icd.type == QET::Absolute) {
|
||||||
abs_widths_sum += icd.value;
|
abs_widths_sum += icd.value;
|
||||||
final_widths[i] = icd.value;
|
final_widths[i] = icd.value;
|
||||||
@@ -449,7 +449,7 @@ QList<int> InsetTemplate::columnsWidth(int total_width) const {
|
|||||||
|
|
||||||
// we do a second iteration to build the final widths list
|
// we do a second iteration to build the final widths list
|
||||||
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
||||||
InsetColDimension icd = columns_width_.at(i);
|
TitleBlockColDimension icd = columns_width_.at(i);
|
||||||
if (icd.type == QET::RelativeToRemainingLength) {
|
if (icd.type == QET::RelativeToRemainingLength) {
|
||||||
final_widths[i] = int(remaining_width * icd.value / 100);
|
final_widths[i] = int(remaining_width * icd.value / 100);
|
||||||
}
|
}
|
||||||
@@ -457,7 +457,7 @@ QList<int> InsetTemplate::columnsWidth(int total_width) const {
|
|||||||
return(final_widths.toList());
|
return(final_widths.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
int InsetTemplate::height() const {
|
int TitleBlockTemplate::height() const {
|
||||||
int height = 0;
|
int height = 0;
|
||||||
foreach(int row_height, rows_heights_) {
|
foreach(int row_height, rows_heights_) {
|
||||||
height += row_height;
|
height += row_height;
|
||||||
@@ -466,22 +466,22 @@ int InsetTemplate::height() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Render the inset.
|
Render the titleblock.
|
||||||
@param painter Painter to use to render the inset
|
@param painter Painter to use to render the titleblock
|
||||||
@param diagram_context Diagram context to use to generate the inset strings
|
@param diagram_context Diagram context to use to generate the titleblock strings
|
||||||
@param inset_width Width of the inset to render
|
@param titleblock_width Width of the titleblock to render
|
||||||
*/
|
*/
|
||||||
void InsetTemplate::render(QPainter &painter, const DiagramContext &diagram_context, int inset_width) const {
|
void TitleBlockTemplate::render(QPainter &painter, const DiagramContext &diagram_context, int titleblock_width) const {
|
||||||
QList<int> widths = columnsWidth(inset_width);
|
QList<int> widths = columnsWidth(titleblock_width);
|
||||||
int inset_height = height();
|
int titleblock_height = height();
|
||||||
|
|
||||||
// prepare the QPainter
|
// prepare the QPainter
|
||||||
painter.setPen(Qt::black);
|
painter.setPen(Qt::black);
|
||||||
painter.setBrush(Qt::white);
|
painter.setBrush(Qt::white);
|
||||||
painter.setFont(QETApp::diagramTextsFont());
|
painter.setFont(QETApp::diagramTextsFont());
|
||||||
|
|
||||||
// draw the inset border
|
// draw the titleblock border
|
||||||
painter.drawRect(QRect(0, 0, inset_width, inset_height));
|
painter.drawRect(QRect(0, 0, titleblock_width, titleblock_height));
|
||||||
|
|
||||||
// run through each inidividual cell
|
// run through each inidividual cell
|
||||||
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
||||||
@@ -524,7 +524,7 @@ void InsetTemplate::render(QPainter &painter, const DiagramContext &diagram_cont
|
|||||||
@param diagram_context Diagram context to use to generate the final text for the given cell
|
@param diagram_context Diagram context to use to generate the final text for the given cell
|
||||||
@return the final text that has to be drawn in the given cell
|
@return the final text that has to be drawn in the given cell
|
||||||
*/
|
*/
|
||||||
QString InsetTemplate::finalTextForCell(const InsetCell &cell, const DiagramContext &diagram_context) const {
|
QString TitleBlockTemplate::finalTextForCell(const TitleBlockCell &cell, const DiagramContext &diagram_context) const {
|
||||||
QString cell_text = cell.value;
|
QString cell_text = cell.value;
|
||||||
|
|
||||||
foreach (QString key, diagram_context.keys()) {
|
foreach (QString key, diagram_context.keys()) {
|
||||||
@@ -532,7 +532,7 @@ QString InsetTemplate::finalTextForCell(const InsetCell &cell, const DiagramCont
|
|||||||
cell_text.replace("%" + key, diagram_context[key].toString());
|
cell_text.replace("%" + key, diagram_context[key].toString());
|
||||||
}
|
}
|
||||||
if (cell.display_label && !cell.label.isEmpty()) {
|
if (cell.display_label && !cell.label.isEmpty()) {
|
||||||
cell_text = QString(tr(" %1 : %2", "inset content - please let the blank space at the beginning")).arg(cell.label).arg(cell_text);
|
cell_text = QString(tr(" %1 : %2", "titleblock content - please let the blank space at the beginning")).arg(cell.label).arg(cell_text);
|
||||||
} else {
|
} else {
|
||||||
cell_text = QString(tr(" %1")).arg(cell_text);
|
cell_text = QString(tr(" %1")).arg(cell_text);
|
||||||
}
|
}
|
||||||
@@ -544,7 +544,7 @@ QString InsetTemplate::finalTextForCell(const InsetCell &cell, const DiagramCont
|
|||||||
@param start start border number
|
@param start start border number
|
||||||
@param end end border number
|
@param end end border number
|
||||||
*/
|
*/
|
||||||
int InsetTemplate::lengthRange(int start, int end, const QList<int> &lengths_list) const {
|
int TitleBlockTemplate::lengthRange(int start, int end, const QList<int> &lengths_list) const {
|
||||||
if (start > end || start >= lengths_list.count() || end > lengths_list.count()) {
|
if (start > end || start >= lengths_list.count() || end > lengths_list.count()) {
|
||||||
qDebug() << Q_FUNC_INFO << "wont use" << start << "and" << end;
|
qDebug() << Q_FUNC_INFO << "wont use" << start << "and" << end;
|
||||||
return(0);
|
return(0);
|
||||||
@@ -562,7 +562,7 @@ int InsetTemplate::lengthRange(int start, int end, const QList<int> &lengths_lis
|
|||||||
/**
|
/**
|
||||||
Constructor
|
Constructor
|
||||||
*/
|
*/
|
||||||
InsetCell::InsetCell() {
|
TitleBlockCell::TitleBlockCell() {
|
||||||
num_row = num_col = -1;
|
num_row = num_col = -1;
|
||||||
row_span = col_span = 0;
|
row_span = col_span = 0;
|
||||||
display_label = is_null = true;
|
display_label = is_null = true;
|
||||||
@@ -570,11 +570,11 @@ InsetCell::InsetCell() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return A string representing the inset cell
|
@return A string representing the titleblock cell
|
||||||
*/
|
*/
|
||||||
QString InsetCell::toString() const {
|
QString TitleBlockCell::toString() const {
|
||||||
if (is_null) return("InsetCell{null}");
|
if (is_null) return("TitleBlockCell{null}");
|
||||||
QString span_desc = (row_span > 0 || col_span > 0) ? QString("+%3,%4").arg(row_span).arg(col_span) : QET::pointerString(spanner_cell);
|
QString span_desc = (row_span > 0 || col_span > 0) ? QString("+%3,%4").arg(row_span).arg(col_span) : QET::pointerString(spanner_cell);
|
||||||
QString base_desc = QString("InsetCell{ [%1, %2] %3 }").arg(num_row).arg(num_col).arg(span_desc);
|
QString base_desc = QString("TitleBlockCell{ [%1, %2] %3 }").arg(num_row).arg(num_col).arg(span_desc);
|
||||||
return(base_desc);
|
return(base_desc);
|
||||||
}
|
}
|
||||||
@@ -15,43 +15,43 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef INSET_TEMPLATE_H
|
#ifndef TITLEBLOCK_TEMPLATE_H
|
||||||
#define INSET_TEMPLATE_H
|
#define TITLEBLOCK_TEMPLATE_H
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include <QtSvg>
|
#include <QtSvg>
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
#include "insetcell.h"
|
#include "titleblockcell.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This struct is a simple container associating a length with its type.
|
This struct is a simple container associating a length with its type.
|
||||||
@see InsetColumnLength
|
@see TitleBlockColumnLength
|
||||||
*/
|
*/
|
||||||
struct InsetColDimension {
|
struct TitleBlockColDimension {
|
||||||
InsetColDimension(int v, QET::InsetColumnLength t = QET::Absolute) {
|
TitleBlockColDimension(int v, QET::TitleBlockColumnLength t = QET::Absolute) {
|
||||||
value = v;
|
value = v;
|
||||||
type = t;
|
type = t;
|
||||||
}
|
}
|
||||||
QET::InsetColumnLength type;
|
QET::TitleBlockColumnLength type;
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents an inset templ)ate for an electric diagram.
|
This class represents an titleblock templ)ate for an electric diagram.
|
||||||
It can read from an XML document the layout of the table that graphically
|
It can read from an XML document the layout of the table that graphically
|
||||||
represents the inset, and can produce a graphical rendering of it from a
|
represents the titleblock, and can produce a graphical rendering of it from a
|
||||||
diagram context (object embedding the informations of the diagram we want to
|
diagram context (object embedding the informations of the diagram we want to
|
||||||
represent the inset.
|
represent the titleblock.
|
||||||
*/
|
*/
|
||||||
class InsetTemplate : public QObject {
|
class TitleBlockTemplate : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
InsetTemplate(QObject * = 0);
|
TitleBlockTemplate(QObject * = 0);
|
||||||
virtual ~InsetTemplate();
|
virtual ~TitleBlockTemplate();
|
||||||
private:
|
private:
|
||||||
InsetTemplate(const InsetTemplate &);
|
TitleBlockTemplate(const TitleBlockTemplate &);
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
@@ -74,11 +74,11 @@ class InsetTemplate : public QObject {
|
|||||||
private:
|
private:
|
||||||
void parseRows(const QString &);
|
void parseRows(const QString &);
|
||||||
void parseColumns(const QString &);
|
void parseColumns(const QString &);
|
||||||
bool checkCell(const QDomElement &, InsetCell ** = 0);
|
bool checkCell(const QDomElement &, TitleBlockCell ** = 0);
|
||||||
void flushCells();
|
void flushCells();
|
||||||
void initCells();
|
void initCells();
|
||||||
int lengthRange(int, int, const QList<int> &) const;
|
int lengthRange(int, int, const QList<int> &) const;
|
||||||
QString finalTextForCell(const InsetCell &, const DiagramContext &) const;
|
QString finalTextForCell(const TitleBlockCell &, const DiagramContext &) const;
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -86,7 +86,7 @@ class InsetTemplate : public QObject {
|
|||||||
QHash<QString, QSvgRenderer *> vector_logos_;
|
QHash<QString, QSvgRenderer *> vector_logos_;
|
||||||
QHash<QString, QPixmap *> bitmap_logos_;
|
QHash<QString, QPixmap *> bitmap_logos_;
|
||||||
QList<int> rows_heights_;
|
QList<int> rows_heights_;
|
||||||
QList<InsetColDimension> columns_width_;
|
QList<TitleBlockColDimension> columns_width_;
|
||||||
QVector< QVector<InsetCell> > cells_;
|
QVector< QVector<TitleBlockCell> > cells_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
96
sources/titleblocktemplaterenderer.cpp
Normal file
96
sources/titleblocktemplaterenderer.cpp
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#include "titleblocktemplaterenderer.h"
|
||||||
|
#include "titleblocktemplate.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructor
|
||||||
|
@param parnet Parent QObject of this renderer
|
||||||
|
*/
|
||||||
|
TitleBlockTemplateRenderer::TitleBlockTemplateRenderer(QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
titleblock_template_(0),
|
||||||
|
last_known_titleblock_width_(-1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructor
|
||||||
|
*/
|
||||||
|
TitleBlockTemplateRenderer::~TitleBlockTemplateRenderer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return the titleblock template used for the rendering
|
||||||
|
*/
|
||||||
|
const TitleBlockTemplate *TitleBlockTemplateRenderer::titleBlockTemplate() const {
|
||||||
|
return(titleblock_template_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param titleblock_template TitleBlock template to render.
|
||||||
|
*/
|
||||||
|
void TitleBlockTemplateRenderer::setTitleBlockTemplate(const TitleBlockTemplate *titleblock_template) {
|
||||||
|
if (titleblock_template != titleblock_template_) {
|
||||||
|
titleblock_template_ = titleblock_template;
|
||||||
|
invalidateRenderedTemplate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param context Diagram Context to use when rendering the titleblock
|
||||||
|
*/
|
||||||
|
void TitleBlockTemplateRenderer::setContext(const DiagramContext &context) {
|
||||||
|
context_ = context;
|
||||||
|
invalidateRenderedTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return the height of the rendered template, or -1 if no template has been
|
||||||
|
set for this renderer.
|
||||||
|
@see TitleBlockTemplate::height()
|
||||||
|
*/
|
||||||
|
int TitleBlockTemplateRenderer::height() const {
|
||||||
|
if (!titleblock_template_) return(-1);
|
||||||
|
return(titleblock_template_ -> height());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Render the titleblock.
|
||||||
|
@param provided_painter QPainter to use to render the titleblock.
|
||||||
|
@param titleblock_width The total width of the titleblock to render
|
||||||
|
*/
|
||||||
|
void TitleBlockTemplateRenderer::render(QPainter *provided_painter, int titleblock_width) {
|
||||||
|
if (!titleblock_template_) return;
|
||||||
|
|
||||||
|
// Do we really need to calculate all this again?
|
||||||
|
if (titleblock_width != last_known_titleblock_width_ || rendered_template_.isNull()) {
|
||||||
|
renderToQPicture(titleblock_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
provided_painter -> save();
|
||||||
|
rendered_template_.play(provided_painter);
|
||||||
|
provided_painter -> restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Renders the titleblock to the internal QPicture
|
||||||
|
@param titleblock_width Width of the titleblock to render
|
||||||
|
*/
|
||||||
|
void TitleBlockTemplateRenderer::renderToQPicture(int titleblock_width) {
|
||||||
|
if (!titleblock_template_) return;
|
||||||
|
|
||||||
|
// we render the template on our internal QPicture
|
||||||
|
QPainter painter(&rendered_template_);
|
||||||
|
|
||||||
|
titleblock_template_ -> render(painter, context_, titleblock_width);
|
||||||
|
|
||||||
|
// memorize the last known width
|
||||||
|
last_known_titleblock_width_ = titleblock_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Invalidates the previous rendering of the template by resetting the internal
|
||||||
|
QPicture.
|
||||||
|
*/
|
||||||
|
void TitleBlockTemplateRenderer::invalidateRenderedTemplate() {
|
||||||
|
rendered_template_ = QPicture();
|
||||||
|
}
|
||||||
@@ -15,19 +15,19 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef INSET_TEMPLATE_RENDERER_H
|
#ifndef TITLEBLOCK_TEMPLATE_RENDERER_H
|
||||||
#define INSET_TEMPLATE_RENDERER_H
|
#define TITLEBLOCK_TEMPLATE_RENDERER_H
|
||||||
#include <QPicture>
|
#include <QPicture>
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
class InsetTemplate;
|
class TitleBlockTemplate;
|
||||||
class InsetTemplateRenderer : public QObject {
|
class TitleBlockTemplateRenderer : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InsetTemplateRenderer(QObject * = 0);
|
TitleBlockTemplateRenderer(QObject * = 0);
|
||||||
virtual ~InsetTemplateRenderer();
|
virtual ~TitleBlockTemplateRenderer();
|
||||||
const InsetTemplate *insetTemplate() const;
|
const TitleBlockTemplate *titleBlockTemplate() const;
|
||||||
void setInsetTemplate(const InsetTemplate *);
|
void setTitleBlockTemplate(const TitleBlockTemplate *);
|
||||||
void setContext(const DiagramContext &context);
|
void setContext(const DiagramContext &context);
|
||||||
int height() const;
|
int height() const;
|
||||||
void render(QPainter *, int);
|
void render(QPainter *, int);
|
||||||
@@ -37,9 +37,9 @@ class InsetTemplateRenderer : public QObject {
|
|||||||
void invalidateRenderedTemplate();
|
void invalidateRenderedTemplate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const InsetTemplate *inset_template_;
|
const TitleBlockTemplate *titleblock_template_;
|
||||||
QPicture rendered_template_;
|
QPicture rendered_template_;
|
||||||
DiagramContext context_;
|
DiagramContext context_;
|
||||||
int last_known_inset_width_;
|
int last_known_titleblock_width_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<insettemplate name="default">
|
<titleblocktemplate name="default">
|
||||||
<informations>Author: The QElectroTech team
|
<informations>Author: The QElectroTech team
|
||||||
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
|
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
|
||||||
<grid rows="25px;25px" cols="t22%;r100%;t22%">
|
<grid rows="25px;25px" cols="t22%;r100%;t22%">
|
||||||
@@ -8,4 +8,4 @@ License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
|
|||||||
<field row="0" col="2" name="file" label="Fichier" displaylabel="true" align="left" rowspan="0" value="%filename" />
|
<field row="0" col="2" name="file" label="Fichier" displaylabel="true" align="left" rowspan="0" value="%filename" />
|
||||||
<field row="1" col="2" name="folio" label="Folio" displaylabel="true" align="left" rowspan="0" value="%{folio-id}/%{folio-total}" />
|
<field row="1" col="2" name="folio" label="Folio" displaylabel="true" align="left" rowspan="0" value="%{folio-id}/%{folio-total}" />
|
||||||
</grid>
|
</grid>
|
||||||
</insettemplate>
|
</titleblocktemplate>
|
||||||
Reference in New Issue
Block a user