[qet] [2847] Folio List: XML save/open added. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2847
Author: abhishekm71
Date: 2014-02-10 14:58:30 +0100 (Mon, 10 Feb 2014)
Log Message:
-----------
Folio List: XML save/open added. When Application starts, folio list is not added
so that user gets the option to choose whether he wants to add folio list or not.
Bug remaining:
- When open project file with folio_list present, folio list sheets are at the end,
not at the beginning.
- Possibly many others. Thorough testing required.
Modified Paths:
--------------
trunk/sources/diagramfoliolist.cpp
trunk/sources/diagramfoliolist.h
trunk/sources/projectview.cpp
trunk/sources/qetdiagrameditor.cpp
trunk/sources/qetproject.cpp
trunk/sources/qetproject.h
Modified: trunk/sources/diagramfoliolist.cpp
===================================================================
--- trunk/sources/diagramfoliolist.cpp 2014-02-10 11:48:05 UTC (rev 2846)
+++ trunk/sources/diagramfoliolist.cpp 2014-02-10 13:58:30 UTC (rev 2847)
@@ -19,7 +19,6 @@
#include <QPainter>
#include "qetapp.h"
-int DiagramFolioList::folioList_quantity = 0;
qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
/**
@@ -27,11 +26,13 @@
* Constructor
* @param parent parent QObject
*/
-DiagramFolioList::DiagramFolioList(QObject *parent) : Diagram(parent) {
-
- id = folioList_quantity;
- folioList_quantity++;
-
+DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) {
+ if (project) {
+ setProject(project);
+ id = project -> getFolioSheetsQuantity();
+ }
+ else
+ id = 0;
}
/**
@@ -40,8 +41,9 @@
*/
DiagramFolioList::~DiagramFolioList()
{
- if (folioList_quantity > 0)
- folioList_quantity--;
+ int folioSheetQty = project() -> getFolioSheetsQuantity();
+ if (folioSheetQty > 0)
+ project() -> setFolioSheetsQuantity(folioSheetQty-1);
}
/**
Modified: trunk/sources/diagramfoliolist.h
===================================================================
--- trunk/sources/diagramfoliolist.h 2014-02-10 11:48:05 UTC (rev 2846)
+++ trunk/sources/diagramfoliolist.h 2014-02-10 13:58:30 UTC (rev 2847)
@@ -24,14 +24,13 @@
class DiagramFolioList : public Diagram
{
public:
- DiagramFolioList(QObject *parent = 0);
+ DiagramFolioList( QETProject *project = 0, QObject *parent = 0);
virtual ~DiagramFolioList();
virtual QList<QLineF *> lines() const {return list_lines_;}
virtual QList<QRectF *> rectangles() const {return list_rectangles_;}
void setId(int i) {id = i;}
int getId() const {return id;}
- static int folioList_quantity;
static qreal colWidths[4];
protected:
Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp 2014-02-10 11:48:05 UTC (rev 2846)
+++ trunk/sources/projectview.cpp 2014-02-10 13:58:30 UTC (rev 2847)
@@ -305,7 +305,7 @@
DiagramView *new_diagram_view = new DiagramView(new_diagram);
addDiagram(new_diagram_view);
- if (project_ -> diagrams().size() % 58 == 1 && DiagramFolioList::folioList_quantity != 0)
+ if (project_ -> diagrams().size() % 58 == 1 && project_ -> getFolioSheetsQuantity() != 0)
addNewDiagramFolioList();
showDiagram(new_diagram_view);
}
@@ -340,11 +340,7 @@
tabs_ -> addTab(diagram, QET::Icons::Diagram, diagram -> title());
diagram -> setFrameStyle(QFrame::Plain | QFrame::NoFrame);
- // Add diagram type is a folio list then add it just after the last folio list in project, else add it at the back.
- //if (DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diagram))
- //diagrams_.insert(DiagramFolioList::folioList_quantity, diagram);
- //else
- diagrams_ << diagram;
+ diagrams_ << diagram;
rebuildDiagramsMap();
connect(diagram, SIGNAL(showDiagram(Diagram*)), this, SLOT(showDiagram(Diagram*)));
@@ -356,11 +352,9 @@
// signal diagram was added
emit(diagramAdded(diagram));
// move tab to front if wanted
- if (front) { //DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diagram ->diagram())) {
- //int tabCount = tabs_ -> count();
- //for (int i = 0; i < (tabCount-1) - (DiagramFolioList::folioList_quantity-1); i++)
- //moveDiagramUp(diagram);
- tabs_->moveTab(tabs_->count()-1, DiagramFolioList::folioList_quantity-1);
+ if (front) {
+ tabs_->moveTab(tabs_->count()-1, project_ -> getFolioSheetsQuantity()-1);
+ //diagram -> diagram() -> project() -> setFolioSheetsQuantity(true);
}
}
@@ -431,7 +425,6 @@
void ProjectView::showDiagram(DiagramView *diagram) {
if (!diagram) return;
tabs_ -> setCurrentWidget(diagram);
- ;
}
/**
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2014-02-10 11:48:05 UTC (rev 2846)
+++ trunk/sources/qetdiagrameditor.cpp 2014-02-10 13:58:30 UTC (rev 2847)
@@ -1681,7 +1681,7 @@
void QETDiagramEditor::addDiagramFolioListToProject() {
ProjectView *current_project = currentProject();
- if (current_project && DiagramFolioList::folioList_quantity == 0) {
+ if (current_project && current_project -> project() -> getFolioSheetsQuantity() == 0) {
int diagram_qty = current_project -> diagrams().size();
for (int i = 0; i <= diagram_qty/58; i++)
current_project -> addNewDiagramFolioList();
@@ -1814,11 +1814,14 @@
current_project -> removeDiagram(diag);
}
}
+ //current_project ->project() ->setFolioSheetsQuantity(0);
} else if (current_project -> diagrams().size() % 58 == 0) {
foreach (DiagramView *diag, current_project -> diagrams()) {
DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diag -> diagram());
- if (ptr && ptr -> getId() == DiagramFolioList::folioList_quantity-1) {
+ 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);
}
}
}
Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp 2014-02-10 11:48:05 UTC (rev 2846)
+++ trunk/sources/qetproject.cpp 2014-02-10 13:58:30 UTC (rev 2847)
@@ -46,14 +46,15 @@
project_qet_version_(-1),
modified_(false),
read_only_(false),
- titleblocks_(this)
+ titleblocks_(this),
+ folioSheetsQuantity(0)
{
// 0 a n schema(s) vide(s)
int diagrams_count = qMax(0, diagrams);
for (int i = 0 ; i < diagrams_count ; ++ i) {
addNewDiagram();
}
-
+
// une collection d'elements vide
collection_ = new XmlElementsCollection();
collection_ -> setProtocol("embed");
@@ -79,7 +80,8 @@
project_qet_version_(-1),
modified_(false),
read_only_(false),
- titleblocks_(this)
+ titleblocks_(this),
+ folioSheetsQuantity(0)
{
// ouvre le fichier
QFile project_file(path);
@@ -121,7 +123,8 @@
project_qet_version_(-1),
modified_(false),
read_only_(false),
- titleblocks_(this)
+ titleblocks_(this),
+ folioSheetsQuantity(0)
{
// copie le contenu XML
document_root_.appendChild(document_root_.importNode(xml_element, true));
@@ -154,6 +157,8 @@
diagrams_.removeAll(diagram);
delete diagram;
}
+
+ folioSheetsQuantity = 0;
// qDebug() << diagrams_;
delete undo_stack_;
}
@@ -167,6 +172,14 @@
return(state_);
}
+int QETProject::getFolioSheetsQuantity() const {
+ return(folioSheetsQuantity);
+}
+
+void QETProject::setFolioSheetsQuantity(int quantity) {
+ folioSheetsQuantity = quantity;
+}
+
/**
@return la liste des schemas de ce projet
*/
@@ -440,6 +453,7 @@
QDomElement project_root = xml_doc.createElement("project");
project_root.setAttribute("version", QET::version);
project_root.setAttribute("title", project_title_);
+ project_root.setAttribute("folioSheetQuantity", QString::number(folioSheetsQuantity));
xml_doc.appendChild(project_root);
// titleblock templates, if any
@@ -467,9 +481,12 @@
// qDebug() << "Export XML de" << diagrams_.count() << "schemas";
int order_num = 1;
foreach(Diagram *diagram, diagrams_) {
- qDebug() << qPrintable(QString("QETProject::toXml() : exporting diagram \"%1\" [%2]").arg(diagram -> title()).arg(QET::pointerString(diagram)));
- QDomNode appended_diagram = project_root.appendChild(diagram -> writeXml(xml_doc));
- appended_diagram.toElement().setAttribute("order", order_num ++);
+ DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diagram);
+ if ( !ptr ) {
+ qDebug() << qPrintable(QString("QETProject::toXml() : exporting diagram \"%1\" [%2]").arg(diagram -> title()).arg(QET::pointerString(diagram)));
+ QDomNode appended_diagram = project_root.appendChild(diagram -> writeXml(xml_doc));
+ appended_diagram.toElement().setAttribute("order", order_num ++);
+ }
}
// collection
@@ -841,7 +858,7 @@
if (isReadOnly()) return(0);
//create new diagram
- Diagram *diagram_folio_list = new DiagramFolioList();
+ Diagram *diagram_folio_list = new DiagramFolioList(this);
// setup default properties
diagram_folio_list -> border_and_titleblock.importBorder(defaultBorderProperties());
@@ -853,7 +870,9 @@
diagram_folio_list -> border_and_titleblock.displayRows(false);
diagram_folio_list -> border_and_titleblock.displayColumns(false);
+
addDiagram(diagram_folio_list);
+ setFolioSheetsQuantity( getFolioSheetsQuantity()+1 );
emit(diagramAdded(this, diagram_folio_list));
return(diagram_folio_list);
@@ -946,6 +965,10 @@
// la racine du document XML est sensee etre un element "project"
if (root_elmt.tagName() == "project") {
+
+ if (root_elmt.hasAttribute("folioSheetQuantity"))
+ setFolioSheetsQuantity(root_elmt.attribute("folioSheetQuantity","0").toInt());
+
// mode d'ouverture normal
if (root_elmt.hasAttribute("version")) {
bool conv_ok;
@@ -1042,6 +1065,13 @@
d->initElementsLinks();
}
+ if (getFolioSheetsQuantity()) {
+ setFolioSheetsQuantity(0);
+ int diagCount = diagrams().size();
+ for (int i = 0; i <= diagCount/58; i++)
+ addNewDiagramFolioList();
+ }
+
//delete dialog object
delete dlgWaiting;
}
Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h 2014-02-10 11:48:05 UTC (rev 2846)
+++ trunk/sources/qetproject.h 2014-02-10 13:58:30 UTC (rev 2847)
@@ -74,6 +74,8 @@
public:
ProjectState state() const;
QList<Diagram *> diagrams() const;
+ int getFolioSheetsQuantity() const;
+ void setFolioSheetsQuantity(int);
int folioIndex(const Diagram *) const;
ElementsCollection *embeddedCollection() const;
TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection();
@@ -175,6 +177,8 @@
QDomDocument document_root_;
/// Diagrams carried by the project
QList<Diagram *> diagrams_;
+ /// Folio List Sheet is added to this project.
+ int folioSheetsQuantity;
/// Embedded elements collection
XmlElementsCollection *collection_;
/// Project title