From 52aeedfc0db49efd76520d9392d8751d43e3d870 Mon Sep 17 00:00:00 2001 From: abhishekm71 Date: Fri, 7 Feb 2014 07:54:54 +0000 Subject: [PATCH] Folio List: New Diagram Folio list can be added if not already present. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2818 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/diagramfoliolist.cpp | 7 ++++++- sources/projectview.cpp | 9 +++++++++ sources/projectview.h | 1 + sources/qetdiagrameditor.cpp | 10 +++++++++- sources/qetdiagrameditor.h | 1 + sources/qetproject.cpp | 8 +++++++- sources/qetproject.h | 3 +++ 7 files changed, 36 insertions(+), 3 deletions(-) diff --git a/sources/diagramfoliolist.cpp b/sources/diagramfoliolist.cpp index fdbe2c9d7..915371f52 100644 --- a/sources/diagramfoliolist.cpp +++ b/sources/diagramfoliolist.cpp @@ -31,7 +31,12 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r) 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, "Auteur", "Titre", "Folio", "Date"); + QString authorTranslatable = tr("Auteur"); + QString titleTranslatable = tr("Titre"); + QString folioTranslatable = tr("Folio"); + QString dateTranslatable = tr("Date"); + + fillRow(p, row_RectF, authorTranslatable, titleTranslatable, folioTranslatable, dateTranslatable); foreach (Diagram *diagram, diagram_list) { y0 += rowHeight; QRectF row_rect(x0 + width*.1, y0 + height*.05, width*0.8, rowHeight); diff --git a/sources/projectview.cpp b/sources/projectview.cpp index cab207af7..a4d23170f 100644 --- a/sources/projectview.cpp +++ b/sources/projectview.cpp @@ -306,6 +306,15 @@ void ProjectView::addNewDiagram() { showDiagram(new_diagram_view); } +void ProjectView::addNewDiagramFolioList() { + if (project_ -> isReadOnly() || project_ -> isFolioListAdded()) return; + + Diagram *new_diagram = project_ -> addNewDiagramFolioList(); + DiagramView *new_diagram_view = new DiagramView(new_diagram); + addDiagram(new_diagram_view); + showDiagram(new_diagram_view); +} + /** Ajoute un schema au ProjectView @param diagram Schema a ajouter diff --git a/sources/projectview.h b/sources/projectview.h index f602f67fb..388a09868 100644 --- a/sources/projectview.h +++ b/sources/projectview.h @@ -60,6 +60,7 @@ class ProjectView : public QWidget { public slots: void addNewDiagram(); + void addNewDiagramFolioList(); void addDiagram(DiagramView *); void removeDiagram(DiagramView *); void removeDiagram(Diagram *); diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 0ba67a5da..c74b1528b 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -222,6 +222,7 @@ void QETDiagramEditor::actions() { prj_edit_prop = new QAction(QET::Icons::DialogInformation, tr("Propri\351t\351s du projet"), this); prj_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un sch\351ma"), this); + //prj_add_diagram_foliolist = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un sch\351ma"), this); prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer le sch\351ma"), this); prj_clean = new QAction(QET::Icons::EditClear, tr("Nettoyer le projet"), this); prj_diagramNum = new QAction(QET::Icons::ConductorSettings, tr("Annoter les sch\351mas"), this); @@ -374,7 +375,7 @@ void QETDiagramEditor::actions() { connect(prj_del_diagram, SIGNAL(triggered()), this, SLOT(removeDiagramFromProject()) ); connect(prj_clean, SIGNAL(triggered()), this, SLOT(cleanCurrentProject()) ); connect(prj_diagramNum, SIGNAL(triggered()), this, SLOT(diagramNumProject()) ); - //connect(prj_diagramList, SIGNAL(triggered()), this, SLOT(addNewDiagramFolioList()) ); + connect(prj_diagramList, SIGNAL(triggered()), this, SLOT(addDiagramFolioListToProject())); connect(prj_nomenclature, SIGNAL(triggered()), this, SLOT(nomenclatureProject()) ); connect(zoom_in, SIGNAL(triggered()), this, SLOT(slot_zoomIn()) ); connect(zoom_out, SIGNAL(triggered()), this, SLOT(slot_zoomOut()) ); @@ -1135,6 +1136,7 @@ void QETDiagramEditor::slot_updateActions() { save_cur_diagram -> setEnabled(editable_diagram); prj_edit_prop -> setEnabled(opened_project); prj_add_diagram -> setEnabled(editable_project); + //prj_add_diagram_foliolist -> setEnabled(editable_project); prj_del_diagram -> setEnabled(editable_project); prj_clean -> setEnabled(editable_project); prj_diagramNum -> setEnabled(editable_project); @@ -1679,6 +1681,12 @@ void QETDiagramEditor::addDiagramToProject() { } } +void QETDiagramEditor::addDiagramFolioListToProject() { + if (ProjectView *current_project = currentProject()) { + current_project -> addNewDiagramFolioList(); + } +} + /** Ajoute un nouveau schema a un projet @param project Projet auquel il faut ajouter un schema diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h index 384ce9ed0..f4eaa5c17 100644 --- a/sources/qetdiagrameditor.h +++ b/sources/qetdiagrameditor.h @@ -143,6 +143,7 @@ class QETDiagramEditor : public QETMainWindow { void editDiagramProperties(DiagramView *); void editDiagramProperties(Diagram *); void addDiagramToProject(); + void addDiagramFolioListToProject(); void addDiagramToProject(QETProject *); void removeDiagram(Diagram *); void removeDiagramFromProject(); diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index d5bf52799..fb732c47f 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -46,7 +46,8 @@ QETProject::QETProject(int diagrams, QObject *parent) : project_qet_version_(-1), modified_(false), read_only_(false), - titleblocks_(this) + titleblocks_(this), + folio_list_added_(false) { // 0 a n schema(s) vide(s) int diagrams_count = qMax(0, diagrams); @@ -846,6 +847,7 @@ Diagram *QETProject::addNewDiagramFolioList() { diagram_folio_list -> border_and_titleblock.setTitle(title); addDiagram(diagram_folio_list); + folio_list_added_ = true; emit(diagramAdded(this, diagram_folio_list)); return(diagram_folio_list); } @@ -861,6 +863,10 @@ void QETProject::removeDiagram(Diagram *diagram) { if (!diagram || !diagrams_.contains(diagram)) return; if (diagrams_.removeAll(diagram)) { + + DiagramFolioList *ptr = dynamic_cast(diagram); + if (ptr) + folio_list_added_ = false; emit(diagramRemoved(this, diagram)); delete diagram; } diff --git a/sources/qetproject.h b/sources/qetproject.h index 8be3ae23a..357fe5a1f 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -121,6 +121,7 @@ class QETProject : public QObject { DiagramContext projectProperties(); void setProjectProperties(const DiagramContext &); QUndoStack* undoStack() {return undo_stack_;} + bool isFolioListAdded() {return folio_list_added_;} public slots: void componentWritten(); @@ -185,6 +186,8 @@ class QETProject : public QObject { bool modified_; /// Whether the project is read only bool read_only_; + /// Whether folio_list has been added. + bool folio_list_added_; /// Filepath for which this project is considered read only QString read_only_file_path_; /// Name of the category used when automatically integrating elements within the embedded collection