mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Diagram editor : add new context menu action "group the selected texts"
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5372 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1068,7 +1068,7 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) {
|
|||||||
} else {
|
} else {
|
||||||
m_context_menu -> addAction(qde -> m_cut);
|
m_context_menu -> addAction(qde -> m_cut);
|
||||||
m_context_menu -> addAction(qde -> m_copy);
|
m_context_menu -> addAction(qde -> m_copy);
|
||||||
m_context_menu->addAction(m_multi_paste);
|
m_context_menu -> addAction(m_multi_paste);
|
||||||
m_context_menu -> addSeparator();
|
m_context_menu -> addSeparator();
|
||||||
m_context_menu -> addAction(qde -> m_conductor_reset);
|
m_context_menu -> addAction(qde -> m_conductor_reset);
|
||||||
m_context_menu -> addSeparator();
|
m_context_menu -> addSeparator();
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#include "rotatetextscommand.h"
|
#include "rotatetextscommand.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include "dialogwaiting.h"
|
#include "dialogwaiting.h"
|
||||||
|
#include "addelementtextcommand.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
@@ -358,6 +359,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
m_rotate_texts = m_selection_actions_group.addAction( QET::Icons::ObjectRotateRight, tr("Orienter les textes") );
|
m_rotate_texts = m_selection_actions_group.addAction( QET::Icons::ObjectRotateRight, tr("Orienter les textes") );
|
||||||
m_find_element = m_selection_actions_group.addAction( QET::Icons::ZoomDraw, tr("Retrouver dans le panel") );
|
m_find_element = m_selection_actions_group.addAction( QET::Icons::ZoomDraw, tr("Retrouver dans le panel") );
|
||||||
m_edit_selection = m_selection_actions_group.addAction( QET::Icons::ElementEdit, tr("Éditer l'item sélectionné") );
|
m_edit_selection = m_selection_actions_group.addAction( QET::Icons::ElementEdit, tr("Éditer l'item sélectionné") );
|
||||||
|
m_group_selected_texts = m_selection_actions_group.addAction(QET::Icons::textGroup, tr("Grouper les textes séléctionné"));
|
||||||
|
|
||||||
m_delete_selection -> setShortcut( QKeySequence::Delete);
|
m_delete_selection -> setShortcut( QKeySequence::Delete);
|
||||||
m_rotate_selection -> setShortcut( QKeySequence( tr("Space") ) );
|
m_rotate_selection -> setShortcut( QKeySequence( tr("Space") ) );
|
||||||
@@ -374,6 +376,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
m_rotate_texts ->setData("rotate_selected_text");
|
m_rotate_texts ->setData("rotate_selected_text");
|
||||||
m_find_element ->setData("find_selected_element");
|
m_find_element ->setData("find_selected_element");
|
||||||
m_edit_selection ->setData("edit_selected_element");
|
m_edit_selection ->setData("edit_selected_element");
|
||||||
|
m_group_selected_texts ->setData("group_selected_texts");
|
||||||
|
|
||||||
connect(&m_selection_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::selectionGroupTriggered);
|
connect(&m_selection_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::selectionGroupTriggered);
|
||||||
|
|
||||||
@@ -1283,6 +1286,14 @@ void QETDiagramEditor::selectionGroupTriggered(QAction *action)
|
|||||||
findElementInPanel(currentCustomElement()->location());
|
findElementInPanel(currentCustomElement()->location());
|
||||||
else if (value == "edit_selected_element")
|
else if (value == "edit_selected_element")
|
||||||
dv->editSelection();
|
dv->editSelection();
|
||||||
|
else if (value == "group_selected_texts")
|
||||||
|
{
|
||||||
|
QList<DynamicElementTextItem *> deti_list = dc.m_element_texts.toList();
|
||||||
|
if(deti_list.size() <= 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
diagram->undoStack().push(new AddTextsGroupCommand(deti_list.first()->parentElement(), tr("Groupe"), deti_list));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
|
void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
|
||||||
@@ -1404,7 +1415,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
|||||||
if(!dv)
|
if(!dv)
|
||||||
{
|
{
|
||||||
QList <QAction *> action_list;
|
QList <QAction *> action_list;
|
||||||
action_list << m_conductor_reset << m_find_element << m_cut << m_copy << m_delete_selection << m_rotate_selection << m_edit_selection;
|
action_list << m_conductor_reset << m_find_element << m_cut << m_copy << m_delete_selection << m_rotate_selection << m_edit_selection << m_group_selected_texts;
|
||||||
for(QAction *action : action_list)
|
for(QAction *action : action_list)
|
||||||
action->setEnabled(false);
|
action->setEnabled(false);
|
||||||
|
|
||||||
@@ -1440,6 +1451,22 @@ void QETDiagramEditor::slot_updateComplexActions()
|
|||||||
int selected_dynamic_elmt_text = 0; for(DiagramTextItem *dti : texts) {if(dti->type() == DynamicElementTextItem::Type) selected_dynamic_elmt_text++;}
|
int selected_dynamic_elmt_text = 0; for(DiagramTextItem *dti : texts) {if(dti->type() == DynamicElementTextItem::Type) selected_dynamic_elmt_text++;}
|
||||||
m_rotate_texts->setEnabled(!ro && (selected_texts || groups.size()));
|
m_rotate_texts->setEnabled(!ro && (selected_texts || groups.size()));
|
||||||
|
|
||||||
|
//Action that need only element text selected
|
||||||
|
QList<DynamicElementTextItem *> deti_list = dc.m_element_texts.toList();
|
||||||
|
if(deti_list.size() > 1 && dc.count() == deti_list.count())
|
||||||
|
{
|
||||||
|
Element *elmt = deti_list.first()->parentElement();
|
||||||
|
bool ok = true;
|
||||||
|
for(DynamicElementTextItem *deti : deti_list)
|
||||||
|
{
|
||||||
|
if(elmt != deti->parentElement())
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
m_group_selected_texts->setEnabled(!ro && ok);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_group_selected_texts->setDisabled(true);
|
||||||
|
|
||||||
// actions need only one editable item
|
// actions need only one editable item
|
||||||
int selected_image = dc.count(DiagramContent::Images);
|
int selected_image = dc.count(DiagramContent::Images);
|
||||||
|
|
||||||
@@ -2184,18 +2211,6 @@ void QETDiagramEditor::selectionChanged()
|
|||||||
m_selection_properties_editor->setDiagram(dv->diagram());
|
m_selection_properties_editor->setDiagram(dv->diagram());
|
||||||
}
|
}
|
||||||
|
|
||||||
///**
|
|
||||||
// * @brief QETDiagramEditor::activeUndoStackCleanChanged
|
|
||||||
// * Enable the QAction save_file when @clean is set to false
|
|
||||||
// * @clean at true do nothing;
|
|
||||||
// * @param clean
|
|
||||||
// */
|
|
||||||
//void QETDiagramEditor::activeUndoStackCleanChanged(bool clean) {
|
|
||||||
// if (!clean) {
|
|
||||||
// //save_file -> setEnabled(true);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QETDiagramEditor::slot_generateTerminalBlock
|
* @brief QETDiagramEditor::slot_generateTerminalBlock
|
||||||
|
|||||||
@@ -156,7 +156,6 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
//void activeUndoStackCleanChanged (bool clean);
|
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
@@ -211,6 +210,7 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
QAction *m_rotate_selection; ///< Rotate selected elements and text items by 90 degrees
|
QAction *m_rotate_selection; ///< Rotate selected elements and text items by 90 degrees
|
||||||
QAction *m_rotate_texts; ///< Direct selected text items to a specific angle
|
QAction *m_rotate_texts; ///< Direct selected text items to a specific angle
|
||||||
QAction *m_find_element; ///< Find the selected element in the panel
|
QAction *m_find_element; ///< Find the selected element in the panel
|
||||||
|
QAction *m_group_selected_texts = nullptr;
|
||||||
|
|
||||||
QActionGroup m_file_actions_group; ///Actions related to file (open, close, save...)
|
QActionGroup m_file_actions_group; ///Actions related to file (open, close, save...)
|
||||||
QAction *m_close_file; ///< Close current project file
|
QAction *m_close_file; ///< Close current project file
|
||||||
|
|||||||
@@ -89,6 +89,30 @@ AddTextsGroupCommand::AddTextsGroupCommand(Element *element, QDomElement dom_ele
|
|||||||
setText(QObject::tr("Ajouter un groupe de textes d'élément"));
|
setText(QObject::tr("Ajouter un groupe de textes d'élément"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AddTextsGroupCommand::AddTextsGroupCommand
|
||||||
|
* @param element : The element to add a new group
|
||||||
|
* @param texts_list : a list of texts to add to the created group (texts must be child of element)
|
||||||
|
* @param parent : parent undo
|
||||||
|
*/
|
||||||
|
AddTextsGroupCommand::AddTextsGroupCommand(Element *element, QString groupe_name, QList<DynamicElementTextItem *> texts_list, QUndoCommand *parent) :
|
||||||
|
QUndoCommand(parent),
|
||||||
|
m_element(element),
|
||||||
|
m_name(groupe_name)
|
||||||
|
{
|
||||||
|
for(DynamicElementTextItem *deti : texts_list)
|
||||||
|
{
|
||||||
|
deti->setSelected(false);
|
||||||
|
if(deti->parentElement() == element)
|
||||||
|
{
|
||||||
|
m_deti_list << deti;
|
||||||
|
deti->setSelected(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setText(QObject::tr("Grouper des textes d'élément"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AddTextsGroupCommand::~AddTextsGroupCommand
|
* @brief AddTextsGroupCommand::~AddTextsGroupCommand
|
||||||
* Destructor
|
* Destructor
|
||||||
@@ -118,6 +142,11 @@ void AddTextsGroupCommand::redo()
|
|||||||
m_deti_list = m_group.data()->texts();
|
m_deti_list = m_group.data()->texts();
|
||||||
m_group.data()->updateAlignment();
|
m_group.data()->updateAlignment();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(DynamicElementTextItem *deti : m_deti_list)
|
||||||
|
m_element.data()->addTextToGroup(deti, m_group.data());
|
||||||
|
}
|
||||||
m_first_undo = false;
|
m_first_undo = false;
|
||||||
}
|
}
|
||||||
else if(m_group)
|
else if(m_group)
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class AddTextsGroupCommand : public QUndoCommand
|
|||||||
public:
|
public:
|
||||||
AddTextsGroupCommand(Element *element, QString groupe_name, QUndoCommand *parent = nullptr);
|
AddTextsGroupCommand(Element *element, QString groupe_name, QUndoCommand *parent = nullptr);
|
||||||
AddTextsGroupCommand(Element *element, QDomElement dom_element, QUndoCommand *parent = nullptr);
|
AddTextsGroupCommand(Element *element, QDomElement dom_element, QUndoCommand *parent = nullptr);
|
||||||
|
AddTextsGroupCommand(Element *element, QString groupe_name, QList<DynamicElementTextItem *> texts_list, QUndoCommand *parent = nullptr);
|
||||||
~AddTextsGroupCommand() override;
|
~AddTextsGroupCommand() override;
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user