Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 57cabe23 authored by Ralf Habacker's avatar Ralf Habacker

Keep return code of widget related property dialogs in sync with uml object related

CCBUG:390507
parent cf0a87d1
......@@ -151,16 +151,19 @@ void ActivityWidget::setPostconditionText(const QString& aPostText)
* Reimplemented from UMLWidget::showPropertiesDialog to show a
* properties dialog for an ActivityWidget.
*/
void ActivityWidget::showPropertiesDialog()
bool ActivityWidget::showPropertiesDialog()
{
bool result = false;
UMLApp::app()->docWindow()->updateDocumentation(false);
QPointer<ActivityDialog> dialog = new ActivityDialog(umlScene()->activeView(), this);
if (dialog->exec() && dialog->getChangesMade()) {
UMLApp::app()->docWindow()->showDocumentation(this, true);
UMLApp::app()->document()->setModified(true);
result = true;
}
delete dialog;
return result;
}
/**
......
......@@ -62,7 +62,7 @@ public:
QString postconditionText() const;
void setPostconditionText(const QString&);
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void moveWidgetBy(qreal diffX, qreal diffY);
......
......@@ -449,14 +449,17 @@ void AssociationWidget::setText(FloatingTextWidget *ft, const QString &text)
* Shows the association properties dialog and updates the
* corresponding texts if its execution is successful.
*/
void AssociationWidget::showPropertiesDialog()
bool AssociationWidget::showPropertiesDialog()
{
bool result = false;
UMLApp::app()->docWindow()->updateDocumentation();
QPointer<AssociationPropertiesDialog> dlg = new AssociationPropertiesDialog(static_cast<QWidget*>(m_scene->activeView()), this);
if (dlg->exec()) {
UMLApp::app()->docWindow()->showDocumentation(this, true);
result = true;
}
delete dlg;
return result;
}
/**
......
......@@ -77,7 +77,7 @@ public:
virtual void setMessageText(FloatingTextWidget *ft);
virtual void setText(FloatingTextWidget *ft, const QString &newText);
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
virtual QString lwOperationText();
virtual UMLClassifier *lwClassifier();
......
......@@ -68,14 +68,17 @@ void BoxWidget::saveToXMI1(QDomDocument& qDoc, QDomElement& qElement)
/**
* Show a properties dialog for a BoxWidget.
*/
void BoxWidget::showPropertiesDialog()
bool BoxWidget::showPropertiesDialog()
{
QColor newColor = QColorDialog::getColor(lineColor()); // krazy:exclude=qclasses
if (!newColor.isValid())
return false;
if (newColor != lineColor()) {
setLineColor(newColor);
setUsesDiagramLineColor(false);
umlDoc()->setModified(true);
}
return true;
}
void BoxWidget::toForeground()
......
......@@ -33,7 +33,7 @@ public:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void saveToXMI1(QDomDocument& qDoc, QDomElement& qElement);
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
protected:
void toForeground();
......
......@@ -225,19 +225,20 @@ void FloatingTextWidget::showChangeTextDialog()
*
* @param enableAutoIncrement Enable auto increment checkbox
*/
void FloatingTextWidget::showOperationDialog(bool enableAutoIncrement)
bool FloatingTextWidget::showOperationDialog(bool enableAutoIncrement)
{
if (!m_linkWidget) {
uError() << "m_linkWidget is NULL";
return;
return false;
}
QString seqNum = m_linkWidget->sequenceNumber();
UMLClassifier* c = m_linkWidget->lwClassifier();
QString opText = m_linkWidget->lwOperationText();
if (!c) {
uError() << "m_linkWidget->lwClassifier() returns a NULL classifier";
return;
return false;
}
bool result = false;
QPointer<SelectOperationDialog> selectDialog = new SelectOperationDialog(m_scene->activeView(), c, enableAutoIncrement);
if (enableAutoIncrement && m_scene->autoIncrementSequence()) {
......@@ -289,8 +290,10 @@ void FloatingTextWidget::showOperationDialog(bool enableAutoIncrement)
m_scene->setAutoIncrementSequence(selectDialog->autoIncrementSequence());
}
setMessageText();
result = true;
}
delete selectDialog;
return result;
}
/**
......@@ -299,17 +302,18 @@ void FloatingTextWidget::showOperationDialog(bool enableAutoIncrement)
* for the floating text widget, the rename dialog for floating text or
* the options dialog for the link widget are shown.
*/
void FloatingTextWidget::showPropertiesDialog()
bool FloatingTextWidget::showPropertiesDialog()
{
if (m_textRole == Uml::TextRole::Coll_Message || m_textRole == Uml::TextRole::Coll_Message_Self ||
m_textRole == Uml::TextRole::Seq_Message || m_textRole == Uml::TextRole::Seq_Message_Self) {
showOperationDialog(false);
return showOperationDialog(false);
} else if (m_textRole == Uml::TextRole::Floating) {
// double clicking on a text line opens the dialog to change the text
handleRename();
return handleRename();
} else if (m_linkWidget) {
m_linkWidget->showPropertiesDialog();
return m_linkWidget->showPropertiesDialog();
}
return false;
}
/**
......@@ -391,7 +395,7 @@ Uml::TextRole::Enum FloatingTextWidget::textRole() const
* Handle the ListPopupMenu::mt_Rename case of the slotMenuSelection.
* Given an own method because it requires rather lengthy code.
*/
void FloatingTextWidget::handleRename()
bool FloatingTextWidget::handleRename()
{
QString t;
if (m_textRole == Uml::TextRole::RoleAName || m_textRole == Uml::TextRole::RoleBName) {
......@@ -413,10 +417,11 @@ void FloatingTextWidget::handleRename()
QString newText = text();
bool ok = Dialog_Utils::askName(i18n("Rename"), t, newText);
if (!ok || newText == text()) {
return;
return false;
}
UMLApp::app()->executeCommand(new Uml::CmdHandleRename(this, newText));
return true;
}
/**
......
......@@ -57,8 +57,8 @@ public:
bool isEmpty();
void showChangeTextDialog();
void showOperationDialog(bool enableAutoIncrement = true);
virtual void showPropertiesDialog();
bool showOperationDialog(bool enableAutoIncrement = true);
virtual bool showPropertiesDialog();
LinkWidget* link() const;
void setLink(LinkWidget * l);
......@@ -68,7 +68,7 @@ public:
Uml::TextRole::Enum textRole() const;
void setTextRole(Uml::TextRole::Enum role);
void handleRename();
bool handleRename();
void changeName(const QString& newText);
void setSequenceNumber(const QString &sequenceNumber);
......
......@@ -116,14 +116,17 @@ void ForkJoinWidget::saveToXMI1(QDomDocument& qDoc, QDomElement& qElement)
/**
* Show a properties dialog for a Fork/Join Widget.
*/
void ForkJoinWidget::showPropertiesDialog()
bool ForkJoinWidget::showPropertiesDialog()
{
QColor newColor = QColorDialog::getColor(fillColor()); // krazy:exclude=qclasses
if (!newColor.isValid())
return false;
if (newColor != fillColor()) {
setFillColor(newColor);
setUsesDiagramFillColor(false);
umlDoc()->setModified(true);
}
return true;
}
/**
......
......@@ -38,7 +38,7 @@ public:
virtual bool loadFromXMI1(QDomElement & qElement);
virtual void saveToXMI1(QDomDocument& qDoc, QDomElement& qElement);
void showPropertiesDialog();
virtual bool showPropertiesDialog();
public Q_SLOTS:
virtual void slotMenuSelection(QAction* action);
......
......@@ -72,8 +72,9 @@ void LinkWidget::resetTextPositions()
* Motivated by FloatingTextWidget::mouseDoubleClickEvent()
* Only applies to AssociationWidget.
*/
void LinkWidget::showPropertiesDialog()
bool LinkWidget::showPropertiesDialog()
{
return false;
}
/**
......
......@@ -83,7 +83,7 @@ public:
*/
virtual void setText(FloatingTextWidget *ft, const QString &newText) = 0;
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
/**
* Motivated by FloatingTextWidget::showOpDialog()
......
......@@ -276,8 +276,9 @@ void NoteWidget::saveToXMI1(QDomDocument & qDoc, QDomElement & qElement)
/**
* Show a properties dialog for a NoteWidget.
*/
void NoteWidget::showPropertiesDialog()
bool NoteWidget::showPropertiesDialog()
{
bool result = false;
NoteDialog * dlg = 0;
UMLApp::app()->docWindow()->updateDocumentation(false);
dlg = new NoteDialog(umlScene()->activeView(), this);
......@@ -285,8 +286,10 @@ void NoteWidget::showPropertiesDialog()
UMLApp::app()->docWindow()->showDocumentation(this, true);
UMLApp::app()->document()->setModified(true);
update();
result = true;
}
delete dlg;
return result;
}
/**
......
......@@ -59,7 +59,7 @@ public:
void askForNoteType(UMLWidget* &targetWidget);
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
virtual bool loadFromXMI1(QDomElement & qElement);
virtual void saveToXMI1(QDomDocument & qDoc, QDomElement & qElement);
......
......@@ -252,16 +252,19 @@ void ObjectNodeWidget::slotMenuSelection(QAction* action)
/**
* Show a properties dialog for an ObjectNodeWidget.
*/
void ObjectNodeWidget::showPropertiesDialog()
bool ObjectNodeWidget::showPropertiesDialog()
{
UMLApp::app()->docWindow()->updateDocumentation(false);
bool result = false;
QPointer<ObjectNodeDialog> dialog = new ObjectNodeDialog(UMLApp::app()->currentView(), this);
if (dialog->exec() && dialog->getChangesMade()) {
UMLApp::app()->docWindow()->showDocumentation(this, true);
UMLApp::app()->document()->setModified(true);
result = true;
}
delete dialog;
return result;
}
/**
......
......@@ -52,7 +52,7 @@ public:
void setState(const QString& state);
QString state() const;
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
void askStateForWidget();
void askForObjectNodeType(UMLWidget* &targetWidget);
......
......@@ -368,16 +368,19 @@ void ObjectWidget::cleanup()
/**
* Show a properties dialog for an ObjectWidget.
*/
void ObjectWidget::showPropertiesDialog()
bool ObjectWidget::showPropertiesDialog()
{
bool result = false;
UMLApp::app()->docWindow()->updateDocumentation(false);
QPointer<ClassPropertiesDialog> dlg = new ClassPropertiesDialog((QWidget*)UMLApp::app(), this);
if (dlg->exec()) {
UMLApp::app()->docWindow()->showDocumentation(this, true);
UMLApp::app()->document()->setModified(true);
result = true;
}
dlg->close();
delete dlg;
return result;
}
/**
......
......@@ -50,7 +50,7 @@ public:
void cleanup();
void showPropertiesDialog();
virtual bool showPropertiesDialog();
void setDrawAsActor(bool drawAsActor);
bool drawAsActor() const;
......
......@@ -228,8 +228,9 @@ void SignalWidget::setSignalType(SignalType signalType)
/**
* Show a properties dialog for a UMLWidget.
*/
void SignalWidget::showPropertiesDialog()
bool SignalWidget::showPropertiesDialog()
{
return false;
}
/**
......
......@@ -51,7 +51,7 @@ public:
QString signalTypeStr() const;
void setSignalType(SignalType signalType);
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
void mouseMoveEvent(QGraphicsSceneMouseEvent *me);
......
......@@ -399,16 +399,19 @@ void StateWidget::setDrawVertical(bool to)
/**
* Show a properties dialog for a StateWidget.
*/
void StateWidget::showPropertiesDialog()
bool StateWidget::showPropertiesDialog()
{
bool result = false;
UMLApp::app()->docWindow()->updateDocumentation(false);
QPointer<StateDialog> dialog = new StateDialog(m_scene->activeView(), this);
if (dialog->exec() && dialog->getChangesMade()) {
UMLApp::app()->docWindow()->showDocumentation(this, true);
UMLApp::app()->document()->setModified(true);
result = true;
}
delete dialog;
return result;
}
/**
......
......@@ -76,7 +76,7 @@ public:
bool drawVertical() const;
void setDrawVertical(bool to = true);
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
virtual bool loadFromXMI1(QDomElement & qElement);
virtual void saveToXMI1(QDomDocument & qDoc, QDomElement & qElement);
......
......@@ -1183,8 +1183,9 @@ void UMLWidget::adjustUnselectedAssocs(qreal dx, qreal dy)
/**
* Show a properties dialog for a UMLWidget.
*/
void UMLWidget::showPropertiesDialog()
bool UMLWidget::showPropertiesDialog()
{
bool result = false;
// will already be selected so make sure docWindow updates the doc
// back it the widget
UMLApp::app()->docWindow()->updateDocumentation(false);
......@@ -1193,9 +1194,11 @@ void UMLWidget::showPropertiesDialog()
if (dlg->exec()) {
UMLApp::app()->docWindow()->showDocumentation(umlObject(), true);
m_doc->setModified(true);
result = true;
}
dlg->close(); //wipe from memory
delete dlg;
return result;
}
/**
......
......@@ -172,7 +172,7 @@ public:
bool showStereotype() const;
virtual void setShowStereotype(bool flag);
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
virtual void adjustAssocs(qreal dx, qreal dy);
void adjustUnselectedAssocs(qreal dx, qreal dy);
......
......@@ -499,9 +499,16 @@ void WidgetBase::setAutoResize(bool state)
/**
* A virtual method for the widget to display a property dialog box.
* Subclasses should reimplment this appropriately.
* In case the user cancels the dialog or there are some requirements
* not fullfilled the method returns false; true otherwise.
*
* @return true - properties has been applyed
* @return false - properties has not been applied
*
*/
void WidgetBase::showPropertiesDialog()
bool WidgetBase::showPropertiesDialog()
{
return false;
}
/**
......
......@@ -173,7 +173,7 @@ public:
bool autoResize();
void setAutoResize(bool state);
virtual void showPropertiesDialog();
virtual bool showPropertiesDialog();
virtual bool loadFromXMI1(QDomElement &qElement);
virtual void saveToXMI1(QDomDocument &qDoc, QDomElement &qElement);
......
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