[qet] [3596] Add button to disable/enable auto conductor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3596
Author: blacksun
Date: 2015-01-11 12:10:57 +0100 (Sun, 11 Jan 2015)
Log Message:
-----------
Add button to disable/enable auto conductor
Modified Paths:
--------------
trunk/sources/elementsmover.cpp
trunk/sources/qetdiagrameditor.cpp
trunk/sources/qetdiagrameditor.h
trunk/sources/qetgraphicsitem/terminal.cpp
trunk/sources/qetproject.cpp
trunk/sources/qetproject.h
Modified: trunk/sources/elementsmover.cpp
===================================================================
--- trunk/sources/elementsmover.cpp 2015-01-11 08:50:36 UTC (rev 3595)
+++ trunk/sources/elementsmover.cpp 2015-01-11 11:10:57 UTC (rev 3596)
@@ -134,10 +134,12 @@
current_movement_
);
- //There is only one element moved, we try auto connection of conductor;
+ //There is only one element moved, and project authorize auto conductor,
+ //we try auto connection of conductor;
typedef DiagramContent dc;
if (moved_content_.items(dc::TextFields | dc::Images | dc::Shapes).size() == 0 &&
- moved_content_.items(dc::Elements).size() == 1)
+ moved_content_.items(dc::Elements).size() == 1 &&
+ diagram_ -> project() -> autoConductor())
{
Element *elmt = moved_content_.elements.toList().first();
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2015-01-11 08:50:36 UTC (rev 3595)
+++ trunk/sources/qetdiagrameditor.cpp 2015-01-11 11:10:57 UTC (rev 3596)
@@ -188,6 +188,13 @@
copy = new QAction(QET::Icons::EditCopy, tr("Cop&ier"), this);
paste = new QAction(QET::Icons::EditPaste, tr("C&oller"), this);
conductor_reset = new QAction(QET::Icons::ConductorSettings, tr("R\351initialiser les conducteurs"), this);
+
+ m_auto_conductor = new QAction (QET::Icons::ConductorSettings, tr("Cr\351ation automatique de conducteur(s)","Tool tip of auto conductor"), this);
+ m_auto_conductor -> setStatusTip (tr("Utiliser la cr\351ation automatique de conducteur(s) quand cela est possible", "Status tip of auto conductor"));
+ m_auto_conductor -> setCheckable (true);
+ m_auto_conductor -> setDisabled (true);
+ connect(m_auto_conductor, SIGNAL(triggered(bool)), this, SLOT(slot_autoConductor(bool)));
+
infos_diagram = new QAction(QET::Icons::DialogInformation, tr("Propri\351t\351s du sch\351ma"), this);
prj_edit_prop = new QAction(QET::Icons::DialogInformation, tr("Propri\351t\351s du projet"), this);
prj_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un sch\351ma"), this);
@@ -199,10 +206,10 @@
windowed_view_mode= new QAction( tr("en utilisant des fen\352tres"), this);
mode_selection = new QAction(QET::Icons::PartSelect, tr("Mode Selection"), this);
mode_visualise = new QAction(QET::Icons::ViewMove, tr("Mode Visualisation"), this);
- tile_window = new QAction( tr("&Mosa\357que"), this);
- cascade_window = new QAction( tr("&Cascade"), this);
- next_window = new QAction( tr("Projet suivant"), this);
- prev_window = new QAction( tr("Projet pr\351c\351dent"), this);
+ tile_window = new QAction( tr("&Mosa\357que"), this);
+ cascade_window = new QAction( tr("&Cascade"), this);
+ next_window = new QAction( tr("Projet suivant"), this);
+ prev_window = new QAction( tr("Projet pr\351c\351dent"), this);
///Files action///
QAction *new_file = m_file_actions_group.addAction( QET::Icons::DocumentNew, tr("&Nouveau") );
@@ -454,8 +461,9 @@
view_bar -> addSeparator();
view_bar -> addActions(m_zoom_action_toolBar);
- diagram_bar -> addAction(infos_diagram);
- diagram_bar -> addAction(conductor_reset);
+ diagram_bar -> addAction (infos_diagram);
+ diagram_bar -> addAction (conductor_reset);
+ diagram_bar -> addAction (m_auto_conductor);
m_add_item_toolBar = new QToolBar(tr("Ajouter"), this);
m_add_item_toolBar->setObjectName("adding");
@@ -1179,6 +1187,7 @@
m_add_item_actions_group. setEnabled(editable_project);
m_row_column_actions_group.setEnabled(editable_project);
+
slot_updateUndoStack();
slot_updateModeActions();
slot_updatePasteAction();
@@ -1266,18 +1275,21 @@
}
}
-
/**
- Gere les actions relatives au mode du schema
-*/
+ * @brief QETDiagramEditor::slot_updateModeActions
+ * Manage action who need an opened diagram or project to be updated
+ */
void QETDiagramEditor::slot_updateModeActions() {
DiagramView *dv = currentDiagram();
- // actions ayant aussi besoin d'un document ouvert et de la connaissance de son mode
- if (!dv) {
+ if (!dv)
+ {
grp_visu_sel -> setEnabled(false);
- } else {
- switch((int)(dv -> dragMode())) {
+ }
+ else
+ {
+ switch((int)(dv -> dragMode()))
+ {
case QGraphicsView::NoDrag:
grp_visu_sel -> setEnabled(false);
break;
@@ -1291,6 +1303,15 @@
break;
}
}
+
+
+ if (ProjectView *pv = currentProject())
+ {
+ m_auto_conductor -> setEnabled (true);
+ m_auto_conductor -> setChecked (pv -> project() -> autoConductor());
+ }
+ else
+ m_auto_conductor -> setDisabled(true);
}
/**
@@ -1514,6 +1535,17 @@
}
/**
+ * @brief QETDiagramEditor::slot_autoConductor
+ * @param ac
+ * Update the auto conductor status of current project;
+ */
+void QETDiagramEditor::slot_autoConductor(bool ac)
+{
+ if (ProjectView *pv = currentProject())
+ pv -> project() -> setAutoConductor(ac);
+}
+
+/**
* @brief QETDiagramEditor::slot_addText
* add text to curent diagram
*/
Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h 2015-01-11 08:50:36 UTC (rev 3595)
+++ trunk/sources/qetdiagrameditor.h 2015-01-11 11:10:57 UTC (rev 3596)
@@ -115,6 +115,7 @@
void slot_removeRow();
void editSelectionProperties();
void slot_resetConductors();
+ void slot_autoConductor(bool ac);
void slot_addText();
void slot_addImage();
void slot_addLine();
@@ -179,6 +180,7 @@
QAction *copy; ///< Copy selection to clipboard
QAction *paste; ///< Paste clipboard content on the current diagram
QAction *conductor_reset; ///< Reset paths of selected conductors
+ QAction *m_auto_conductor; ///< Enable/Disable the use of auto conductor
QAction *conductor_default; ///< Show a dialog to edit default conductor properties
QAction *infos_diagram; ///< Show a dialog to edit diagram properties
QAction *prj_edit_prop; ///< Edit the properties of the current project.
Modified: trunk/sources/qetgraphicsitem/terminal.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/terminal.cpp 2015-01-11 08:50:36 UTC (rev 3595)
+++ trunk/sources/qetgraphicsitem/terminal.cpp 2015-01-11 11:10:57 UTC (rev 3596)
@@ -280,19 +280,22 @@
{
if (!m_help_line)
m_help_line = new QGraphicsLineItem(this);
+ m_help_line -> setPen(QPen (Qt::darkBlue));
QLineF line(HelpLine());
- Terminal *t = alignedWithTerminal();
- if (t)
+ if (Diagram *dia = diagram())
{
- line.setP2(t -> dockConductor());
- m_help_line -> setPen(QPen (Qt::darkGreen));
+ if (dia -> project() -> autoConductor())
+ {
+ Terminal *t = alignedWithTerminal();
+ if (t)
+ {
+ line.setP2(t -> dockConductor());
+ m_help_line -> setPen(QPen (Qt::darkGreen));
+ }
+ }
}
- else
- {
- m_help_line -> setPen(QPen (Qt::darkBlue));
- }
//Map the line (in scene coordinate) to help_line coordinate
line.setP1(m_help_line -> mapFromScene(line.p1()));
Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp 2015-01-11 08:50:36 UTC (rev 3595)
+++ trunk/sources/qetproject.cpp 2015-01-11 11:10:57 UTC (rev 3596)
@@ -41,13 +41,14 @@
@param parent QObject parent
*/
QETProject::QETProject(int diagrams, QObject *parent) :
- QObject(parent),
- collection_(0),
- project_qet_version_(-1),
- modified_(false),
- read_only_(false),
- titleblocks_(this),
- folioSheetsQuantity(0)
+ QObject (parent),
+ collection_ (0 ),
+ project_qet_version_ (-1 ),
+ modified_ (false ),
+ read_only_ (false ),
+ titleblocks_ (this ),
+ folioSheetsQuantity (0 ),
+ m_auto_conductor (true )
{
// 0 a n schema(s) vide(s)
int diagrams_count = qMax(0, diagrams);
@@ -75,13 +76,14 @@
@param parent QObject parent
*/
QETProject::QETProject(const QString &path, QObject *parent) :
- QObject(parent),
- collection_(0),
- project_qet_version_(-1),
- modified_(false),
- read_only_(false),
- titleblocks_(this),
- folioSheetsQuantity(0)
+ QObject (parent),
+ collection_ (0 ),
+ project_qet_version_ (-1 ),
+ modified_ (false ),
+ read_only_ (false ),
+ titleblocks_ (this ),
+ folioSheetsQuantity (0 ),
+ m_auto_conductor (true )
{
// ouvre le fichier
QFile project_file(path);
@@ -118,13 +120,14 @@
L'element XML fourni est copie et conserve dans la classe.
*/
QETProject::QETProject(const QDomElement &xml_element, QObject *parent) :
- QObject(parent),
- collection_(0),
- project_qet_version_(-1),
- modified_(false),
- read_only_(false),
- titleblocks_(this),
- folioSheetsQuantity(0)
+ QObject (parent),
+ collection_ (0 ),
+ project_qet_version_ (-1 ),
+ modified_ (false ),
+ read_only_ (false ),
+ titleblocks_ (this ),
+ folioSheetsQuantity (0 ),
+ m_auto_conductor (true )
{
// copie le contenu XML
document_root_.appendChild(document_root_.importNode(xml_element, true));
@@ -506,6 +509,28 @@
}
/**
+ * @brief QETProject::autoConductor
+ * @return true if use of auto conductor is authorized.
+ * See also Q_PROPERTY autoConductor
+ */
+bool QETProject::autoConductor() const
+{
+ return m_auto_conductor;
+}
+
+/**
+ * @brief QETProject::setAutoConductor
+ * @param ac
+ * Enable the use of auto conductor if true
+ * See also Q_PROPERTY autoConductor
+ */
+void QETProject::setAutoConductor(bool ac)
+{
+ if (ac != m_auto_conductor)
+ m_auto_conductor = ac;
+}
+
+/**
@return un document XML representant le projet
*/
QDomDocument QETProject::toXml() {
Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h 2015-01-11 08:50:36 UTC (rev 3595)
+++ trunk/sources/qetproject.h 2015-01-11 11:10:57 UTC (rev 3596)
@@ -45,20 +45,24 @@
collection. This collection enables users to export diagrams on remote
machines without wondering whether required elements are available to them.
*/
-class QETProject : public QObject {
- Q_OBJECT
+class QETProject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool autoConductor READ autoConductor WRITE setAutoConductor)
- // constructors, destructor
+ // constructors, destructor
public:
- QETProject(int = 1, QObject * = 0);
- QETProject(const QString &, QObject * = 0);
- QETProject(const QDomElement &, QObject * = 0);
- virtual ~QETProject();
+ QETProject (int = 1, QObject * = 0);
+ QETProject (const QString &, QObject * = 0);
+ QETProject (const QDomElement &, QObject * = 0);
+ virtual ~QETProject();
private:
- QETProject(const QETProject &);
+ QETProject(const QETProject &);
+ void init ();
- // enums
+ // enums
public:
/**
This enum lists possible states for a particular project.
@@ -72,74 +76,77 @@
FileOpenDiscard = 5 /// the user cancelled the file opening
};
- // methods
+ // methods
public:
- ProjectState state() const;
- QList<Diagram *> diagrams() const;
- int getFolioSheetsQuantity() const; /// get the folio sheets quantity for this project
- void setFolioSheetsQuantity(int); /// set the folio sheets quantity for this project
- int folioIndex(const Diagram *) const;
- ElementsCollection *embeddedCollection() const;
- TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection();
- QString filePath();
- void setFilePath(const QString &);
- QString currentDir() const;
- QString pathNameTitle() const;
- QString title() const;
- qreal declaredQElectroTechVersion();
- void setTitle(const QString &);
- QList<QString> embeddedTitleBlockTemplates();
- const TitleBlockTemplate *getTemplateByName(const QString &template_name);
- QDomElement getTemplateXmlDescriptionByName(const QString &);
- bool setTemplateXmlDescription(const QString &, const QDomElement &);
- void removeTemplateByName(const QString &);
+ ProjectState state() const;
+ QList<Diagram *> diagrams() const;
+ int getFolioSheetsQuantity() const; /// get the folio sheets quantity for this project
+ void setFolioSheetsQuantity(int); /// set the folio sheets quantity for this project
+ int folioIndex(const Diagram *) const;
+ ElementsCollection *embeddedCollection() const;
+ TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection();
+ QString filePath();
+ void setFilePath(const QString &);
+ QString currentDir() const;
+ QString pathNameTitle() const;
+ QString title() const;
+ qreal declaredQElectroTechVersion();
+ void setTitle(const QString &);
+ QList<QString> embeddedTitleBlockTemplates();
+ const TitleBlockTemplate *getTemplateByName(const QString &template_name);
+ QDomElement getTemplateXmlDescriptionByName(const QString &);
+ bool setTemplateXmlDescription(const QString &, const QDomElement &);
+ void removeTemplateByName(const QString &);
- ///DEFAULT PROPERTIES
- BorderProperties defaultBorderProperties() const;
- void setDefaultBorderProperties(const BorderProperties &);
+ ///DEFAULT PROPERTIES
+ BorderProperties defaultBorderProperties() const;
+ void setDefaultBorderProperties(const BorderProperties &);
- TitleBlockProperties defaultTitleBlockProperties() const;
- void setDefaultTitleBlockProperties(const TitleBlockProperties &);
+ TitleBlockProperties defaultTitleBlockProperties() const;
+ void setDefaultTitleBlockProperties(const TitleBlockProperties &);
- ConductorProperties defaultConductorProperties() const;
- void setDefaultConductorProperties(const ConductorProperties &);
+ ConductorProperties defaultConductorProperties() const;
+ void setDefaultConductorProperties(const ConductorProperties &);
- QString defaultReportProperties() const;
- void setDefaultReportProperties (const QString &properties);
+ QString defaultReportProperties() const;
+ void setDefaultReportProperties (const QString &properties);
- XRefProperties defaultXRefProperties (const QString &type) const {return m_default_xref_properties[type];}
- QHash <QString, XRefProperties> defaultXRefProperties() const {return m_default_xref_properties;}
- void setDefaultXRefProperties(const QString type, const XRefProperties &properties);
- void setDefaultXRefProperties(QHash <QString, XRefProperties> hash);
+ XRefProperties defaultXRefProperties (const QString &type) const {return m_default_xref_properties[type];}
+ QHash <QString, XRefProperties> defaultXRefProperties() const {return m_default_xref_properties;}
+ void setDefaultXRefProperties(const QString type, const XRefProperties &properties);
+ void setDefaultXRefProperties(QHash <QString, XRefProperties> hash);
- QHash <QString, NumerotationContext> conductorAutoNum() const;
- void addConductorAutoNum (QString key, NumerotationContext context);
- void removeConductorAutonum (QString key);
- NumerotationContext conductorAutoNum(const QString &key) const;
+ QHash <QString, NumerotationContext> conductorAutoNum() const;
+ void addConductorAutoNum (QString key, NumerotationContext context);
+ void removeConductorAutonum (QString key);
+ NumerotationContext conductorAutoNum(const QString &key) const;
- QDomDocument toXml();
- bool close();
- QETResult write();
- bool isReadOnly() const;
- void setReadOnly(bool);
- bool isEmpty() const;
- bool ensureIntegrationCategoryExists();
- ElementsCategory *integrationCategory() const;
- QString integrateElement(const QString &, QString &);
- QString integrateElement(const QString &, MoveElementsHandler *, QString &);
- QString integrateTitleBlockTemplate(const TitleBlockTemplateLocation &, MoveTitleBlockTemplatesHandler *handler);
- bool usesElement(const ElementsLocation &);
- bool usesTitleBlockTemplate(const TitleBlockTemplateLocation &);
- void cleanUnusedTitleBlocKTemplates();
- void cleanUnusedElements(MoveElementsHandler *);
- void cleanEmptyCategories(MoveElementsHandler *);
- bool projectWasModified();
- bool projectOptionsWereModified();
- bool embeddedCollectionWasModified();
- bool titleBlockTemplateCollectionWasModified();
- DiagramContext projectProperties();
- void setProjectProperties(const DiagramContext &);
- QUndoStack* undoStack() {return undo_stack_;}
+ bool autoConductor () const;
+ void setAutoConductor (bool ac);
+
+ QDomDocument toXml();
+ bool close();
+ QETResult write();
+ bool isReadOnly() const;
+ void setReadOnly(bool);
+ bool isEmpty() const;
+ bool ensureIntegrationCategoryExists();
+ ElementsCategory *integrationCategory() const;
+ QString integrateElement(const QString &, QString &);
+ QString integrateElement(const QString &, MoveElementsHandler *, QString &);
+ QString integrateTitleBlockTemplate(const TitleBlockTemplateLocation &, MoveTitleBlockTemplatesHandler *handler);
+ bool usesElement(const ElementsLocation &);
+ bool usesTitleBlockTemplate(const TitleBlockTemplateLocation &);
+ void cleanUnusedTitleBlocKTemplates();
+ void cleanUnusedElements(MoveElementsHandler *);
+ void cleanEmptyCategories(MoveElementsHandler *);
+ bool projectWasModified();
+ bool projectOptionsWereModified();
+ bool embeddedCollectionWasModified();
+ bool titleBlockTemplateCollectionWasModified();
+ DiagramContext projectProperties();
+ void setProjectProperties(const DiagramContext &);
+ QUndoStack* undoStack() {return undo_stack_;}
public slots:
void componentWritten();
@@ -229,6 +236,7 @@
QHash <QString, NumerotationContext> m_conductor_autonum;
/// Folio List Sheets quantity for this project.
int folioSheetsQuantity;
+ bool m_auto_conductor;
};
Q_DECLARE_METATYPE(QETProject *)
#endif