Title block can be displayed at right edge of diagram (work in progress)

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3827 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-03-16 13:29:27 +00:00
parent 8919e8e690
commit 04687effda
10 changed files with 291 additions and 291 deletions

View File

@@ -23,6 +23,12 @@
#include "qetapp.h" #include "qetapp.h"
#include "math.h" #include "math.h"
#include "createdxf.h" #include "createdxf.h"
#include "diagram.h"
#define MIN_COLUMN_COUNT 3
#define MIN_ROW_COUNT 3
#define MIN_COLUMN_WIDTH 5.0
#define MIN_ROW_HEIGHT 5.0
/** /**
Constructeur simple : construit une bordure en recuperant les dimensions Constructeur simple : construit une bordure en recuperant les dimensions
@@ -67,31 +73,58 @@ qreal BorderTitleBlock::titleBlockHeight() const {
} }
/** /**
@return Le nombre minimum de colonnes qu'un schema doit comporter * @brief BorderTitleBlock::titleBlockRect
*/ * @return the rectangle of the titleblock in scene coordinate.
int BorderTitleBlock::minNbColumns() { */
return(3); QRectF BorderTitleBlock::titleBlockRect() const
{
if (m_edge == Qt::BottomEdge)
return QRectF(diagram_rect_.bottomLeft(), QSize(diagram_rect_.width(), titleBlockHeight()));
else
return QRectF(diagram_rect_.topRight(), QSize(titleBlockHeight(), diagram_rect_.height()));
} }
/** /**
@return la largeur minimale d'une colonne de schema * @brief BorderTitleBlock::titleBlockRectForQPainter
*/ * @return The title block rect to use with the QPainter in the method draw.
qreal BorderTitleBlock::minColumnsWidth() { * The returned rect is alway horizontal (like displayed at the bottom of rect) only the top left change of pos
return(5.0); * according to the edge where the title block need to be displayed.
* Rect according to edge:
* Bottom : top left is at the bottom left edge of the diagram rect.
* Right : top left is at the bottom right of diagram rect. Befor use this rect you need to rotate the QPainter by -90°
* for snap the rect at the right edge of diagram.
*/
QRectF BorderTitleBlock::titleBlockRectForQPainter() const
{
if (m_edge == Qt::BottomEdge) //Rect at bottom have same position and dimension of displayed rect
return titleBlockRect();
else
return QRectF (diagram_rect_.bottomRight(), QSize(diagram_rect_.height(), titleBlockHeight()));
} }
/** /**
@return Le nombre minimum de lignes qu'un schema doit comporter * @brief BorderTitleBlock::borderRect
*/ * @return the bounding rectangle of diagram and titleblock.
int BorderTitleBlock::minNbRows() { */
return(2); QRectF BorderTitleBlock::borderRect() const {
return diagram_rect_ | titleBlockRect();
} }
/** /**
@return la hauteur minimale d'une ligne de schema * @brief BorderTitleBlock::borderWidth
*/ * @return the border width
qreal BorderTitleBlock::minRowsHeight() { */
return(5.0); qreal BorderTitleBlock::borderWidth() const {
return borderRect().width();
}
/**
* @brief BorderTitleBlock::borderHeight
* @return the border height
*/
qreal BorderTitleBlock::borderHeight() const {
return borderRect().height();
} }
/** /**
@@ -162,7 +195,7 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
displayColumns(xml_elmt.attribute("displaycols") != "false"); displayColumns(xml_elmt.attribute("displaycols") != "false");
displayRows(xml_elmt.attribute("displayrows") != "false"); displayRows(xml_elmt.attribute("displayrows") != "false");
adjustTitleBlockToColumns(); updateRectangles();
} }
/** /**
@@ -177,20 +210,27 @@ TitleBlockProperties BorderTitleBlock::exportTitleBlock() {
ip.filename = fileName(); ip.filename = fileName();
ip.folio = folio(); ip.folio = folio();
ip.template_name = titleBlockTemplateName(); ip.template_name = titleBlockTemplateName();
ip.display_at = m_edge;
ip.context = additional_fields_; ip.context = additional_fields_;
return(ip); return(ip);
} }
/** /**
@param ip les nouvelles proprietes du cartouche * @brief BorderTitleBlock::importTitleBlock
*/ * @param ip the new properties of titleblock
*/
void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) { void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
setAuthor(ip.author); setAuthor(ip.author);
setDate(ip.date); setDate(ip.date);
setTitle(ip.title); setTitle(ip.title);
setFileName(ip.filename); setFileName(ip.filename);
setFolio(ip.folio); setFolio(ip.folio);
if (m_edge != ip.display_at)
{
m_edge = ip.display_at;
emit(displayChanged());
}
additional_fields_ = ip.context; additional_fields_ = ip.context;
emit(needFolioData()); // Note: we expect additional data to be provided emit(needFolioData()); // Note: we expect additional data to be provided
@@ -320,53 +360,48 @@ void BorderTitleBlock::displayBorder(bool db) {
} }
/** /**
Methode recalculant les rectangles composant le cadre et le cartouche en * @brief BorderTitleBlock::updateRectangles
fonction des attributs de taille * This method update the diagram rect according to the value of rows and columns (number and size)
*/ */
void BorderTitleBlock::updateRectangles() { void BorderTitleBlock::updateRectangles()
// rectangle delimitant le schema {
QRectF previous_diagram = diagram_rect_; QRectF previous_diagram = diagram_rect_;
diagram_rect_ = QRectF(0, 0, diagramWidth(), diagramHeight()); diagram_rect_ = QRectF(Diagram::margin, Diagram::margin, diagramWidth(), diagramHeight());
if (diagram_rect_ != previous_diagram) emit(borderChanged(previous_diagram, diagram_rect_)); if (diagram_rect_ != previous_diagram) emit(borderChanged(previous_diagram, diagram_rect_));
// rectangles relatifs au cartouche
titleblock_rect_ = QRectF(diagram_rect_.bottomLeft().x(), diagram_rect_.bottomLeft().y(), titleBlockWidth(), titleBlockHeight());
} }
/** /**
Dessine le cadre et le cartouche * @brief BorderTitleBlock::draw
@param qp QPainter a utiliser pour dessiner le cadre et le cartouche * Draw the border and the titleblock.
@param x Abscisse du cadre * @param painter, QPainter to use for draw this.
@param y Ordonnee du cadre */
*/ void BorderTitleBlock::draw(QPainter *painter)
void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) { {
// translate tous les rectangles //Set the QPainter
diagram_rect_ .translate(x, y); painter -> save();
titleblock_rect_ .translate(x, y); QPen pen(Qt::black);
pen.setCosmetic(true);
painter -> setPen(pen);
painter -> setBrush(Qt::NoBrush);
// prepare le QPainter //Draw the borer
qp -> save(); if (display_border_) painter -> drawRect(diagram_rect_);
qp -> setPen(Qt::black);
qp -> setBrush(Qt::NoBrush);
// dessine le cadre painter -> setFont(QETApp::diagramTextsFont());
if (display_border_) qp -> drawRect(diagram_rect_);
qp -> setFont(QETApp::diagramTextsFont()); //Draw the empty case at the top left of diagram when there is header
// dessine la case vide qui apparait des qu'il y a un entete
if (display_border_ && (display_columns_ || display_rows_)) { if (display_border_ && (display_columns_ || display_rows_)) {
qp -> setBrush(Qt::white); painter -> setBrush(Qt::white);
QRectF first_rectangle( QRectF first_rectangle(
diagram_rect_.topLeft().x(), diagram_rect_.topLeft().x(),
diagram_rect_.topLeft().y(), diagram_rect_.topLeft().y(),
rows_header_width_, rows_header_width_,
columns_header_height_ columns_header_height_
); );
qp -> drawRect(first_rectangle); painter -> drawRect(first_rectangle);
} }
// dessine la numerotation des colonnes //Draw the nums of columns
if (display_border_ && display_columns_) { if (display_border_ && display_columns_) {
for (int i = 1 ; i <= columns_count_ ; ++ i) { for (int i = 1 ; i <= columns_count_ ; ++ i) {
QRectF numbered_rectangle = QRectF( QRectF numbered_rectangle = QRectF(
@@ -375,12 +410,12 @@ void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) {
columns_width_, columns_width_,
columns_header_height_ columns_header_height_
); );
qp -> drawRect(numbered_rectangle); painter -> drawRect(numbered_rectangle);
qp -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i)); painter -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i));
} }
} }
// dessine la numerotation des lignes //Draw the nums of rows
if (display_border_ && display_rows_) { if (display_border_ && display_rows_) {
QString row_string("A"); QString row_string("A");
for (int i = 1 ; i <= rows_count_ ; ++ i) { for (int i = 1 ; i <= rows_count_ ; ++ i) {
@@ -390,24 +425,32 @@ void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) {
rows_header_width_, rows_header_width_,
rows_height_ rows_height_
); );
qp -> drawRect(lettered_rectangle); painter -> drawRect(lettered_rectangle);
qp -> drawText(lettered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, row_string); painter -> drawText(lettered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, row_string);
row_string = incrementLetters(row_string); row_string = incrementLetters(row_string);
} }
} }
// render the titleblock, using the TitleBlockTemplate object // render the titleblock, using the TitleBlockTemplate object
if (display_titleblock_) { if (display_titleblock_) {
qp -> translate(titleblock_rect_.topLeft()); QRectF tbt_rect = titleBlockRectForQPainter();
titleblock_template_renderer_ -> render(qp, titleblock_rect_.width()); if (m_edge == Qt::BottomEdge)
qp -> translate(-titleblock_rect_.topLeft()); {
painter -> translate(tbt_rect.topLeft());
titleblock_template_renderer_ -> render(painter, tbt_rect.width());
painter -> translate(-tbt_rect.topLeft());
}
else
{
painter->translate(tbt_rect.topLeft());
painter->rotate(-90);
titleblock_template_renderer_ -> render(painter, tbt_rect.width());
painter->rotate(90);
painter -> translate(-tbt_rect.topLeft());
}
} }
qp -> restore(); painter -> restore();
// annule la translation des rectangles
diagram_rect_ .translate(-x, -y);
titleblock_rect_ .translate(-x, -y);
} }
void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QString &file_path, int color) { void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QString &file_path, int color) {
@@ -471,7 +514,8 @@ void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QS
// render the titleblock, using the TitleBlockTemplate object // render the titleblock, using the TitleBlockTemplate object
if (display_titleblock_) { if (display_titleblock_) {
//qp -> translate(titleblock_rect_.topLeft()); //qp -> translate(titleblock_rect_.topLeft());
titleblock_template_renderer_ -> renderDxf(titleblock_rect_, titleblock_rect_.width(), file_path, color); QRectF rect = titleBlockRect();
titleblock_template_renderer_ -> renderDxf(rect, rect.width(), file_path, color);
//qp -> translate(-titleblock_rect_.topLeft()); //qp -> translate(-titleblock_rect_.topLeft());
} }
@@ -483,38 +527,6 @@ void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QS
} }
/**
Ajoute une colonne.
*/
void BorderTitleBlock::addColumn() {
setColumnsCount(columnsCount() + 1);
}
/**
Enleve une colonne sans passer sous le minimum requis.
@see minNbColumns()
*/
void BorderTitleBlock::removeColumn() {
setColumnsCount(columnsCount() - 1);
}
/**
Ajoute une ligne.
*/
void BorderTitleBlock::addRow() {
setRowsCount(rowsCount() + 1);
}
/**
Enleve une ligne sans passer sous le minimum requis.
@see minNbRows()
*/
void BorderTitleBlock::removeRow() {
setRowsCount(rowsCount() - 1);
}
/** /**
Permet de changer le nombre de colonnes. Permet de changer le nombre de colonnes.
Si ce nombre de colonnes est inferieur au minimum requis, c'est ce minimum Si ce nombre de colonnes est inferieur au minimum requis, c'est ce minimum
@@ -524,8 +536,8 @@ void BorderTitleBlock::removeRow() {
*/ */
void BorderTitleBlock::setColumnsCount(int nb_c) { void BorderTitleBlock::setColumnsCount(int nb_c) {
if (nb_c == columnsCount()) return; if (nb_c == columnsCount()) return;
columns_count_ = qMax(minNbColumns(), nb_c); columns_count_ = qMax(MIN_COLUMN_COUNT , nb_c);
setTitleBlockWidth(diagramWidth()); updateRectangles();
} }
/** /**
@@ -537,8 +549,8 @@ void BorderTitleBlock::setColumnsCount(int nb_c) {
*/ */
void BorderTitleBlock::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(MIN_COLUMN_WIDTH , new_cw);
setTitleBlockWidth(diagramWidth()); updateRectangles();
} }
/** /**
@@ -560,8 +572,7 @@ void BorderTitleBlock::setColumnsHeaderHeight(const qreal &new_chh) {
*/ */
void BorderTitleBlock::setRowsCount(int nb_r) { void BorderTitleBlock::setRowsCount(int nb_r) {
if (nb_r == rowsCount()) return; if (nb_r == rowsCount()) return;
rows_count_ = qMax(minNbRows(), nb_r); rows_count_ = qMax(MIN_ROW_COUNT, nb_r);
setTitleBlockWidth(diagramWidth());
updateRectangles(); updateRectangles();
} }
@@ -574,7 +585,7 @@ void BorderTitleBlock::setRowsCount(int nb_r) {
*/ */
void BorderTitleBlock::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(MIN_ROW_HEIGHT, new_rh);
updateRectangles(); updateRectangles();
} }
@@ -597,24 +608,6 @@ void BorderTitleBlock::setDiagramHeight(const qreal &height) {
setRowsCount(qRound(ceil(height / rows_height_))); setRowsCount(qRound(ceil(height / rows_height_)));
} }
/**
Change la largeur du cartouche. Cette largeur sera restreinte a celle du
schema.
*/
void BorderTitleBlock::setTitleBlockWidth(const qreal &new_iw) {
titleblock_width_ = qMin(diagramWidth(), new_iw);
updateRectangles();
}
/**
Ajuste la largeur du cartouche de facon a ce que celui-ci soit aussi large
que le schema
*/
void BorderTitleBlock::adjustTitleBlockToColumns() {
setTitleBlockWidth(diagramWidth());
}
/** /**
@param pos Position cartesienne (ex : 10.3, 45.2) a transformer en position @param pos Position cartesienne (ex : 10.3, 45.2) a transformer en position
dans la grille (ex : B2) dans la grille (ex : B2)

View File

@@ -31,10 +31,10 @@ class TitleBlockTemplateRenderer;
This class represents the border and the titleblock which frame a This class represents the border and the titleblock which frame a
particular electric diagram. particular electric diagram.
*/ */
class BorderTitleBlock : public QObject { class BorderTitleBlock : public QObject
{
Q_OBJECT Q_OBJECT
// constructors, destructor
public: public:
BorderTitleBlock(QObject * = 0); BorderTitleBlock(QObject * = 0);
virtual ~BorderTitleBlock(); virtual ~BorderTitleBlock();
@@ -42,18 +42,13 @@ class BorderTitleBlock : public QObject {
private: private:
BorderTitleBlock(const BorderTitleBlock &); BorderTitleBlock(const BorderTitleBlock &);
// methods //METHODS
public: public:
static int minNbColumns(); void draw(QPainter *painter);
static qreal minColumnsWidth();
static int minNbRows();
static qreal minRowsHeight();
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
void drawDxf(int, int, bool, QString &, int); void drawDxf(int, int, bool, QString &, int);
// methods to get dimensions //METHODS TO GET DIMENSION
// columns //COLUMNS
/// @return the number of columns /// @return the number of columns
int columnsCount() const { return(columns_count_); } int columnsCount() const { return(columns_count_); }
/// @return the columns width, in pixels /// @return the columns width, in pixels
@@ -63,7 +58,7 @@ class BorderTitleBlock : public QObject {
/// @return the column headers height, in pixels /// @return the column headers height, in pixels
qreal columnsHeaderHeight() const { return(columns_header_height_); } qreal columnsHeaderHeight() const { return(columns_header_height_); }
// rows //ROWS
/// @return the number of rows /// @return the number of rows
int rowsCount() const { return(rows_count_); } int rowsCount() const { return(rows_count_); }
/// @return the rows height, in pixels /// @return the rows height, in pixels
@@ -80,15 +75,16 @@ class BorderTitleBlock : public QObject {
qreal diagramHeight() const { return(rowsTotalHeight() + columnsHeaderHeight()); } qreal diagramHeight() const { return(rowsTotalHeight() + columnsHeaderHeight()); }
// title block // title block
/// @return the title block width
qreal titleBlockWidth() const { return(titleblock_width_); }
qreal titleBlockHeight() const; qreal titleBlockHeight() const;
// border + title block QRectF titleBlockRect () const;
/// @return the border width private:
qreal borderWidth() const { return(diagramWidth()); } QRectF titleBlockRectForQPainter () const;
/// @return the border height
qreal borderHeight() const { return(diagramHeight() + titleBlockHeight()); } public:
QRectF borderRect () const;
qreal borderWidth () const;
qreal borderHeight() const;
// methods to get title block basic data // methods to get title block basic data
/// @return the value of the title block "Author" field /// @return the value of the title block "Author" field
@@ -113,10 +109,6 @@ class BorderTitleBlock : public QObject {
bool borderIsDisplayed() const { return(display_border_); } bool borderIsDisplayed() const { return(display_border_); }
// methods to set dimensions // methods to set dimensions
void addColumn();
void addRow();
void removeColumn();
void removeRow();
void setColumnsCount(int); void setColumnsCount(int);
void setRowsCount(int); void setRowsCount(int);
void setColumnsWidth(const qreal &); void setColumnsWidth(const qreal &);
@@ -124,8 +116,6 @@ class BorderTitleBlock : 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 setTitleBlockWidth(const qreal &);
void adjustTitleBlockToColumns();
DiagramPosition convertPosition(const QPointF &); DiagramPosition convertPosition(const QPointF &);
@@ -218,6 +208,7 @@ class BorderTitleBlock : public QObject {
int folio_total_; int folio_total_;
QString btb_filename_; QString btb_filename_;
DiagramContext additional_fields_; DiagramContext additional_fields_;
Qt::Edge m_edge;
// border dimensions (rows and columns) // border dimensions (rows and columns)
// columns: number and dimensions // columns: number and dimensions
@@ -231,12 +222,10 @@ class BorderTitleBlock : public QObject {
qreal rows_header_width_; qreal rows_header_width_;
// title block dimensions // title block dimensions
qreal titleblock_width_;
qreal titleblock_height_; qreal titleblock_height_;
// rectangles used for drawing operations // rectangles used for drawing operations
QRectF diagram_rect_; QRectF diagram_rect_;
QRectF titleblock_rect_;
// display options // display options
bool display_titleblock_; bool display_titleblock_;

View File

@@ -152,7 +152,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
p -> drawPoints(points); p -> drawPoints(points);
} }
if (use_border_) border_and_titleblock.draw(p, margin, margin); if (use_border_) border_and_titleblock.draw(p);
p -> restore(); p -> restore();
} }
@@ -1074,16 +1074,8 @@ void Diagram::invertSelection() {
* @return The rectangle (coordinates relative to the scene) * @return The rectangle (coordinates relative to the scene)
* delimiting the edge of the diagram * delimiting the edge of the diagram
*/ */
QRectF Diagram::border() const QRectF Diagram::border() const {
{ return border_and_titleblock.borderRect();
return(
QRectF(
margin,
margin,
border_and_titleblock.borderWidth(),
border_and_titleblock.borderHeight()
)
);
} }
/** /**

View File

@@ -112,7 +112,7 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
diagram_list[i] -> border_and_titleblock.date().toString(Qt::SystemLocaleShortDate)); diagram_list[i] -> border_and_titleblock.date().toString(Qt::SystemLocaleShortDate));
} }
border_and_titleblock.draw(p, margin, margin); border_and_titleblock.draw(p);
p -> restore(); p -> restore();
} }

View File

@@ -1180,14 +1180,6 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
BorderTitleBlock &bi = scene -> border_and_titleblock; BorderTitleBlock &bi = scene -> border_and_titleblock;
//Get the rectangle of the titleblock
QRectF titleblock_rect(
Diagram::margin,
Diagram::margin + bi.diagramHeight(),
bi.titleBlockWidth(),
bi.titleBlockHeight()
);
// Get the rectangle of the header column // Get the rectangle of the header column
QRectF columns_rect( QRectF columns_rect(
Diagram::margin, Diagram::margin,
@@ -1207,7 +1199,7 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
//Get the click pos on the diagram //Get the click pos on the diagram
QPointF click_pos = viewportTransform().inverted().map(e -> pos()); QPointF click_pos = viewportTransform().inverted().map(e -> pos());
if (titleblock_rect.contains(click_pos) || columns_rect.contains(click_pos) || rows_rect.contains(click_pos)) { if (bi.titleBlockRect().contains(click_pos) || columns_rect.contains(click_pos) || rows_rect.contains(click_pos)) {
e->accept(); e->accept();
editDiagramProperties(); editDiagramProperties();
return; return;

View File

@@ -25,7 +25,8 @@
*/ */
TitleBlockProperties::TitleBlockProperties() : TitleBlockProperties::TitleBlockProperties() :
date(), date(),
useDate(UseDateValue) useDate(UseDateValue),
display_at(Qt::BottomEdge)
{ {
} }
@@ -47,7 +48,8 @@ bool TitleBlockProperties::operator==(const TitleBlockProperties &ip) {
ip.filename == filename &&\ ip.filename == filename &&\
ip.folio == folio &&\ ip.folio == folio &&\
ip.template_name == template_name &&\ ip.template_name == template_name &&\
ip.context == context ip.context == context &&\
ip.display_at == display_at
); );
} }
@@ -70,6 +72,7 @@ void TitleBlockProperties::toXml(QDomElement &e) const {
e.setAttribute("filename", filename); e.setAttribute("filename", filename);
e.setAttribute("folio", folio); e.setAttribute("folio", folio);
e.setAttribute("date", exportDate()); e.setAttribute("date", exportDate());
e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
if (!template_name.isEmpty()) { if (!template_name.isEmpty()) {
e.setAttribute("titleblocktemplate", template_name); e.setAttribute("titleblocktemplate", template_name);
} }
@@ -92,6 +95,7 @@ void TitleBlockProperties::fromXml(const QDomElement &e) {
if (e.hasAttribute("filename")) filename = e.attribute("filename"); if (e.hasAttribute("filename")) filename = e.attribute("filename");
if (e.hasAttribute("folio")) folio = e.attribute("folio"); if (e.hasAttribute("folio")) folio = e.attribute("folio");
if (e.hasAttribute("date")) setDateFromString(e.attribute("date")); if (e.hasAttribute("date")) setDateFromString(e.attribute("date"));
if (e.hasAttribute("displayAt")) display_at = (e.attribute("displayAt") == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
// reads the template used to render the title block // reads the template used to render the title block
if (e.hasAttribute("titleblocktemplate")) template_name = e.attribute("titleblocktemplate"); if (e.hasAttribute("titleblocktemplate")) template_name = e.attribute("titleblocktemplate");
@@ -114,6 +118,7 @@ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix
settings.setValue(prefix + "filename", filename); settings.setValue(prefix + "filename", filename);
settings.setValue(prefix + "folio", folio); settings.setValue(prefix + "folio", folio);
settings.setValue(prefix + "date", exportDate()); settings.setValue(prefix + "date", exportDate());
settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
context.toSettings(settings, prefix + "properties"); context.toSettings(settings, prefix + "properties");
} }
@@ -128,6 +133,7 @@ void TitleBlockProperties::fromSettings(QSettings &settings, const QString &pref
filename = settings.value(prefix + "filename").toString(); filename = settings.value(prefix + "filename").toString();
folio = settings.value(prefix + "folio", "%id/%total").toString(); folio = settings.value(prefix + "folio", "%id/%total").toString();
setDateFromString(settings.value(prefix + "date").toString()); setDateFromString(settings.value(prefix + "date").toString());
display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
context.fromSettings(settings, prefix + "properties"); context.fromSettings(settings, prefix + "properties");
} }

View File

@@ -55,6 +55,7 @@ class TitleBlockProperties {
DateManagement useDate; ///< Wheter to use the date attribute DateManagement useDate; ///< Wheter to use the date attribute
QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application" QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application"
DiagramContext context; ///< Container for the additional, user-defined fields DiagramContext context; ///< Container for the additional, user-defined fields
Qt::Edge display_at; ///< Edge to display the titleblock
private: private:
QString exportDate() const; QString exportDate() const;

View File

@@ -1228,8 +1228,11 @@ void TitleBlockTemplate::render(QPainter &painter, const DiagramContext &diagram
QList<int> widths = columnsWidth(titleblock_width); QList<int> widths = columnsWidth(titleblock_width);
int titleblock_height = height(); int titleblock_height = height();
// prepare the QPainter painter.save();
painter.setPen(Qt::black); //Setup the QPainter
QPen pen(Qt::black);
pen.setCosmetic(true);
painter.setPen(pen);
painter.setBrush(Qt::white); painter.setBrush(Qt::white);
// draw the titleblock border // draw the titleblock border
@@ -1256,6 +1259,7 @@ void TitleBlockTemplate::render(QPainter &painter, const DiagramContext &diagram
renderCell(painter, *cells_[i][j], diagram_context, cell_rect); renderCell(painter, *cells_[i][j], diagram_context, cell_rect);
} }
} }
painter.restore();
} }
/** /**

View File

@@ -76,6 +76,7 @@ void TitleBlockPropertiesWidget::setProperties(const TitleBlockProperties &prope
ui -> m_author_le -> setText (properties.author); ui -> m_author_le -> setText (properties.author);
ui -> m_file_le -> setText (properties.filename); ui -> m_file_le -> setText (properties.filename);
ui -> m_folio_le -> setText (properties.folio); ui -> m_folio_le -> setText (properties.folio);
ui -> m_display_at_cb -> setCurrentIndex(properties.display_at == Qt::BottomEdge ? 0 : 1);
//About date //About date
ui -> m_date_now_pb -> setDisabled(true); ui -> m_date_now_pb -> setDisabled(true);
@@ -126,6 +127,7 @@ TitleBlockProperties TitleBlockPropertiesWidget::properties() const {
prop.author = ui -> m_author_le -> text(); prop.author = ui -> m_author_le -> text();
prop.filename = ui -> m_file_le -> text(); prop.filename = ui -> m_file_le -> text();
prop.folio = ui -> m_folio_le -> text(); prop.folio = ui -> m_folio_le -> text();
prop.display_at = ui -> m_display_at_cb -> currentIndex() == 0 ? Qt::BottomEdge : Qt::RightEdge;
if (ui->m_no_date_rb->isChecked()) { if (ui->m_no_date_rb->isChecked()) {
prop.useDate = TitleBlockProperties::UseDateValue; prop.useDate = TitleBlockProperties::UseDateValue;

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>528</width> <width>528</width>
<height>387</height> <height>439</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -108,10 +108,10 @@
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="5" column="1"> <item row="5" column="2">
<widget class="QLabel" name="label_6"> <widget class="QLineEdit" name="m_folio_le">
<property name="text"> <property name="toolTip">
<string>Folio :</string> <string>Disponible en tant que %folio pour les modèles de cartouches</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -122,10 +122,28 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item row="7" column="1">
<widget class="QLineEdit" name="m_file_le"> <widget class="QLabel" name="label">
<property name="toolTip"> <property name="text">
<string>Disponible en tant que %filename pour les modèles de cartouches</string> <string>Afficher :</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_7">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>Les variables suivantes sont utilisables dans le champ Folio :
- %id : numéro du schéma courant dans le projet
- %total : nombre total de schémas dans le projet</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property> </property>
</widget> </widget>
</item> </item>
@@ -181,45 +199,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Titre :</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Fichier :</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="m_folio_le">
<property name="toolTip">
<string>Disponible en tant que %folio pour les modèles de cartouches</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_7">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>Les variables suivantes sont utilisables dans le champ Folio :
- %id : numéro du schéma courant dans le projet
- %total : nombre total de schémas dans le projet</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
@@ -230,10 +209,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="4" column="1">
<widget class="QLineEdit" name="m_author_le"> <widget class="QLabel" name="label_5">
<property name="toolTip"> <property name="text">
<string>Disponible en tant que %author pour les modèles de cartouches</string> <string>Fichier :</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -244,6 +223,48 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Titre :</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="m_author_le">
<property name="toolTip">
<string>Disponible en tant que %author pour les modèles de cartouches</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Folio :</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="m_file_le">
<property name="toolTip">
<string>Disponible en tant que %filename pour les modèles de cartouches</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QComboBox" name="m_display_at_cb">
<item>
<property name="text">
<string>Bas</string>
</property>
</item>
<item>
<property name="text">
<string>Droite (expérimental)</string>
</property>
</item>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>