[qet] [2839] minor improvement to diagram folio list. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2839
Author: blacksun
Date: 2014-02-09 00:54:15 +0100 (Sun, 09 Feb 2014)
Log Message:
-----------
minor improvement to diagram folio list.
Add diagram folio list put it on first folio.
Modified Paths:
--------------
trunk/sources/diagramfoliolist.cpp
trunk/sources/diagramfoliolist.h
trunk/sources/projectview.cpp
trunk/sources/projectview.h
trunk/sources/qetdiagrameditor.cpp
trunk/sources/qetproject.cpp
Modified: trunk/sources/diagramfoliolist.cpp
===================================================================
--- trunk/sources/diagramfoliolist.cpp 2014-02-08 18:51:06 UTC (rev 2838)
+++ trunk/sources/diagramfoliolist.cpp 2014-02-08 23:54:15 UTC (rev 2839)
@@ -17,12 +17,18 @@
*/
#include "diagramfoliolist.h"
#include <QPainter>
+#include "qetapp.h"
int DiagramFolioList::folioList_quantity = 0;
qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
-DiagramFolioList::DiagramFolioList(QObject *parent) : Diagram(parent)
-{
+/**
+ * @brief DiagramFolioList::DiagramFolioList
+ * Constructor
+ * @param parent parent QObject
+ */
+DiagramFolioList::DiagramFolioList(QObject *parent) : Diagram(parent) {
+
list_lines_.clear();
list_rectangles_.clear();
@@ -40,38 +46,43 @@
buildGrid(row_RectF,30,2,colWidths);
}
+/**
+ * @brief DiagramFolioList::~DiagramFolioList
+ * Destructor
+ */
DiagramFolioList::~DiagramFolioList()
{
if (folioList_quantity > 0)
folioList_quantity--;
}
+/**
+ * @brief DiagramFolioList::drawBackground
+ * Draw background, and call method to draw the folio list (grid)
+ * @param p painter to use
+ * @param r rectangle where we paint
+ */
void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
{
p -> save();
- // desactive tout antialiasing, sauf pour le texte
+ // disable all antialiasing, except for the texts
p -> setRenderHint(QPainter::Antialiasing, false);
p -> setRenderHint(QPainter::TextAntialiasing, true);
p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
- // dessine un fond blanc
+ // draw white background
p -> setPen(Qt::NoPen);
p -> setBrush(Diagram::background_color);
p -> drawRect(r);
p -> setPen(Qt::black);
- QString authorTranslatable = tr("Auteur");
- QString titleTranslatable = tr("Titre");
- QString folioTranslatable = tr("Folio");
- QString dateTranslatable = tr("Date");
-
qreal x0 = list_rectangles_[0] -> topLeft().x();
qreal y0 = list_rectangles_[0] -> topLeft().y();
qreal rowHeight = (list_rectangles_[0] -> height())/30;
QRectF row_RectF(x0, y0, list_rectangles_[0] -> width(), rowHeight);
- fillRow(p, row_RectF, authorTranslatable, titleTranslatable, folioTranslatable, dateTranslatable);
+ fillHeader(p, row_RectF);
QList<Diagram *> diagram_list = project() -> diagrams();
int startDiagram = id * 58;
@@ -80,8 +91,8 @@
y0 += rowHeight;
QRectF row_rect(x0, y0, list_rectangles_[0] -> width(), rowHeight);
fillRow(p, row_rect, diagram_list[i] -> border_and_titleblock.author(),
- diagram_list[i] -> border_and_titleblock.title(),
- diagram_list[i] -> border_and_titleblock.folio(),
+ diagram_list[i] -> title(),
+ QString::number(diagram_list[i] ->folioIndex()+1),
diagram_list[i] -> border_and_titleblock.date().toString("dd/MM/yyyy"));
}
@@ -89,7 +100,7 @@
y0 = list_rectangles_[1] -> topLeft().y();
rowHeight = (list_rectangles_[1] -> height())/30;
QRectF row_RectF2(x0, y0, list_rectangles_[1] -> width(), rowHeight);
- fillRow(p, row_RectF2, authorTranslatable, titleTranslatable, folioTranslatable, dateTranslatable);
+ fillHeader(p, row_RectF2);
startDiagram += 29;
@@ -97,8 +108,8 @@
y0 += rowHeight;
QRectF row_rect(x0, y0, list_rectangles_[1] -> width(), rowHeight);
fillRow(p, row_rect, diagram_list[i] -> border_and_titleblock.author(),
- diagram_list[i] -> border_and_titleblock.title(),
- diagram_list[i] -> border_and_titleblock.folio(),
+ diagram_list[i] -> title(),
+ QString::number(diagram_list[i] ->folioIndex()+1),
diagram_list[i] -> border_and_titleblock.date().toString("dd/MM/yyyy"));
}
@@ -106,6 +117,12 @@
p -> restore();
}
+/**
+ * @brief DiagramFolioList::fillRow
+ * Add new row and fill it with the given information.
+ * @param qp Qpainter to use
+ * @param row_rect rectangle where we must draw the new row
+ */
void DiagramFolioList::fillRow(QPainter *qp, const QRectF &row_rect, QString author, QString title,
QString folio, QString date)
{
@@ -160,3 +177,21 @@
x0 += colWidths[cols-1]*tableWidth + tablesSpacing;
}
}
+
+/**
+ * @brief DiagramFolioList::fillHeader
+ * Fill the header with bigger font
+ * @param qp the painter to use
+ * @param row_RectF rectangle of header
+ */
+void DiagramFolioList::fillHeader(QPainter *qp, const QRectF &row_RectF) {
+ QString authorTranslatable = tr("Auteur");
+ QString titleTranslatable = tr("Titre");
+ QString folioTranslatable = tr("Folio");
+ QString dateTranslatable = tr("Date");
+
+ qp->save();
+ qp->setFont(QETApp::diagramTextsFont(13));
+ fillRow(qp, row_RectF, authorTranslatable, titleTranslatable, folioTranslatable, dateTranslatable);
+ qp->restore();
+}
Modified: trunk/sources/diagramfoliolist.h
===================================================================
--- trunk/sources/diagramfoliolist.h 2014-02-08 18:51:06 UTC (rev 2838)
+++ trunk/sources/diagramfoliolist.h 2014-02-08 23:54:15 UTC (rev 2839)
@@ -40,6 +40,7 @@
private:
void fillRow(QPainter *, const QRectF &, QString, QString, QString, QString);
void buildGrid(const QRectF &, int, int, qreal[]);
+ void fillHeader(QPainter *, const QRectF &);
QList<QLineF *> list_lines_;
Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp 2014-02-08 18:51:06 UTC (rev 2838)
+++ trunk/sources/projectview.cpp 2014-02-08 23:54:15 UTC (rev 2839)
@@ -315,7 +315,7 @@
Diagram *new_diagram = project_ -> addNewDiagramFolioList();
DiagramView *new_diagram_view = new DiagramView(new_diagram);
- addDiagram(new_diagram_view);
+ addDiagram(new_diagram_view, true);
showDiagram(new_diagram_view);
}
@@ -323,13 +323,20 @@
Ajoute un schema au ProjectView
@param diagram Schema a ajouter
*/
-void ProjectView::addDiagram(DiagramView *diagram) {
+/**
+ * @brief ProjectView::addDiagram
+ * Add new digram to this project view
+ * @param diagram added diagram
+ * @param front: true add page at front
+ * false add page at back
+ */
+void ProjectView::addDiagram(DiagramView *diagram, bool front) {
if (!diagram) return;
-
- // verifie que le schema n'est pas deja present dans le projet
+
+ // check diagram isn't present in the project
if (diagram_ids_.values().contains(diagram)) return;
- // ajoute un nouvel onglet pour le nouveau schema
+ // Add new tab for the diagram
tabs_ -> addTab(diagram, QET::Icons::Diagram, diagram -> title());
diagram -> setFrameStyle(QFrame::Plain | QFrame::NoFrame);
diagrams_ << diagram;
@@ -340,8 +347,11 @@
connect(diagram, SIGNAL(editElementRequired(const ElementsLocation &)), this, SIGNAL(editElementRequired(const ElementsLocation &)));
connect(diagram, SIGNAL(editTitleBlockTemplate(const QString &, bool)), this, SLOT(editTitleBlockTemplateRequired(const QString &, bool)));
- // signale l'ajout du schema
+ // signal diagram was added
emit(diagramAdded(diagram));
+ // move tab to front if wanted
+ if (front)
+ tabs_->moveTab(tabs_->count()-1, 0);
}
/**
Modified: trunk/sources/projectview.h
===================================================================
--- trunk/sources/projectview.h 2014-02-08 18:51:06 UTC (rev 2838)
+++ trunk/sources/projectview.h 2014-02-08 23:54:15 UTC (rev 2839)
@@ -61,7 +61,7 @@
public slots:
void addNewDiagram();
void addNewDiagramFolioList();
- void addDiagram(DiagramView *);
+ void addDiagram(DiagramView *, bool front=false);
void removeDiagram(DiagramView *);
void removeDiagram(Diagram *);
void showDiagram(DiagramView *);
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2014-02-08 18:51:06 UTC (rev 2838)
+++ trunk/sources/qetdiagrameditor.cpp 2014-02-08 23:54:15 UTC (rev 2839)
@@ -651,9 +651,9 @@
new_project -> setDefaultTitleBlockProperties(defaultTitleBlockProperties());
new_project -> setDefaultReportProperties(defaultReportProperties());
- // ajoute un schema au projet
+ // add summary and new diagram
+ new_project -> addNewDiagramFolioList();
new_project -> addNewDiagram();
- new_project -> addNewDiagramFolioList();
return(addProject(new_project));
}
@@ -834,7 +834,7 @@
}
/**
- Ajoute un projet
+ Ajoute un projetmoveDiagramUp(
@param project projet a ajouter
@param update_panel Whether the elements panel should be warned this
project has been added. Defaults to true.
Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp 2014-02-08 18:51:06 UTC (rev 2838)
+++ trunk/sources/qetproject.cpp 2014-02-08 23:54:15 UTC (rev 2839)
@@ -831,21 +831,30 @@
return(diagram);
}
+/**
+ * @brief QETProject::addNewDiagramFolioList
+ * Add new diagram folio list
+ * @return the created diagram
+ */
Diagram *QETProject::addNewDiagramFolioList() {
- // ne fait rien si le projet est en lecture seule
+ // do nothing if project is read only
if (isReadOnly()) return(0);
- // cree un nouveau schema
+ //create new diagram
Diagram *diagram_folio_list = new DiagramFolioList();
- // lui transmet les parametres par defaut
+ // setup default properties
diagram_folio_list -> border_and_titleblock.importBorder(defaultBorderProperties());
diagram_folio_list -> border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
diagram_folio_list -> defaultConductorProperties = defaultConductorProperties();
- QString title = (tr("Liste des Sch\351mas"));
- diagram_folio_list -> border_and_titleblock.setTitle(title);
+ diagram_folio_list -> border_and_titleblock.setTitle(tr("Liste des Sch\351mas"));
+ // no need to display rows and columns
+ diagram_folio_list -> border_and_titleblock.displayRows(false);
+ diagram_folio_list -> border_and_titleblock.displayColumns(false);
+
addDiagram(diagram_folio_list);
+
emit(diagramAdded(this, diagram_folio_list));
return(diagram_folio_list);
}
@@ -1187,13 +1196,19 @@
Cette methode ajoute un schema donne au projet
@param diagram Schema a ajouter
*/
+/**
+ * @brief QETProject::addDiagram
+ * Add a diagram in this project
+ * @param diagram added diagram
+ * @param position postion of the new diagram, by default at the end
+ */
void QETProject::addDiagram(Diagram *diagram) {
if (!diagram) return;
- // s'assure que le schema connaisse son projet parent
+ // Ensure diagram know is parent project
diagram -> setProject(this);
- // si le schema est ecrit, alors il faut reecrire le fichier projet
+ // If diagram is write, we must rewrite the project
connect(diagram, SIGNAL(written()), this, SLOT(componentWritten()));
connect(
&(diagram -> border_and_titleblock),
@@ -1206,8 +1221,8 @@
this, SLOT(usedTitleBlockTemplateChanged(const QString &))
);
- // ajoute le schema au projet
- diagrams_ << diagram;
+ // add diagram to project
+ diagrams_ << diagram;
updateDiagramsFolioData();
}