[qet] [2812] New Diagram: List of Drawings (rough draft) added |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2812
Author: abhishekm71
Date: 2014-02-06 16:19:27 +0100 (Thu, 06 Feb 2014)
Log Message:
-----------
New Diagram: List of Drawings (rough draft) added
Modified Paths:
--------------
trunk/sources/qetdiagrameditor.cpp
trunk/sources/qetproject.cpp
trunk/sources/qetproject.h
Added Paths:
-----------
trunk/sources/diagramfoliolist.cpp
trunk/sources/diagramfoliolist.h
Added: trunk/sources/diagramfoliolist.cpp
===================================================================
--- trunk/sources/diagramfoliolist.cpp (rev 0)
+++ trunk/sources/diagramfoliolist.cpp 2014-02-06 15:19:27 UTC (rev 2812)
@@ -0,0 +1,61 @@
+#include "diagramfoliolist.h"
+#include <QPainter>
+
+
+void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
+{
+ p -> save();
+
+ // desactive tout antialiasing, sauf pour le texte
+ p -> setRenderHint(QPainter::Antialiasing, false);
+ p -> setRenderHint(QPainter::TextAntialiasing, true);
+ p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
+
+ // dessine un fond blanc
+ p -> setPen(Qt::NoPen);
+ //set brush color to present background color.
+ p -> setBrush(Diagram::background_color);
+ p -> drawRect(r);
+
+ p -> setPen(Qt::black);
+ qreal width = border_and_titleblock.columnsTotalWidth();
+ qreal height = border_and_titleblock.rowsTotalHeight();
+
+ QList<Diagram *> diagram_list = project() -> diagrams();
+
+ //top left corner of drawable area
+ qreal x0 = border_and_titleblock.rowsHeaderWidth();
+ qreal y0 = border_and_titleblock.columnsHeaderHeight();
+ qreal drawings_quantity = diagram_list.size();
+ qreal rowHeight = height / (drawings_quantity+1) * 0.8;
+ rowHeight = (rowHeight > height*0.05) ? height*0.05 : rowHeight;
+ QRectF row_RectF(x0 + width*.1, y0 + height*.05, width*0.8, rowHeight);
+
+ fillRow(p, row_RectF, "Author", "Title", "Folio", "Date");
+ foreach (Diagram *diagram, diagram_list) {
+ y0 += rowHeight;
+ QRectF row_rect(x0 + width*.1, y0 + height*.05, width*0.8, rowHeight);
+ fillRow(p, row_rect, diagram -> border_and_titleblock.author(), diagram -> border_and_titleblock.title(),
+ diagram -> border_and_titleblock.folio(), diagram -> border_and_titleblock.date().toString());
+ }
+ p -> setPen(Qt::NoPen);
+ border_and_titleblock.draw(p, margin, margin);
+ p -> restore();
+}
+
+void DiagramFolioList::fillRow(QPainter *qp, const QRectF &row_rect, QString author, QString title,
+ QString folio, QString date)
+{
+ qp -> drawRect(row_rect);
+ qreal x = row_rect.topLeft().x();
+ qreal y = row_rect.topLeft().y();
+ qreal column_width = row_rect.width() / 4;
+
+ qp -> drawText(QRectF(x, y, column_width, row_rect.height()), Qt::AlignCenter, folio);
+ qp -> drawText(QRectF(x + column_width, y, column_width, row_rect.height()), Qt::AlignCenter, title);
+ qp -> drawText(QRectF(x + 2*column_width, y, column_width, row_rect.height()), Qt::AlignCenter, author);
+ qp -> drawText(QRectF(x + 3*column_width, y, column_width, row_rect.height()), Qt::AlignCenter, date);
+
+ for (int i = 1; i <= 3; i++ )
+ qp -> drawLine(x + i*column_width, y, x + i*column_width, y + row_rect.height());
+}
Added: trunk/sources/diagramfoliolist.h
===================================================================
--- trunk/sources/diagramfoliolist.h (rev 0)
+++ trunk/sources/diagramfoliolist.h 2014-02-06 15:19:27 UTC (rev 2812)
@@ -0,0 +1,20 @@
+#ifndef DIAGRAMFOLIOLIST_H
+#define DIAGRAMFOLIOLIST_H
+
+#include "diagram.h"
+
+class DiagramFolioList : public Diagram
+{
+ public:
+ DiagramFolioList(QObject *parent = 0) : Diagram(parent) {}
+ virtual ~DiagramFolioList() {}
+
+ protected:
+ void drawBackground(QPainter *, const QRectF &);
+
+ private:
+ void fillRow(QPainter *, const QRectF &, QString, QString, QString, QString);
+
+};
+
+#endif // DIAGRAMFOLIOLIST_H
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2014-02-06 11:05:47 UTC (rev 2811)
+++ trunk/sources/qetdiagrameditor.cpp 2014-02-06 15:19:27 UTC (rev 2812)
@@ -648,6 +648,7 @@
// ajoute un schema au projet
new_project -> addNewDiagram();
+ new_project -> addNewDiagramFolioList();
return(addProject(new_project));
}
Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp 2014-02-06 11:05:47 UTC (rev 2811)
+++ trunk/sources/qetproject.cpp 2014-02-06 15:19:27 UTC (rev 2812)
@@ -17,6 +17,7 @@
*/
#include "qetproject.h"
#include "diagram.h"
+#include "diagramfoliolist.h"
#include "elementdefinition.h"
#include "xmlelementscollection.h"
#include "elementscategory.h"
@@ -830,6 +831,25 @@
return(diagram);
}
+Diagram *QETProject::addNewDiagramFolioList() {
+ // ne fait rien si le projet est en lecture seule
+ if (isReadOnly()) return(0);
+
+ // cree un nouveau schema
+ Diagram *diagram_folio_list = new DiagramFolioList();
+
+ // lui transmet les parametres par defaut
+ diagram_folio_list -> border_and_titleblock.importBorder(defaultBorderProperties());
+ diagram_folio_list -> border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
+ diagram_folio_list -> defaultConductorProperties = defaultConductorProperties();
+ QString title = "List of Drawings";
+ diagram_folio_list -> border_and_titleblock.setTitle(title);
+
+ addDiagram(diagram_folio_list);
+ emit(diagramAdded(this, diagram_folio_list));
+ return(diagram_folio_list);
+}
+
/**
Enleve un schema du projet et emet le signal diagramRemoved
@param diagram le schema a enlever
Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h 2014-02-06 11:05:47 UTC (rev 2811)
+++ trunk/sources/qetproject.h 2014-02-06 15:19:27 UTC (rev 2812)
@@ -125,6 +125,7 @@
public slots:
void componentWritten();
Diagram *addNewDiagram();
+ Diagram *addNewDiagramFolioList();
void removeDiagram(Diagram *);
void diagramOrderChanged(int, int);
void setModified(bool);