mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Diagram editor: added "Find in panel" and "Edit" actions to the context menu.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2040 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
d36820ca2b
commit
62688aa0da
@ -1186,6 +1186,8 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
context_menu -> addAction(qde -> delete_selection);
|
||||
context_menu -> addAction(qde -> rotate_selection);
|
||||
context_menu -> addAction(qde -> rotate_texts);
|
||||
context_menu -> addAction(qde -> find_element);
|
||||
context_menu -> addAction(qde -> edit_element);
|
||||
context_menu -> addAction(qde -> selection_prop);
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,13 @@
|
||||
*/
|
||||
#include "qetdiagrameditor.h"
|
||||
#include "qetapp.h"
|
||||
#include "diagramcontent.h"
|
||||
#include "diagramview.h"
|
||||
#include "diagram.h"
|
||||
#include "element.h"
|
||||
#include "elementspanelwidget.h"
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include "customelement.h"
|
||||
#include "qetproject.h"
|
||||
#include "projectview.h"
|
||||
#include "recentfiles.h"
|
||||
@ -202,6 +205,8 @@ void QETDiagramEditor::actions() {
|
||||
delete_selection = new QAction(QET::Icons::EditDelete, tr("Supprimer"), this);
|
||||
rotate_selection = new QAction(QET::Icons::ObjectRotateRight, tr("Pivoter"), this);
|
||||
rotate_texts = new QAction(QET::Icons::ObjectRotateRight, tr("Orienter les textes"), this);
|
||||
find_element = new QAction( tr("Retrouver dans le panel"), this);
|
||||
edit_element = new QAction(QET::Icons::ElementEdit, tr("\311diter l'\351l\351ment"), this);
|
||||
selection_prop = new QAction(QET::Icons::DialogInformation, tr("Propri\351t\351s de la s\351lection"), this);
|
||||
conductor_reset = new QAction(QET::Icons::ConductorSettings, tr("R\351initialiser les conducteurs"), this);
|
||||
infos_diagram = new QAction(QET::Icons::DialogInformation, tr("Propri\351t\351s du sch\351ma"), this);
|
||||
@ -297,6 +302,8 @@ void QETDiagramEditor::actions() {
|
||||
delete_selection -> setStatusTip(tr("Enl\350ve les \351l\351ments s\351lectionn\351s du sch\351ma", "status bar tip"));
|
||||
rotate_selection -> setStatusTip(tr("Pivote les \351l\351ments et textes s\351lectionn\351s", "status bar tip"));
|
||||
rotate_texts -> setStatusTip(tr("Pivote les textes s\351lectionn\351s \340 un angle pr\351cis", "status bar tip"));
|
||||
find_element -> setStatusTip(tr("Retrouve l'\351l\351ment s\351lectionn\351 dans le panel", "status bar tip"));
|
||||
edit_element -> setStatusTip(tr("Retrouve l'\351l\351ment s\351lectionn\351 dans le panel avant de l'\351diter", "status bar tip"));
|
||||
selection_prop -> setStatusTip(tr("\311dite les propri\351t\351s des objets s\351lectionn\351", "status bar tip"));
|
||||
conductor_reset -> setStatusTip(tr("Recalcule les chemins des conducteurs sans tenir compte des modifications", "status bar tip"));
|
||||
infos_diagram -> setStatusTip(tr("\311dite les informations affich\351es par le cartouche", "status bar tip"));
|
||||
@ -348,6 +355,9 @@ void QETDiagramEditor::actions() {
|
||||
connect(delete_selection, SIGNAL(triggered()), this, SLOT(slot_delete()) );
|
||||
connect(rotate_selection, SIGNAL(triggered()), this, SLOT(slot_rotate()) );
|
||||
connect(rotate_texts, SIGNAL(triggered()), this, SLOT(slot_rotateTexts()) );
|
||||
connect(find_element, SIGNAL(triggered()), this, SLOT(findSelectedElementInPanel()));
|
||||
connect(edit_element, SIGNAL(triggered()), this, SLOT(findSelectedElementInPanel()));
|
||||
connect(edit_element, SIGNAL(triggered()), this, SLOT(editSelectedElementInEditor()));
|
||||
connect(windowed_view_mode, SIGNAL(triggered()), this, SLOT(setWindowedMode()) );
|
||||
connect(tabbed_view_mode, SIGNAL(triggered()), this, SLOT(setTabbedMode()) );
|
||||
connect(mode_selection, SIGNAL(triggered()), this, SLOT(slot_setSelectionMode()) );
|
||||
@ -868,6 +878,33 @@ DiagramView *QETDiagramEditor::currentDiagram() const {
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@return the selected element in the current diagram view, or 0 if:
|
||||
* no diagram is being viewed in this editor.
|
||||
* no element is selected
|
||||
* more than one element is selected
|
||||
*/
|
||||
Element *QETDiagramEditor::currentElement() const {
|
||||
DiagramView *dv = currentDiagram();
|
||||
if (!dv) return(0);
|
||||
|
||||
QList<Element *> selected_elements = dv -> diagram() -> selectedContent().elements.toList();
|
||||
if (selected_elements.count() != 1) return(0);
|
||||
|
||||
return(selected_elements.first());
|
||||
}
|
||||
|
||||
/**
|
||||
@return the selected element in the current diagram view, or 0 if:
|
||||
* no diagram is being viewed in this editor.
|
||||
* no element is selected
|
||||
* more than one element is selected
|
||||
* the selected element is not a custom element
|
||||
*/
|
||||
CustomElement *QETDiagramEditor::currentCustomElement() const {
|
||||
return(dynamic_cast<CustomElement *>(currentElement()));
|
||||
}
|
||||
|
||||
/**
|
||||
Cette methode permet de retrouver le projet contenant un schema donne.
|
||||
@param diagram_view Schema dont il faut retrouver
|
||||
@ -1130,6 +1167,11 @@ void QETDiagramEditor::slot_updateComplexActions() {
|
||||
int selected_conductors_count = dv ? dv -> diagram() -> selectedConductors().count() : 0;
|
||||
conductor_reset -> setEnabled(editable_diagram && selected_conductors_count);
|
||||
|
||||
// number of selected elements
|
||||
int selected_elements_count = dv ? dv -> diagram() -> selectedContent().count(DiagramContent::Elements) : 0;
|
||||
find_element -> setEnabled(selected_elements_count == 1);
|
||||
edit_element -> setEnabled(selected_elements_count == 1);
|
||||
|
||||
// actions ayant aussi besoin d'items (elements, conducteurs, textes, ...) selectionnes
|
||||
bool copiable_items = dv ? (dv -> hasCopiableItems()) : false;
|
||||
bool deletable_items = dv ? (dv -> hasDeletableItems()) : false;
|
||||
@ -1719,6 +1761,15 @@ void QETDiagramEditor::findElementInPanel(const ElementsLocation &location) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Search the panel for the definition for the selected element in the current
|
||||
diagram view.
|
||||
*/
|
||||
void QETDiagramEditor::findSelectedElementInPanel() {
|
||||
if (CustomElement *selected_element = currentCustomElement()) {
|
||||
findElementInPanel(selected_element -> location());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Lance l'editeur d'element pour l'element filename
|
||||
@ -1728,6 +1779,16 @@ void QETDiagramEditor::editElementInEditor(const ElementsLocation &location) {
|
||||
QETApp::instance() -> openElementLocations(QList<ElementsLocation>() << location);
|
||||
}
|
||||
|
||||
/**
|
||||
Launch an element editor to edit the selected element in the current
|
||||
diagram view.
|
||||
*/
|
||||
void QETDiagramEditor::editSelectedElementInEditor() {
|
||||
if (CustomElement *selected_element = currentCustomElement()) {
|
||||
editElementInEditor(selected_element -> location());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Show the error message contained in \a result.
|
||||
*/
|
||||
|
@ -26,8 +26,10 @@
|
||||
class QETProject;
|
||||
class QETResult;
|
||||
class ProjectView;
|
||||
class CustomElement;
|
||||
class Diagram;
|
||||
class DiagramView;
|
||||
class Element;
|
||||
class ElementsPanelWidget;
|
||||
class ElementsLocation;
|
||||
class RecentFiles;
|
||||
@ -69,6 +71,8 @@ class QETDiagramEditor : public QETMainWindow {
|
||||
bool addProject(QETProject *, bool = true);
|
||||
ProjectView *currentProject() const;
|
||||
DiagramView *currentDiagram() const;
|
||||
Element *currentElement() const;
|
||||
CustomElement * currentCustomElement() const;
|
||||
ProjectView *findProject(DiagramView *) const;
|
||||
ProjectView *findProject(Diagram *) const;
|
||||
ProjectView *findProject(QETProject *) const;
|
||||
@ -145,7 +149,9 @@ class QETDiagramEditor : public QETMainWindow {
|
||||
void diagramIsAboutToBeRemoved(DiagramView *);
|
||||
void diagramWasRemoved(DiagramView *);
|
||||
void findElementInPanel(const ElementsLocation &);
|
||||
void findSelectedElementInPanel();
|
||||
void editElementInEditor(const ElementsLocation &);
|
||||
void editSelectedElementInEditor();
|
||||
void showError(const QETResult &);
|
||||
void showError(const QString &);
|
||||
|
||||
@ -179,6 +185,8 @@ class QETDiagramEditor : public QETMainWindow {
|
||||
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
|
||||
QAction *edit_element; ///< Edit the selected element
|
||||
QAction *selection_prop; ///< Show a dialog describing the selection
|
||||
QAction *conductor_reset; ///< Reset paths of selected conductors
|
||||
QAction *conductor_default; ///< Show a dialog to edit default conductor properties
|
||||
|
Loading…
x
Reference in New Issue
Block a user