From 662e3b20d2dc8d2d21a8c8975e80850111d30a2e Mon Sep 17 00:00:00 2001 From: scorpio810 Date: Fri, 13 May 2016 15:00:22 +0000 Subject: [PATCH] Restore commit 4476 git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4478 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- qelectrotech.pro.user | 271 ----------- sources/bordertitleblock.cpp | 13 +- sources/bordertitleblock.h | 8 +- sources/configdialog.h | 8 +- sources/configpages.cpp | 48 +- sources/configpages.h | 13 +- sources/diagram.cpp | 2 + sources/diagramview.cpp | 106 +++-- sources/elementspanelwidget.cpp | 29 +- sources/elementspanelwidget.h | 3 + sources/projectconfigpages.cpp | 202 +++++++- sources/projectconfigpages.h | 39 +- sources/projectview.cpp | 215 ++++++--- sources/projectview.h | 32 +- sources/qetdiagrameditor.cpp | 28 ++ sources/qetdiagrameditor.h | 4 +- sources/qetproject.cpp | 137 +++++- sources/qetproject.h | 12 + sources/titleblockproperties.cpp | 5 + sources/titleblockproperties.h | 1 + sources/ui/diagrampropertiesdialog.cpp | 19 +- sources/ui/diagrampropertiesdialog.h | 1 + sources/ui/folioautonumbering.cpp | 218 +++++++++ sources/ui/folioautonumbering.h | 72 +++ sources/ui/folioautonumbering.ui | 295 ++++++++++++ sources/ui/projectpropertiesdialog.cpp | 20 +- sources/ui/projectpropertiesdialog.h | 5 +- sources/ui/selectautonumw.ui | 406 ++++++++++------ sources/ui/titleblockpropertieswidget.cpp | 82 +++- sources/ui/titleblockpropertieswidget.h | 18 +- sources/ui/titleblockpropertieswidget.ui | 536 ++++++++++++---------- 31 files changed, 1999 insertions(+), 849 deletions(-) delete mode 100644 qelectrotech.pro.user create mode 100644 sources/ui/folioautonumbering.cpp create mode 100644 sources/ui/folioautonumbering.h create mode 100644 sources/ui/folioautonumbering.ui diff --git a/qelectrotech.pro.user b/qelectrotech.pro.user deleted file mode 100644 index 3f91b7843..000000000 --- a/qelectrotech.pro.user +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - EnvironmentId - {6eea4121-5ff9-4cef-b169-5ef0ff03834b} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.5.1 GCC 64bit - Desktop Qt 5.5.1 GCC 64bit - qt.55.gcc_64_kit - 0 - 0 - 0 - - /home/davi/Documents/qelectro/build-qelectrotech-Desktop_Qt_5_5_1_GCC_64bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - /home/davi/Documents/qelectro/build-qelectrotech-Desktop_Qt_5_5_1_GCC_64bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 2 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - qelectrotech - - Qt4ProjectManager.Qt4RunConfiguration:/home/davi/Documents/qelectro/qet-0.5_original/qelectrotech.pro - - qelectrotech.pro - false - false - - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 18 - - - Version - 18 - - diff --git a/sources/bordertitleblock.cpp b/sources/bordertitleblock.cpp index e1f3c2dd4..95d062022 100644 --- a/sources/bordertitleblock.cpp +++ b/sources/bordertitleblock.cpp @@ -243,6 +243,7 @@ TitleBlockProperties BorderTitleBlock::exportTitleBlock() { ip.folio = folio(); ip.template_name = titleBlockTemplateName(); ip.display_at = m_edge; + ip.auto_page_num = autoPageNum(); ip.context = additional_fields_; ip.collection = QET::QetCollection::Embedded; @@ -259,6 +260,7 @@ void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) { setTitle(ip.title); setFileName(ip.filename); setFolio(ip.folio); + setAutoPageNum(ip.auto_page_num); if (m_edge != ip.display_at) { m_edge = ip.display_at; @@ -685,6 +687,7 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(const DiagramContext &i context.addValue("folio", btb_final_folio_); context.addValue("folio-id", folio_index_); context.addValue("folio-total", folio_total_); + context.addValue("auto_page_num", btb_auto_page_num_); titleblock_template_renderer_ -> setContext(context); } @@ -711,7 +714,7 @@ QString BorderTitleBlock::incrementLetters(const QString &string) { @param total nombre total de schemas dans le projet @param project_properties Project-wide properties, to be merged with diagram-wide ones. */ -void BorderTitleBlock::setFolioData(int index, int total, const DiagramContext &project_properties) { +void BorderTitleBlock::setFolioData(int index, int total, QString autonum, const DiagramContext &project_properties) { if (index < 1 || total < 1 || index > total) return; // memorise les informations @@ -720,8 +723,14 @@ void BorderTitleBlock::setFolioData(int index, int total, const DiagramContext & // regenere le contenu du champ folio btb_final_folio_ = btb_folio_; + + if (btb_final_folio_.contains("%autonum")){ + btb_final_folio_.replace("%autonum", autonum); + btb_folio_ = btb_final_folio_; + } btb_final_folio_.replace("%id", QString::number(folio_index_)); btb_final_folio_.replace("%total", QString::number(folio_total_)); - + + updateDiagramContextForTitleBlock(project_properties); } diff --git a/sources/bordertitleblock.h b/sources/bordertitleblock.h index bb5778643..289b067da 100644 --- a/sources/bordertitleblock.h +++ b/sources/bordertitleblock.h @@ -23,6 +23,7 @@ #include #include #include +#include "numerotationcontext.h" class QPainter; class DiagramPosition; class TitleBlockTemplate; @@ -106,6 +107,8 @@ class BorderTitleBlock : public QObject bool rowsAreDisplayed() const { return(display_rows_); } /// @return true si la bordure est affichee, false sinon bool borderIsDisplayed() const { return(display_border_); } + + QString autoPageNum() const { return(btb_auto_page_num_); } // methods to set dimensions void setColumnsCount(int); @@ -132,9 +135,11 @@ class BorderTitleBlock : public QObject } /// @param author the new value of the "Folio" field void setFolio(const QString &folio) { btb_folio_ = folio; } - void setFolioData(int, int, const DiagramContext & = DiagramContext()); + void setFolioData(int, int, QString = NULL, const DiagramContext & = DiagramContext()); /// @param author the new value of the "File" field void setFileName(const QString &filename) { btb_filename_ = filename; } + /// @param author the new value of the "Auto Page Num" field + void setAutoPageNum(const QString &auto_page_num) { btb_auto_page_num_ = auto_page_num;} void titleBlockToXml(QDomElement &); void titleBlockFromXml(const QDomElement &); @@ -203,6 +208,7 @@ class BorderTitleBlock : public QObject QString btb_title_; QString btb_folio_; QString btb_final_folio_; + QString btb_auto_page_num_; int folio_index_; int folio_total_; QString btb_filename_; diff --git a/sources/configdialog.h b/sources/configdialog.h index 499916928..13d852ac2 100644 --- a/sources/configdialog.h +++ b/sources/configdialog.h @@ -36,6 +36,10 @@ class ConfigDialog : public QDialog { virtual ~ConfigDialog(); private: ConfigDialog(const ConfigDialog &); + + public: + QList pages; + // methods public slots: @@ -52,6 +56,8 @@ class ConfigDialog : public QDialog { QListWidget *pages_list; QStackedWidget *pages_widget; QDialogButtonBox *buttons; - QList pages; + + + }; #endif diff --git a/sources/configpages.cpp b/sources/configpages.cpp index 81ba0edd2..eda677cd8 100644 --- a/sources/configpages.cpp +++ b/sources/configpages.cpp @@ -35,8 +35,9 @@ * else edit the properties by default of QElectroTech * @param parent, parent widget */ -NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent) : +NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent, ProjectPropertiesDialog *ppd) : ConfigPage (parent), + ppd_ (ppd), m_project (project) { //By default we set the global default properties @@ -47,7 +48,7 @@ NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent) : QList c; c << QETApp::commonTitleBlockTemplatesCollection() << QETApp::customTitleBlockTemplatesCollection(); if (m_project) c << m_project->embeddedTitleBlockTemplatesCollection(); - ipw = new TitleBlockPropertiesWidget(c, TitleBlockProperties::defaultProperties(), true); + ipw = new TitleBlockPropertiesWidget(c, TitleBlockProperties::defaultProperties(), true, project, parent); // default conductor properties cpw = new ConductorPropertiesWidget(ConductorProperties::defaultProperties()); // default propertie of report label @@ -64,6 +65,8 @@ NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent) : xrefpw -> setProperties (m_project -> defaultXRefProperties()); } + connect(ipw,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(changeToAutoFolioTab())); + // main tab widget QTabWidget *tab_widget = new QTabWidget(this); QWidget *diagram_widget = new QWidget(); @@ -87,6 +90,7 @@ NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent) : * @brief NewDiagramPage::~NewDiagramPage */ NewDiagramPage::~NewDiagramPage() { + disconnect(ipw,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(changeToAutoFolioTab())); } /** @@ -173,10 +177,48 @@ QIcon NewDiagramPage::icon() const { * @return title of this page */ QString NewDiagramPage::title() const { - if (m_project) return(tr("Nouveau folio", "configuration page title")); + if (m_project) return(tr("Nouveau folio", "configuration page title")); return(tr("Nouveau projet", "configuration page title")); } +/** + * @brief NewDiagramPage::changeToAutoFolioTab + * Set the current tab to Autonum + */ +void NewDiagramPage::changeToAutoFolioTab(){ + if (m_project){ + ppd_->setCurrentPage(ProjectPropertiesDialog::Autonum); + ppd_->changeToFolio(); + ppd_->exec(); + } +} + +/** + * @brief NewDiagramPage::setFolioAutonum + * Set temporary TBP to use in auto folio num + */ +void NewDiagramPage::setFolioAutonum(QString autoNum){ + TitleBlockProperties tbptemp = ipw->propertiesAutoNum(autoNum); + ipw->setProperties(tbptemp); + applyConf(); +} + +/** + * @brief NewDiagramPage::saveCurrentTbp + * Save current TBP to retrieve after auto folio num + */ +void NewDiagramPage::saveCurrentTbp(){ + savedTbp = ipw->properties(); +} + +/** + * @brief NewDiagramPage::loadSavedTbp + * Retrieve saved auto folio num + */ +void NewDiagramPage::loadSavedTbp(){ + ipw->setProperties(savedTbp); + applyConf(); +} /** Constructeur diff --git a/sources/configpages.h b/sources/configpages.h index bad988820..2e049b738 100644 --- a/sources/configpages.h +++ b/sources/configpages.h @@ -19,6 +19,8 @@ #define CONFIG_PAGES_H #include #include "configpage.h" +#include "projectpropertiesdialog.h" //davi +#include "titleblockpropertieswidget.h" //davi class BorderPropertiesWidget; class ConductorPropertiesWidget; class TitleBlockPropertiesWidget; @@ -26,6 +28,7 @@ class ExportPropertiesWidget; class ReportPropertieWidget; class XRefPropertiesWidget; class QETProject; +class TitleBlockProperties; /** This configuration page enables users to define the properties of new @@ -35,10 +38,16 @@ class NewDiagramPage : public ConfigPage { Q_OBJECT // constructors, destructor public: - NewDiagramPage(QETProject *project = 0, QWidget * = 0); + NewDiagramPage(QETProject *project = 0, QWidget * = 0, ProjectPropertiesDialog *teste = NULL); virtual ~NewDiagramPage(); private: NewDiagramPage(const NewDiagramPage &); +public slots: + void changeToAutoFolioTab(); + void setFolioAutonum(QString); + void saveCurrentTbp(); + void loadSavedTbp(); + // methods public: @@ -48,12 +57,14 @@ class NewDiagramPage : public ConfigPage { // attributes private: + ProjectPropertiesDialog *ppd_; QETProject *m_project; ///< Project to edit propertie BorderPropertiesWidget *bpw; ///< Widget to edit default diagram dimensions TitleBlockPropertiesWidget *ipw; ///< Widget to edit default title block properties ConductorPropertiesWidget *cpw; ///< Widget to edit default conductor properties ReportPropertieWidget *rpw; ///< Widget to edit default report label XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties + TitleBlockProperties savedTbp; ///< Used to save current TBP and retrieve later }; diff --git a/sources/diagram.cpp b/sources/diagram.cpp index c18ae5fa1..0589e6770 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -235,6 +235,7 @@ void Diagram::keyPressEvent(QKeyEvent *e) bool transmit_event = true; if (!isReadOnly()) { QPointF movement; + if (!this->selectedContent().elements.isEmpty()) { switch(e -> key()) { case Qt::Key_Left: movement = QPointF(-xGrid, 0.0); break; case Qt::Key_Right: movement = QPointF(+xGrid, 0.0); break; @@ -250,6 +251,7 @@ void Diagram::keyPressEvent(QKeyEvent *e) } if (transmit_event) { QGraphicsScene::keyPressEvent(e); + } } } diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 52b9243a5..a8ca41f20 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -1,17 +1,17 @@ /* Copyright 2006-2015 The QElectroTech Team This file is part of QElectroTech. - + QElectroTech is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - + QElectroTech is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with QElectroTech. If not, see . */ @@ -30,6 +30,7 @@ #include "templatelocation.h" #include "qetapp.h" #include "qetproject.h" +#include "projectview.h" #include "integrationmoveelementshandler.h" #include "integrationmovetemplateshandler.h" #include "qetdiagrameditor.h" @@ -67,12 +68,12 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : "\"What's this?\" tip" ); setWhatsThis(whatsthis); - + // active l'antialiasing setRenderHint(QPainter::Antialiasing, true); setRenderHint(QPainter::TextAntialiasing, true); setRenderHint(QPainter::SmoothPixmapTransform, true); - + setScene(scene); scene -> undoStack().setClean(); setWindowIcon(QET::Icons::QETLogo); @@ -82,18 +83,18 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : setSelectionMode(); adjustSceneRect(); updateWindowTitle(); - + context_menu = new QMenu(this); paste_here = new QAction(QET::Icons::EditPaste, tr("Coller ici", "context menu action"), this); connect(paste_here, SIGNAL(triggered()), this, SLOT(pasteHere())); - + connect(scene, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*))); connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); connect(scene, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(adjustSceneRect())); connect(&(scene -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle())); connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation))); connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation))); - + connect( this, SIGNAL(aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &)), this, SLOT(setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &)), @@ -146,7 +147,7 @@ void DiagramView::deleteSelection() { */ void DiagramView::rotateSelection() { if (scene -> isReadOnly()) return; - + // recupere les elements et les champs de texte a pivoter QList elements_to_rotate; QList texts_to_rotate; @@ -167,7 +168,7 @@ void DiagramView::rotateSelection() { images_to_rotate << dii; } } - + // effectue les rotations s'il y a quelque chose a pivoter if (elements_to_rotate.isEmpty() && texts_to_rotate.isEmpty() && images_to_rotate.isEmpty()) return; scene -> undoStack().push(new RotateElementsCommand(elements_to_rotate, texts_to_rotate, images_to_rotate)); @@ -175,7 +176,7 @@ void DiagramView::rotateSelection() { void DiagramView::rotateTexts() { if (scene -> isReadOnly()) return; - + // recupere les champs de texte a orienter QList texts_to_rotate; foreach (QGraphicsItem *item, scene -> selectedItems()) { @@ -188,10 +189,10 @@ void DiagramView::rotateTexts() { texts_to_rotate << eti; } } - + // effectue les rotations s'il y a quelque chose a pivoter if (texts_to_rotate.isEmpty()) return; - + // demande un angle a l'utilisateur QDialog ori_text_dialog(diagramEditor()); ori_text_dialog.setSizeGripEnabled(false); @@ -200,27 +201,27 @@ void DiagramView::rotateTexts() { #endif ori_text_dialog.setWindowTitle(tr("Orienter les textes sélectionnés", "window title")); // ori_text_dialog.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - - + + QTextOrientationSpinBoxWidget *ori_widget = QETApp::createTextOrientationSpinBoxWidget(); ori_widget -> setParent(&ori_text_dialog); if (texts_to_rotate.count() == 1) { ori_widget -> setOrientation(texts_to_rotate.at(0) -> rotationAngle()); } ori_widget -> spinBox() -> selectAll(); - + // boutons QDialogButtonBox buttons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(&buttons, SIGNAL(accepted()), &ori_text_dialog, SLOT(accept())); connect(&buttons, SIGNAL(rejected()), &ori_text_dialog, SLOT(reject())); - + // ajout dans une disposition verticale QVBoxLayout layout_v(&ori_text_dialog); layout_v.setSizeConstraint(QLayout::SetFixedSize); layout_v.addWidget(ori_widget); layout_v.addStretch(); layout_v.addWidget(&buttons); - + // si le dialogue est accepte if (ori_text_dialog.exec() == QDialog::Accepted) { scene -> undoStack().push(new RotateTextsCommand(texts_to_rotate, ori_widget -> orientation())); @@ -261,7 +262,7 @@ void DiagramView::dragMoveEvent(QDragMoveEvent *e) { } /** - Handle the drops accepted on diagram (elements and title block templates). + Handle the drops accepted on diagram (elements and title block templates). @param e the QDropEvent describing the current drag'n drop */ void DiagramView::dropEvent(QDropEvent *e) { @@ -421,17 +422,17 @@ void DiagramView::copy() { */ void DiagramView::paste(const QPointF &pos, QClipboard::Mode clipboard_mode) { if (!isInteractive() || scene -> isReadOnly()) return; - + QString texte_presse_papier = QApplication::clipboard() -> text(clipboard_mode); if ((texte_presse_papier).isEmpty()) return; - + QDomDocument document_xml; if (!document_xml.setContent(texte_presse_papier)) return; - + // objet pour recuperer le contenu ajoute au schema par le coller DiagramContent content_pasted; scene -> fromXml(document_xml, pos, false, &content_pasted); - + // si quelque chose a effectivement ete ajoute au schema, on cree un objet d'annulation if (content_pasted.count()) { scene -> clearSelection(); @@ -589,7 +590,22 @@ void DiagramView::focusInEvent(QFocusEvent *e) { */ void DiagramView::keyPressEvent(QKeyEvent *e) { if (m_event_interface && m_event_interface->keyPressEvent(e)) return; - + ProjectView *current_project = this->diagramEditor()->acessCurrentProject(); +switch(e -> key()) + { + case Qt::Key_PageUp: + current_project->changeTabUp(); + return; + case Qt::Key_PageDown: + current_project->changeTabDown(); + return; + case Qt::Key_Home: + current_project->changeFirstTab(); + return; + case Qt::Key_End: + current_project->changeLastTab(); + return; + } switchToVisualisationModeIfNeeded(e); QGraphicsView::keyPressEvent(e); } @@ -751,14 +767,14 @@ void DiagramView::adjustGridToZoom() { QRectF DiagramView::viewedSceneRect() const { // recupere la taille du widget viewport QSize viewport_size = viewport() -> size(); - + // recupere la transformation viewport -> scene QTransform view_to_scene = viewportTransform().inverted(); - + // mappe le coin superieur gauche et le coin inferieur droit de la viewport sur la scene QPointF scene_left_top = view_to_scene.map(QPointF(0.0, 0.0)); QPointF scene_right_bottom = view_to_scene.map(QPointF(viewport_size.width(), viewport_size.height())); - + // en deduit le rectangle visualise par la scene return(QRectF(scene_left_top, scene_right_bottom)); } @@ -773,7 +789,7 @@ bool DiagramView::mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocati // unlike elements, the integration of title block templates is mandatory, so we simply check whether the parent project of the template is also the parent project of the diagram QETProject *tbt_parent_project = tbt_loc.parentProject(); if (!tbt_parent_project) return(true); - + return(tbt_parent_project != scene -> project()); } @@ -783,7 +799,7 @@ bool DiagramView::mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocati */ void DiagramView::applyReadOnly() { if (!scene) return; - + bool is_writable = !scene -> isReadOnly(); setInteractive(is_writable); setAcceptDrops(is_writable); @@ -795,11 +811,11 @@ void DiagramView::applyReadOnly() { void DiagramView::editSelectionProperties() { // get selection DiagramContent selection = scene -> selectedContent(); - + // if selection contains nothing return int selected_items_count = selection.count(DiagramContent::All | DiagramContent::SelectedOnly); if (!selected_items_count) return; - + // if selection contains one item and this item can be editable, edit this item with an appropriate dialog if (selected_items_count == 1 && selection.items(DiagramContent::Elements | DiagramContent::AnyConductor | @@ -811,7 +827,7 @@ void DiagramView::editSelectionProperties() { else if (selection.elements.size()) selection.elements.toList().first() -> editProperty(); } - + else { QET::QetMessageBox::information( this, @@ -832,7 +848,7 @@ void DiagramView::editSelectionProperties() { void DiagramView::editSelectedConductorColor() { // retrieve selected content DiagramContent selection = scene -> selectedContent(); - + // we'll focus on the selected conductor (we do not handle multiple conductors edition) QList selected_conductors = selection.conductors(DiagramContent::AnyConductor | DiagramContent::SelectedOnly); if (selected_conductors.count() == 1) { @@ -847,10 +863,10 @@ void DiagramView::editSelectedConductorColor() { void DiagramView::editConductorColor(Conductor *edited_conductor) { if (scene -> isReadOnly() || !edited_conductor) return; - + // store the initial properties of the provided conductor ConductorProperties initial_properties = edited_conductor -> properties(); - + // prepare a color dialog showing the initial conductor color QColorDialog *color_dialog = new QColorDialog(this); color_dialog -> setWindowTitle(tr("Choisir la nouvelle couleur de ce conducteur")); @@ -858,7 +874,7 @@ void DiagramView::editConductorColor(Conductor *edited_conductor) color_dialog -> setWindowFlags(Qt::Sheet); #endif color_dialog -> setCurrentColor(initial_properties.color); - + // asks the user what color he wishes to apply if (color_dialog -> exec() == QDialog::Accepted) { @@ -885,7 +901,7 @@ void DiagramView::resetConductors() { if (scene -> isReadOnly()) return; // recupere les conducteurs selectionnes QSet selected_conductors = scene -> selectedConductors(); - + // repere les conducteurs modifies (= profil non nul) QHash conductors_and_profiles; foreach(Conductor *conductor, selected_conductors) { @@ -899,7 +915,7 @@ void DiagramView::resetConductors() { conductors_and_profiles.insert(conductor, profile); } } - + if (conductors_and_profiles.isEmpty()) return; scene -> undoStack().push(new ResetConductorCommand(conductors_and_profiles)); } @@ -1043,7 +1059,7 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) { if (!qgi -> isSelected()) scene -> clearSelection(); qgi -> setSelected(true); } - + if (QETDiagramEditor *qde = diagramEditor()) { context_menu -> clear(); if (scene -> selectedItems().isEmpty()) { @@ -1061,7 +1077,7 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) { context_menu -> addSeparator(); context_menu -> addActions(qde -> m_selection_actions_group.actions()); } - + // affiche le menu contextuel context_menu -> popup(e -> globalPos()); } @@ -1090,10 +1106,10 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) if (m_event_interface && m_event_interface -> mouseDoubleClickEvent(e)) return; BorderTitleBlock &bi = scene -> border_and_titleblock; - + //Get the click pos on the diagram QPointF click_pos = viewportTransform().inverted().map(e -> pos()); - + if (bi.titleBlockRect().contains(click_pos) || bi.columnsRect().contains(click_pos) || bi.rowsRect().contains(click_pos)) { e->accept(); editDiagramProperties(); @@ -1108,14 +1124,14 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) void DiagramView::setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &tbt) { // fetch the current title block properties TitleBlockProperties titleblock_properties_before = scene -> border_and_titleblock.exportTitleBlock(); - + // check the provided template is not already applied QETProject *tbt_parent_project = tbt.parentProject(); if (tbt_parent_project && tbt_parent_project == scene -> project()) { // same parent project and same name = same title block template if (tbt.name() == titleblock_properties_before.template_name) return; } - + // integrate the provided template into the project if needed QString integrated_template_name = tbt.name(); if (mustIntegrateTitleBlockTemplate(tbt)) { @@ -1124,7 +1140,7 @@ void DiagramView::setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation integrated_template_name = scene -> project() -> integrateTitleBlockTemplate(tbt, handler); if (integrated_template_name.isEmpty()) return; } - + // apply the provided title block template if (titleblock_properties_before.template_name == integrated_template_name) return; TitleBlockProperties titleblock_properties_after = titleblock_properties_before; diff --git a/sources/elementspanelwidget.cpp b/sources/elementspanelwidget.cpp index 8a222e9ab..4c6f592be 100644 --- a/sources/elementspanelwidget.cpp +++ b/sources/elementspanelwidget.cpp @@ -67,14 +67,14 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) { prj_activate = new QAction(QET::Icons::ProjectFile, tr("Basculer vers ce projet"), this); prj_close = new QAction(QET::Icons::DocumentClose, tr("Fermer ce projet"), this); prj_edit_prop = new QAction(QET::Icons::DialogInformation, tr("Propriétés du projet"), this); - prj_prop_diagram = new QAction(QET::Icons::DialogInformation, tr("Propriétés du folio"), this); - prj_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this); - prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer ce folio"), this); - prj_move_diagram_up = new QAction(QET::Icons::GoUp, tr("Remonter ce folio"), this); - prj_move_diagram_down = new QAction(QET::Icons::GoDown, tr("Abaisser ce folio"), this); - prj_move_diagram_upx10 = new QAction(QET::Icons::GoUp, tr("Remonter ce folio x10"), this); - prj_move_diagram_top = new QAction(QET::Icons::GoUp, tr("Remonter ce folio au debut"), this); - prj_move_diagram_downx10 = new QAction(QET::Icons::GoDown, tr("Abaisser ce folio x10"), this); + prj_prop_diagram = new QAction(QET::Icons::DialogInformation, tr("Propriétés du folio"), this); + prj_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this); + prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer ce folio"), this); + prj_move_diagram_up = new QAction(QET::Icons::GoUp, tr("Remonter ce folio"), this); + prj_move_diagram_down = new QAction(QET::Icons::GoDown, tr("Abaisser ce folio"), this); + prj_move_diagram_upx10 = new QAction(QET::Icons::GoUp, tr("Remonter ce folio x10"), this); + prj_move_diagram_top = new QAction(QET::Icons::GoUp, tr("Remonter ce folio au debut"), this); + prj_move_diagram_downx10 = new QAction(QET::Icons::GoDown, tr("Abaisser ce folio x10"), this); tbt_add = new QAction(QET::Icons::TitleBlock, tr("Nouveau modèle"), this); tbt_edit = new QAction(QET::Icons::TitleBlock, tr("Éditer ce modèle"), this); tbt_remove = new QAction(QET::Icons::TitleBlock, tr("Supprimer ce modèle"), this); @@ -777,6 +777,19 @@ void ElementsPanelWidget::deleteElement() { } } +/** + Treat key press event inside elements panel widget +*/ +void ElementsPanelWidget::keyPressEvent (QKeyEvent *e) { + switch(e -> key()) { + case Qt::Key_Delete: //delete diagram through elements panel widget + if (Diagram *selected_diagram = elements_panel -> selectedDiagram()) { + emit(requestForDiagramDeletion(selected_diagram)); + } + } + return; +} + /** Lance l'editeur d'element pour l'element filename @param location Emplacement de l'element a editer diff --git a/sources/elementspanelwidget.h b/sources/elementspanelwidget.h index b408be2ad..818e607e6 100644 --- a/sources/elementspanelwidget.h +++ b/sources/elementspanelwidget.h @@ -110,6 +110,9 @@ class ElementsPanelWidget : public QWidget { void updateProgressBar(int, int); void loadingFinished(); void filterEdited(const QString &); + + protected: + virtual void keyPressEvent (QKeyEvent *e); private: void launchElementEditor(const ElementsLocation &); diff --git a/sources/projectconfigpages.cpp b/sources/projectconfigpages.cpp index 933603f99..1aeac80e6 100644 --- a/sources/projectconfigpages.cpp +++ b/sources/projectconfigpages.cpp @@ -27,7 +27,7 @@ #include "ui/xrefpropertieswidget.h" #include "selectautonumw.h" #include "numerotationcontext.h" - +#include "folioautonumbering.h" /** Constructor @param project Project this page is editing. @@ -141,7 +141,6 @@ void ProjectMainConfigPage::applyProjectConf() { project_ -> setProjectProperties(new_properties); modified_project = true; } - if (modified_project) { project_ -> setModified(true); } @@ -186,6 +185,8 @@ void ProjectMainConfigPage::initLayout() { main_layout0 -> addWidget(project_variables_label_); main_layout0 -> addWidget(project_variables_); setLayout(main_layout0); + this -> setMinimumWidth(630); + } /** @@ -250,17 +251,44 @@ void ProjectAutoNumConfigPage::applyProjectConf() {} * Init some widget of this page */ void ProjectAutoNumConfigPage::initWidgets() { - m_label = new QLabel(tr("Numérotations disponibles :", "availables numerotations"), this); - m_context_cb = new QComboBox(this); + tab_widget = new QTabWidget(this); + tab_widget->setMinimumWidth(440); + + //Conductor Tab + conductor_tab_widget = new QWidget(this); + + m_label = new QLabel(tr("Numérotations disponibles :", "availables numerotations"), conductor_tab_widget); + + m_context_cb = new QComboBox(conductor_tab_widget); m_context_cb->setEditable(true); m_context_cb->lineEdit()->setClearButtonEnabled(true); m_context_cb->addItem(tr("Nom de la nouvelle numérotation")); - m_remove_pb = new QPushButton(QET::Icons::EditDelete, QString(), this); + m_remove_pb = new QPushButton(QET::Icons::EditDelete, QString(), conductor_tab_widget); m_remove_pb -> setToolTip(tr("Supprimer la numérotation")); - m_saw = new SelectAutonumW(this); + m_saw = new SelectAutonumW(conductor_tab_widget); + + //Folio Tab + folio_tab_widget = new QWidget(this); + + m_label_2 = new QLabel(tr("Numérotations disponibles :", "availables numerotations"), folio_tab_widget); + + m_context_cb_2 = new QComboBox(folio_tab_widget); + m_context_cb_2->setEditable(true); + m_context_cb_2->lineEdit()->setClearButtonEnabled(true); + m_context_cb_2->addItem(tr("Nom de la nouvelle numérotation")); + + m_remove_pb_2 = new QPushButton(QET::Icons::EditDelete, QString(), folio_tab_widget); + m_remove_pb_2 -> setToolTip(tr("Supprimer la numérotation")); + + m_saw_2 = new SelectAutonumW(folio_tab_widget); + +/* //AutoNumbering Tab - Needs Further Testing + autoNumbering_tab_widget = new QWidget(this); + m_faw = new FolioAutonumberingW(project(),autoNumbering_tab_widget); +*/ } /** @@ -268,15 +296,40 @@ void ProjectAutoNumConfigPage::initWidgets() { * Init the layout of this page */ void ProjectAutoNumConfigPage::initLayout() { - QHBoxLayout *context_layout = new QHBoxLayout(); + //Conductor tab + tab_widget->addTab(conductor_tab_widget, tr("Conductor")); + + QHBoxLayout *context_layout = new QHBoxLayout(); context_layout -> addWidget (m_label); context_layout -> addWidget (m_context_cb); context_layout -> addWidget (m_remove_pb); - QVBoxLayout *main_layout = new QVBoxLayout(this); - this -> setLayout (main_layout); - main_layout -> addLayout (context_layout); - main_layout -> addWidget (m_saw); + QVBoxLayout *main_layout = new QVBoxLayout(); + QVBoxLayout *aux_layout = new QVBoxLayout(); + aux_layout->addLayout(context_layout); + aux_layout->addWidget(m_saw); + + main_layout->addLayout(aux_layout); + conductor_tab_widget -> setLayout (main_layout); + + // Folio Tab + tab_widget->addTab(folio_tab_widget, tr("Folio")); + + QHBoxLayout *context_layout_2 = new QHBoxLayout(); + context_layout_2 -> addWidget (m_label_2); + context_layout_2 -> addWidget (m_context_cb_2); + context_layout_2 -> addWidget (m_remove_pb_2); + + QVBoxLayout *main_layout_2 = new QVBoxLayout(); + QVBoxLayout *aux_layout_2 = new QVBoxLayout(); + aux_layout_2->addLayout(context_layout_2); + aux_layout_2->addWidget(m_saw_2); + + main_layout_2->addLayout(aux_layout_2); + folio_tab_widget -> setLayout (main_layout_2); + + //Auto Numbering Tab - Needs Further Testing +// tab_widget->addTab(autoNumbering_tab_widget,tr ("Folio Auto Numbering")); } /** @@ -284,9 +337,20 @@ void ProjectAutoNumConfigPage::initLayout() { * Read value stored on project, and update display */ void ProjectAutoNumConfigPage::readValuesFromProject() { + //Conductor Tab QList keys = project_->conductorAutoNum().keys(); - if (keys.isEmpty()) return; + if (!keys.isEmpty()){ foreach (QString str, keys) { m_context_cb -> addItem(str); } + } + + //Folio Tab + QList keys_2 = project_->folioAutoNum().keys(); + if (!keys_2.isEmpty()){ + foreach (QString str, keys_2) { m_context_cb_2 -> addItem(str);} + } + + //Folio AutoNumbering Tab - Needs Further Testing +// m_faw->setContext(keys_2); } /** @@ -301,14 +365,28 @@ void ProjectAutoNumConfigPage::adjustReadOnly() { * setup some connections */ void ProjectAutoNumConfigPage::buildConnections() { + + connect(tab_widget,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int))); + + //Conductor Tab connect (m_context_cb, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext(QString))); connect (m_saw, SIGNAL (applyPressed()), this, SLOT (saveContext())); - connect (m_remove_pb, SIGNAL(clicked()), this, SLOT(removeContext())); + connect (m_remove_pb, SIGNAL (clicked()), this, SLOT(removeContext())); + + //Folio Tab + connect (m_context_cb_2, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_2(QString))); + connect (m_saw_2, SIGNAL (applyPressed()), this, SLOT (saveContext_2())); + connect (m_remove_pb_2, SIGNAL (clicked()), this, SLOT (removeContext_2())); + +/* //Auto Folio Numbering - Needs Further Testing + connect (m_faw, SIGNAL (applyPressed()), this, SLOT (applyAutoNum())); + connect (m_faw, SIGNAL (m_autonumber_tabs_rb_clicked()), this, SLOT (tabChanged(int))); +*/ } /** * @brief ProjectAutoNumConfigPage::updateContext - * Display the current selected context + * Display the current selected context for conductor * @param str, key of context stored in project */ void ProjectAutoNumConfigPage::updateContext(QString str) { @@ -316,9 +394,19 @@ void ProjectAutoNumConfigPage::updateContext(QString str) { else m_saw ->setContext(project_->conductorAutoNum(str)); } +/** + * @brief ProjectAutoNumConfigPage::updateContext_2 + * Display the current selected context for folio + * @param str, key of context stored in project + */ +void ProjectAutoNumConfigPage::updateContext_2(QString str) { + if (str == tr("Nom de la nouvelle numérotation")) m_saw_2 -> setContext(NumerotationContext()); + else m_saw_2 ->setContext(project_->folioAutoNum(str)); +} + /** * @brief ProjectAutoNumConfigPage::saveContext - * Save the current displayed context in project + * Save the current displayed conductor context in project */ void ProjectAutoNumConfigPage::saveContext() { // If the text is the default text "Name of new numerotation" save the edited context @@ -338,9 +426,57 @@ void ProjectAutoNumConfigPage::saveContext() { } } +/** + * @brief ProjectAutoNumConfigPage::saveContext_2 + * Save the current displayed folio context in project + */ +void ProjectAutoNumConfigPage::saveContext_2() { + // If the text is the default text "Name of new numerotation" save the edited context + // With the the name "No name" + if (m_context_cb_2 -> currentText() == tr("Nom de la nouvelle numérotation")) { + project_->addFolioAutoNum (tr("Sans nom"), m_saw_2 -> toNumContext()); + m_context_cb_2 -> addItem(tr("Sans nom")); + } + // If the text isn't yet to the autonum of the project, add this new item to the combo box. + else if ( !project_ -> folioAutoNum().keys().contains( m_context_cb_2->currentText())) { + project()->addFolioAutoNum(m_context_cb_2->currentText(), m_saw_2->toNumContext()); + m_context_cb_2 -> addItem(m_context_cb_2->currentText()); + } + // Else, the text already exist in the autonum of the project, just update the context + else { + project_->addFolioAutoNum (m_context_cb_2 -> currentText(), m_saw_2 -> toNumContext()); + } +} + +/** + * @brief ProjectAutoNumConfigPage::applyAutoNum + * Apply auto folio numbering, New Folios or Selected Folios + */ +/* +void ProjectAutoNumConfigPage::applyAutoNum() { + + if (m_faw->newFolios){ + int foliosRemaining = m_faw->newFoliosNumber(); + emit (saveCurrentTbp()); + emit (setAutoNum(m_faw->autoNumSelected())); + while (foliosRemaining > 0){ + project()->autoFolioNumberingNewFolios(); + foliosRemaining = foliosRemaining-1; + } + emit (loadSavedTbp()); + } + else{ + QString autoNum = m_faw->autoNumSelected(); + int fromFolio = m_faw->fromFolio(); + int toFolio = m_faw->toFolio(); + project_->autoFolioNumberingSelectedFolios(fromFolio,toFolio,autoNum); + } +} +*/ + /** * @brief ProjectAutoNumConfigPage::removeContext - * Remove from project the current numerotation context + * Remove from project the current conductor numerotation context */ void ProjectAutoNumConfigPage::removeContext() { //if default text, return @@ -348,3 +484,37 @@ void ProjectAutoNumConfigPage::removeContext() { project_ -> removeConductorAutonum (m_context_cb -> currentText() ); m_context_cb -> removeItem (m_context_cb -> currentIndex() ); } +/** + * @brief ProjectAutoNumConfigPage::removeContext_2 + * Remove from project the current folio numerotation context + */ +void ProjectAutoNumConfigPage::removeContext_2() { + //if default text, return + if ( m_context_cb_2 -> currentText() == tr("Nom de la nouvelle numérotation") ) return; + project_ -> removeFolioAutoNum (m_context_cb_2 -> currentText() ); + m_context_cb_2 -> removeItem (m_context_cb_2 -> currentIndex() ); +} +/** + * @brief ProjectAutoNumConfigPage::changeToTab + * @param tab index + * Change to Selected Tab + */ +void ProjectAutoNumConfigPage::changeToTab(int i){ + tab_widget->setCurrentIndex(i); +} + +/** + * @brief ProjectAutoNumConfigPage::tabChanged + * @param tab index + * Used to resize window to correct size + */ +void ProjectAutoNumConfigPage::tabChanged(int i){ + if (i>0){ + if (tab_widget->currentIndex()==2){ + tab_widget->resize(470,tab_widget->height()); + } + else { + tab_widget->adjustSize(); + } + } +} diff --git a/sources/projectconfigpages.h b/sources/projectconfigpages.h index 66a47fe78..451ff423d 100644 --- a/sources/projectconfigpages.h +++ b/sources/projectconfigpages.h @@ -20,6 +20,8 @@ #ifndef PROJECTCONFIGPAGES_H #define PROJECTCONFIGPAGES_H #include "configpage.h" +#include + class QLabel; class QLineEdit; class QETProject; @@ -32,6 +34,7 @@ class XRefPropertiesWidget; class SelectAutonumW; class QComboBox; class QPushButton; +class FolioAutonumberingW; /** This class, derived from ConfigPage, aims at providing the basic skeleton @@ -128,27 +131,49 @@ class ProjectAutoNumConfigPage : public ProjectConfigPage { virtual QString title() const; virtual QIcon icon() const; virtual void applyProjectConf(); - + virtual void changeToTab(int); protected: virtual void initWidgets(); virtual void initLayout(); virtual void readValuesFromProject(); virtual void adjustReadOnly(); - private: void buildConnections(); - private slots: void updateContext(QString); void saveContext(); void removeContext(); + void updateContext_2(QString); + void saveContext_2(); + void removeContext_2(); + +// void applyAutoNum(); - Needs Further Testing + + void tabChanged(int); + + signals: + void setAutoNum(QString); + void setAutoNum(int,int); + void saveCurrentTbp(); + void loadSavedTbp(); //Attributes private: - QLabel *m_label; - QComboBox *m_context_cb; - QPushButton *m_remove_pb; - SelectAutonumW *m_saw; + QTabWidget *tab_widget; + QWidget *element_widget; + QWidget *conductor_tab_widget; + QWidget *folio_tab_widget; + QWidget *autoNumbering_tab_widget; + QScrollArea *scrollArea; + QLabel *m_label; + QLabel *m_label_2; + QComboBox *m_context_cb; + QComboBox *m_context_cb_2; + QPushButton *m_remove_pb; + QPushButton *m_remove_pb_2; + SelectAutonumW *m_saw; + SelectAutonumW *m_saw_2; + FolioAutonumberingW *m_faw; }; diff --git a/sources/projectview.cpp b/sources/projectview.cpp index 65c3ec781..a2d7ac413 100644 --- a/sources/projectview.cpp +++ b/sources/projectview.cpp @@ -1,17 +1,17 @@ /* Copyright 2006-2015 The QElectroTech Team This file is part of QElectroTech. - + QElectroTech is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - + QElectroTech is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with QElectroTech. If not, see . */ @@ -32,7 +32,6 @@ #include "qettemplateeditor.h" #include "diagramfoliolist.h" #include "projectpropertiesdialog.h" - #include /** @@ -47,7 +46,7 @@ ProjectView::ProjectView(QETProject *project, QWidget *parent) : initActions(); initWidgets(); initLayout(); - + setProject(project); } @@ -79,8 +78,9 @@ void ProjectView::setProject(QETProject *project) { if (!project_) { project_ = project; connect(project_, SIGNAL(projectTitleChanged(QETProject *, const QString &)), this, SLOT(updateWindowTitle())); - connect(project_, SIGNAL(projectModified (QETProject *, bool)), this, SLOT(updateWindowTitle())); - connect(project_, SIGNAL(readOnlyChanged (QETProject *, bool)), this, SLOT(adjustReadOnlyState())); + connect(project_, SIGNAL(projectModified (QETProject *, bool)), this, SLOT(updateWindowTitle())); + connect(project_, SIGNAL(readOnlyChanged (QETProject *, bool)), this, SLOT(adjustReadOnlyState())); + connect(project_, SIGNAL(addAutoNumDiagram()), this, SLOT(addNewDiagram())); adjustReadOnlyState(); loadDiagrams(); } @@ -112,7 +112,7 @@ QList ProjectView::getDiagrams(ProjectSaveOptions options) { selection.removeOne(current); } } - + return(selection); } @@ -138,6 +138,83 @@ void ProjectView::closeEvent(QCloseEvent *qce) { } } +/** + @brief change current diagramview to next folio +*/ +void ProjectView::changeTabDown(){ + DiagramView *nextDiagramView = this->nextDiagram(); + if (nextDiagramView!=NULL){ + rebuildDiagramsMap(); + m_tab -> setCurrentWidget(nextDiagramView); + } +} + +/** + @return next folio of current diagramview +*/ +DiagramView *ProjectView::nextDiagram() { + int current_tab_index = m_tab -> currentIndex(); + int next_tab_index = current_tab_index + 1; //get next tab index + if (next_tab_index= greatest tab the last tab is activated so no need to change tab. + return(diagram_ids_[next_tab_index]); + else + return NULL; +} + +/** + @brief change current diagramview to previous tab +*/ +void ProjectView::changeTabUp(){ + DiagramView *previousDiagramView = this->previousDiagram(); + if (previousDiagramView!=NULL){ + rebuildDiagramsMap(); + m_tab -> setCurrentWidget(previousDiagramView); + } +} + +/** + @return previous folio of current diagramview +*/ +DiagramView *ProjectView::previousDiagram() { + int current_tab_index = m_tab -> currentIndex(); + int previous_tab_index = current_tab_index - 1; //get previous tab index + if (previous_tab_index>=0) //if previous tab index = 0 then the first tab is activated so no need to change tab. + return(diagram_ids_[previous_tab_index]); + else + return NULL; +} + +/** + @brief change current diagramview to last tab +*/ +void ProjectView::changeLastTab(){ + DiagramView *lastDiagramView = this->lastDiagram(); + m_tab->setCurrentWidget(lastDiagramView); +} + +/** + @return last folio of current project +*/ +DiagramView *ProjectView::lastDiagram(){ + return(diagram_ids_.last()); +} + +/** + @brief change current diagramview to first tab +*/ +void ProjectView::changeFirstTab(){ + DiagramView *firstDiagramView = this->firstDiagram(); + m_tab->setCurrentWidget(firstDiagramView); +} + +/** + @return first folio of current project +*/ +DiagramView *ProjectView::firstDiagram(){ + return(diagram_ids_.first()); +} + + /** Cette methode essaye de fermer successivement les editeurs d'element puis les schemas du projet. L'utilisateur peut refuser de fermer un schema ou un @@ -148,19 +225,19 @@ void ProjectView::closeEvent(QCloseEvent *qce) { */ bool ProjectView::tryClosing() { if (!project_) return(true); - + // First step: require external editors closing -- users may either cancel // the whole closing process or save (and therefore add) content into this // project. Of course, they may also discard them. if (!tryClosingElementEditors()) { return(false); } - + // Check how different the current situation is from a brand new, untouched project if (project_ -> filePath().isEmpty() && !project_ -> projectWasModified()) { return(true); } - + // Second step: users are presented with a dialog that enables them to // choose whether they want to: // - cancel the closing process, @@ -173,12 +250,12 @@ bool ProjectView::tryClosing() { } else if (user_input == QMessageBox::Discard) { return(true); // all modifications were discarded } - + // Check how different the current situation is from a brand new, untouched project (yes , again) if (project_ -> filePath().isEmpty() && !project_ -> projectWasModified()) { return(true); } - + if (project_ -> filePath().isEmpty()) { QString filepath = askUserForFilePath(); if (filepath.isEmpty()) return(false); // users may cancel the closing @@ -205,7 +282,7 @@ bool ProjectView::tryClosingElementEditors() { foreach(QETElementEditor *editor, editors) { if (!editor -> close()) return(false); } - + QList template_editors = QETApp::titleBlockTemplateEditors(project_); foreach(QETTitleBlockTemplateEditor *template_editor, template_editors) { if (!template_editor -> close()) return(false); @@ -243,7 +320,7 @@ int ProjectView::tryClosingDiagrams() { if (close_dialog == QMessageBox::Save) { saveDiagrams(project()->diagrams()); } - + return(close_dialog); } @@ -260,20 +337,20 @@ QString ProjectView::askUserForFilePath(bool assign) { this, tr("Enregistrer sous", "dialog title"), project_ -> currentDir(), - tr("Projet QElectroTech (*.qet)", "filetypes allowed when saving a project file") + tr("Projet QElectroTech (*.qet)", "filetypes allowed when saving a project file") ); - + // if no filepath is provided, return an empty string if (filepath.isEmpty()) return(filepath); - + // if the name does not end with the .qet extension, append it if (!filepath.endsWith(".qet", Qt::CaseInsensitive)) filepath += ".qet"; - + if (assign) { // assign the provided filepath to the currently edited project project_ -> setFilePath(filepath); } - + return(filepath); } @@ -292,7 +369,7 @@ QETResult ProjectView::noProjectResult() const { */ void ProjectView::addNewDiagram() { if (project_ -> isReadOnly()) return; - + Diagram *new_diagram = project_ -> addNewDiagram(); DiagramView *new_diagram_view = new DiagramView(new_diagram); addDiagram(new_diagram_view); @@ -335,7 +412,7 @@ void ProjectView::addDiagram(DiagramView *diagram) { // check diagram isn't present in the project if (diagram_ids_.values().contains(diagram)) return; - + // Add new tab for the diagram m_tab -> addTab(diagram, QET::Icons::Diagram, diagram -> title()); diagram -> setFrameStyle(QFrame::Plain | QFrame::NoFrame); @@ -348,7 +425,7 @@ void ProjectView::addDiagram(DiagramView *diagram) { connect(diagram, SIGNAL(findElementRequired(const ElementsLocation &)), this, SIGNAL(findElementRequired(const ElementsLocation &))); connect(diagram, SIGNAL(editElementRequired(const ElementsLocation &)), this, SIGNAL(editElementRequired(const ElementsLocation &))); connect(diagram, SIGNAL(editTitleBlockTemplate(const QString &, bool)), this, SLOT(editTitleBlockTemplateRequired(const QString &, bool))); - + // signal diagram was added emit(diagramAdded(diagram)); } @@ -360,36 +437,36 @@ void ProjectView::addDiagram(DiagramView *diagram) { void ProjectView::removeDiagram(DiagramView *diagram_view) { if (!diagram_view) return; if (project_ -> isReadOnly()) return; - + // verifie que le schema est bien present dans le projet if (!diagram_ids_.values().contains(diagram_view)) return; - + //Ask confirmation to user. int answer = QET::QetMessageBox::question( this, - tr("Supprimer le folio ?", "message box title"), - tr("Êtes-vous sûr de vouloir supprimer ce folio du projet ? Ce changement est irréversible.", "message box content"), + tr("Supprimer le folio ?", "message box title"), + tr("Êtes-vous sûr de vouloir supprimer ce folio du projet ? Ce changement est irréversible.", "message box content"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::No ); if (answer != QMessageBox::Yes) { return; } - + // enleve le DiagramView des onglets int diagram_tab_id = diagram_ids_.key(diagram_view); m_tab -> removeTab(diagram_tab_id); diagrams_.removeAll(diagram_view); rebuildDiagramsMap(); - + // supprime le DiagramView, puis le Diagram project_ -> removeDiagram(diagram_view -> diagram()); delete diagram_view; - + // signale le retrait du schema emit(diagramRemoved(diagram_view)); - + // rend definitif le retrait du schema project_ -> write(); } @@ -400,7 +477,7 @@ void ProjectView::removeDiagram(DiagramView *diagram_view) { */ void ProjectView::removeDiagram(Diagram *diagram) { if (!diagram) return; - + if (DiagramView *diagram_view = findDiagram(diagram)) { removeDiagram(diagram_view); } @@ -464,7 +541,7 @@ void ProjectView::editDiagramProperties(Diagram *diagram) { */ void ProjectView::moveDiagramUp(DiagramView *diagram_view) { if (!diagram_view) return; - + int diagram_view_position = diagram_ids_.key(diagram_view); if (!diagram_view_position) { // le schema est le premier du projet @@ -485,7 +562,7 @@ void ProjectView::moveDiagramUp(Diagram *diagram) { */ void ProjectView::moveDiagramDown(DiagramView *diagram_view) { if (!diagram_view) return; - + int diagram_view_position = diagram_ids_.key(diagram_view); if (diagram_view_position + 1 == diagram_ids_.count()) { // le schema est le dernier du projet @@ -572,7 +649,7 @@ void ProjectView::moveDiagramDownx10(Diagram *diagram) { */ void ProjectView::printProject() { if (!project_) return; - + // transforme le titre du projet en nom utilisable pour le document QString doc_name; if (!(project_ -> title().isEmpty())) { @@ -584,13 +661,13 @@ void ProjectView::printProject() { if (doc_name.isEmpty()) { doc_name = tr("projet", "string used to generate a filename"); } - + // recupere le dossier contenant le fichier courant QString dir_path = project_ -> currentDir(); - + // determine un chemin pour le pdf / ps QString file_name = QDir::toNativeSeparators(QDir::cleanPath(dir_path + "/" + doc_name)); - + DiagramPrintDialog print_dialog(project_, this); print_dialog.setDocName(doc_name); print_dialog.setFileName(file_name); @@ -602,7 +679,7 @@ void ProjectView::printProject() { */ void ProjectView::exportProject() { if (!project_) return; - + ExportDialog ed(project_, parentWidget()); #ifdef Q_OS_MAC ed.setWindowFlags(Qt::Sheet); @@ -629,7 +706,7 @@ QETResult ProjectView::save() { */ QETResult ProjectView::saveAs(ProjectSaveOptions options) { if (!project_) return(noProjectResult()); - + QString filepath = askUserForFilePath(); if (filepath.isEmpty()) return(QETResult()); return(doSave(options)); @@ -645,16 +722,16 @@ QETResult ProjectView::saveAs(ProjectSaveOptions options) { */ QETResult ProjectView::doSave(ProjectSaveOptions options) { if (!project_) return(noProjectResult()); - + if (project_ -> filePath().isEmpty()) { // The project has not been saved to a file yet, // so save() actually means saveAs(). return(saveAs(options)); } - + // look for diagrams matching the required save options saveDiagrams(getDiagrams(options)); - + // write to file QETResult result = project_ -> write(); updateWindowTitle(); @@ -688,7 +765,7 @@ void ProjectView::saveDiagrams(const QList &diagrams) { */ int ProjectView::cleanProject() { if (!project_) return(0); - + // s'assure que le schema n'est pas en lecture seule if (project_ -> isReadOnly()) { QET::QetMessageBox::critical( @@ -698,22 +775,22 @@ int ProjectView::cleanProject() { ); return(0); } - + // construit un petit dialogue pour parametrer le nettoyage - QCheckBox *clean_tbt = new QCheckBox(tr("Supprimer les modèles de cartouche inutilisés dans le projet")); + QCheckBox *clean_tbt = new QCheckBox(tr("Supprimer les modèles de cartouche inutilisés dans le projet")); QCheckBox *clean_elements = new QCheckBox(tr("Supprimer les éléments inutilisés dans le projet")); QCheckBox *clean_categories = new QCheckBox(tr("Supprimer les catégories vides")); QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - - clean_tbt -> setChecked(true); + + clean_tbt -> setChecked(true); clean_elements -> setChecked(true); clean_categories -> setChecked(true); - + QDialog clean_dialog(parentWidget()); #ifdef Q_OS_MAC clean_dialog.setWindowFlags(Qt::Sheet); #endif - + clean_dialog.setWindowTitle(tr("Nettoyer le projet", "window title")); QVBoxLayout *clean_dialog_layout = new QVBoxLayout(); clean_dialog_layout -> addWidget(clean_tbt); @@ -721,10 +798,10 @@ int ProjectView::cleanProject() { clean_dialog_layout -> addWidget(clean_categories); clean_dialog_layout -> addWidget(buttons); clean_dialog.setLayout(clean_dialog_layout); - + connect(buttons, SIGNAL(accepted()), &clean_dialog, SLOT(accept())); connect(buttons, SIGNAL(rejected()), &clean_dialog, SLOT(reject())); - + int clean_count = 0; if (clean_dialog.exec() == QDialog::Accepted) { @@ -751,7 +828,7 @@ int ProjectView::cleanProject() { Initialize actions for this widget. */ void ProjectView::initActions() { - add_new_diagram_ = new QAction(QET::Icons::AddFolio, tr("Ajouter un folio"), this); + add_new_diagram_ = new QAction(QET::Icons::AddFolio, tr("Ajouter un folio"), this); connect(add_new_diagram_, SIGNAL(triggered()), this, SLOT(addNewDiagram())); } @@ -761,30 +838,30 @@ void ProjectView::initActions() { void ProjectView::initWidgets() { setObjectName("ProjectView"); setWindowIcon(QET::Icons::ProjectFileGP); - + // initialize the "fallback" widget fallback_widget_ = new QWidget(); fallback_label_ = new QLabel( tr( - "Ce projet ne contient aucun folio", + "Ce projet ne contient aucun folio", "label displayed when a project contains no diagram" ) ); fallback_label_ -> setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); - + // initialize tabs m_tab = new QTabWidget(this); m_tab -> setMovable(true); - + QToolButton *add_new_diagram_button = new QToolButton; add_new_diagram_button -> setDefaultAction(add_new_diagram_); add_new_diagram_button -> setAutoRaise(true); m_tab -> setCornerWidget(add_new_diagram_button, Qt::TopRightCorner); - + connect(m_tab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); connect(m_tab, SIGNAL(tabBarDoubleClicked(int)), this, SLOT(tabDoubleClicked(int))); connect(m_tab->tabBar(), SIGNAL(tabMoved(int, int)), this, SLOT(tabMoved(int, int))); - + fallback_widget_ -> setVisible(false); m_tab -> setVisible(false); } @@ -795,7 +872,7 @@ void ProjectView::initWidgets() { void ProjectView::initLayout() { QVBoxLayout *fallback_widget_layout_ = new QVBoxLayout(fallback_widget_); fallback_widget_layout_ -> addWidget(fallback_label_); - + layout_ = new QVBoxLayout(this); #ifdef Q_OS_MAC layout_ -> setContentsMargins(0, 8, 0, 0); @@ -816,9 +893,9 @@ void ProjectView::initLayout() { */ void ProjectView::loadDiagrams() { if (!project_) return; - + setDisplayFallbackWidget(project_ -> diagrams().isEmpty()); - + foreach(Diagram *diagram, project_ -> diagrams()) { DiagramView *sv = new DiagramView(diagram); addDiagram(sv); @@ -851,12 +928,12 @@ void ProjectView::updateWindowTitle() { */ void ProjectView::adjustReadOnlyState() { bool editable = !(project_ -> isReadOnly()); - + // prevent users from moving existing diagrams m_tab -> setMovable(editable); // prevent users from adding new diagrams add_new_diagram_ -> setEnabled(editable); - + // on met a jour le titre du widget, qui reflete l'etat de lecture seule updateWindowTitle(); } @@ -879,13 +956,13 @@ void ProjectView::updateTabTitle(DiagramView *diagram, const QString &diagram_ti */ void ProjectView::tabMoved(int from, int to) { if (!project_) return; - + // signale au QETProject le changement d'ordre des schemas project_ -> diagramOrderChanged(from, to); - + // reconstruit la liste associant les index des onglets aux schemas rebuildDiagramsMap(); - + // emet un signal pour informer le reste du monde que l'ordre des schemas a change emit(diagramOrderChanged(this, from, to)); } @@ -926,7 +1003,7 @@ DiagramView *ProjectView::findDiagram(Diagram *diagram) { void ProjectView::rebuildDiagramsMap() { // vide la map diagram_ids_.clear(); - + foreach(DiagramView *diagram_view, diagrams_) { int dv_idx = m_tab -> indexOf(diagram_view); if (dv_idx == -1) continue; @@ -958,7 +1035,7 @@ void ProjectView::tabDoubleClicked(int tab_id) { // repere le schema concerne DiagramView *diagram_view = diagram_ids_[tab_id]; if (!diagram_view) return; - + diagram_view -> editDiagramProperties(); } diff --git a/sources/projectview.h b/sources/projectview.h index 3407ec492..380873deb 100644 --- a/sources/projectview.h +++ b/sources/projectview.h @@ -1,17 +1,17 @@ /* Copyright 2006-2015 The QElectroTech Team This file is part of QElectroTech. - + QElectroTech is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - + QElectroTech is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with QElectroTech. If not, see . */ @@ -31,7 +31,7 @@ class QTabWidget; */ class ProjectView : public QWidget { Q_OBJECT - + public: enum ProjectSaveOption { CurrentDiagram = 2, @@ -39,15 +39,15 @@ class ProjectView : public QWidget { AllDiagrams = 6 }; Q_DECLARE_FLAGS(ProjectSaveOptions, ProjectSaveOption) - - + + // constructors, destructor public: ProjectView(QETProject *, QWidget * = 0); virtual ~ProjectView(); private: ProjectView(const ProjectView &); - + // methods public: QETProject *project(); @@ -56,7 +56,11 @@ class ProjectView : public QWidget { QList getDiagrams(ProjectSaveOptions options); DiagramView *currentDiagram() const; void closeEvent(QCloseEvent *); - + void changeTabUp(); + void changeTabDown(); + void changeFirstTab(); + void changeLastTab(); + public slots: void addNewDiagram(); void addNewDiagramFolioList(); @@ -90,7 +94,7 @@ class ProjectView : public QWidget { void updateTabTitle(DiagramView *, const QString &); void tabMoved(int, int); void editTitleBlockTemplateRequired(const QString &, bool); - + signals: void diagramAdded(DiagramView *); void diagramRemoved(DiagramView *); @@ -102,26 +106,30 @@ class ProjectView : public QWidget { void findElementRequired(const ElementsLocation &); void editElementRequired(const ElementsLocation &); void editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool); - + private: void initActions(); void initWidgets(); void initLayout(); void loadDiagrams(); DiagramView *findDiagram(Diagram *); + DiagramView *nextDiagram(); + DiagramView *previousDiagram(); + DiagramView *firstDiagram(); + DiagramView *lastDiagram(); void rebuildDiagramsMap(); bool tryClosing(); bool tryClosingElementEditors(); int tryClosingDiagrams(); QString askUserForFilePath(bool = true); QETResult noProjectResult() const; - + private slots: void tabChanged(int); void tabDoubleClicked(int); void setDisplayFallbackWidget(bool); void adjustReadOnlyState(); - + // attributes private: QAction *add_new_diagram_; diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 435455e56..f53cd0149 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -1524,6 +1524,34 @@ ProjectView *QETDiagramEditor::viewForFile(const QString &filepath) const { return(0); } +/** + * @brief QETDiagramEditor::acessCurrentProject + * Retrieve current Project open in diagram editor + */ +ProjectView *QETDiagramEditor::acessCurrentProject (){ + QMdiSubWindow *current_window = workspace.activeSubWindow(); + if (!current_window) return(0); + + QWidget *current_widget = current_window -> widget(); + if (!current_widget) return(0); + + if (ProjectView *project_view = qobject_cast(current_widget)) { + return(project_view); + } + return(0); +} + +/** + * @brief QETDiagramEditor::acessCurrentDiagramView + * Retrieve current DiagramView used in diagram editor + */ +DiagramView *QETDiagramEditor::acessCurrentDiagramView () { + if (ProjectView *project_view = currentProject()) { + return(project_view -> currentDiagram()); + } + return(0); +} + /** met a jour le menu "Fenetres" */ diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h index 778c0bcdf..2ad43e519 100644 --- a/sources/qetdiagrameditor.h +++ b/sources/qetdiagrameditor.h @@ -65,7 +65,9 @@ class QETDiagramEditor : public QETMainWindow { bool openAndAddProject (const QString &, bool = true, bool = true); QList editedFiles () const; ProjectView *viewForFile (const QString &) const; - + ProjectView *acessCurrentProject (); + DiagramView *acessCurrentDiagramView (); + protected: virtual bool event(QEvent *); diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index a80b2f813..0cc634dfc 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -34,6 +34,8 @@ #include "integrationmovetemplateshandler.h" #include "xmlelementcollection.h" #include "importelementdialog.h" +#include "numerotationcontextcommands.h" + #include @@ -54,7 +56,8 @@ QETProject::QETProject(int diagrams, QObject *parent) : titleblocks_ (this ), folioSheetsQuantity (0 ), m_auto_conductor (true ), - m_elements_collection (nullptr) + m_elements_collection (nullptr), + m_auto_folio (true ) { // 0 a n schema(s) vide(s) int diagrams_count = qMax(0, diagrams); @@ -91,7 +94,8 @@ QETProject::QETProject(const QString &path, QObject *parent) : titleblocks_ (this ), folioSheetsQuantity (0 ), m_auto_conductor (true ), - m_elements_collection (nullptr) + m_elements_collection (nullptr), + m_auto_folio (true ) { //Open the file QFile project_file(path); @@ -442,9 +446,17 @@ QHash QETProject::conductorAutoNum() const { return m_conductor_autonum; } +/** + * @brief QETProject::folioAutoNum + * @return All value of conductor autonum stored in project + */ +QHash QETProject::folioAutoNum() const { + return m_folio_autonum; +} + /** * @brief QETProject::addConductorAutoNum - * Add a new numerotation context. If key already exist, + * Add a new conductor numerotation context. If key already exist, * replace old context by the new context * @param key * @param context @@ -453,18 +465,38 @@ void QETProject::addConductorAutoNum(QString key, NumerotationContext context) { m_conductor_autonum.insert(key, context); } +/** + * @brief QETProject::addFolioAutoNum + * Add a new folio numerotation context. If key already exist, + * replace old context by the new context + * @param key + * @param context + */ +void QETProject::addFolioAutoNum(QString key, NumerotationContext context) { + m_folio_autonum.insert(key, context); +} + /** * @brief QETProject::removeConductorAutonum - * Remove the Numerotation Context stored with key + * Remove Conductor Numerotation Context stored with key * @param key */ void QETProject::removeConductorAutonum(QString key) { m_conductor_autonum.remove(key); } +/** + * @brief QETProject::removeFolioAutonum + * Remove Folio Numerotation Context stored with key + * @param key + */ +void QETProject::removeFolioAutoNum(QString key) { + m_folio_autonum.remove(key); +} + /** * @brief QETProject::conductorAutoNum - * Return the numerotation context stored with @key. + * Return conductor numerotation context stored with @key. * If key is not found, return an empty numerotation context * @param key */ @@ -473,6 +505,17 @@ NumerotationContext QETProject::conductorAutoNum (const QString &key) const { else return NumerotationContext(); } +/** + * @brief QETProject::folioAutoNum + * Return folio numerotation context stored with @key. + * If key is not found, return an empty numerotation context + * @param key + */ +NumerotationContext QETProject::folioAutoNum (const QString &key) const { + if (m_folio_autonum.contains(key)) return m_folio_autonum[key]; + else return NumerotationContext(); +} + /** * @brief QETProject::autoConductor * @return true if use of auto conductor is authorized. @@ -483,6 +526,16 @@ bool QETProject::autoConductor() const return m_auto_conductor; } +/** + * @brief QETProject::autoFolio + * @return true if use of auto folio is authorized. + * See also Q_PROPERTY autoFolio + */ +bool QETProject::autoFolio() const +{ + return m_auto_folio; +} + /** * @brief QETProject::setAutoConductor * @param ac @@ -495,6 +548,46 @@ void QETProject::setAutoConductor(bool ac) m_auto_conductor = ac; } +/** + * @brief QETProject::setAutoFolio + * @param ac + * Enable the use of auto folio if true + * See also Q_PROPERTY autoConductor + */ +void QETProject::setAutoFolio(bool af) +{ + if (af != m_auto_folio) + m_auto_folio = af; +} + +/** + * @brief QETProject::autoFolioNumberingNewFolios + * emit Signal to add new Diagram with autonum + * properties + */ +void QETProject::autoFolioNumberingNewFolios(){ + emit addAutoNumDiagram(); +} + +/** + * @brief QETProject::autoFolioNumberingNewFolios + * @param autonum used, index from selected tabs "from" and "to" + * rename folios with selected autonum + */ +void QETProject::autoFolioNumberingSelectedFolios(int from, int to, QString autonum){ + int total_folio = diagrams_.count(); + DiagramContext project_wide_properties = project_properties_; + for (int i=from; i<=to; i++) { + QString title = diagrams_[i] -> title(); + NumerotationContext nC = folioAutoNum(autonum); + NumerotationContextCommands nCC = NumerotationContextCommands(nC); + diagrams_[i] -> border_and_titleblock.setFolio("%autonum"); + diagrams_[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties); + diagrams_[i] -> project() -> addFolioAutoNum(autonum,nCC.next()); + diagrams_[i] -> update(); + } +} + /** @return un document XML representant le projet */ @@ -1157,7 +1250,7 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project) m_default_xref_properties = XRefProperties:: defaultProperties(); //Read values indicate in project - QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums; + QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums; for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling()) { @@ -1176,6 +1269,8 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project) xref_elmt = child_elmt; else if (child_elmt.tagName() == "conductors_autonums") conds_autonums = child_elmt; + else if (child_elmt.tagName()== "folio_autonums") + folio_autonums = child_elmt; } // size, titleblock, conductor, report, conductor autonum @@ -1201,6 +1296,15 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project) m_conductor_autonum.insert(elmt.attribute("title"), nc); } } + if (!folio_autonums.isNull()) + { + foreach (QDomElement elmt, QET::findInDomElement(folio_autonums, "folio_autonum")) + { + NumerotationContext nc; + nc.fromXml(elmt); + m_folio_autonum.insert(elmt.attribute("title"), nc); + } + } } /** @@ -1261,6 +1365,15 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) { conds_autonums.appendChild(cond_autonum); } xml_element.appendChild(conds_autonums); + + //Export Folio Autonums + QDomElement folio_autonums = xml_document.createElement("folio_autonums"); + foreach (QString key, folioAutoNum().keys()) { + QDomElement folio_autonum = folioAutoNum(key).toXml(xml_document, "folio_autonum"); + folio_autonum.setAttribute("title", key); + folio_autonums.appendChild(folio_autonum); + } + xml_element.appendChild(folio_autonums); } /** @@ -1416,7 +1529,17 @@ void QETProject::updateDiagramsFolioData() { project_wide_properties.addValue("projecttitle", title()); for (int i = 0 ; i < total_folio ; ++ i) { - diagrams_[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, project_wide_properties); + QString title = diagrams_[i] -> title(); + QString autopagenum = diagrams_[i]->border_and_titleblock.autoPageNum(); + NumerotationContext nC = folioAutoNum(autopagenum); + NumerotationContextCommands nCC = NumerotationContextCommands(nC); + if((diagrams_[i]->border_and_titleblock.folio().contains("%autonum"))&&(!autopagenum.isNull())){ + diagrams_[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties); + diagrams_[i]->project()->addFolioAutoNum(autopagenum,nCC.next()); + } + else{ + diagrams_[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, NULL, project_wide_properties); + } diagrams_[i] -> update(); } } diff --git a/sources/qetproject.h b/sources/qetproject.h index 5633cfc83..e18cf720d 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -115,12 +115,21 @@ class QETProject : public QObject void setDefaultXRefProperties(QHash hash); QHash conductorAutoNum() const; + QHash folioAutoNum() const; void addConductorAutoNum (QString key, NumerotationContext context); + void addFolioAutoNum (QString key, NumerotationContext context); void removeConductorAutonum (QString key); + void removeFolioAutoNum (QString key); NumerotationContext conductorAutoNum(const QString &key) const; + NumerotationContext folioAutoNum(const QString &key) const; bool autoConductor () const; + bool autoFolio () const; void setAutoConductor (bool ac); + void setAutoFolio (bool af); + void autoFolioNumberingNewFolios (); + void autoFolioNumberingSelectedFolios(int, int, QString); + QDomDocument toXml(); bool close(); QETResult write(); @@ -162,6 +171,7 @@ class QETProject : public QObject void readOnlyChanged(QETProject *, bool); void reportPropertiesChanged(QString); void XRefPropertiesChanged (); + void addAutoNumDiagram(); private slots: void updateDiagramsFolioData(); @@ -226,10 +236,12 @@ class QETProject : public QObject QUndoStack *undo_stack_; /// Conductor auto numerotation QHash m_conductor_autonum; + QHash m_folio_autonum; /// Folio List Sheets quantity for this project. int folioSheetsQuantity; bool m_auto_conductor; XmlElementCollection *m_elements_collection; + bool m_auto_folio; }; Q_DECLARE_METATYPE(QETProject *) #endif diff --git a/sources/titleblockproperties.cpp b/sources/titleblockproperties.cpp index 4e66ee27c..d5eab8240 100644 --- a/sources/titleblockproperties.cpp +++ b/sources/titleblockproperties.cpp @@ -48,6 +48,7 @@ bool TitleBlockProperties::operator==(const TitleBlockProperties &ip) { ip.date == date &&\ ip.filename == filename &&\ ip.folio == folio &&\ + ip.auto_page_num == auto_page_num &&\ ip.template_name == template_name &&\ ip.context == context &&\ ip.display_at == display_at &&\ @@ -73,6 +74,7 @@ void TitleBlockProperties::toXml(QDomElement &e) const { e.setAttribute("title", title); e.setAttribute("filename", filename); e.setAttribute("folio", folio); + e.setAttribute("auto_page_num", auto_page_num); e.setAttribute("date", exportDate()); e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right")); if (!template_name.isEmpty()) @@ -98,6 +100,7 @@ void TitleBlockProperties::fromXml(const QDomElement &e) { if (e.hasAttribute("title")) title = e.attribute("title"); if (e.hasAttribute("filename")) filename = e.attribute("filename"); if (e.hasAttribute("folio")) folio = e.attribute("folio"); + if (e.hasAttribute("auto_page_num")) auto_page_num = e.attribute("auto_page_num"); if (e.hasAttribute("date")) setDateFromString(e.attribute("date")); if (e.hasAttribute("displayAt")) display_at = (e.attribute("displayAt") == "bottom" ? Qt::BottomEdge : Qt::RightEdge); @@ -126,6 +129,7 @@ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix settings.setValue(prefix + "author", author); settings.setValue(prefix + "filename", filename); settings.setValue(prefix + "folio", folio); + settings.setValue(prefix + "auto_page_num", auto_page_num); settings.setValue(prefix + "date", exportDate()); settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right")); settings.setValue(prefix + "titleblocktemplate", template_name.isEmpty()? QString() : template_name); @@ -143,6 +147,7 @@ void TitleBlockProperties::fromSettings(QSettings &settings, const QString &pref author = settings.value(prefix + "author").toString(); filename = settings.value(prefix + "filename").toString(); folio = settings.value(prefix + "folio", "%id/%total").toString(); + auto_page_num = settings.value(prefix + "auto_page_num").toString(); setDateFromString(settings.value(prefix + "date").toString()); display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge); template_name = settings.value(prefix + "titleblocktemplate").toString(); diff --git a/sources/titleblockproperties.h b/sources/titleblockproperties.h index 7189e5bba..963c785c4 100644 --- a/sources/titleblockproperties.h +++ b/sources/titleblockproperties.h @@ -53,6 +53,7 @@ class TitleBlockProperties { QDate date; ///< Date (displayed by the default template) QString filename; ///< Filename (displayed by the default template) QString folio; ///< Folio information (displayed by the default template) + QString auto_page_num; DateManagement useDate; ///< Wheter to use the date attribute QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application" DiagramContext context; ///< Container for the additional, user-defined fields diff --git a/sources/ui/diagrampropertiesdialog.cpp b/sources/ui/diagrampropertiesdialog.cpp index cf4bbddae..eaa2e7029 100644 --- a/sources/ui/diagrampropertiesdialog.cpp +++ b/sources/ui/diagrampropertiesdialog.cpp @@ -55,12 +55,14 @@ DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *pare //Title block widget TitleBlockPropertiesWidget *titleblock_infos; if (QETProject *parent_project = diagram -> project()) { - titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, this); + titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, diagram->project(), this); connect(titleblock_infos, SIGNAL(editTitleBlockTemplate(QString, bool)), diagram->views().first(), SIGNAL(editTitleBlockTemplate(QString, bool))); } else - titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, this); + titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, diagram->project(), this); titleblock_infos -> setReadOnly(diagram_is_read_only); + connect(titleblock_infos,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(editAutoFolioNum())); + titleblock_infos->setMinimumSize(590,480); //Minimum Size needed for correct display //Conductor widget ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors, this); @@ -124,7 +126,7 @@ void DiagramPropertiesDialog::diagramPropertiesDialog(Diagram *diagram, QWidget /** * @brief DiagramPropertiesDialog::editAutonum - * Open the autonum editor + * Open conductor autonum editor */ void DiagramPropertiesDialog::editAutonum() { ProjectPropertiesDialog ppd (m_diagram->project(), this); @@ -132,3 +134,14 @@ void DiagramPropertiesDialog::editAutonum() { ppd.exec(); m_asw -> setItems (m_diagram -> project() -> conductorAutoNum().keys()); } + +/** + * @brief DiagramPropertiesDialog::editAutonum + * Open folio autonum editor + */ +void DiagramPropertiesDialog::editAutoFolioNum () { + ProjectPropertiesDialog ppd (m_diagram->project(), this); + ppd.setCurrentPage(ProjectPropertiesDialog::Autonum); + ppd.changeToFolio(); + ppd.exec(); +} diff --git a/sources/ui/diagrampropertiesdialog.h b/sources/ui/diagrampropertiesdialog.h index ebf293dcc..672e0e968 100644 --- a/sources/ui/diagrampropertiesdialog.h +++ b/sources/ui/diagrampropertiesdialog.h @@ -37,6 +37,7 @@ class DiagramPropertiesDialog : public QDialog { public slots: void editAutonum (); + void editAutoFolioNum (); private: Diagram *m_diagram; diff --git a/sources/ui/folioautonumbering.cpp b/sources/ui/folioautonumbering.cpp new file mode 100644 index 000000000..5253142f4 --- /dev/null +++ b/sources/ui/folioautonumbering.cpp @@ -0,0 +1,218 @@ +/* + Copyright 2006-2015 The QElectroTech Team + This file is part of QElectroTech. + + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . +*/ +#include "folioautonumbering.h" +#include "ui_folioautonumbering.h" +#include +#include +#include +#include "qdebug.h" +#include "qetproject.h" +#include "diagram.h" +/** + * Constructor + */ +FolioAutonumberingW::FolioAutonumberingW(QETProject *project, QWidget *parent) : + QWidget(parent), + project_(project), + ui(new Ui::FolioAutonumberingW) + +{ + ui->setupUi(this); + applyEnable(false); + ui->m_from_cb->setEnabled(false); + ui->m_new_tabs_sb->setEnabled(false); + ui->m_to_cb->setEnabled(false); +} + +/** + * Destructor + */ +FolioAutonumberingW::~FolioAutonumberingW() +{ + delete ui; +} + +/** + * @brief FolioAutonumberingW::setContext + * construct autonums in the comboBox selected in the @autonum_chooser QcomboBox + */ +void FolioAutonumberingW::setContext(QList autonums) { + foreach (QString str, autonums) { ui->m_autonums_cb->addItem(str);} +} + +/** + * @brief FolioAutonumberingW::autoNumSelected + * returns the current autonum selected + */ +QString FolioAutonumberingW::autoNumSelected(){ + return ui->m_autonums_cb->currentText(); +} + +/** + * @brief FolioAutonumberingW::fromFolio + * returns the current "From Folio" index + */ +int FolioAutonumberingW::fromFolio(){ + return ui->m_from_cb->currentIndex()-1; +} + +/** + * @brief FolioAutonumberingW::toFolio + * returns the current "To Folio" index + */ +int FolioAutonumberingW::toFolio(){ + return ui->m_to_cb->currentIndex()+this->fromFolio()+1; +} + +/** + * @brief FolioAutonumberingW::newFoliosNumber + * returns the number of folios to create + */ +int FolioAutonumberingW::newFoliosNumber(){ + return ui->m_new_tabs_sb->value(); +} + +/** + * @brief FolioAutonumberingW::updateFolioList + * update Folio List in From and To ComboBox + */ +void FolioAutonumberingW::updateFolioList(){ + ui -> m_from_cb->clear(); + ui -> m_to_cb->clear(); + if (newFolios){ + this -> on_m_create_new_tabs_rb_clicked(); + } else { + this -> on_m_autonumber_tabs_rb_clicked(); + } +} + +/** + * @brief FolioAutonumberingW::on_m_create_new_tabs_rb_clicked + * Enable New Tabs SpinBox + */ +void FolioAutonumberingW::on_m_create_new_tabs_rb_clicked() { + ui->m_from_cb->setEnabled(false); + ui->m_to_cb->setEnabled(false); + ui->m_new_tabs_sb->setEnabled(true); + applyEnable(); + newFolios = true; +} + +/** + * @brief FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked + * Enable From ComboBox, fill From ComboBox + */ +void FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked() { + ui->m_new_tabs_sb->setEnabled(false); + ui->m_from_cb->setEnabled(true); + ui->m_to_cb->setEnabled(true); + if (ui->m_from_cb->count()<=0){ + ui->m_from_cb->clear(); + ui->m_from_cb->addItem(""); + foreach (Diagram *diagram, project_->diagrams()){ + ui->m_from_cb->addItem(diagram->title()); + } + } + applyEnable(); + newFolios = false; +} + +/** + * @brief FolioAutonumberingW::on_m_new_tabs_sb_valueChanged + * Enable Apply if any new folio is to be created + */ +void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(){ + if (ui->m_new_tabs_sb->value()>0) applyEnable(true); + else applyEnable(false); +} + +/** + * @brief FolioAutonumberingW::on_m_from_cb_currentIndexChanged + * Enable To ComboBox + */ +void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(){ + int index = ui->m_from_cb->currentIndex(); + ui->m_to_cb->clear(); + if (index > 0){ + ui->m_to_cb->setEnabled(true); + for (int i=index;idiagrams().size();i++) + ui->m_to_cb->addItem(project_->diagrams().at(i)->title()); + applyEnable(true); + } + else{ + applyEnable(); + } + +} + +/** + * @brief SelectAutonumW::on_buttonBox_clicked + * Action on @buttonBox clicked + */ +void FolioAutonumberingW::on_buttonBox_clicked(QAbstractButton *button) { + //transform button to int + int answer = ui -> buttonBox -> buttonRole(button); + + switch (answer) { + //help dialog - not implemented yet - + case QDialogButtonBox::HelpRole: + break; + /*QMessageBox::information (this, tr("Folio Autonumbering", "title window"), + tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux conducteurs.\n" + "-Une numérotation est composée d'une variable minimum.\n" + "-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n" + "-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n" + + "\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", " + "qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n" + "-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n" + "Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit," + "celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n" + + "\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n" + + "\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.", + "help dialog about the autonumerotation")); */ + case QDialogButtonBox::ApplyRole: + applyEnable(true); + emit applyPressed(); + updateFolioList(); + break; + } +} + +/** + * @brief SelectAutonumW::applyEnable + * enable/disable the apply button + */ +void FolioAutonumberingW::applyEnable(bool b) { + if (b){ + bool valid = true; + if (ui->m_create_new_tabs_rb->isChecked()){ + if (ui->m_new_tabs_sb->value()==0) valid = false; + ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid); + } + else{ + if (ui->m_to_cb->currentText()=="") valid = false; + ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid); + } + } + else{ + ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b); + } +} diff --git a/sources/ui/folioautonumbering.h b/sources/ui/folioautonumbering.h new file mode 100644 index 000000000..345baceb5 --- /dev/null +++ b/sources/ui/folioautonumbering.h @@ -0,0 +1,72 @@ +/* + Copyright 2006-2015 The QElectroTech Team + This file is part of QElectroTech. + + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . +*/ +#ifndef FOLIOAUTONUMBERING_H +#define FOLIOAUTONUMBERING_H + +#include +#include "numerotationcontext.h" + +class NumPartEditorW; +class QAbstractButton; +class QETProject; + +namespace Ui { + class FolioAutonumberingW; +} + +class FolioAutonumberingW : public QWidget +{ + Q_OBJECT + + //METHODS + public: + explicit FolioAutonumberingW(QETProject *project, QWidget *parent = 0); + ~FolioAutonumberingW(); + + void setContext (QList autonums); + NumerotationContext toNumContext() const; + QString autoNumSelected(); + int newFoliosNumber(); + bool newFolios; + int fromFolio(); + int toFolio(); + + // SIGNALS + signals: + void applyPressed(); + void m_autonumber_tabs_rb_clicked(); + + //SLOTS + private slots: + void on_m_create_new_tabs_rb_clicked(); + void on_m_autonumber_tabs_rb_clicked(); + void on_m_new_tabs_sb_valueChanged(); + void on_buttonBox_clicked(QAbstractButton *); + void on_m_from_cb_currentIndexChanged(); + void applyEnable (bool = true); + + //ATTRIBUTES + private: + QETProject *project_; + Ui::FolioAutonumberingW *ui; + QList num_part_list_; + NumerotationContext m_context; + void updateFolioList(); +}; + +#endif // FOLIOAUTONUMBERING_H diff --git a/sources/ui/folioautonumbering.ui b/sources/ui/folioautonumbering.ui new file mode 100644 index 000000000..2d0601426 --- /dev/null +++ b/sources/ui/folioautonumbering.ui @@ -0,0 +1,295 @@ + + + FolioAutonumberingW + + + + 0 + 0 + 467 + 550 + + + + + 0 + 0 + + + + + 460 + 0 + + + + Form + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 50 + + + + + 450 + 253 + + + + + 0 + 50 + + + + false + + + Qt::LeftToRight + + + Qt::ScrollBarAsNeeded + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents + + + true + + + Qt::AlignHCenter|Qt::AlignTop + + + + + 0 + 0 + 448 + 497 + + + + + 0 + 0 + + + + + 430 + 250 + + + + + QLayout::SetFixedSize + + + + + + 0 + 0 + + + + Numbering Options + + + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + + + + + + 0 + 0 + + + + New Tabs + + + + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + + + + + + 0 + 0 + + + + 999 + + + 10 + + + + + + + + 0 + 0 + + + + To + + + + + + + + 0 + 0 + + + + From + + + + + + + + + + + 0 + 0 + + + + Select: + + + + + + + 0 + 0 + + + + Create New Tabs + + + + + + + + 0 + 0 + + + + Autonumber Selected Tabs + + + + + + + + + + + 0 + 0 + + + + Folio Auto Numbering: + + + + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Apply|QDialogButtonBox::Help|QDialogButtonBox::Reset + + + + + + + + diff --git a/sources/ui/projectpropertiesdialog.cpp b/sources/ui/projectpropertiesdialog.cpp index c0fb845a0..e2fa659ae 100644 --- a/sources/ui/projectpropertiesdialog.cpp +++ b/sources/ui/projectpropertiesdialog.cpp @@ -28,11 +28,18 @@ * @param parent : parent widget of this dialog */ ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *parent) { + NewDiagramPage *newDiagramPage = new NewDiagramPage(project,parent,this); + ProjectAutoNumConfigPage *projectAutoNumConfigPage = new ProjectAutoNumConfigPage (project); m_properties_dialog = new ConfigDialog (parent); m_properties_dialog -> setWindowTitle(QObject::tr("Propriétés du projet", "window title")); m_properties_dialog -> addPage(new ProjectMainConfigPage (project)); - m_properties_dialog -> addPage(new NewDiagramPage (project)); - m_properties_dialog -> addPage(new ProjectAutoNumConfigPage (project)); + m_properties_dialog -> addPage(newDiagramPage); + m_properties_dialog -> addPage(projectAutoNumConfigPage); + connect(projectAutoNumConfigPage,SIGNAL(setAutoNum(QString)),newDiagramPage,SLOT(setFolioAutonum(QString))); + connect(projectAutoNumConfigPage,SIGNAL(saveCurrentTbp()),newDiagramPage,SLOT(saveCurrentTbp())); + connect(projectAutoNumConfigPage,SIGNAL(loadSavedTbp()),newDiagramPage,SLOT(loadSavedTbp())); + m_properties_dialog->setMinimumHeight(690); + } /** @@ -58,3 +65,12 @@ void ProjectPropertiesDialog::exec() { void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) { m_properties_dialog -> setCurrentPage(static_cast (p)); } + +/** + * @brief ProjectPropertiesDialog::changeToFolio + * Change the current displayed tab to folio tab. + */ +void ProjectPropertiesDialog::changeToFolio() { + ProjectAutoNumConfigPage *autoNumPage = static_cast (m_properties_dialog->pages.at(2)); + autoNumPage->changeToTab(1); +} diff --git a/sources/ui/projectpropertiesdialog.h b/sources/ui/projectpropertiesdialog.h index 8bbbdcf17..14c2c1c90 100644 --- a/sources/ui/projectpropertiesdialog.h +++ b/sources/ui/projectpropertiesdialog.h @@ -17,6 +17,7 @@ */ #ifndef PROJECTPROPERTIESDIALOG_H #define PROJECTPROPERTIESDIALOG_H +#include class QETProject; class QWidget; @@ -26,8 +27,7 @@ class ConfigDialog; * @brief The ProjectPropertiesDialog class * this class builds a dialog to edit whole properties of a project */ -class ProjectPropertiesDialog -{ +class ProjectPropertiesDialog : public QObject { public: enum Page { Main = 0, @@ -39,6 +39,7 @@ class ProjectPropertiesDialog ~ProjectPropertiesDialog(); void exec(); void setCurrentPage(ProjectPropertiesDialog::Page); + void changeToFolio(); private: ConfigDialog *m_properties_dialog; diff --git a/sources/ui/selectautonumw.ui b/sources/ui/selectautonumw.ui index 871772497..a2630d8ec 100644 --- a/sources/ui/selectautonumw.ui +++ b/sources/ui/selectautonumw.ui @@ -6,183 +6,289 @@ 0 0 - 432 - 273 + 466 + 506 + + + 0 + 0 + + Form - - - Définition + + + + 0 + 0 + - - - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - <html><head/><body><p>Supprimer une variable de numérotation</p></body></html> - - - - - - - :/ico/22x22/list-remove.png:/ico/22x22/list-remove.png - - - false - - - - - - - <html><head/><body><p>Ajouter une variable de numérotation</p></body></html> - - - - - - - :/ico/22x22/list-add.png:/ico/22x22/list-add.png - - - false - - - - - - - Précédent - - - - - - - :/ico/16x16/arrow-left.png:/ico/16x16/arrow-left.png - - - - - - - Suivant - - - - - - - :/ico/16x16/arrow-right.png:/ico/16x16/arrow-right.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - - - 0 + + + 430 + 455 + + + + + 0 + 0 + + + + false + + + Qt::LeftToRight + + + Qt::ScrollBarAsNeeded + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents + + + true + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + 0 + 0 + 460 + 453 + + + + + 0 + 0 + + + + + 460 + 450 + + + + + QLayout::SetFixedSize + + + + + + 0 + 0 + + + + Définition + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + QLayout::SetFixedSize - - - Type + + + 0 - - Qt::AlignCenter + + QLayout::SetDefaultConstraint - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p>Supprimer une variable de numérotation</p></body></html> + + + + + + + :/ico/22x22/list-remove.png:/ico/22x22/list-remove.png + + + false + + + + + + + <html><head/><body><p>Ajouter une variable de numérotation</p></body></html> + + + + + + + :/ico/22x22/list-add.png:/ico/22x22/list-add.png + + + false + + + + + + + Précédent + + + + + + + :/ico/16x16/arrow-left.png:/ico/16x16/arrow-left.png + + + + + + + Suivant + + + + + + + :/ico/16x16/arrow-right.png:/ico/16x16/arrow-right.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - Valeur + + + 0 - - Qt::AlignCenter + + QLayout::SetDefaultConstraint - + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + Type + + + Qt::AlignCenter + + + + + + + Valeur + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Incrémentation + + + Qt::AlignCenter + + + + + + - - - - 0 - 0 - + + + Qt::Vertical - - Incrémentation + + QSizePolicy::MinimumExpanding - - Qt::AlignCenter + + + 20 + 30 + - + - - - - + + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - + + + 0 + 0 + + QDialogButtonBox::Apply|QDialogButtonBox::Help|QDialogButtonBox::Reset diff --git a/sources/ui/titleblockpropertieswidget.cpp b/sources/ui/titleblockpropertieswidget.cpp index 86e1fbd9e..54b3befe1 100644 --- a/sources/ui/titleblockpropertieswidget.cpp +++ b/sources/ui/titleblockpropertieswidget.cpp @@ -29,13 +29,13 @@ * @param current_date if true, display the radio button "current date" * @param parent parent widget */ -TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current_date, QWidget *parent) : +TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current_date, QETProject *project, QWidget *parent) : QWidget(parent), ui(new Ui::TitleBlockPropertiesWidget) { ui->setupUi(this); - initDialog(current_date); - setProperties(titleblock); + initDialog(current_date, project); + setProperties(titleblock); } /** @@ -46,12 +46,12 @@ TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockPropertie * @param current_date if true, display the radio button "current date" * @param parent parent widget */ -TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(TitleBlockTemplatesCollection *tbt_collection, const TitleBlockProperties &titleblock, bool current_date, QWidget *parent) : +TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(TitleBlockTemplatesCollection *tbt_collection, const TitleBlockProperties &titleblock, bool current_date, QETProject *project, QWidget *parent) : QWidget(parent), ui(new Ui::TitleBlockPropertiesWidget) { ui->setupUi(this); - initDialog(current_date); + initDialog(current_date,project); addCollection(tbt_collection); updateTemplateList(); setProperties(titleblock); @@ -65,12 +65,12 @@ TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(TitleBlockTemplatesCollec * @param current_date if true, display the radio button "current date" * @param parent parent widget */ -TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(QList tbt_collection, const TitleBlockProperties &titleblock, bool current_date, QWidget *parent) : +TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(QList tbt_collection, const TitleBlockProperties &titleblock, bool current_date, QETProject *project, QWidget *parent) : QWidget(parent), ui(new Ui::TitleBlockPropertiesWidget) { ui->setupUi(this); - initDialog(current_date); + initDialog(current_date,project); foreach (TitleBlockTemplatesCollection *c, tbt_collection) addCollection(c); updateTemplateList(); @@ -96,6 +96,7 @@ void TitleBlockPropertiesWidget::setProperties(const TitleBlockProperties &prope ui -> m_file_le -> setText (properties.filename); ui -> m_folio_le -> setText (properties.folio); ui -> m_display_at_cb -> setCurrentIndex(properties.display_at == Qt::BottomEdge ? 0 : 1); + ui->auto_page_cb->setCurrentText(properties.auto_page_num); //About date ui -> m_date_now_pb -> setDisabled(true); @@ -172,6 +173,46 @@ TitleBlockProperties TitleBlockPropertiesWidget::properties() const { prop.context = m_dcw -> context(); + prop.auto_page_num = ui->auto_page_cb->currentText(); + + return prop; +} + +/** + * @brief TitleBlockPropertiesWidget::properties + * @return return properties to enable folio autonum + */ +TitleBlockProperties TitleBlockPropertiesWidget::propertiesAutoNum(QString autoNum) const { + TitleBlockProperties prop; + prop.title = ui -> m_title_le -> text(); + prop.author = ui -> m_author_le -> text(); + prop.filename = ui -> m_file_le -> text(); + prop.folio = "%autonum"; + prop.display_at = ui -> m_display_at_cb -> currentIndex() == 0 ? Qt::BottomEdge : Qt::RightEdge; + + if (ui->m_no_date_rb->isChecked()) { + prop.useDate = TitleBlockProperties::UseDateValue; + prop.date = QDate(); + } + else if (ui -> m_fixed_date_rb -> isChecked()) { + prop.useDate = TitleBlockProperties::UseDateValue; + prop.date = ui->m_date_edit->date(); + } + else if (ui->m_current_date_rb->isVisible() && ui->m_current_date_rb->isChecked()) { + prop.useDate = TitleBlockProperties::CurrentDate; + prop.date = QDate::currentDate(); + } + + if (!currentTitleBlockTemplateName().isEmpty()) + { + prop.template_name = currentTitleBlockTemplateName(); + prop.collection = m_map_index_to_collection_type.at(ui->m_tbt_cb->currentIndex()); + } + + prop.context = m_dcw -> context(); + + prop.auto_page_num = autoNum; + return prop; } @@ -220,7 +261,7 @@ void TitleBlockPropertiesWidget::addCollection(TitleBlockTemplatesCollection *tb * Init this dialog * @param current_date true for display current date radio button */ -void TitleBlockPropertiesWidget::initDialog(const bool ¤t_date) { +void TitleBlockPropertiesWidget::initDialog(const bool ¤t_date, QETProject *project) { m_dcw = new DiagramContextWidget(); ui -> m_tab2_vlayout -> addWidget(m_dcw); @@ -239,6 +280,19 @@ void TitleBlockPropertiesWidget::initDialog(const bool ¤t_date) { ui -> m_tbt_pb -> setMenu(m_tbt_menu); connect(ui->m_tbt_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentTitleBlockTemplate(int))); + + if (project!= NULL){ + keys_2 = project -> folioAutoNum().keys(); + foreach (QString str, keys_2) { ui -> auto_page_cb -> addItem(str); } + if (ui->auto_page_cb->currentText()==NULL) + ui->auto_page_cb->addItem("Create an Auto Folio Numbering"); + } + else{ + ui->auto_page_cb->hide(); + ui->m_edit_autofolionum_pb->hide(); + ui->label_9->hide(); + } + } /** @@ -342,3 +396,15 @@ void TitleBlockPropertiesWidget::changeCurrentTitleBlockTemplate(int index) void TitleBlockPropertiesWidget::on_m_date_now_pb_clicked() { ui -> m_date_edit -> setDate(QDate::currentDate()); } + +/** + * @brief TitleBlockPropertiesWidget::on_m_edit_autofolionum_pb_clicked + * Open Auto Folio Num dialog + */ +void TitleBlockPropertiesWidget::on_m_edit_autofolionum_pb_clicked() { + emit openAutoNumFolioEditor(ui->auto_page_cb->currentText()); + if (ui->auto_page_cb->currentText()!="Create an Auto Folio Numbering") + { + //still to implement: load current auto folio num settings + } +} diff --git a/sources/ui/titleblockpropertieswidget.h b/sources/ui/titleblockpropertieswidget.h index 3c4491cea..d6020c185 100644 --- a/sources/ui/titleblockpropertieswidget.h +++ b/sources/ui/titleblockpropertieswidget.h @@ -18,11 +18,15 @@ #ifndef TITLEBLOCKPROPERTIESWIDGET_H #define TITLEBLOCKPROPERTIESWIDGET_H +#include "qetproject.h" #include #include "titleblockproperties.h" #include "diagramcontextwidget.h" #include "qet.h" +#include "numerotationcontext.h" +class NumerotationContext; +class QETProject; class QMenu; class TitleBlockTemplatesCollection; @@ -35,13 +39,15 @@ class TitleBlockPropertiesWidget : public QWidget Q_OBJECT public: - explicit TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QWidget *parent = 0); - explicit TitleBlockPropertiesWidget(TitleBlockTemplatesCollection *tbt_collection, const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QWidget *parent = 0); - explicit TitleBlockPropertiesWidget(QList tbt_collection, const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QWidget *parent = 0); + explicit TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QETProject *project = NULL, QWidget *parent = 0); + explicit TitleBlockPropertiesWidget(TitleBlockTemplatesCollection *tbt_collection, const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QETProject *project = NULL, QWidget *parent = 0); + explicit TitleBlockPropertiesWidget(QList tbt_collection, const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QETProject *project = NULL, QWidget *parent = 0); ~TitleBlockPropertiesWidget(); void setProperties(const TitleBlockProperties &properties); TitleBlockProperties properties() const; + TitleBlockProperties propertiesAutoNum(QString autoNum) const; + void setPropertiesWithAutoNum(const TitleBlockProperties &properties, QString autoNum); void setTitleBlockTemplatesVisible(const bool &visible); void setReadOnly (const bool &ro); @@ -49,7 +55,7 @@ class TitleBlockPropertiesWidget : public QWidget private: void addCollection (TitleBlockTemplatesCollection *tbt_collection); QString currentTitleBlockTemplateName () const; - void initDialog(const bool ¤t_date); + void initDialog(const bool ¤t_date, QETProject *project); int getIndexFor (const QString &tbt_name, const QET::QetCollection collection) const; private slots: @@ -58,9 +64,12 @@ class TitleBlockPropertiesWidget : public QWidget void updateTemplateList(); void changeCurrentTitleBlockTemplate(int); void on_m_date_now_pb_clicked(); + void on_m_edit_autofolionum_pb_clicked(); signals: void editTitleBlockTemplate(const QString &, bool); + void set_auto_page_num() const; + void openAutoNumFolioEditor (QString); private: Ui::TitleBlockPropertiesWidget *ui; @@ -69,6 +78,7 @@ class TitleBlockPropertiesWidget : public QWidget QMenu *m_tbt_menu; QList m_tbt_collection_list; QList m_map_index_to_collection_type; + QList keys_2; }; #endif // TITLEBLOCKPROPERTIESWIDGET_H diff --git a/sources/ui/titleblockpropertieswidget.ui b/sources/ui/titleblockpropertieswidget.ui index 084d7ff19..2a3f53d0b 100644 --- a/sources/ui/titleblockpropertieswidget.ui +++ b/sources/ui/titleblockpropertieswidget.ui @@ -6,8 +6,8 @@ 0 0 - 530 - 452 + 572 + 590 @@ -33,256 +33,316 @@ 9 - - - Informations des cartouches + + + true - - false - - - false - - - - - - QLayout::SetDefaultConstraint - - - - - Modèle : - - - - - - - - - - - - - - :/ico/16x16/label.png:/ico/16x16/label.png - - - false - - - - - - - - - - 0 - 0 - - - - QTabWidget::South - - - QTabWidget::Rounded - - - 0 - - - Qt::ElideNone - - - true - - - false - - - - Principales - - + + + + 0 + 0 + 552 + 570 + + + + + + + Informations des cartouches + + + false + + + false + + - - - - - Disponible en tant que %folio pour les modèles de cartouches + + + QLayout::SetDefaultConstraint + + + + + Modèle : - - - - Auteur : - - + + - - + + - Afficher : + - - - - - - QFrame::NoFrame + + + :/ico/16x16/label.png:/ico/16x16/label.png - - Les variables suivantes sont utilisables dans le champ Folio : -- %id : numéro du folio courant dans le projet -- %total : nombre total de folios dans le projet - - + false - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - Pas de date - - - - - - - Date courante - - - - - - - Appliquer la date actuelle - - - - - - - :/ico/22x22/start.png:/ico/22x22/start.png - - - - - - - Disponible en tant que %date pour les modèles de cartouches - - - true - - - true - - - - - - - Date fixe : - - - - - - - - - Date : - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Fichier : - - - - - - - Disponible en tant que %title pour les modèles de cartouches - - - - - - - Titre : - - - - - - - Disponible en tant que %author pour les modèles de cartouches - - - - - - - Folio : - - - - - - - Disponible en tant que %filename pour les modèles de cartouches - - - - - - - <html><head/><body><p>Affiche le cartouche en bas (horizontalement) ou à droite (verticalement) du folio.</p></body></html> - - - - en bas - - - - - à droite (expérimental) - - - - - - - Personnalisées - - - - - - - Vous pouvez définir ici vos propres associations noms/valeurs pour que le cartouche en tienne compte. Exemple : + + + + 0 + 0 + + + + QTabWidget::South + + + QTabWidget::Rounded + + + 0 + + + Qt::ElideNone + + + true + + + false + + + + Principales + + + + + + + + Fichier : + + + + + + + QFrame::NoFrame + + + Les variables suivantes sont utilisables dans le champ Folio : +- %id : numéro du folio courant dans le projet +- %total : nombre total de folios dans le projet +- %autonum : Folio Auto Numeration + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Date : + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Folio : + + + + + + + Titre : + + + + + + + Disponible en tant que %folio pour les modèles de cartouches + + + + + + + Disponible en tant que %title pour les modèles de cartouches + + + + + + + <html><head/><body><p>Affiche le cartouche en bas (horizontalement) ou à droite (verticalement) du folio.</p></body></html> + + + + en bas + + + + + à droite (expérimental) + + + + + + + + Disponible en tant que %filename pour les modèles de cartouches + + + + + + + Auteur : + + + + + + + + + Pas de date + + + + + + + Date courante + + + + + + + Appliquer la date actuelle + + + + + + + :/ico/22x22/start.png:/ico/22x22/start.png + + + + + + + Disponible en tant que %date pour les modèles de cartouches + + + true + + + true + + + + + + + Date fixe : + + + + + + + + + Disponible en tant que %author pour les modèles de cartouches + + + + + + + Afficher : + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + + + + + :/ico/16x16/configure.png:/ico/16x16/configure.png + + + + + + + + + Page Num: + + + + + + + + + + Personnalisées + + + + + + + + Vous pouvez définir ici vos propres associations noms/valeurs pour que le cartouche en tienne compte. Exemple : associer le nom "volta" et la valeur "1745" remplacera %{volta} par 1745 dans le cartouche. @@ -300,6 +360,10 @@ associer le nom "volta" et la valeur "1745" remplacera %{vol + + + +