Skip to content

Commit

Permalink
Fix bug 'Widget selection issue outside mouse selection rectangle on …
Browse files Browse the repository at this point in the history
…sequence diagrams'.

When selecting messages on a sequence diagram using the mouse do not auto select
object widgets outside the selecting rectangle.

Object widgets required for pasting into other diagrams are added automatically
on widget copy operation.

BUG:340728
  • Loading branch information
rhabacker committed Nov 22, 2014
1 parent 0923518 commit 0780af1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 43 deletions.
42 changes: 41 additions & 1 deletion umbrello/clipboard/umlclipboard.cpp
Expand Up @@ -21,6 +21,7 @@
#include "enum.h"
#include "entity.h"
#include "floatingtextwidget.h"
#include "messagewidget.h"
#include "operation.h"
#include "template.h"
#include "enumliteral.h"
Expand Down Expand Up @@ -88,7 +89,6 @@ QMimeData* UMLClipboard::copy(bool fromView/*=false*/)
uError() << "currentView umlScene() is NULL";
return NULL;
}
scene->checkSelections();
m_WidgetList = scene->selectedWidgetsExt();
//if there is no selected widget then there is no copy action
if (!m_WidgetList.count()) {
Expand All @@ -97,6 +97,9 @@ QMimeData* UMLClipboard::copy(bool fromView/*=false*/)
m_AssociationList = scene->selectedAssocs();
scene->copyAsImage(png);

// Clip4 needs related widgets.
addRelatedWidgets();

// Clip4 needs UMLObjects because it's possible the UMLObject
// is no longer there when pasting this mime data. This happens for
// example when using cut-paste or pasting to another Umbrello
Expand Down Expand Up @@ -217,6 +220,43 @@ bool UMLClipboard::paste(const QMimeData* data)
return result;
}

/**
* Fills object list based on a selection of widgets
*
* @param UMLWidgetList& widgets
*/
void UMLClipboard::addRelatedWidgets()
{
UMLWidgetList relatedWidgets;
UMLWidget *pWA =0, *pWB = 0;

foreach (UMLWidget* widget, m_WidgetList) {
if (widget->baseType() == WidgetBase::wt_Message) {
MessageWidget * pMessage = static_cast<MessageWidget *>(widget);
pWA = (UMLWidget*)pMessage->objectWidget(Uml::RoleType::A);
pWB = (UMLWidget*)pMessage->objectWidget(Uml::RoleType::B);
if (!relatedWidgets.contains(pWA))
relatedWidgets.append(pWA);
if (!relatedWidgets.contains(pWB))
relatedWidgets.append(pWB);
}
}

foreach(AssociationWidget *pAssoc, m_AssociationList) {
pWA = pAssoc->widgetForRole(Uml::RoleType::A);
pWB = pAssoc->widgetForRole(Uml::RoleType::B);
if (!relatedWidgets.contains(pWA))
relatedWidgets.append(pWA);
if (!relatedWidgets.contains(pWB))
relatedWidgets.append(pWB);
}

foreach(UMLWidget *widget, relatedWidgets) {
if (!m_WidgetList.contains(widget))
m_WidgetList.append(widget);
}
}

/**
* Fills object list based on a selection of widgets
*
Expand Down
1 change: 1 addition & 0 deletions umbrello/clipboard/umlclipboard.h
Expand Up @@ -70,6 +70,7 @@ class UMLClipboard : public QObject
UMLCopyType m_type; ///< Type of copy operation to perform.

private:
void addRelatedWidgets();

void fillObjectListForWidgets(UMLWidgetList& widgets);

Expand Down
40 changes: 0 additions & 40 deletions umbrello/umlscene.cpp
Expand Up @@ -1661,8 +1661,6 @@ void UMLScene::selectWidget(UMLWidget* widget, QRectF* rect)
MessageWidget * mw = dynamic_cast<MessageWidget*>(lw);
if (mw) {
makeSelected(mw);
makeSelected(mw->objectWidget(Uml::RoleType::A));
makeSelected(mw->objectWidget(Uml::RoleType::B));
} else if (t != Uml::TextRole::Floating) {
AssociationWidget * a = dynamic_cast<AssociationWidget*>(lw);
if (a)
Expand Down Expand Up @@ -3220,44 +3218,6 @@ void UMLScene::setClassWidgetOptions(ClassOptionsPage * page)
}
}

/**
* Call before copying/cutting selected widgets. This will make sure
* any associations/message selected will make sure both the widgets
* widgets they are connected to are selected.
*/
void UMLScene::checkSelections()
{
UMLWidget * pWA = 0, * pWB = 0;
//check messages
foreach(UMLWidget *pTemp, selectedWidgets()) {
if (pTemp->baseType() == WidgetBase::wt_Message && pTemp->isSelected()) {
MessageWidget * pMessage = static_cast<MessageWidget *>(pTemp);
pWA = pMessage->objectWidget(Uml::RoleType::A);
pWB = pMessage->objectWidget(Uml::RoleType::B);
if (!pWA->isSelected()) {
pWA->setSelectedFlag(true);
}
if (!pWB->isSelected()) {
pWB->setSelectedFlag(true);
}
}//end if
}//end for
//check Associations

foreach(AssociationWidget *pAssoc, m_AssociationList) {
if (pAssoc->isSelected()) {
pWA = pAssoc->widgetForRole(Uml::RoleType::A);
pWB = pAssoc->widgetForRole(Uml::RoleType::B);
if (!pWA->isSelected()) {
pWA->setSelectedFlag(true);
}
if (!pWB->isSelected()) {
pWB->setSelectedFlag(true);
}
}//end if
}//end foreach
}

/**
* Returns the type of the selected widget or widgets.
*
Expand Down
2 changes: 0 additions & 2 deletions umbrello/umlscene.h
Expand Up @@ -251,8 +251,6 @@ class UMLScene : public QGraphicsScene

void setClassWidgetOptions(ClassOptionsPage * page);

void checkSelections();

WidgetBase::WidgetType getUniqueSelectionType();

void clearDiagram();
Expand Down

0 comments on commit 0780af1

Please sign in to comment.