mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-05 20:20:52 +01:00
Forget qet.cpp and qet.h from previous comit.
Add new function for create QAction used for edit the depth of items. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5402 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -343,11 +343,11 @@ void ChangeNamesCommand::redo() {
|
||||
*/
|
||||
ChangeZValueCommand::ChangeZValueCommand(
|
||||
ElementScene *elmt,
|
||||
ChangeZValueCommand::Option o,
|
||||
QET::DepthOption o,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
ElementEditionCommand(elmt, nullptr, parent),
|
||||
option(o)
|
||||
m_option(o)
|
||||
{
|
||||
// retrieve all primitives but terminals
|
||||
QList<QGraphicsItem *> items_list = m_scene -> zItems(ElementScene::SortByZValue | ElementScene::SelectedOrNot);
|
||||
@@ -356,16 +356,16 @@ ChangeZValueCommand::ChangeZValueCommand(
|
||||
foreach(QGraphicsItem *qgi, items_list) undo_hash.insert(qgi, qgi -> zValue());
|
||||
|
||||
// choisit le nom en fonction du traitement
|
||||
if (option == BringForward) {
|
||||
if (m_option == QET::BringForward) {
|
||||
setText(QObject::tr("amener au premier plan", "undo caption"));
|
||||
applyBringForward(items_list);
|
||||
} else if (option == Raise) {
|
||||
} else if (m_option == QET::Raise) {
|
||||
setText(QObject::tr("rapprocher", "undo caption"));
|
||||
applyRaise(items_list);
|
||||
} else if (option == Lower) {
|
||||
} else if (m_option == QET::Lower) {
|
||||
setText(QObject::tr("éloigner", "undo caption"));
|
||||
applyLower(items_list);
|
||||
} else if (option == SendBackward) {
|
||||
} else if (m_option == QET::SendBackward) {
|
||||
setText(QObject::tr("envoyer au fond", "undo caption"));
|
||||
applySendBackward(items_list);
|
||||
}
|
||||
|
||||
@@ -197,17 +197,11 @@ class ChangeNamesCommand : public ElementEditionCommand {
|
||||
This command changes the zValue of a set of primitives when editing an
|
||||
electrical element.
|
||||
*/
|
||||
class ChangeZValueCommand : public ElementEditionCommand {
|
||||
// constructors, destructor
|
||||
class ChangeZValueCommand : public ElementEditionCommand
|
||||
{
|
||||
// constructors, destructor
|
||||
public:
|
||||
/// List the various kind of changes for the zValue
|
||||
enum Option {
|
||||
BringForward, ///< Bring primitives to the foreground so they have the highest zValue
|
||||
Raise, ///< Raise primitives one layer above their current one; zValues are incremented
|
||||
Lower, ///< Send primitives one layer below their current one; zValues are decremented
|
||||
SendBackward ///< Send primitives to the background so they have the lowest zValue
|
||||
};
|
||||
ChangeZValueCommand(ElementScene *, Option, QUndoCommand * = nullptr);
|
||||
ChangeZValueCommand(ElementScene *, QET::DepthOption , QUndoCommand * = nullptr);
|
||||
~ChangeZValueCommand() override;
|
||||
private:
|
||||
ChangeZValueCommand(const ChangeZValueCommand &);
|
||||
@@ -230,7 +224,7 @@ class ChangeZValueCommand : public ElementEditionCommand {
|
||||
/// associates impacted primitives with their new zValues
|
||||
QHash<QGraphicsItem *, qreal> redo_hash;
|
||||
/// kind of treatment to apply
|
||||
Option option;
|
||||
QET::DepthOption m_option;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -759,38 +759,6 @@ void ElementScene::slot_editNames() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Amene les elements selectionnes au premier plan
|
||||
*/
|
||||
void ElementScene::slot_bringForward() {
|
||||
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::BringForward));
|
||||
emit(partsZValueChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
Remonte les elements selectionnes d'un plan
|
||||
*/
|
||||
void ElementScene::slot_raise() {
|
||||
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::Raise));
|
||||
emit(partsZValueChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
Descend les elements selectionnes d'un plan
|
||||
*/
|
||||
void ElementScene::slot_lower() {
|
||||
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::Lower));
|
||||
emit(partsZValueChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
Envoie les elements selectionnes au fond
|
||||
*/
|
||||
void ElementScene::slot_sendBackward() {
|
||||
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::SendBackward));
|
||||
emit(partsZValueChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
@return the list of primitives currently present on the scene.
|
||||
*/
|
||||
|
||||
@@ -152,10 +152,6 @@ class ElementScene : public QGraphicsScene
|
||||
void slot_editNames();
|
||||
void slot_editAuthorInformations();
|
||||
void slot_editProperties();
|
||||
void slot_bringForward();
|
||||
void slot_raise();
|
||||
void slot_lower();
|
||||
void slot_sendBackward();
|
||||
void managePrimitivesGroups();
|
||||
void stackAction(ElementEditionCommand *);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "recentfiles.h"
|
||||
#include "qeticons.h"
|
||||
#include "qetmessagebox.h"
|
||||
#include "editorcommands.h"
|
||||
|
||||
// editeurs de primitives
|
||||
#include "arceditor.h"
|
||||
@@ -224,30 +225,17 @@ void QETElementEditor::setupActions() {
|
||||
connect(edit_author, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_editAuthorInformations()));
|
||||
connect(m_edit_properties, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_editProperties()));
|
||||
|
||||
|
||||
/*
|
||||
* Action related to change depth of primitive
|
||||
*/
|
||||
m_depth_ag = new QActionGroup(this);
|
||||
|
||||
QAction *edit_forward = new QAction(QET::Icons::BringForward, tr("Amener au premier plan"), m_depth_ag);
|
||||
QAction *edit_raise = new QAction(QET::Icons::Raise, tr("Rapprocher"), m_depth_ag);
|
||||
QAction *edit_lower = new QAction(QET::Icons::Lower, tr("Éloigner"), m_depth_ag);
|
||||
QAction *edit_backward = new QAction(QET::Icons::SendBackward, tr("Envoyer au fond"), m_depth_ag);
|
||||
|
||||
edit_raise -> setShortcut(QKeySequence(tr("Ctrl+Shift+Up")));
|
||||
edit_lower -> setShortcut(QKeySequence(tr("Ctrl+Shift+Down")));
|
||||
edit_backward -> setShortcut(QKeySequence(tr("Ctrl+Shift+End")));
|
||||
edit_forward -> setShortcut(QKeySequence(tr("Ctrl+Shift+Home")));
|
||||
|
||||
connect(edit_forward, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_bringForward() ));
|
||||
connect(edit_raise, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_raise() ));
|
||||
connect(edit_lower, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_lower() ));
|
||||
connect(edit_backward, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_sendBackward() ));
|
||||
|
||||
//Action related to change depth of primitive
|
||||
m_depth_action_group = QET::depthActionGroup(this);
|
||||
|
||||
connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) {
|
||||
this->elementScene()->undoStack().push(new ChangeZValueCommand(this->elementScene(), action->data().value<QET::DepthOption>()));
|
||||
emit(this->elementScene()->partsZValueChanged());
|
||||
});
|
||||
|
||||
depth_toolbar = addToolBar(tr("Profondeur", "toolbar title"));
|
||||
depth_toolbar -> setObjectName("depth_toolbar");
|
||||
depth_toolbar -> addActions(m_depth_ag -> actions());
|
||||
depth_toolbar -> addActions(m_depth_action_group -> actions());
|
||||
addToolBar(Qt::TopToolBarArea, depth_toolbar);
|
||||
|
||||
|
||||
@@ -402,7 +390,7 @@ void QETElementEditor::setupMenus() {
|
||||
edit_menu -> addAction(edit_author);
|
||||
edit_menu -> addAction(m_edit_properties);
|
||||
edit_menu -> addSeparator();
|
||||
edit_menu -> addActions(m_depth_ag -> actions());
|
||||
edit_menu -> addActions(m_depth_action_group -> actions());
|
||||
|
||||
display_menu -> addActions(m_zoom_ag -> actions());
|
||||
|
||||
@@ -432,7 +420,7 @@ void QETElementEditor::contextMenu(QPoint p)
|
||||
menu.addAction(paste_in_area);
|
||||
menu.addMenu(paste_from_menu);
|
||||
menu.addSeparator();
|
||||
menu.addActions(m_depth_ag -> actions());
|
||||
menu.addActions(m_depth_action_group -> actions());
|
||||
|
||||
//Remove from the context menu the actions which are disabled.
|
||||
const QList<QAction *>actions = menu.actions();
|
||||
@@ -467,7 +455,7 @@ void QETElementEditor::slot_updateMenus() {
|
||||
cut -> setEnabled(selected_items);
|
||||
copy -> setEnabled(selected_items);
|
||||
edit_delete -> setEnabled(selected_items);
|
||||
foreach (QAction *action, m_depth_ag -> actions())
|
||||
foreach (QAction *action, m_depth_action_group -> actions())
|
||||
action->setEnabled(selected_items);
|
||||
|
||||
// actions dependant du contenu du presse-papiers
|
||||
|
||||
@@ -80,7 +80,7 @@ class QETElementEditor : public QETMainWindow {
|
||||
/// toolbars
|
||||
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
||||
/// Action group
|
||||
QActionGroup *parts, *m_zoom_ag, *m_depth_ag;
|
||||
QActionGroup *parts, *m_zoom_ag, *m_depth_action_group;
|
||||
/// minimum window title
|
||||
QString min_title;
|
||||
/// filename of the currently edited element
|
||||
|
||||
Reference in New Issue
Block a user