mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Fix behavior when use arrow key with dynamic element text item and element text item group
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5789 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -191,7 +191,8 @@ MoveElementsCommand::MoveElementsCommand(
|
||||
DiagramContent::ConductorsToUpdate |
|
||||
DiagramContent::ConductorsToMove |
|
||||
DiagramContent::Images |
|
||||
DiagramContent::Shapes
|
||||
DiagramContent::Shapes |
|
||||
DiagramContent::ElementTextFields
|
||||
);
|
||||
|
||||
setText(
|
||||
@@ -248,7 +249,7 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
|
||||
typedef DiagramContent dc;
|
||||
|
||||
//Move every movable items, except conductor
|
||||
for (QGraphicsItem *qgi : content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::TextGroup))
|
||||
for (QGraphicsItem *qgi : content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::TextGroup | dc::ElementTextFields))
|
||||
{
|
||||
//If curent item have parent, and parent item is in content_to_move
|
||||
//we don't apply movement to this item, because this item will be moved by is parent.
|
||||
|
||||
@@ -355,6 +355,21 @@ bool DiagramContent::potentialIsManaged(QList<Conductor *> conductors)
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DiagramContent::hasTextEditing
|
||||
* @return true if handle a text currently in editing intercation
|
||||
*/
|
||||
bool DiagramContent::hasTextEditing()
|
||||
{
|
||||
for (DiagramTextItem *dti : selectedTexts()) {
|
||||
if (dti->textInteractionFlags() == Qt::TextEditorInteraction) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DiagramContent::items
|
||||
* @param filter
|
||||
|
||||
@@ -89,6 +89,7 @@ class DiagramContent
|
||||
|
||||
DiagramContent& operator+=(const DiagramContent& other);
|
||||
bool potentialIsManaged(QList<Conductor *>conductors);
|
||||
bool hasTextEditing();
|
||||
};
|
||||
QDebug &operator<<(QDebug, DiagramContent &);
|
||||
#endif
|
||||
|
||||
@@ -703,22 +703,22 @@ void DiagramView::keyPressEvent(QKeyEvent *e)
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Up: {
|
||||
if(!(dc.items(DiagramContent::All).isEmpty()))
|
||||
if(!dc.items(DiagramContent::All).isEmpty() && !dc.hasTextEditing())
|
||||
scrollOnMovement(e);
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Down: {
|
||||
if(!(dc.items(DiagramContent::All).isEmpty()))
|
||||
if(!dc.items(DiagramContent::All).isEmpty() && !dc.hasTextEditing())
|
||||
scrollOnMovement(e);
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Left: {
|
||||
if(!(dc.items(DiagramContent::All).isEmpty()))
|
||||
if(!dc.items(DiagramContent::All).isEmpty() && !dc.hasTextEditing())
|
||||
scrollOnMovement(e);
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Right: {
|
||||
if(!(dc.items(DiagramContent::All).isEmpty()))
|
||||
if(!dc.items(DiagramContent::All).isEmpty() && !dc.hasTextEditing())
|
||||
scrollOnMovement(e);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "independenttextitem.h"
|
||||
#include "diagramimageitem.h"
|
||||
#include "conductorautonumerotation.h"
|
||||
#include "dynamicelementtextitem.h"
|
||||
#include "elementtextitemgroup.h"
|
||||
|
||||
/**
|
||||
* @brief ElementsMover::ElementsMover Constructor
|
||||
@@ -60,7 +62,8 @@ bool ElementsMover::isReady() const {
|
||||
* @param driver_item item moved by mouse and don't be moved by Element mover
|
||||
* @return the numbers of items to be moved or -1 if movement can't be init.
|
||||
*/
|
||||
int ElementsMover::beginMovement(Diagram *diagram, QGraphicsItem *driver_item) {
|
||||
int ElementsMover::beginMovement(Diagram *diagram, QGraphicsItem *driver_item)
|
||||
{
|
||||
// They must be no movement in progress
|
||||
if (movement_running_) return(-1);
|
||||
|
||||
@@ -77,6 +80,21 @@ int ElementsMover::beginMovement(Diagram *diagram, QGraphicsItem *driver_item) {
|
||||
m_moved_content = DiagramContent(diagram);
|
||||
m_moved_content.removeNonMovableItems();
|
||||
|
||||
//Remove element text, if the parent element is selected.
|
||||
QList<DynamicElementTextItem *> deti_list = m_moved_content.m_element_texts.toList();
|
||||
for(DynamicElementTextItem *deti : deti_list) {
|
||||
if(m_moved_content.m_elements.contains(deti->parentElement())) {
|
||||
m_moved_content.m_element_texts.remove(deti);
|
||||
}
|
||||
}
|
||||
|
||||
QList<ElementTextItemGroup *> etig_list = m_moved_content.m_texts_groups.toList();
|
||||
for(ElementTextItemGroup *etig : etig_list) {
|
||||
if (m_moved_content.m_elements.contains(etig->parentElement())) {
|
||||
m_moved_content.m_texts_groups.remove(etig);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_moved_content.count()) return(-1);
|
||||
|
||||
/* At this point, we've got all info to manage movement.
|
||||
@@ -98,7 +116,7 @@ void ElementsMover::continueMovement(const QPointF &movement) {
|
||||
|
||||
//Move every movable item, except conductor
|
||||
typedef DiagramContent dc;
|
||||
for (QGraphicsItem *qgi : m_moved_content.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes))
|
||||
for (QGraphicsItem *qgi : m_moved_content.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::ElementTextFields | dc::TextGroup))
|
||||
{
|
||||
if (qgi == m_movement_driver)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user