Add button to disable/enable auto conductor

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3596 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-01-11 11:10:57 +00:00
parent 8079b2e83a
commit 811142bff7
6 changed files with 185 additions and 113 deletions

View File

@@ -134,10 +134,12 @@ void ElementsMover::endMovement()
current_movement_ 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; typedef DiagramContent dc;
if (moved_content_.items(dc::TextFields | dc::Images | dc::Shapes).size() == 0 && 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(); Element *elmt = moved_content_.elements.toList().first();

View File

@@ -188,6 +188,13 @@ void QETDiagramEditor::setUpActions() {
copy = new QAction(QET::Icons::EditCopy, tr("Cop&ier"), this); copy = new QAction(QET::Icons::EditCopy, tr("Cop&ier"), this);
paste = new QAction(QET::Icons::EditPaste, tr("C&oller"), this); paste = new QAction(QET::Icons::EditPaste, tr("C&oller"), this);
conductor_reset = new QAction(QET::Icons::ConductorSettings, tr("R\351initialiser les conducteurs"), 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); 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_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); prj_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un sch\351ma"), this);
@@ -456,6 +463,7 @@ void QETDiagramEditor::setUpToolBar() {
diagram_bar -> addAction (infos_diagram); diagram_bar -> addAction (infos_diagram);
diagram_bar -> addAction (conductor_reset); diagram_bar -> addAction (conductor_reset);
diagram_bar -> addAction (m_auto_conductor);
m_add_item_toolBar = new QToolBar(tr("Ajouter"), this); m_add_item_toolBar = new QToolBar(tr("Ajouter"), this);
m_add_item_toolBar->setObjectName("adding"); m_add_item_toolBar->setObjectName("adding");
@@ -1179,6 +1187,7 @@ void QETDiagramEditor::slot_updateActions()
m_add_item_actions_group. setEnabled(editable_project); m_add_item_actions_group. setEnabled(editable_project);
m_row_column_actions_group.setEnabled(editable_project); m_row_column_actions_group.setEnabled(editable_project);
slot_updateUndoStack(); slot_updateUndoStack();
slot_updateModeActions(); slot_updateModeActions();
slot_updatePasteAction(); slot_updatePasteAction();
@@ -1266,18 +1275,21 @@ void QETDiagramEditor::slot_updateComplexActions() {
} }
} }
/** /**
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() { void QETDiagramEditor::slot_updateModeActions() {
DiagramView *dv = currentDiagram(); 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); grp_visu_sel -> setEnabled(false);
} else { }
switch((int)(dv -> dragMode())) { else
{
switch((int)(dv -> dragMode()))
{
case QGraphicsView::NoDrag: case QGraphicsView::NoDrag:
grp_visu_sel -> setEnabled(false); grp_visu_sel -> setEnabled(false);
break; break;
@@ -1291,6 +1303,15 @@ void QETDiagramEditor::slot_updateModeActions() {
break; break;
} }
} }
if (ProjectView *pv = currentProject())
{
m_auto_conductor -> setEnabled (true);
m_auto_conductor -> setChecked (pv -> project() -> autoConductor());
}
else
m_auto_conductor -> setDisabled(true);
} }
/** /**
@@ -1513,6 +1534,17 @@ void QETDiagramEditor::slot_resetConductors() {
} }
} }
/**
* @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 * @brief QETDiagramEditor::slot_addText
* add text to curent diagram * add text to curent diagram

View File

@@ -115,6 +115,7 @@ class QETDiagramEditor : public QETMainWindow {
void slot_removeRow(); void slot_removeRow();
void editSelectionProperties(); void editSelectionProperties();
void slot_resetConductors(); void slot_resetConductors();
void slot_autoConductor(bool ac);
void slot_addText(); void slot_addText();
void slot_addImage(); void slot_addImage();
void slot_addLine(); void slot_addLine();
@@ -179,6 +180,7 @@ class QETDiagramEditor : public QETMainWindow {
QAction *copy; ///< Copy selection to clipboard QAction *copy; ///< Copy selection to clipboard
QAction *paste; ///< Paste clipboard content on the current diagram QAction *paste; ///< Paste clipboard content on the current diagram
QAction *conductor_reset; ///< Reset paths of selected conductors 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 *conductor_default; ///< Show a dialog to edit default conductor properties
QAction *infos_diagram; ///< Show a dialog to edit diagram properties QAction *infos_diagram; ///< Show a dialog to edit diagram properties
QAction *prj_edit_prop; ///< Edit the properties of the current project. QAction *prj_edit_prop; ///< Edit the properties of the current project.

View File

@@ -280,18 +280,21 @@ void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidg
{ {
if (!m_help_line) if (!m_help_line)
m_help_line = new QGraphicsLineItem(this); m_help_line = new QGraphicsLineItem(this);
m_help_line -> setPen(QPen (Qt::darkBlue));
QLineF line(HelpLine()); QLineF line(HelpLine());
if (Diagram *dia = diagram())
{
if (dia -> project() -> autoConductor())
{
Terminal *t = alignedWithTerminal(); Terminal *t = alignedWithTerminal();
if (t) if (t)
{ {
line.setP2(t -> dockConductor()); line.setP2(t -> dockConductor());
m_help_line -> setPen(QPen (Qt::darkGreen)); 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 //Map the line (in scene coordinate) to help_line coordinate

View File

@@ -47,7 +47,8 @@ QETProject::QETProject(int diagrams, QObject *parent) :
modified_ (false ), modified_ (false ),
read_only_ (false ), read_only_ (false ),
titleblocks_ (this ), titleblocks_ (this ),
folioSheetsQuantity(0) folioSheetsQuantity (0 ),
m_auto_conductor (true )
{ {
// 0 a n schema(s) vide(s) // 0 a n schema(s) vide(s)
int diagrams_count = qMax(0, diagrams); int diagrams_count = qMax(0, diagrams);
@@ -81,7 +82,8 @@ QETProject::QETProject(const QString &path, QObject *parent) :
modified_ (false ), modified_ (false ),
read_only_ (false ), read_only_ (false ),
titleblocks_ (this ), titleblocks_ (this ),
folioSheetsQuantity(0) folioSheetsQuantity (0 ),
m_auto_conductor (true )
{ {
// ouvre le fichier // ouvre le fichier
QFile project_file(path); QFile project_file(path);
@@ -124,7 +126,8 @@ QETProject::QETProject(const QDomElement &xml_element, QObject *parent) :
modified_ (false ), modified_ (false ),
read_only_ (false ), read_only_ (false ),
titleblocks_ (this ), titleblocks_ (this ),
folioSheetsQuantity(0) folioSheetsQuantity (0 ),
m_auto_conductor (true )
{ {
// copie le contenu XML // copie le contenu XML
document_root_.appendChild(document_root_.importNode(xml_element, true)); document_root_.appendChild(document_root_.importNode(xml_element, true));
@@ -505,6 +508,28 @@ NumerotationContext QETProject::conductorAutoNum (const QString &key) const {
else return NumerotationContext(); else return NumerotationContext();
} }
/**
* @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 @return un document XML representant le projet
*/ */

View File

@@ -45,9 +45,12 @@ class NumerotationContext;
collection. This collection enables users to export diagrams on remote collection. This collection enables users to export diagrams on remote
machines without wondering whether required elements are available to them. machines without wondering whether required elements are available to them.
*/ */
class QETProject : public QObject { class QETProject : public QObject
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool autoConductor READ autoConductor WRITE setAutoConductor)
// constructors, destructor // constructors, destructor
public: public:
QETProject (int = 1, QObject * = 0); QETProject (int = 1, QObject * = 0);
@@ -57,6 +60,7 @@ class QETProject : public QObject {
private: private:
QETProject(const QETProject &); QETProject(const QETProject &);
void init ();
// enums // enums
public: public:
@@ -117,6 +121,9 @@ class QETProject : public QObject {
void removeConductorAutonum (QString key); void removeConductorAutonum (QString key);
NumerotationContext conductorAutoNum(const QString &key) const; NumerotationContext conductorAutoNum(const QString &key) const;
bool autoConductor () const;
void setAutoConductor (bool ac);
QDomDocument toXml(); QDomDocument toXml();
bool close(); bool close();
QETResult write(); QETResult write();
@@ -229,6 +236,7 @@ class QETProject : public QObject {
QHash <QString, NumerotationContext> m_conductor_autonum; QHash <QString, NumerotationContext> m_conductor_autonum;
/// Folio List Sheets quantity for this project. /// Folio List Sheets quantity for this project.
int folioSheetsQuantity; int folioSheetsQuantity;
bool m_auto_conductor;
}; };
Q_DECLARE_METATYPE(QETProject *) Q_DECLARE_METATYPE(QETProject *)
#endif #endif