diff --git a/sources/bordertitleblock.cpp b/sources/bordertitleblock.cpp index 0c08e93cd..9c9f351a6 100644 --- a/sources/bordertitleblock.cpp +++ b/sources/bordertitleblock.cpp @@ -23,6 +23,12 @@ #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 @@ -47,8 +53,8 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) : // contenu par defaut du cartouche importTitleBlock(TitleBlockProperties()); - display_titleblock_ = true; - display_border_ = true; + display_titleblock_ = true; + display_border_ = true; setFolioData(1, 1); updateRectangles(); } @@ -67,31 +73,58 @@ qreal BorderTitleBlock::titleBlockHeight() const { } /** - @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(); } /** @@ -161,8 +194,8 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) { // rows and columns display displayColumns(xml_elmt.attribute("displaycols") != "false"); displayRows(xml_elmt.attribute("displayrows") != "false"); - - adjustTitleBlockToColumns(); + + updateRectangles(); } /** @@ -177,20 +210,27 @@ TitleBlockProperties BorderTitleBlock::exportTitleBlock() { 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 @@ void BorderTitleBlock::displayBorder(bool db) { } /** - 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 @@ void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) { 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 @@ void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) { 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 @@ void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QS // 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,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. 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) { 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::setColumnsCount(int nb_c) { */ 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::setColumnsHeaderHeight(const qreal &new_chh) { */ 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::setRowsCount(int nb_r) { */ 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(); } @@ -597,24 +608,6 @@ void BorderTitleBlock::setDiagramHeight(const qreal &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 dans la grille (ex : B2) diff --git a/sources/bordertitleblock.h b/sources/bordertitleblock.h index 0fc1dc237..df30f7f91 100644 --- a/sources/bordertitleblock.h +++ b/sources/bordertitleblock.h @@ -31,64 +31,60 @@ class TitleBlockTemplateRenderer; 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 + //METHODS + public: + void draw(QPainter *painter); + 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_); } + + //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()); } + + // title block + qreal titleBlockHeight() const; + + QRectF titleBlockRect () const; + private: + QRectF titleBlockRectForQPainter () const; + public: - static int minNbColumns(); - 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); - - // 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_); } - - // 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 - /// @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()); } + QRectF borderRect () const; + qreal borderWidth () const; + qreal borderHeight() const; // methods to get title block basic data /// @return the value of the title block "Author" field @@ -113,10 +109,6 @@ class BorderTitleBlock : public QObject { 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 @@ class BorderTitleBlock : public QObject { 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 @@ class BorderTitleBlock : public QObject { */ 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 diff --git a/sources/diagram.cpp b/sources/diagram.cpp index c31967757..4e49dec66 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -152,7 +152,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) { 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 @@ void Diagram::invertSelection() { * @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(); } /** diff --git a/sources/diagramfoliolist.cpp b/sources/diagramfoliolist.cpp index 3ae98aefd..7455c2840 100644 --- a/sources/diagramfoliolist.cpp +++ b/sources/diagramfoliolist.cpp @@ -112,7 +112,7 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r) diagram_list[i] -> border_and_titleblock.date().toString(Qt::SystemLocaleShortDate)); } - border_and_titleblock.draw(p, margin, margin); + border_and_titleblock.draw(p); p -> restore(); } diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 2c8f50ed0..2b07a87e1 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -1180,14 +1180,6 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) { 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 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) { //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; diff --git a/sources/titleblockproperties.cpp b/sources/titleblockproperties.cpp index 49c270369..b3cfd6c56 100644 --- a/sources/titleblockproperties.cpp +++ b/sources/titleblockproperties.cpp @@ -25,7 +25,8 @@ */ TitleBlockProperties::TitleBlockProperties() : date(), - useDate(UseDateValue) + useDate(UseDateValue), + display_at(Qt::BottomEdge) { } @@ -47,7 +48,8 @@ bool TitleBlockProperties::operator==(const TitleBlockProperties &ip) { 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 @@ void TitleBlockProperties::toXml(QDomElement &e) const { 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 @@ void TitleBlockProperties::fromXml(const QDomElement &e) { 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 @@ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix 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 @@ void TitleBlockProperties::fromSettings(QSettings &settings, const QString &pref 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"); } diff --git a/sources/titleblockproperties.h b/sources/titleblockproperties.h index d45c86dfa..83e7bc50a 100644 --- a/sources/titleblockproperties.h +++ b/sources/titleblockproperties.h @@ -55,6 +55,7 @@ class TitleBlockProperties { 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; diff --git a/sources/titleblocktemplate.cpp b/sources/titleblocktemplate.cpp index 68f473daf..55d88f2ab 100644 --- a/sources/titleblocktemplate.cpp +++ b/sources/titleblocktemplate.cpp @@ -1228,8 +1228,11 @@ void TitleBlockTemplate::render(QPainter &painter, const DiagramContext &diagram QList 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 @@ void TitleBlockTemplate::render(QPainter &painter, const DiagramContext &diagram renderCell(painter, *cells_[i][j], diagram_context, cell_rect); } } + painter.restore(); } /** diff --git a/sources/ui/titleblockpropertieswidget.cpp b/sources/ui/titleblockpropertieswidget.cpp index 4a8ef1749..505d8bfa3 100644 --- a/sources/ui/titleblockpropertieswidget.cpp +++ b/sources/ui/titleblockpropertieswidget.cpp @@ -76,6 +76,7 @@ void TitleBlockPropertiesWidget::setProperties(const TitleBlockProperties &prope 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 @@ TitleBlockProperties TitleBlockPropertiesWidget::properties() const { 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; diff --git a/sources/ui/titleblockpropertieswidget.ui b/sources/ui/titleblockpropertieswidget.ui index 4963f9742..f043379fe 100644 --- a/sources/ui/titleblockpropertieswidget.ui +++ b/sources/ui/titleblockpropertieswidget.ui @@ -7,7 +7,7 @@ 0 0 528 - 387 + 439 @@ -108,10 +108,10 @@ - - - - Folio : + + + + Disponible en tant que %folio pour les modèles de cartouches @@ -122,10 +122,28 @@ - - - - Disponible en tant que %filename pour les modèles de cartouches + + + + Afficher : + + + + + + + QFrame::NoFrame + + + 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 + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -181,45 +199,6 @@ - - - - Titre : - - - - - - - Fichier : - - - - - - - Disponible en tant que %folio pour les modèles de cartouches - - - - - - - QFrame::NoFrame - - - 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 - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - @@ -230,10 +209,10 @@ - - - - Disponible en tant que %author pour les modèles de cartouches + + + + Fichier : @@ -244,6 +223,48 @@ + + + + Titre : + + + + + + + Disponible en tant que %author pour les modèles de cartouches + + + + + + + Folio : + + + + + + + Disponible en tant que %filename pour les modèles de cartouches + + + + + + + + Bas + + + + + Droite (expérimental) + + + +