mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
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. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2847 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
|
||||||
int DiagramFolioList::folioList_quantity = 0;
|
|
||||||
qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
|
qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,11 +26,13 @@ qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
|
|||||||
* Constructor
|
* Constructor
|
||||||
* @param parent parent QObject
|
* @param parent parent QObject
|
||||||
*/
|
*/
|
||||||
DiagramFolioList::DiagramFolioList(QObject *parent) : Diagram(parent) {
|
DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) {
|
||||||
|
if (project) {
|
||||||
id = folioList_quantity;
|
setProject(project);
|
||||||
folioList_quantity++;
|
id = project -> getFolioSheetsQuantity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,8 +41,9 @@ DiagramFolioList::DiagramFolioList(QObject *parent) : Diagram(parent) {
|
|||||||
*/
|
*/
|
||||||
DiagramFolioList::~DiagramFolioList()
|
DiagramFolioList::~DiagramFolioList()
|
||||||
{
|
{
|
||||||
if (folioList_quantity > 0)
|
int folioSheetQty = project() -> getFolioSheetsQuantity();
|
||||||
folioList_quantity--;
|
if (folioSheetQty > 0)
|
||||||
|
project() -> setFolioSheetsQuantity(folioSheetQty-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,14 +24,13 @@
|
|||||||
class DiagramFolioList : public Diagram
|
class DiagramFolioList : public Diagram
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DiagramFolioList(QObject *parent = 0);
|
DiagramFolioList( QETProject *project = 0, QObject *parent = 0);
|
||||||
virtual ~DiagramFolioList();
|
virtual ~DiagramFolioList();
|
||||||
virtual QList<QLineF *> lines() const {return list_lines_;}
|
virtual QList<QLineF *> lines() const {return list_lines_;}
|
||||||
virtual QList<QRectF *> rectangles() const {return list_rectangles_;}
|
virtual QList<QRectF *> rectangles() const {return list_rectangles_;}
|
||||||
void setId(int i) {id = i;}
|
void setId(int i) {id = i;}
|
||||||
int getId() const {return id;}
|
int getId() const {return id;}
|
||||||
|
|
||||||
static int folioList_quantity;
|
|
||||||
static qreal colWidths[4];
|
static qreal colWidths[4];
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ void ProjectView::addNewDiagram() {
|
|||||||
DiagramView *new_diagram_view = new DiagramView(new_diagram);
|
DiagramView *new_diagram_view = new DiagramView(new_diagram);
|
||||||
addDiagram(new_diagram_view);
|
addDiagram(new_diagram_view);
|
||||||
|
|
||||||
if (project_ -> diagrams().size() % 58 == 1 && DiagramFolioList::folioList_quantity != 0)
|
if (project_ -> diagrams().size() % 58 == 1 && project_ -> getFolioSheetsQuantity() != 0)
|
||||||
addNewDiagramFolioList();
|
addNewDiagramFolioList();
|
||||||
showDiagram(new_diagram_view);
|
showDiagram(new_diagram_view);
|
||||||
}
|
}
|
||||||
@@ -340,11 +340,7 @@ void ProjectView::addDiagram(DiagramView *diagram, bool front) {
|
|||||||
tabs_ -> addTab(diagram, QET::Icons::Diagram, diagram -> title());
|
tabs_ -> addTab(diagram, QET::Icons::Diagram, diagram -> title());
|
||||||
diagram -> setFrameStyle(QFrame::Plain | QFrame::NoFrame);
|
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.
|
diagrams_ << diagram;
|
||||||
//if (DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diagram))
|
|
||||||
//diagrams_.insert(DiagramFolioList::folioList_quantity, diagram);
|
|
||||||
//else
|
|
||||||
diagrams_ << diagram;
|
|
||||||
|
|
||||||
rebuildDiagramsMap();
|
rebuildDiagramsMap();
|
||||||
connect(diagram, SIGNAL(showDiagram(Diagram*)), this, SLOT(showDiagram(Diagram*)));
|
connect(diagram, SIGNAL(showDiagram(Diagram*)), this, SLOT(showDiagram(Diagram*)));
|
||||||
@@ -356,11 +352,9 @@ void ProjectView::addDiagram(DiagramView *diagram, bool front) {
|
|||||||
// signal diagram was added
|
// signal diagram was added
|
||||||
emit(diagramAdded(diagram));
|
emit(diagramAdded(diagram));
|
||||||
// move tab to front if wanted
|
// move tab to front if wanted
|
||||||
if (front) { //DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diagram ->diagram())) {
|
if (front) {
|
||||||
//int tabCount = tabs_ -> count();
|
tabs_->moveTab(tabs_->count()-1, project_ -> getFolioSheetsQuantity()-1);
|
||||||
//for (int i = 0; i < (tabCount-1) - (DiagramFolioList::folioList_quantity-1); i++)
|
//diagram -> diagram() -> project() -> setFolioSheetsQuantity(true);
|
||||||
//moveDiagramUp(diagram);
|
|
||||||
tabs_->moveTab(tabs_->count()-1, DiagramFolioList::folioList_quantity-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +425,6 @@ void ProjectView::removeDiagram(Diagram *diagram) {
|
|||||||
void ProjectView::showDiagram(DiagramView *diagram) {
|
void ProjectView::showDiagram(DiagramView *diagram) {
|
||||||
if (!diagram) return;
|
if (!diagram) return;
|
||||||
tabs_ -> setCurrentWidget(diagram);
|
tabs_ -> setCurrentWidget(diagram);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1681,7 +1681,7 @@ void QETDiagramEditor::addDiagramToProject() {
|
|||||||
|
|
||||||
void QETDiagramEditor::addDiagramFolioListToProject() {
|
void QETDiagramEditor::addDiagramFolioListToProject() {
|
||||||
ProjectView *current_project = currentProject();
|
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();
|
int diagram_qty = current_project -> diagrams().size();
|
||||||
for (int i = 0; i <= diagram_qty/58; i++)
|
for (int i = 0; i <= diagram_qty/58; i++)
|
||||||
current_project -> addNewDiagramFolioList();
|
current_project -> addNewDiagramFolioList();
|
||||||
@@ -1814,11 +1814,14 @@ void QETDiagramEditor::removeDiagramFromProject() {
|
|||||||
current_project -> removeDiagram(diag);
|
current_project -> removeDiagram(diag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//current_project ->project() ->setFolioSheetsQuantity(0);
|
||||||
} else if (current_project -> diagrams().size() % 58 == 0) {
|
} else if (current_project -> diagrams().size() % 58 == 0) {
|
||||||
foreach (DiagramView *diag, current_project -> diagrams()) {
|
foreach (DiagramView *diag, current_project -> diagrams()) {
|
||||||
DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diag -> diagram());
|
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);
|
current_project -> removeDiagram(diag);
|
||||||
|
//int folioQuantity = current_project -> project() -> getFolioSheetsQuantity();
|
||||||
|
//current_project -> project() -> setFolioSheetsQuantity(folioQuantity - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,14 +46,15 @@ QETProject::QETProject(int diagrams, QObject *parent) :
|
|||||||
project_qet_version_(-1),
|
project_qet_version_(-1),
|
||||||
modified_(false),
|
modified_(false),
|
||||||
read_only_(false),
|
read_only_(false),
|
||||||
titleblocks_(this)
|
titleblocks_(this),
|
||||||
|
folioSheetsQuantity(0)
|
||||||
{
|
{
|
||||||
// 0 a n schema(s) vide(s)
|
// 0 a n schema(s) vide(s)
|
||||||
int diagrams_count = qMax(0, diagrams);
|
int diagrams_count = qMax(0, diagrams);
|
||||||
for (int i = 0 ; i < diagrams_count ; ++ i) {
|
for (int i = 0 ; i < diagrams_count ; ++ i) {
|
||||||
addNewDiagram();
|
addNewDiagram();
|
||||||
}
|
}
|
||||||
|
|
||||||
// une collection d'elements vide
|
// une collection d'elements vide
|
||||||
collection_ = new XmlElementsCollection();
|
collection_ = new XmlElementsCollection();
|
||||||
collection_ -> setProtocol("embed");
|
collection_ -> setProtocol("embed");
|
||||||
@@ -79,7 +80,8 @@ QETProject::QETProject(const QString &path, QObject *parent) :
|
|||||||
project_qet_version_(-1),
|
project_qet_version_(-1),
|
||||||
modified_(false),
|
modified_(false),
|
||||||
read_only_(false),
|
read_only_(false),
|
||||||
titleblocks_(this)
|
titleblocks_(this),
|
||||||
|
folioSheetsQuantity(0)
|
||||||
{
|
{
|
||||||
// ouvre le fichier
|
// ouvre le fichier
|
||||||
QFile project_file(path);
|
QFile project_file(path);
|
||||||
@@ -121,7 +123,8 @@ QETProject::QETProject(const QDomElement &xml_element, QObject *parent) :
|
|||||||
project_qet_version_(-1),
|
project_qet_version_(-1),
|
||||||
modified_(false),
|
modified_(false),
|
||||||
read_only_(false),
|
read_only_(false),
|
||||||
titleblocks_(this)
|
titleblocks_(this),
|
||||||
|
folioSheetsQuantity(0)
|
||||||
{
|
{
|
||||||
// copie le contenu XML
|
// copie le contenu XML
|
||||||
document_root_.appendChild(document_root_.importNode(xml_element, true));
|
document_root_.appendChild(document_root_.importNode(xml_element, true));
|
||||||
@@ -154,6 +157,8 @@ QETProject::~QETProject() {
|
|||||||
diagrams_.removeAll(diagram);
|
diagrams_.removeAll(diagram);
|
||||||
delete diagram;
|
delete diagram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
folioSheetsQuantity = 0;
|
||||||
// qDebug() << diagrams_;
|
// qDebug() << diagrams_;
|
||||||
delete undo_stack_;
|
delete undo_stack_;
|
||||||
}
|
}
|
||||||
@@ -167,6 +172,14 @@ QETProject::ProjectState QETProject::state() const {
|
|||||||
return(state_);
|
return(state_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QETProject::getFolioSheetsQuantity() const {
|
||||||
|
return(folioSheetsQuantity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QETProject::setFolioSheetsQuantity(int quantity) {
|
||||||
|
folioSheetsQuantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return la liste des schemas de ce projet
|
@return la liste des schemas de ce projet
|
||||||
*/
|
*/
|
||||||
@@ -440,6 +453,7 @@ QDomDocument QETProject::toXml() {
|
|||||||
QDomElement project_root = xml_doc.createElement("project");
|
QDomElement project_root = xml_doc.createElement("project");
|
||||||
project_root.setAttribute("version", QET::version);
|
project_root.setAttribute("version", QET::version);
|
||||||
project_root.setAttribute("title", project_title_);
|
project_root.setAttribute("title", project_title_);
|
||||||
|
project_root.setAttribute("folioSheetQuantity", QString::number(folioSheetsQuantity));
|
||||||
xml_doc.appendChild(project_root);
|
xml_doc.appendChild(project_root);
|
||||||
|
|
||||||
// titleblock templates, if any
|
// titleblock templates, if any
|
||||||
@@ -467,9 +481,12 @@ QDomDocument QETProject::toXml() {
|
|||||||
// qDebug() << "Export XML de" << diagrams_.count() << "schemas";
|
// qDebug() << "Export XML de" << diagrams_.count() << "schemas";
|
||||||
int order_num = 1;
|
int order_num = 1;
|
||||||
foreach(Diagram *diagram, diagrams_) {
|
foreach(Diagram *diagram, diagrams_) {
|
||||||
qDebug() << qPrintable(QString("QETProject::toXml() : exporting diagram \"%1\" [%2]").arg(diagram -> title()).arg(QET::pointerString(diagram)));
|
DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diagram);
|
||||||
QDomNode appended_diagram = project_root.appendChild(diagram -> writeXml(xml_doc));
|
if ( !ptr ) {
|
||||||
appended_diagram.toElement().setAttribute("order", order_num ++);
|
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
|
// collection
|
||||||
@@ -841,7 +858,7 @@ Diagram *QETProject::addNewDiagramFolioList() {
|
|||||||
if (isReadOnly()) return(0);
|
if (isReadOnly()) return(0);
|
||||||
|
|
||||||
//create new diagram
|
//create new diagram
|
||||||
Diagram *diagram_folio_list = new DiagramFolioList();
|
Diagram *diagram_folio_list = new DiagramFolioList(this);
|
||||||
|
|
||||||
// setup default properties
|
// setup default properties
|
||||||
diagram_folio_list -> border_and_titleblock.importBorder(defaultBorderProperties());
|
diagram_folio_list -> border_and_titleblock.importBorder(defaultBorderProperties());
|
||||||
@@ -853,7 +870,9 @@ Diagram *QETProject::addNewDiagramFolioList() {
|
|||||||
diagram_folio_list -> border_and_titleblock.displayRows(false);
|
diagram_folio_list -> border_and_titleblock.displayRows(false);
|
||||||
diagram_folio_list -> border_and_titleblock.displayColumns(false);
|
diagram_folio_list -> border_and_titleblock.displayColumns(false);
|
||||||
|
|
||||||
|
|
||||||
addDiagram(diagram_folio_list);
|
addDiagram(diagram_folio_list);
|
||||||
|
setFolioSheetsQuantity( getFolioSheetsQuantity()+1 );
|
||||||
|
|
||||||
emit(diagramAdded(this, diagram_folio_list));
|
emit(diagramAdded(this, diagram_folio_list));
|
||||||
return(diagram_folio_list);
|
return(diagram_folio_list);
|
||||||
@@ -946,6 +965,10 @@ void QETProject::readProjectXml() {
|
|||||||
|
|
||||||
// la racine du document XML est sensee etre un element "project"
|
// la racine du document XML est sensee etre un element "project"
|
||||||
if (root_elmt.tagName() == "project") {
|
if (root_elmt.tagName() == "project") {
|
||||||
|
|
||||||
|
if (root_elmt.hasAttribute("folioSheetQuantity"))
|
||||||
|
setFolioSheetsQuantity(root_elmt.attribute("folioSheetQuantity","0").toInt());
|
||||||
|
|
||||||
// mode d'ouverture normal
|
// mode d'ouverture normal
|
||||||
if (root_elmt.hasAttribute("version")) {
|
if (root_elmt.hasAttribute("version")) {
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
@@ -1042,6 +1065,13 @@ void QETProject::readDiagramsXml() {
|
|||||||
d->initElementsLinks();
|
d->initElementsLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getFolioSheetsQuantity()) {
|
||||||
|
setFolioSheetsQuantity(0);
|
||||||
|
int diagCount = diagrams().size();
|
||||||
|
for (int i = 0; i <= diagCount/58; i++)
|
||||||
|
addNewDiagramFolioList();
|
||||||
|
}
|
||||||
|
|
||||||
//delete dialog object
|
//delete dialog object
|
||||||
delete dlgWaiting;
|
delete dlgWaiting;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ class QETProject : public QObject {
|
|||||||
public:
|
public:
|
||||||
ProjectState state() const;
|
ProjectState state() const;
|
||||||
QList<Diagram *> diagrams() const;
|
QList<Diagram *> diagrams() const;
|
||||||
|
int getFolioSheetsQuantity() const;
|
||||||
|
void setFolioSheetsQuantity(int);
|
||||||
int folioIndex(const Diagram *) const;
|
int folioIndex(const Diagram *) const;
|
||||||
ElementsCollection *embeddedCollection() const;
|
ElementsCollection *embeddedCollection() const;
|
||||||
TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection();
|
TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection();
|
||||||
@@ -175,6 +177,8 @@ class QETProject : public QObject {
|
|||||||
QDomDocument document_root_;
|
QDomDocument document_root_;
|
||||||
/// Diagrams carried by the project
|
/// Diagrams carried by the project
|
||||||
QList<Diagram *> diagrams_;
|
QList<Diagram *> diagrams_;
|
||||||
|
/// Folio List Sheet is added to this project.
|
||||||
|
int folioSheetsQuantity;
|
||||||
/// Embedded elements collection
|
/// Embedded elements collection
|
||||||
XmlElementsCollection *collection_;
|
XmlElementsCollection *collection_;
|
||||||
/// Project title
|
/// Project title
|
||||||
|
|||||||
Reference in New Issue
Block a user