[qet] [4637] QetDiagramEditor : add option 'Display grid'

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4637
Author:   blacksun
Date:     2016-08-18 18:30:24 +0200 (Thu, 18 Aug 2016)
Log Message:
-----------
QetDiagramEditor : add option 'Display grid'

Modified Paths:
--------------
    trunk/sources/diagramview.cpp
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetdiagrameditor.h

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2016-08-17 13:00:32 UTC (rev 4636)
+++ trunk/sources/diagramview.cpp	2016-08-18 16:30:24 UTC (rev 4637)
@@ -884,7 +884,10 @@
 */
 void DiagramView::adjustGridToZoom() {
 	QRectF viewed_scene = viewedSceneRect();
-	scene -> setDisplayGrid(viewed_scene.width() < 2000 || viewed_scene.height() < 2000);
+	if (diagramEditor()->drawGrid())
+		scene->setDisplayGrid(viewed_scene.width() < 2000 || viewed_scene.height() < 2000);
+	else
+		scene->setDisplayGrid(false);
 }
 
 /**

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2016-08-17 13:00:32 UTC (rev 4636)
+++ trunk/sources/qetdiagrameditor.cpp	2016-08-18 16:30:24 UTC (rev 4637)
@@ -277,6 +277,18 @@
 			this->currentDiagram()->diagram()->update();
 	});
 
+	m_draw_grid = new QAction (tr("Afficher la grille"), this);
+	m_draw_grid->setStatusTip(tr("Affiche ou masque la grille des folios"));
+	m_draw_grid->setCheckable(true);
+	m_draw_grid->setChecked(true);
+	connect(m_draw_grid, &QAction::triggered, [this](bool checked) {
+		foreach (ProjectView *prjv, this->openedProjects())
+			foreach (Diagram *d, prjv->project()->diagrams()) {
+				d->setDisplayGrid(checked);
+				d->update();
+			}
+	});
+
 	infos_diagram     = new QAction(QET::Icons::DialogInformation,     tr("Propriétés du folio"),                 this);
 	infos_diagram    -> setShortcut( QKeySequence( tr("Ctrl+L")		) );
 	prj_edit_prop     = new QAction(QET::Icons::DialogInformation,     tr("Propriétés du projet"),                 this);
@@ -525,6 +537,7 @@
 	view_bar -> addAction(mode_selection);
 	view_bar -> addAction(mode_visualise);
 	view_bar -> addSeparator();
+	view_bar -> addAction(m_draw_grid);
 	view_bar -> addAction (m_grey_background);
 	view_bar -> addSeparator();
 	view_bar -> addActions(m_zoom_action_toolBar);
@@ -617,6 +630,7 @@
 	menu_affichage -> addAction(mode_selection);
 	menu_affichage -> addAction(mode_visualise);
 	menu_affichage -> addSeparator();
+	menu_affichage -> addAction(m_draw_grid);
 	menu_affichage -> addAction(m_grey_background);
 	menu_affichage -> addSeparator();
 	menu_affichage -> addActions(m_zoom_actions_group.actions());
@@ -1574,6 +1588,14 @@
 }
 
 /**
+ * @brief QETDiagramEditor::drawGrid
+ * @return true if the grid of folio must be displayed
+ */
+bool QETDiagramEditor::drawGrid() const {
+	return m_draw_grid->isChecked();
+}
+
+/**
  * @brief QETDiagramEditor::acessCurrentDiagramView
  * Retrieve current DiagramView used in diagram editor
  */

Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h	2016-08-17 13:00:32 UTC (rev 4636)
+++ trunk/sources/qetdiagrameditor.h	2016-08-18 16:30:24 UTC (rev 4637)
@@ -69,6 +69,7 @@
 		ProjectView         *viewForFile       (const QString &) const;
 		ProjectView         *acessCurrentProject ();
 		DiagramView         *acessCurrentDiagramView ();
+		bool drawGrid() const;
 
 	protected:
 	virtual bool event(QEvent *);
@@ -156,7 +157,7 @@
 		void activeUndoStackCleanChanged (bool clean);
 
 		// attributes
-	public:
+	private:
 		// Actions reachable through menus within QElectroTech
 		QActionGroup *grp_visu_sel;  ///< Action group for visualisation vs edition mode
 		QActionGroup *grp_view_mode; ///< Action group for project
@@ -169,14 +170,17 @@
 		QAction *quit_editor;        ///< Quit the diagram editor
 		QAction *undo;               ///< Cancel the latest action
 		QAction *redo;               ///< Redo the latest cancelled operation
+	public:
+		QAction *infos_diagram;      ///< Show a dialog to edit diagram properties
+		QAction *conductor_reset;    ///< Reset paths of selected conductors
 		QAction *cut;                ///< Cut selection to clipboard
 		QAction *copy;               ///< Copy selection to clipboard
+	private:
 		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 *m_grey_background;  ///< Switch the background color in white or grey
-		QAction *infos_diagram;      ///< Show a dialog to edit diagram properties
+		QAction *m_draw_grid;        ///< Switch the background grid display or not
 		QAction *prj_edit_prop;      ///< Edit the properties of the current project.
 		QAction *prj_add_diagram;    ///< Add a diagram to the current project.
 		QAction *prj_del_diagram;    ///< Delete a diagram from the current project
@@ -196,20 +200,20 @@
 
 		QActionGroup m_select_actions_group; ///Action related to global selections
 
+	public:
+		QActionGroup m_row_column_actions_group; /// Action related to add/remove rows/column in diagram
 		QActionGroup m_selection_actions_group; ///Action related to edit a selected item
+	private:
 		QAction *delete_selection;				///< Delete selection
 		QAction *rotate_selection;				///< Rotate selected elements and text items by 90 degrees
 		QAction *rotate_texts;					///< Direct selected text items to a specific angle
 		QAction *find_element;					///< Find the selected element in the panel
 
-		QActionGroup m_row_column_actions_group; /// Action related to add/remove rows/column in diagram
-
 		QActionGroup m_file_actions_group; ///Actions related to file (open, close, save...)
 		QAction *close_file;			   ///< Close current project file
 		QAction *save_file;				   ///< Save current project
 		QAction *save_file_as;			   ///< Save current project as a specific file
 
-	private:
 		QMdiArea workspace;
 		QSignalMapper windowMapper;
 		/// Directory to use for file dialogs such as File > save


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/