Commit f215461b authored by Ralf Habacker's avatar Ralf Habacker

Fix bug 'Incorrect property dialog display for class attributes, methods,...

Fix bug 'Incorrect property dialog display for class attributes, methods, enumeration values or key constrains in tree view'.

Details:
- Move up virtual method showPropertiesDialog() from ClassifierItemList to UMLObject
   to have properties dialog support for all uml objects.
- Add default value to parent attribute of showPropertiesDialog().
- Implement missing methods showPropertiesDialog() used by the tree and the code editor
- Implement fall back method showPropertiesDialog() to UMLObject.
- Remove obsolate method showPropertiesPagedDialog(), which did not work as documented since KDE 4.0.

BUG:342303
FIXED-IN:2.15.1 (KDE 14.12.1)
parent 789b3a36
......@@ -14,6 +14,7 @@
// app includes
#include "debug_utils.h"
#include "classifier.h"
#include "classpropertiesdialog.h"
#include "folder.h"
#include "uml.h"
#include "umldoc.h"
......@@ -26,6 +27,7 @@
#include <klocale.h>
// qt includes
#include <QPointer>
#include <QRegExp>
using namespace Uml;
......@@ -202,6 +204,18 @@ void UMLAssociation::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
qElement.appendChild(associationElement);
}
bool UMLAssociation::showPropertiesDialog(QWidget *parent)
{
QPointer<ClassPropertiesDialog> dlg = new ClassPropertiesDialog(parent, this, true);
bool modified = false;
if (dlg->exec()) {
modified = true;
}
dlg->close();
delete dlg;
return modified;
}
/**
* Creates the <UML:Generalization> or <UML:Association> XMI element
* including its role objects.
......
......@@ -78,6 +78,8 @@ public:
void saveToXMI(QDomDocument& qDoc, QDomElement& qElement);
virtual bool showPropertiesDialog(QWidget *parent = 0);
protected:
bool load(QDomElement& element);
......
......@@ -57,7 +57,7 @@ public:
virtual void saveToXMI(QDomDocument & qDoc, QDomElement & qElement);
virtual bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent = 0);
void setParmKind(Uml::ParameterDirection::Enum pk);
Uml::ParameterDirection::Enum getParmKind() const;
......
......@@ -46,7 +46,7 @@ public:
void saveToXMI(QDomDocument & qDoc, QDomElement & qElement);
virtual bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent = 0);
QString getCheckCondition() const {
return m_CheckCondition;
......
......@@ -45,14 +45,6 @@ public:
virtual QString toString(Uml::SignatureType::Enum sig = Uml::SignatureType::NoSig);
/**
* Display the properties configuration dialog for the list item.
*
* @param parent The parent widget.
* @return True for success of this operation.
*/
virtual bool showPropertiesDialog(QWidget* parent) = 0;
virtual void copyInto(UMLObject *lhs) const;
/**
......
......@@ -163,41 +163,11 @@ void CodeEditor::editTextBlock(TextBlock * tBlock, int para)
if (info) {
UMLObject *obj = info->parent();
if (obj) {
UMLAttribute * at = NULL;
UMLRole * role = NULL;
UMLOperation * op = NULL;
if ((at = dynamic_cast<UMLAttribute*>(obj))) {
QPointer<UMLAttributeDialog> dlg = new UMLAttributeDialog(this, at);
if (dlg->exec() == KDialog::Accepted) {
rebuildView(para);
}
delete dlg;
}
else if ((dynamic_cast<UMLClassifier*>(obj))) {
if (obj->showPropertiesPagedDialog()) {
rebuildView(para);
}
}
else if ((role = dynamic_cast<UMLRole*>(obj))) {
QPointer<UMLRoleDialog> dlg = new UMLRoleDialog(this, role);
if (dlg->exec() == KDialog::Accepted) {
rebuildView(para);
}
delete dlg;
}
else if ((op = dynamic_cast<UMLOperation*>(obj)))
//else if((cop = dynamic_cast<CodeOperation*>(tBlock)))
{
QPointer<UMLOperationDialog> dlg = new UMLOperationDialog(this, op);
if (dlg->exec() == KDialog::Accepted) {
rebuildView(para);
}
delete dlg;
}
else {
uError() << "UNKNOWN parent for textBlock";
if (obj->showPropertiesDialog(this)) {
rebuildView(para);
}
} else {
uError() << "UNKNOWN parent for textBlock";
}
}
}
......
......@@ -67,7 +67,7 @@ public:
virtual void saveToXMI(QDomDocument& qDoc, QDomElement& qElement);
bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent = 0);
protected:
void init();
......
......@@ -39,7 +39,7 @@ public:
virtual void saveToXMI(QDomDocument& qDoc, QDomElement& qElement);
bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent = 0);
protected:
bool load(QDomElement& element);
......
......@@ -64,7 +64,7 @@ public:
void saveToXMI(QDomDocument & qDoc, QDomElement & qElement);
virtual bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent = 0);
bool addEntityAttributePair(UMLEntityAttribute* pAttr, UMLEntityAttribute* rAttr);
......
......@@ -57,7 +57,7 @@ public:
QString getUniqueParameterName();
bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent = 0);
bool isConstructorOperation();
bool isDestructorOperation();
......
......@@ -58,7 +58,7 @@ public:
void saveToXMI(QDomDocument& qDoc, QDomElement& qElement);
bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent);
protected:
int m_refCount;
......
......@@ -44,7 +44,7 @@ public:
virtual QString getTypeName() const;
bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent);
void saveToXMI(QDomDocument & qDoc, QDomElement & qElement);
......
......@@ -2547,7 +2547,7 @@ void UMLApp::slotAllViewsExportImage()
*/
void UMLApp::slotCurrentViewProperties()
{
currentView()->showPropDialog();
currentView()->showPropertiesDialog();
}
/**
......
......@@ -634,7 +634,7 @@ void UMLListView::slotMenuSelection(QAction* action, const QPoint &position)
UMLView * pView = m_doc->findView(currItem->ID());
if (pView) {
UMLApp::app()->docWindow()->updateDocumentation(false);
pView->showPropDialog();
pView->showPropertiesDialog();
UMLApp::app()->docWindow()->showDocumentation(pView->umlScene(), true);
}
return;
......@@ -646,60 +646,7 @@ void UMLListView::slotMenuSelection(QAction* action, const QPoint &position)
uError() << "UMLObject of ... is null! Doing nothing.";
return;
}
umlType = object->baseType();
if (Model_Utils::typeIsCanvasWidget(lvt)) {
object->showPropertiesPagedDialog(ClassPropertiesDialog::page_gen);
} else if (umlType == UMLObject::ot_EnumLiteral) {
// Show the Enum Literal Dialog
UMLEnumLiteral* selectedEnumLiteral = static_cast<UMLEnumLiteral*>(object);
selectedEnumLiteral->showPropertiesDialog(this);
} else if (umlType == UMLObject::ot_Attribute) {
// show the attribute dialog
UMLAttribute* selectedAttribute = static_cast<UMLAttribute*>(object);
QPointer<UMLAttributeDialog> dialog = new UMLAttributeDialog(this, selectedAttribute);
dialog->exec();
delete dialog;
} else if (umlType == UMLObject::ot_EntityAttribute) {
// show the attribute dialog
UMLEntityAttribute* selectedAttribute = static_cast<UMLEntityAttribute*>(object);
QPointer<UMLEntityAttributeDialog> dialog = new UMLEntityAttributeDialog(this, selectedAttribute);
dialog->exec();
delete dialog;
} else if (umlType == UMLObject::ot_Operation) {
// show the operation dialog
UMLOperation* selectedOperation = static_cast<UMLOperation*>(object);
QPointer<UMLOperationDialog> dialog = new UMLOperationDialog(this, selectedOperation);
dialog->exec();
delete dialog;
} else if (umlType == UMLObject::ot_Template) {
// show the template dialog
UMLTemplate* selectedTemplate = static_cast<UMLTemplate*>(object);
QPointer<UMLTemplateDialog> dialog = new UMLTemplateDialog(this, selectedTemplate);
dialog->exec();
delete dialog;
} else if (umlType == UMLObject::ot_UniqueConstraint) {
// show the Unique Constraint dialog
UMLUniqueConstraint* selectedUniqueConstraint = static_cast<UMLUniqueConstraint*>(object);
QPointer<UMLUniqueConstraintDialog> dialog = new UMLUniqueConstraintDialog(this, selectedUniqueConstraint);
dialog->exec();
delete dialog;
} else if (umlType == UMLObject::ot_ForeignKeyConstraint) {
// show the Unique Constraint dialog
UMLForeignKeyConstraint* selectedForeignKeyConstraint = static_cast<UMLForeignKeyConstraint*>(object);
QPointer<UMLForeignKeyConstraintDialog> dialog = new UMLForeignKeyConstraintDialog(this, selectedForeignKeyConstraint);
dialog->exec();
delete dialog;
} else if (umlType == UMLObject::ot_CheckConstraint) {
// show the Check Constraint dialog
UMLCheckConstraint* selectedCheckConstraint = static_cast<UMLCheckConstraint*>(object);
QPointer<UMLCheckConstraintDialog> dialog = new UMLCheckConstraintDialog(this, selectedCheckConstraint);
dialog->exec();
delete dialog;
} else {
uWarning() << "calling properties on unknown type";
}
object->showPropertiesDialog();
}
break;
......@@ -1447,7 +1394,7 @@ void UMLListView::mouseDoubleClickEvent(QMouseEvent * me)
UMLView * pView = m_doc->findView(item->ID());
if (pView) {
UMLApp::app()->docWindow()->updateDocumentation(false);
pView->showPropDialog();
pView->showPropertiesDialog();
UMLApp::app()->docWindow()->showDocumentation(pView->umlScene(), true);
}
return;
......@@ -1459,36 +1406,7 @@ void UMLListView::mouseDoubleClickEvent(QMouseEvent * me)
return;
}
UMLObject::ObjectType type = object->baseType();
int page = ClassPropertiesDialog::page_gen;
if (Model_Utils::isClassifierListitem(type)) {
object = (UMLObject *)object->parent();
}
//set what page to show
switch (type) {
case UMLObject::ot_Attribute:
page = ClassPropertiesDialog::page_att;
break;
case UMLObject::ot_Operation:
page = ClassPropertiesDialog::page_op;
break;
case UMLObject::ot_EntityAttribute:
page = ClassPropertiesDialog::page_entatt;
break;
case UMLObject::ot_UniqueConstraint:
case UMLObject::ot_ForeignKeyConstraint:
case UMLObject::ot_CheckConstraint:
page = ClassPropertiesDialog::page_constraint;
break;
default:
page = ClassPropertiesDialog::page_gen;
break;
}
if (object) {
object->showPropertiesPagedDialog(page);
}
object->showPropertiesDialog(this);
}
/**
......
......@@ -12,7 +12,9 @@
#include "umlobject.h"
// app includes
#include "classpropertiesdialog.h"
#include "debug_utils.h"
#include "enumliteral.h"
#include "uniqueid.h"
#include "uml.h"
#include "umldoc.h"
......@@ -24,7 +26,6 @@
#include "model_utils.h"
#include "import_utils.h"
#include "docwindow.h"
#include "classpropertiesdialog.h"
#include "cmds.h"
// kde includes
......@@ -108,20 +109,16 @@ void UMLObject::init()
}
/**
* This method is called if you wish to see the properties of a
* UMLObject. A dialog box will be displayed from which you
* can change the object's properties.
* Display the properties configuration dialog for the object.
*
* @param page The page to show.
* @param assoc Whether to show association page.
* @return True if we modified the object.
* @param parent The parent widget.
* @return True for success of this operation.
*/
bool UMLObject::showPropertiesPagedDialog(int page, bool assoc)
bool UMLObject::showPropertiesDialog(QWidget *parent)
{
Q_UNUSED(page);
DocWindow *docwindow = UMLApp::app()->docWindow();
docwindow->updateDocumentation(false);
QPointer<ClassPropertiesDialog> dlg = new ClassPropertiesDialog((QWidget*)UMLApp::app(), this, assoc);
QPointer<ClassPropertiesDialog> dlg = new ClassPropertiesDialog(parent, this, false);
bool modified = false;
if (dlg->exec()) {
docwindow->showDocumentation(this, true);
......
......@@ -131,8 +131,7 @@ public:
void setAbstract(bool bAbstract);
bool isAbstract() const;
// FIXME: merge with showPropertiesDialog()
virtual bool showPropertiesPagedDialog(int page = 0, bool assoc = false);
virtual bool showPropertiesDialog(QWidget* parent = 0);
virtual bool resolveRef();
......
......@@ -15,9 +15,11 @@
#include "association.h"
#include "debug_utils.h"
#include "umldoc.h"
#include "umlroledialog.h"
#include "uml.h"
// qt includes
#include <QPointer>
#include <QRegExp>
/**
......@@ -212,6 +214,23 @@ void UMLRole::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
qElement.appendChild(roleElement);
}
/**
* Display the properties configuration dialog for the object.
*
* @param parent The parent widget.
* @return True for success of this operation.
*/
bool UMLRole::showPropertiesDialog(QWidget *parent)
{
QPointer<UMLRoleDialog> dlg = new UMLRoleDialog(parent, this);
bool modified = false;
if (dlg->exec() == KDialog::Accepted) {
modified = true;
}
delete dlg;
return modified;
}
/**
* Loads the <UML:AssociationEnd> XMI element.
* Auxiliary to UMLObject::loadFromXMI.
......
......@@ -48,6 +48,8 @@ public:
void saveToXMI(QDomDocument& qDoc, QDomElement& qElement);
virtual bool showPropertiesDialog(QWidget *parent = 0);
protected:
bool load(QDomElement& element);
......
......@@ -921,7 +921,7 @@ void UMLScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
m_pToolBarState->mouseDoubleClick(event);
if (!event->isAccepted()) {
// show properties dialog of the scene
if (m_view->showPropDialog() == true) {
if (m_view->showPropertiesDialog() == true) {
m_doc->setModified();
}
event->accept();
......@@ -3102,7 +3102,7 @@ void UMLScene::slotMenuSelection(QAction* action)
break;
case ListPopupMenu::mt_Properties:
if (m_view->showPropDialog() == true)
if (m_view->showPropertiesDialog() == true)
m_doc->setModified();
break;
......
......@@ -98,10 +98,10 @@ int UMLView::currentZoom()
/**
* Shows the properties dialog for the view.
*/
bool UMLView::showPropDialog()
bool UMLView::showPropertiesDialog(QWidget *parent)
{
bool success = false;
QPointer<UMLViewDialog> dlg = new UMLViewDialog(this, umlScene());
QPointer<UMLViewDialog> dlg = new UMLViewDialog(parent, umlScene());
if (dlg->exec() == QDialog::Accepted) {
success = true;
}
......
......@@ -44,7 +44,7 @@ public:
void setZoom(int zoom);
int currentZoom();
bool showPropDialog();
virtual bool showPropertiesDialog(QWidget *parent = 0);
public slots:
void zoomIn();
......
......@@ -47,7 +47,7 @@ public:
void saveToXMI(QDomDocument & qDoc, QDomElement & qElement);
virtual bool showPropertiesDialog(QWidget* parent);
virtual bool showPropertiesDialog(QWidget* parent = 0);
bool hasEntityAttribute(UMLEntityAttribute* attr);
......
......@@ -781,7 +781,7 @@ void WidgetBase::slotMenuSelection(QAction *trigger)
showPropertiesDialog();
} else if (wt == WidgetBase::wt_Object) {
m_umlObject->showPropertiesPagedDialog();
m_umlObject->showPropertiesDialog();
} else {
uWarning() << "making properties dialog for unknown widget type";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment