mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
minor improvement to diagram folio list.
Add diagram folio list put it on first folio. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2839 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
fa5a663787
commit
fbff5a3b47
@ -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 @@ DiagramFolioList::DiagramFolioList(QObject *parent) : Diagram(parent)
|
||||
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 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
|
||||
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 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
|
||||
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 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
|
||||
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 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
|
||||
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 @@ void DiagramFolioList::buildGrid(const QRectF &rect, int rows, int tables, qreal
|
||||
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();
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class DiagramFolioList : public Diagram
|
||||
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_;
|
||||
|
@ -315,7 +315,7 @@ void ProjectView::addNewDiagramFolioList() {
|
||||
|
||||
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 @@ void ProjectView::addNewDiagramFolioList() {
|
||||
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 @@ void ProjectView::addDiagram(DiagramView *diagram) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ class ProjectView : public QWidget {
|
||||
public slots:
|
||||
void addNewDiagram();
|
||||
void addNewDiagramFolioList();
|
||||
void addDiagram(DiagramView *);
|
||||
void addDiagram(DiagramView *, bool front=false);
|
||||
void removeDiagram(DiagramView *);
|
||||
void removeDiagram(Diagram *);
|
||||
void showDiagram(DiagramView *);
|
||||
|
@ -651,9 +651,9 @@ bool QETDiagramEditor::newProject() {
|
||||
new_project -> setDefaultTitleBlockProperties(defaultTitleBlockProperties());
|
||||
new_project -> setDefaultReportProperties(defaultReportProperties());
|
||||
|
||||
// ajoute un schema au projet
|
||||
new_project -> addNewDiagram();
|
||||
// add summary and new diagram
|
||||
new_project -> addNewDiagramFolioList();
|
||||
new_project -> addNewDiagram();
|
||||
|
||||
return(addProject(new_project));
|
||||
}
|
||||
@ -834,7 +834,7 @@ bool QETDiagramEditor::openAndAddProject(const QString &filepath, bool interacti
|
||||
}
|
||||
|
||||
/**
|
||||
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.
|
||||
|
@ -831,21 +831,30 @@ Diagram *QETProject::addNewDiagram() {
|
||||
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 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
|
||||
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 @@ void QETProject::addDiagram(Diagram *diagram) {
|
||||
this, SLOT(usedTitleBlockTemplateChanged(const QString &))
|
||||
);
|
||||
|
||||
// ajoute le schema au projet
|
||||
diagrams_ << diagram;
|
||||
// add diagram to project
|
||||
diagrams_ << diagram;
|
||||
|
||||
updateDiagramsFolioData();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user