[Uml-devel] branches/work/soc-umbrello/umbrello
Gopala Krishna A
krishna.ggk at gmail.com
Wed Aug 12 16:00:25 UTC 2009
SVN commit 1010473 by gopala:
* More actions handled in AssociationWidget::slotMenuSelection
* Implemented AssociationWidget::showPropertiesDialog(), which means the
dialog box for AssociationWidget works now ! Yay!
M +2 -3 dialogs/assocpage.cpp
M +157 -4 widgets/associationwidget.cpp
M +6 -2 widgets/associationwidget.h
M +1 -1 widgets/floatingtextwidget.cpp
M +1 -2 widgets/linkwidget.cpp
M +1 -1 widgets/linkwidget.h
--- branches/work/soc-umbrello/umbrello/dialogs/assocpage.cpp #1010472:1010473
@@ -68,9 +68,8 @@
}
AssociationWidget * a = m_List.at(row);
- if (a->showDialog()) {
- fillListBox();
- }
+ a->showPropertiesDialog();
+ fillListBox();
}
/**
--- branches/work/soc-umbrello/umbrello/widgets/associationwidget.cpp #1010472:1010473
@@ -28,7 +28,12 @@
#include "umlwidget.h"
#include "umlview.h"
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kcolordialog.h>
+
#include <QPointer>
+#include <QRegExpValidator>
#include <cmath>
@@ -314,14 +319,12 @@
}
-bool AssociationWidget::showDialog()
+void AssociationWidget::showPropertiesDialog()
{
- bool success = false;
UMLView *view = umlScene() ? umlScene()->activeView() : 0;
QPointer<AssocPropDlg> dlg = new AssocPropDlg(view, this );
if (dlg->exec()) {
- success = true;
//rules built into these functions to stop updating incorrect values
setName(name());
@@ -347,7 +350,6 @@
}
}
delete dlg;
- return success;
}
@@ -982,6 +984,157 @@
return false;
}
+void AssociationWidget::saveToXMI(QDomDocument &qDoc, QDomElement &qElement)
+{
+ //TODO: Port
+}
+
+void AssociationWidget::slotMenuSelection(QAction *action)
+{
+ QString oldText, newText;
+ QFont font;
+ QRegExpValidator v(QRegExp(".*"), 0);
+ Uml::Association_Type atype = associationType();
+ Uml::Role_Type r = Uml::B;
+ UMLScene *scene = umlScene();
+ UMLView *view = scene ? scene->activeView() : 0;
+
+ ListPopupMenu *menu = ListPopupMenu::menuFromAction(action);
+ if (!menu) {
+ uError() << "Action's data field does not contain ListPopupMenu pointer";
+ return;
+ }
+ ListPopupMenu::Menu_Type sel = menu->getMenuType(action);
+
+ //if it's a collaboration message we now just use the code in floatingtextwidget
+ //this means there's some redundant code below but that's better than duplicated code
+ if (isCollaboration() && sel != ListPopupMenu::mt_Delete) {
+ //TODO: Verify the working of following line of code.
+ m_nameWidget->slotMenuSelection(action);
+ return;
+ }
+
+ switch(sel) {
+ case ListPopupMenu::mt_Properties:
+ if(atype == Uml::at_Seq_Message || atype == Uml::at_Seq_Message_Self) {
+ // show op dlg for seq. diagram here
+ // don't worry about here, I don't think it can get here as
+ // line is widget on seq. diagram
+ // here just in case - remove later after testing
+ uDebug() << "mt_Properties: assoctype is " << atype;
+ } else { //standard assoc dialog
+ UMLScene *scene = umlScene();
+ if (scene) {
+ scene->updateDocumentation( false );
+ }
+ showPropertiesDialog();
+ }
+ break;
+
+ case ListPopupMenu::mt_Delete:
+ //TODO:
+#if 0
+ if (m_pAssocClassLineSel0)
+ removeAssocClassLine();
+ else if (getAssociation())
+ m_pView->removeAssocInViewAndDoc(this);
+ else
+ m_pView->removeAssoc(this);
+#endif
+ break;
+
+ case ListPopupMenu::mt_Rename_MultiA:
+ r = Uml::A; // fall through
+ case ListPopupMenu::mt_Rename_MultiB:
+ oldText = multiplicityWidget(r)->text();
+ newText = KInputDialog::getText(i18n("Multiplicity"),
+ i18n("Enter multiplicity:"),
+ oldText, 0, view, &v);
+ if (newText != oldText && FloatingTextWidget::isTextValid(newText)) {
+ setMultiplicity(newText, r);
+ }
+ break;
+
+ case ListPopupMenu::mt_Rename_Name:
+ oldText = m_nameWidget->text();
+ newText = KInputDialog::getText(i18n("Association Name"),
+ i18n("Enter association name:"),
+ oldText, 0, view, &v);
+ if (newText != oldText && FloatingTextWidget::isTextValid(newText)) {
+ setName(newText);
+ }
+ break;
+
+ case ListPopupMenu::mt_Rename_RoleAName:
+ r = Uml::A; // fall through
+ case ListPopupMenu::mt_Rename_RoleBName:
+ oldText = roleName(r);
+ newText = KInputDialog::getText(i18n("Role Name"),
+ i18n("Enter role name:"),
+ oldText, 0, view, &v);
+ if (newText != oldText && FloatingTextWidget::isTextValid(newText)) {
+ setRoleName(newText, r);
+ }
+ break;
+
+ case ListPopupMenu::mt_Change_Font:
+ font = this->font();
+ if (KFontDialog::getFont(font, false, view)) {
+ lwSetFont(font);
+ }
+ break;
+
+ case ListPopupMenu::mt_Change_Font_Selection:
+ font = this->font();
+ if (KFontDialog::getFont(font, false, view)) {
+ if (scene) {
+ scene->selectionSetFont(font);
+ }
+ umlDoc()->setModified(true);
+ }
+ break;
+
+ case ListPopupMenu::mt_Line_Color:
+ {
+ QColor newColor = lineColor();
+ if (KColorDialog::getColor(newColor) && scene) {
+ scene->selectionSetLineColor(newColor);
+ umlDoc()->setModified(true);
+ }
+ }
+ break;
+
+ case ListPopupMenu::mt_Cut:
+ // TODO:
+#if 0
+ m_pView->setStartedCut();
+ UMLApp::app()->slotEditCut();
+#endif
+ break;
+
+ case ListPopupMenu::mt_Copy:
+ // TODO:
+#if 0
+ UMLApp::app()->slotEditCopy();
+#endif
+ break;
+
+ case ListPopupMenu::mt_Paste:
+ // TODO:
+#if 0
+ UMLApp::app()->slotEditPaste();
+#endif
+ break;
+
+ case ListPopupMenu::mt_Reset_Label_Positions:
+ resetTextPositions();
+ break;
+
+ default:
+ uDebug() << "Menu_Type " << sel << " not implemented";
+ }//end switch
+}
+
/**
* Reimplemented to handle updation of underlying UMLObject
* @note syncToModel() is deprecated as I see no point in setting the object's variable
--- branches/work/soc-umbrello/umbrello/widgets/associationwidget.h #1010472:1010473
@@ -70,7 +70,7 @@
virtual void setMessageText(FloatingTextWidget *ft);
virtual void setText(FloatingTextWidget *ft, const QString &newText);
- virtual bool showDialog();
+ virtual void showPropertiesDialog();
virtual UMLClassifier* getSeqNumAndOp(QString& seqNum, QString& op);
virtual void setSeqNumAndOp(const QString &seqNum, const QString &op);
@@ -136,9 +136,13 @@
virtual QPainterPath shape() const;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem* opt, QWidget*);
+ bool loadFromXMI(const QDomElement& element, UMLWidgetList &list);
virtual bool loadFromXMI(QDomElement& element);
- bool loadFromXMI(const QDomElement& element, UMLWidgetList &list);
+ virtual void saveToXMI(QDomDocument &qDoc, QDomElement &qElement);
+ public Q_SLOTS:
+ virtual void slotMenuSelection(QAction *trigger);
+
protected Q_SLOTS:
virtual void slotUMLObjectDataChanged();
--- branches/work/soc-umbrello/umbrello/widgets/floatingtextwidget.cpp #1010472:1010473
@@ -246,7 +246,7 @@
// double clicking on a text line opens the dialog to change the text
handleRename();
} else if (m_linkWidget) {
- m_linkWidget->showDialog();
+ m_linkWidget->showPropertiesDialog();
}
}
--- branches/work/soc-umbrello/umbrello/widgets/linkwidget.cpp #1010472:1010473
@@ -64,8 +64,7 @@
* Motivated by FloatingTextWidget::mouseDoubleClickEvent()
* Only applies to AssociationWidget.
*/
-bool LinkWidget::showDialog() {
- return true;
+void LinkWidget::showPropertiesDialog() {
}
/**
--- branches/work/soc-umbrello/umbrello/widgets/linkwidget.h #1010472:1010473
@@ -83,7 +83,7 @@
*/
virtual void setText(FloatingTextWidget *ft, const QString &newText) = 0;
- virtual bool showDialog();
+ virtual void showPropertiesDialog();
/**
* Motivated by FloatingTextWidget::showOpDlg()
More information about the umbrello-devel
mailing list