From dd9c3139147516d81bc5f4ca451803e66eb02924 Mon Sep 17 00:00:00 2001 From: abhishekm71 Date: Tue, 11 Feb 2014 05:10:16 +0000 Subject: [PATCH] Minor formatting and documenting git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2848 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/createdxf.cpp | 2 ++ sources/diagramfoliolist.cpp | 1 + sources/qetdiagrameditor.cpp | 16 +++++++++++----- sources/qetproject.cpp | 15 +++++++++++++++ sources/qetproject.h | 6 +++--- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/sources/createdxf.cpp b/sources/createdxf.cpp index 2a7ff2922..a6c2fd840 100644 --- a/sources/createdxf.cpp +++ b/sources/createdxf.cpp @@ -488,6 +488,8 @@ void Createdxf::drawText(QString fileName, QString text,double x, double y, doub } /* draw aligned text in DXF Format */ +// leftAlign flag added. If the alignment requested is 'fit to width' and the text length is very small, +// then the text is either centered or left-aligned, depnding on the value of leftAlign. void Createdxf::drawTextAligned(QString fileName, QString text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign,int colour, bool leftAlign, float scale) { diff --git a/sources/diagramfoliolist.cpp b/sources/diagramfoliolist.cpp index 3b24d0c8e..c6bf0574e 100644 --- a/sources/diagramfoliolist.cpp +++ b/sources/diagramfoliolist.cpp @@ -24,6 +24,7 @@ qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15}; /** * @brief DiagramFolioList::DiagramFolioList * Constructor + * @param project QETproject *: The project from which this constructor was called. Important to setProject(). * @param parent parent QObject */ DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) { diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 01acd8698..886ada868 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -651,8 +651,7 @@ bool QETDiagramEditor::newProject() { new_project -> setDefaultTitleBlockProperties(defaultTitleBlockProperties()); new_project -> setDefaultReportProperties(defaultReportProperties()); - // add summary and new diagram - //new_project -> addNewDiagramFolioList(); + // add new diagram new_project -> addNewDiagram(); return(addProject(new_project)); @@ -1682,6 +1681,8 @@ void QETDiagramEditor::addDiagramToProject() { void QETDiagramEditor::addDiagramFolioListToProject() { ProjectView *current_project = currentProject(); if (current_project && current_project -> project() -> getFolioSheetsQuantity() == 0) { + + // The number of folio sheets depend on the number of diagrams in the project. int diagram_qty = current_project -> diagrams().size(); for (int i = 0; i <= diagram_qty/58; i++) current_project -> addNewDiagramFolioList(); @@ -1805,23 +1806,28 @@ void QETDiagramEditor::removeDiagramFromProject() { if (DiagramView *current_diagram = current_project -> currentDiagram()) { can_update_actions = false; bool isFolioList = false; + + // if diagram to remove is a "folio list sheet", then set a flag. if (DiagramFolioList *ptr = dynamic_cast(current_diagram -> diagram())) isFolioList = true; + current_project -> removeDiagram(current_diagram); + + // if the removed diagram was a folio sheet, then delete all the remaining folio sheets also. if (isFolioList) { foreach (DiagramView *diag, current_project -> diagrams()) { if (DiagramFolioList *ptr = dynamic_cast(diag -> diagram())) { current_project -> removeDiagram(diag); } } - //current_project ->project() ->setFolioSheetsQuantity(0); + + // else if after diagram removal, the total diagram quantity becomes a factor of 58, then + // remove one (last) folio sheet. } else if (current_project -> diagrams().size() % 58 == 0) { foreach (DiagramView *diag, current_project -> diagrams()) { DiagramFolioList *ptr = dynamic_cast(diag -> diagram()); if (ptr && ptr -> getId() == current_project -> project() -> getFolioSheetsQuantity() - 1) { current_project -> removeDiagram(diag); - //int folioQuantity = current_project -> project() -> getFolioSheetsQuantity(); - //current_project -> project() -> setFolioSheetsQuantity(folioQuantity - 1); } } } diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 7814ba592..f90e4c10e 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -172,10 +172,18 @@ QETProject::ProjectState QETProject::state() const { return(state_); } +/** + Get the folioSheetQuantity + @return folio Sheets Quantity. +*/ int QETProject::getFolioSheetsQuantity() const { return(folioSheetsQuantity); } +/** + Set the folioSheetQuantity to quantity + @param New value of quantity to be set. +*/ void QETProject::setFolioSheetsQuantity(int quantity) { folioSheetsQuantity = quantity; } @@ -453,6 +461,8 @@ QDomDocument QETProject::toXml() { QDomElement project_root = xml_doc.createElement("project"); project_root.setAttribute("version", QET::version); project_root.setAttribute("title", project_title_); + + // write the present value of folioSheetsQuantity to XML. project_root.setAttribute("folioSheetQuantity", QString::number(folioSheetsQuantity)); xml_doc.appendChild(project_root); @@ -481,6 +491,8 @@ QDomDocument QETProject::toXml() { // qDebug() << "Export XML de" << diagrams_.count() << "schemas"; int order_num = 1; foreach(Diagram *diagram, diagrams_) { + + // Write the diagram to XML only if it is not of type DiagramFolioList. DiagramFolioList *ptr = dynamic_cast(diagram); if ( !ptr ) { qDebug() << qPrintable(QString("QETProject::toXml() : exporting diagram \"%1\" [%2]").arg(diagram -> title()).arg(QET::pointerString(diagram))); @@ -966,6 +978,8 @@ void QETProject::readProjectXml() { // la racine du document XML est sensee etre un element "project" if (root_elmt.tagName() == "project") { + // if there is an attribute for folioSheetQuantity, then set it accordingly. + // If not, then the value remains at the initial value of zero. if (root_elmt.hasAttribute("folioSheetQuantity")) setFolioSheetsQuantity(root_elmt.attribute("folioSheetQuantity","0").toInt()); @@ -1065,6 +1079,7 @@ void QETProject::readDiagramsXml() { d->initElementsLinks(); } + // If the folio sheets quantity is non-zero, then add the folio sheets if (getFolioSheetsQuantity()) { setFolioSheetsQuantity(0); int diagCount = diagrams().size(); diff --git a/sources/qetproject.h b/sources/qetproject.h index 9256d3a7e..64ada790a 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -74,8 +74,8 @@ class QETProject : public QObject { public: ProjectState state() const; QList diagrams() const; - int getFolioSheetsQuantity() const; - void setFolioSheetsQuantity(int); + int getFolioSheetsQuantity() const; /// get the folio sheets quantity for this project + void setFolioSheetsQuantity(int); /// set the folio sheets quantity for this project int folioIndex(const Diagram *) const; ElementsCollection *embeddedCollection() const; TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection(); @@ -177,7 +177,7 @@ class QETProject : public QObject { QDomDocument document_root_; /// Diagrams carried by the project QList diagrams_; - /// Folio List Sheet is added to this project. + /// Folio List Sheets quantity for this project. int folioSheetsQuantity; /// Embedded elements collection XmlElementsCollection *collection_;