[qet] [3827] Title block can be displayed at right edge of diagram ( work in progress) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3827
Author: blacksun
Date: 2015-03-16 14:29:27 +0100 (Mon, 16 Mar 2015)
Log Message:
-----------
Title block can be displayed at right edge of diagram (work in progress)
Modified Paths:
--------------
trunk/sources/bordertitleblock.cpp
trunk/sources/bordertitleblock.h
trunk/sources/diagram.cpp
trunk/sources/diagramfoliolist.cpp
trunk/sources/diagramview.cpp
trunk/sources/titleblockproperties.cpp
trunk/sources/titleblockproperties.h
trunk/sources/titleblocktemplate.cpp
trunk/sources/ui/titleblockpropertieswidget.cpp
trunk/sources/ui/titleblockpropertieswidget.ui
Modified: trunk/sources/bordertitleblock.cpp
===================================================================
--- trunk/sources/bordertitleblock.cpp 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/bordertitleblock.cpp 2015-03-16 13:29:27 UTC (rev 3827)
@@ -23,7 +23,13 @@
#include "qetapp.h"
#include "math.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
dans la configuration de l'application.
@@ -47,8 +53,8 @@
// contenu par defaut du cartouche
importTitleBlock(TitleBlockProperties());
- display_titleblock_ = true;
- display_border_ = true;
+ display_titleblock_ = true;
+ display_border_ = true;
setFolioData(1, 1);
updateRectangles();
}
@@ -67,34 +73,61 @@
}
/**
- @return Le nombre minimum de colonnes qu'un schema doit comporter
-*/
-int BorderTitleBlock::minNbColumns() {
- return(3);
+ * @brief BorderTitleBlock::titleBlockRect
+ * @return the rectangle of the titleblock in scene coordinate.
+ */
+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
-*/
-qreal BorderTitleBlock::minColumnsWidth() {
- return(5.0);
+ * @brief BorderTitleBlock::titleBlockRectForQPainter
+ * @return The title block rect to use with the QPainter in the method draw.
+ * The returned rect is alway horizontal (like displayed at the bottom of rect) only the top left change of pos
+ * 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
-*/
-int BorderTitleBlock::minNbRows() {
- return(2);
+ * @brief BorderTitleBlock::borderRect
+ * @return the bounding rectangle of diagram and titleblock.
+ */
+QRectF BorderTitleBlock::borderRect() const {
+ return diagram_rect_ | titleBlockRect();
}
/**
- @return la hauteur minimale d'une ligne de schema
-*/
-qreal BorderTitleBlock::minRowsHeight() {
- return(5.0);
+ * @brief BorderTitleBlock::borderWidth
+ * @return the border width
+ */
+qreal BorderTitleBlock::borderWidth() const {
+ return borderRect().width();
}
/**
+ * @brief BorderTitleBlock::borderHeight
+ * @return the border height
+ */
+qreal BorderTitleBlock::borderHeight() const {
+ return borderRect().height();
+}
+
+/**
Exports the title block current values to XML.
@param xml_elmt the XML element attributes will be added to
*/
@@ -161,8 +194,8 @@
// rows and columns display
displayColumns(xml_elmt.attribute("displaycols") != "false");
displayRows(xml_elmt.attribute("displayrows") != "false");
-
- adjustTitleBlockToColumns();
+
+ updateRectangles();
}
/**
@@ -177,20 +210,27 @@
ip.filename = fileName();
ip.folio = folio();
ip.template_name = titleBlockTemplateName();
+ ip.display_at = m_edge;
ip.context = additional_fields_;
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) {
setAuthor(ip.author);
setDate(ip.date);
setTitle(ip.title);
setFileName(ip.filename);
setFolio(ip.folio);
+ if (m_edge != ip.display_at)
+ {
+ m_edge = ip.display_at;
+ emit(displayChanged());
+ }
additional_fields_ = ip.context;
emit(needFolioData()); // Note: we expect additional data to be provided
@@ -320,53 +360,48 @@
}
/**
- Methode recalculant les rectangles composant le cadre et le cartouche en
- fonction des attributs de taille
-*/
-void BorderTitleBlock::updateRectangles() {
- // rectangle delimitant le schema
+ * @brief BorderTitleBlock::updateRectangles
+ * This method update the diagram rect according to the value of rows and columns (number and size)
+ */
+void BorderTitleBlock::updateRectangles()
+{
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_));
-
- // rectangles relatifs au cartouche
- titleblock_rect_ = QRectF(diagram_rect_.bottomLeft().x(), diagram_rect_.bottomLeft().y(), titleBlockWidth(), titleBlockHeight());
}
/**
- Dessine le cadre et le cartouche
- @param qp QPainter a utiliser pour dessiner le cadre et le cartouche
- @param x Abscisse du cadre
- @param y Ordonnee du cadre
-*/
-void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) {
- // translate tous les rectangles
- diagram_rect_ .translate(x, y);
- titleblock_rect_ .translate(x, y);
+ * @brief BorderTitleBlock::draw
+ * Draw the border and the titleblock.
+ * @param painter, QPainter to use for draw this.
+ */
+void BorderTitleBlock::draw(QPainter *painter)
+{
+ //Set the QPainter
+ painter -> save();
+ QPen pen(Qt::black);
+ pen.setCosmetic(true);
+ painter -> setPen(pen);
+ painter -> setBrush(Qt::NoBrush);
- // prepare le QPainter
- qp -> save();
- qp -> setPen(Qt::black);
- qp -> setBrush(Qt::NoBrush);
+ //Draw the borer
+ if (display_border_) painter -> drawRect(diagram_rect_);
- // dessine le cadre
- if (display_border_) qp -> drawRect(diagram_rect_);
+ painter -> setFont(QETApp::diagramTextsFont());
- qp -> setFont(QETApp::diagramTextsFont());
-
- // dessine la case vide qui apparait des qu'il y a un entete
+ //Draw the empty case at the top left of diagram when there is header
if (display_border_ && (display_columns_ || display_rows_)) {
- qp -> setBrush(Qt::white);
+ painter -> setBrush(Qt::white);
QRectF first_rectangle(
diagram_rect_.topLeft().x(),
diagram_rect_.topLeft().y(),
rows_header_width_,
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_) {
for (int i = 1 ; i <= columns_count_ ; ++ i) {
QRectF numbered_rectangle = QRectF(
@@ -375,12 +410,12 @@
columns_width_,
columns_header_height_
);
- qp -> drawRect(numbered_rectangle);
- qp -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i));
+ painter -> drawRect(numbered_rectangle);
+ 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_) {
QString row_string("A");
for (int i = 1 ; i <= rows_count_ ; ++ i) {
@@ -390,24 +425,32 @@
rows_header_width_,
rows_height_
);
- qp -> drawRect(lettered_rectangle);
- qp -> drawText(lettered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, row_string);
+ painter -> drawRect(lettered_rectangle);
+ painter -> drawText(lettered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, row_string);
row_string = incrementLetters(row_string);
}
}
- // render the titleblock, using the TitleBlockTemplate object
+ // render the titleblock, using the TitleBlockTemplate object
if (display_titleblock_) {
- qp -> translate(titleblock_rect_.topLeft());
- titleblock_template_renderer_ -> render(qp, titleblock_rect_.width());
- qp -> translate(-titleblock_rect_.topLeft());
+ QRectF tbt_rect = titleBlockRectForQPainter();
+ if (m_edge == Qt::BottomEdge)
+ {
+ 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();
-
- // annule la translation des rectangles
- diagram_rect_ .translate(-x, -y);
- titleblock_rect_ .translate(-x, -y);
+ painter -> restore();
}
void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QString &file_path, int color) {
@@ -471,7 +514,8 @@
// render the titleblock, using the TitleBlockTemplate object
if (display_titleblock_) {
//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());
}
@@ -483,39 +527,7 @@
}
-
-
/**
- 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.
Si ce nombre de colonnes est inferieur au minimum requis, c'est ce minimum
qui est utilise.
@@ -524,8 +536,8 @@
*/
void BorderTitleBlock::setColumnsCount(int nb_c) {
if (nb_c == columnsCount()) return;
- columns_count_ = qMax(minNbColumns(), nb_c);
- setTitleBlockWidth(diagramWidth());
+ columns_count_ = qMax(MIN_COLUMN_COUNT , nb_c);
+ updateRectangles();
}
/**
@@ -537,8 +549,8 @@
*/
void BorderTitleBlock::setColumnsWidth(const qreal &new_cw) {
if (new_cw == columnsWidth()) return;
- columns_width_ = qMax(minColumnsWidth(), new_cw);
- setTitleBlockWidth(diagramWidth());
+ columns_width_ = qMax(MIN_COLUMN_WIDTH , new_cw);
+ updateRectangles();
}
/**
@@ -560,8 +572,7 @@
*/
void BorderTitleBlock::setRowsCount(int nb_r) {
if (nb_r == rowsCount()) return;
- rows_count_ = qMax(minNbRows(), nb_r);
- setTitleBlockWidth(diagramWidth());
+ rows_count_ = qMax(MIN_ROW_COUNT, nb_r);
updateRectangles();
}
@@ -574,7 +585,7 @@
*/
void BorderTitleBlock::setRowsHeight(const qreal &new_rh) {
if (new_rh == rowsHeight()) return;
- rows_height_ = qMax(minRowsHeight(), new_rh);
+ rows_height_ = qMax(MIN_ROW_HEIGHT, new_rh);
updateRectangles();
}
@@ -598,24 +609,6 @@
}
/**
- 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
dans la grille (ex : B2)
@return la position dans la grille correspondant a pos
Modified: trunk/sources/bordertitleblock.h
===================================================================
--- trunk/sources/bordertitleblock.h 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/bordertitleblock.h 2015-03-16 13:29:27 UTC (rev 3827)
@@ -31,65 +31,61 @@
This class represents the border and the titleblock which frame a
particular electric diagram.
*/
-class BorderTitleBlock : public QObject {
- Q_OBJECT
+class BorderTitleBlock : public QObject
+{
+ Q_OBJECT
- // constructors, destructor
public:
- BorderTitleBlock(QObject * = 0);
- virtual ~BorderTitleBlock();
+ BorderTitleBlock(QObject * = 0);
+ virtual ~BorderTitleBlock();
private:
- BorderTitleBlock(const BorderTitleBlock &);
+ BorderTitleBlock(const BorderTitleBlock &);
- // methods
- public:
- static int minNbColumns();
- static qreal minColumnsWidth();
- static int minNbRows();
- static qreal minRowsHeight();
+ //METHODS
+ public:
+ void draw(QPainter *painter);
+ void drawDxf(int, int, bool, QString &, int);
- void draw(QPainter *, qreal = 0.0, qreal = 0.0);
- void drawDxf(int, int, bool, QString &, int);
+ //METHODS TO GET DIMENSION
+ //COLUMNS
+ /// @return the number of columns
+ int columnsCount() const { return(columns_count_); }
+ /// @return the columns width, in pixels
+ qreal columnsWidth() const { return(columns_width_); }
+ /// @return the total width of all columns, headers excluded
+ qreal columnsTotalWidth() const { return(columns_count_ * columns_width_); }
+ /// @return the column headers height, in pixels
+ qreal columnsHeaderHeight() const { return(columns_header_height_); }
- // methods to get dimensions
- // columns
- /// @return the number of columns
- int columnsCount() const { return(columns_count_); }
- /// @return the columns width, in pixels
- qreal columnsWidth() const { return(columns_width_); }
- /// @return the total width of all columns, headers excluded
- qreal columnsTotalWidth() const { return(columns_count_ * columns_width_); }
- /// @return the column headers height, in pixels
- qreal columnsHeaderHeight() const { return(columns_header_height_); }
+ //ROWS
+ /// @return the number of rows
+ int rowsCount() const { return(rows_count_); }
+ /// @return the rows height, in pixels
+ qreal rowsHeight() const { return(rows_height_); }
+ /// @return the total height of all rows, headers excluded
+ qreal rowsTotalHeight() const { return(rows_count_ * rows_height_); }
+ /// @return la rows header width, in pixels
+ qreal rowsHeaderWidth() const { return(rows_header_width_); }
- // rows
- /// @return the number of rows
- int rowsCount() const { return(rows_count_); }
- /// @return the rows height, in pixels
- qreal rowsHeight() const { return(rows_height_); }
- /// @return the total height of all rows, headers excluded
- qreal rowsTotalHeight() const { return(rows_count_ * rows_height_); }
- /// @return la rows header width, in pixels
- qreal rowsHeaderWidth() const { return(rows_header_width_); }
+ // border - title block = diagram
+ /// @return the diagram width, i.e. the width of the border without title block
+ qreal diagramWidth() const { return(columnsTotalWidth() + rowsHeaderWidth()); }
+ /// @return the diagram height, i.e. the height of the border without title block
+ qreal diagramHeight() const { return(rowsTotalHeight() + columnsHeaderHeight()); }
- // border - title block = diagram
- /// @return the diagram width, i.e. the width of the border without title block
- qreal diagramWidth() const { return(columnsTotalWidth() + rowsHeaderWidth()); }
- /// @return the diagram height, i.e. the height of the border without title block
- qreal diagramHeight() const { return(rowsTotalHeight() + columnsHeaderHeight()); }
+ // title block
+ qreal titleBlockHeight() const;
+
+ QRectF titleBlockRect () const;
+ private:
+ QRectF titleBlockRectForQPainter () const;
+
+ public:
+ QRectF borderRect () const;
+ qreal borderWidth () const;
+ qreal borderHeight() const;
- // title block
- /// @return the title block width
- qreal titleBlockWidth() const { return(titleblock_width_); }
- qreal titleBlockHeight() const;
-
- // border + title block
- /// @return the border width
- qreal borderWidth() const { return(diagramWidth()); }
- /// @return the border height
- qreal borderHeight() const { return(diagramHeight() + titleBlockHeight()); }
-
// methods to get title block basic data
/// @return the value of the title block "Author" field
QString author() const { return(btb_author_); }
@@ -113,10 +109,6 @@
bool borderIsDisplayed() const { return(display_border_); }
// methods to set dimensions
- void addColumn();
- void addRow();
- void removeColumn();
- void removeRow();
void setColumnsCount(int);
void setRowsCount(int);
void setColumnsWidth(const qreal &);
@@ -124,8 +116,6 @@
void setColumnsHeaderHeight(const qreal &);
void setRowsHeaderWidth(const qreal &);
void setDiagramHeight(const qreal &);
- void setTitleBlockWidth(const qreal &);
- void adjustTitleBlockToColumns();
DiagramPosition convertPosition(const QPointF &);
@@ -206,43 +196,42 @@
*/
void needTitleBlockTemplate(const QString &);
- // attributes
+ // attributes
private:
- // titleblock basic data
- QString btb_author_;
- QDate btb_date_;
- QString btb_title_;
- QString btb_folio_;
- QString btb_final_folio_;
- int folio_index_;
- int folio_total_;
- QString btb_filename_;
- DiagramContext additional_fields_;
+ // titleblock basic data
+ QString btb_author_;
+ QDate btb_date_;
+ QString btb_title_;
+ QString btb_folio_;
+ QString btb_final_folio_;
+ int folio_index_;
+ int folio_total_;
+ QString btb_filename_;
+ DiagramContext additional_fields_;
+ Qt::Edge m_edge;
- // border dimensions (rows and columns)
- // columns: number and dimensions
- int columns_count_;
- qreal columns_width_;
- qreal columns_header_height_;
+ // border dimensions (rows and columns)
+ // columns: number and dimensions
+ int columns_count_;
+ qreal columns_width_;
+ qreal columns_header_height_;
- // rows: number and dimensions
- int rows_count_;
- qreal rows_height_;
- qreal rows_header_width_;
+ // rows: number and dimensions
+ int rows_count_;
+ qreal rows_height_;
+ qreal rows_header_width_;
- // title block dimensions
- qreal titleblock_width_;
- qreal titleblock_height_;
+ // title block dimensions
+ qreal titleblock_height_;
- // rectangles used for drawing operations
- QRectF diagram_rect_;
- QRectF titleblock_rect_;
+ // rectangles used for drawing operations
+ QRectF diagram_rect_;
- // display options
- bool display_titleblock_;
- bool display_columns_;
- bool display_rows_;
- bool display_border_;
- TitleBlockTemplateRenderer *titleblock_template_renderer_;
+ // display options
+ bool display_titleblock_;
+ bool display_columns_;
+ bool display_rows_;
+ bool display_border_;
+ TitleBlockTemplateRenderer *titleblock_template_renderer_;
};
#endif
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/diagram.cpp 2015-03-16 13:29:27 UTC (rev 3827)
@@ -152,7 +152,7 @@
p -> drawPoints(points);
}
- if (use_border_) border_and_titleblock.draw(p, margin, margin);
+ if (use_border_) border_and_titleblock.draw(p);
p -> restore();
}
@@ -1074,16 +1074,8 @@
* @return The rectangle (coordinates relative to the scene)
* delimiting the edge of the diagram
*/
-QRectF Diagram::border() const
-{
- return(
- QRectF(
- margin,
- margin,
- border_and_titleblock.borderWidth(),
- border_and_titleblock.borderHeight()
- )
- );
+QRectF Diagram::border() const {
+ return border_and_titleblock.borderRect();
}
/**
Modified: trunk/sources/diagramfoliolist.cpp
===================================================================
--- trunk/sources/diagramfoliolist.cpp 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/diagramfoliolist.cpp 2015-03-16 13:29:27 UTC (rev 3827)
@@ -112,7 +112,7 @@
diagram_list[i] -> border_and_titleblock.date().toString(Qt::SystemLocaleShortDate));
}
- border_and_titleblock.draw(p, margin, margin);
+ border_and_titleblock.draw(p);
p -> restore();
}
Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/diagramview.cpp 2015-03-16 13:29:27 UTC (rev 3827)
@@ -1180,14 +1180,6 @@
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
QRectF columns_rect(
Diagram::margin,
@@ -1207,7 +1199,7 @@
//Get the click pos on the diagram
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();
editDiagramProperties();
return;
Modified: trunk/sources/titleblockproperties.cpp
===================================================================
--- trunk/sources/titleblockproperties.cpp 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/titleblockproperties.cpp 2015-03-16 13:29:27 UTC (rev 3827)
@@ -25,7 +25,8 @@
*/
TitleBlockProperties::TitleBlockProperties() :
date(),
- useDate(UseDateValue)
+ useDate(UseDateValue),
+ display_at(Qt::BottomEdge)
{
}
@@ -47,7 +48,8 @@
ip.filename == filename &&\
ip.folio == folio &&\
ip.template_name == template_name &&\
- ip.context == context
+ ip.context == context &&\
+ ip.display_at == display_at
);
}
@@ -70,6 +72,7 @@
e.setAttribute("filename", filename);
e.setAttribute("folio", folio);
e.setAttribute("date", exportDate());
+ e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
if (!template_name.isEmpty()) {
e.setAttribute("titleblocktemplate", template_name);
}
@@ -92,6 +95,7 @@
if (e.hasAttribute("filename")) filename = e.attribute("filename");
if (e.hasAttribute("folio")) folio = e.attribute("folio");
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
if (e.hasAttribute("titleblocktemplate")) template_name = e.attribute("titleblocktemplate");
@@ -114,6 +118,7 @@
settings.setValue(prefix + "filename", filename);
settings.setValue(prefix + "folio", folio);
settings.setValue(prefix + "date", exportDate());
+ settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
context.toSettings(settings, prefix + "properties");
}
@@ -128,6 +133,7 @@
filename = settings.value(prefix + "filename").toString();
folio = settings.value(prefix + "folio", "%id/%total").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");
}
Modified: trunk/sources/titleblockproperties.h
===================================================================
--- trunk/sources/titleblockproperties.h 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/titleblockproperties.h 2015-03-16 13:29:27 UTC (rev 3827)
@@ -55,6 +55,7 @@
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"
DiagramContext context; ///< Container for the additional, user-defined fields
+ Qt::Edge display_at; ///< Edge to display the titleblock
private:
QString exportDate() const;
Modified: trunk/sources/titleblocktemplate.cpp
===================================================================
--- trunk/sources/titleblocktemplate.cpp 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/titleblocktemplate.cpp 2015-03-16 13:29:27 UTC (rev 3827)
@@ -1228,8 +1228,11 @@
QList<int> widths = columnsWidth(titleblock_width);
int titleblock_height = height();
- // prepare the QPainter
- painter.setPen(Qt::black);
+ painter.save();
+ //Setup the QPainter
+ QPen pen(Qt::black);
+ pen.setCosmetic(true);
+ painter.setPen(pen);
painter.setBrush(Qt::white);
// draw the titleblock border
@@ -1256,6 +1259,7 @@
renderCell(painter, *cells_[i][j], diagram_context, cell_rect);
}
}
+ painter.restore();
}
/**
Modified: trunk/sources/ui/titleblockpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/titleblockpropertieswidget.cpp 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/ui/titleblockpropertieswidget.cpp 2015-03-16 13:29:27 UTC (rev 3827)
@@ -76,6 +76,7 @@
ui -> m_author_le -> setText (properties.author);
ui -> m_file_le -> setText (properties.filename);
ui -> m_folio_le -> setText (properties.folio);
+ ui -> m_display_at_cb -> setCurrentIndex(properties.display_at == Qt::BottomEdge ? 0 : 1);
//About date
ui -> m_date_now_pb -> setDisabled(true);
@@ -126,6 +127,7 @@
prop.author = ui -> m_author_le -> text();
prop.filename = ui -> m_file_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()) {
prop.useDate = TitleBlockProperties::UseDateValue;
Modified: trunk/sources/ui/titleblockpropertieswidget.ui
===================================================================
--- trunk/sources/ui/titleblockpropertieswidget.ui 2015-03-14 21:40:44 UTC (rev 3826)
+++ trunk/sources/ui/titleblockpropertieswidget.ui 2015-03-16 13:29:27 UTC (rev 3827)
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>528</width>
- <height>387</height>
+ <height>439</height>
</rect>
</property>
<property name="sizePolicy">
@@ -108,10 +108,10 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_4">
- <item row="5" column="1">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Folio :</string>
+ <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>
@@ -122,13 +122,31 @@
</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>
+ <item row="7" column="1">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <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>
+ </widget>
+ </item>
<item row="3" column="2">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1,0">
<item row="0" column="0">
@@ -181,11 +199,14 @@
</item>
</layout>
</item>
- <item row="1" column="1">
- <widget class="QLabel" name="label_2">
+ <item row="3" column="1">
+ <widget class="QLabel" name="label_4">
<property name="text">
- <string>Titre :</string>
+ <string>Date :</string>
</property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
</widget>
</item>
<item row="4" column="1">
@@ -195,41 +216,20 @@
</property>
</widget>
</item>
- <item row="5" column="2">
- <widget class="QLineEdit" name="m_folio_le">
+ <item row="1" column="2">
+ <widget class="QLineEdit" name="m_title_le">
<property name="toolTip">
- <string>Disponible en tant que %folio pour les modèles de cartouches</string>
+ <string>Disponible en tant que %title 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>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_2">
<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>
+ <string>Titre :</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">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Date :</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- </widget>
- </item>
<item row="2" column="2">
<widget class="QLineEdit" name="m_author_le">
<property name="toolTip">
@@ -237,13 +237,34 @@
</property>
</widget>
</item>
- <item row="1" column="2">
- <widget class="QLineEdit" name="m_title_le">
+ <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 %title pour les modèles de cartouches</string>
+ <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>
</item>
</layout>