[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello
Caroline Bourdeu d'Aguerre
cbda at free.fr
Fri Feb 2 12:49:46 UTC 2007
SVN commit 629349 by bourdeu:
Add the listBox to choose the type of the combined fragment.
M +58 -6 combinedfragmentwidget.cpp
M +11 -6 combinedfragmentwidget.h
M +24 -4 dialog_utils.cpp
M +2 -0 dialog_utils.h
M +1 -1 toolbarstatemessages.cpp
M +1 -5 toolbarstateother.cpp
--- branches/work/isi-umbrello/umbrello/umbrello/combinedfragmentwidget.cpp #629348:629349
@@ -19,6 +19,7 @@
#include <klocale.h>
#include <kdebug.h>
#include <kinputdialog.h>
+#include <kmessagebox.h>
// app includes
#include "uml.h"
@@ -27,15 +28,16 @@
#include "umlview.h"
#include "listpopupmenu.h"
#include "dialogs/activitydialog.h"
+#include "dialog_utils.h"
//Added by qt3to4:
#include <QMouseEvent>
#include <QPolygon>
-CombinedFragmentWidget::CombinedFragmentWidget(UMLView * view, CombinedFragmentType combfragmentType, Uml::IDType id ) : UMLWidget(view, id)
+CombinedFragmentWidget::CombinedFragmentWidget(UMLView * view, CombinedFragmentType combinedfragmentType, Uml::IDType id ) : UMLWidget(view, id)
{
UMLWidget::setBaseType( Uml::wt_Combined_Fragment );
- setCombinedFragmentType( combfragmentType );
+ setCombinedFragmentType( combinedfragmentType );
updateComponentSize();
}
@@ -60,9 +62,9 @@
int textStartY = (h / 2) - (fontHeight / 2);
p.drawRect(offsetX, offsetY, w, h );
- p.drawLine(offsetX, offsetY + 20, offsetX + 30, offsetY + 20);
- p.drawLine(offsetX + 30, offsetY + 20, offsetX + 35, offsetY + 10);
- p.drawLine(offsetX + 35, offsetY + 10, offsetX + 35, offsetY);
+ p.drawLine(offsetX, offsetY + 20, offsetX + 45, offsetY + 20);
+ p.drawLine(offsetX + 45, offsetY + 20, offsetX + 55, offsetY + 10);
+ p.drawLine(offsetX + 55, offsetY + 10, offsetX + 55, offsetY);
p.setPen(Qt::black);
p.setFont( UMLWidget::getFont() );
@@ -81,6 +83,32 @@
w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "opt");
break;
+ case Break :
+ p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
+ w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "break");
+ break;
+
+ case Loop :
+ p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
+ w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "loop");
+ break;
+
+ case Neg :
+ p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
+ w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "neg");
+ break;
+
+ case Crit :
+ p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
+ w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "critical");
+ break;
+
+ case Ass :
+ p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
+ w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "assert");
+ break;
+
+
default : break;
}
}
@@ -94,7 +122,7 @@
const int fontHeight = fm.lineSpacing();
const int textWidth = fm.width(getName());
height = fontHeight;
- width = textWidth + 50 > COMBINED_FRAGMENT_WIDTH ? textWidth + 50: COMBINED_FRAGMENT_WIDTH;
+ width = textWidth + 60 > COMBINED_FRAGMENT_WIDTH ? textWidth + 60: COMBINED_FRAGMENT_WIDTH;
height = height > COMBINED_FRAGMENT_HEIGHT ? height : COMBINED_FRAGMENT_HEIGHT;
width += COMBINED_FRAGMENT_MARGIN * 2;
height += COMBINED_FRAGMENT_MARGIN * 2;
@@ -106,10 +134,34 @@
}
void CombinedFragmentWidget::setCombinedFragmentType( CombinedFragmentType combinedfragmentType ) {
+
m_CombinedFragment = combinedfragmentType;
UMLWidget::m_bResizable = true ; //(m_CombinedFragment == Normal);
}
+CombinedFragmentWidget::CombinedFragmentType CombinedFragmentWidget::getCombinedFragmentType(QString type) const {
+ if(type == "Reference")
+ return (CombinedFragmentWidget::Ref);
+ if(type == "Option")
+ return (CombinedFragmentWidget::Opt);
+ if(type == "Break")
+ return (CombinedFragmentWidget::Break);
+ if(type == "Loop")
+ return (CombinedFragmentWidget::Loop);
+ if(type == "Negative")
+ return (CombinedFragmentWidget::Neg);
+ if(type == "Critical")
+ return (CombinedFragmentWidget::Crit);
+ if(type == "Assertion")
+ return (CombinedFragmentWidget::Ass);
+
+}
+
+void CombinedFragmentWidget::setCombinedFragmentType( QString combinedfragmentType ) {
+
+ setCombinedFragmentType(getCombinedFragmentType(combinedfragmentType) );
+}
+
void CombinedFragmentWidget::slotMenuSelection(int sel) {
bool done = false;
--- branches/work/isi-umbrello/umbrello/umbrello/combinedfragmentwidget.h #629348:629349
@@ -16,8 +16,8 @@
#include "worktoolbar.h"
#define COMBINED_FRAGMENT_MARGIN 5
-#define COMBINED_FRAGMENT_WIDTH 30
-#define COMBINED_FRAGMENT_HEIGHT 10
+#define COMBINED_FRAGMENT_WIDTH 100
+#define COMBINED_FRAGMENT_HEIGHT 50
/**
* This class is the graphical version of a UML combined fragment. A combinedfragmentWidget is created
@@ -37,9 +37,13 @@
public:
enum CombinedFragmentType
{
- Normal,
- Ref,
- Opt
+ Ref = 0,
+ Opt,
+ Break,
+ Loop,
+ Neg,
+ Crit,
+ Ass
};
/**
@@ -66,12 +70,13 @@
* Returns the type of combined fragment.
*/
CombinedFragmentType getCombinedFragmentType() const;
+ CombinedFragmentType getCombinedFragmentType(QString combinedfragmentType) const;
/**
* Sets the type of combined fragment.
*/
void setCombinedFragmentType( CombinedFragmentType combinedfragmentType );
-
+ void setCombinedFragmentType( QString combinedfragmentType );
/**
* Show a properties dialog for a CombinedFragmentWidget.
*
--- branches/work/isi-umbrello/umbrello/umbrello/dialog_utils.cpp #629348:629349
@@ -18,19 +18,20 @@
#include <qlabel.h>
#include <qlineedit.h>
#include <kinputdialog.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+
//Added by qt3to4:
#include <QGridLayout>
// app includes
#include "uml.h"
#include "umlwidget.h"
+#include "combinedfragmentwidget.h"
namespace Dialog_Utils {
-QLineEdit* makeLabeledEditField(Q3GroupBox *containingBox, QGridLayout *layout, int row,
- QLabel * &label, const QString& labelText,
- QLineEdit * &editField,
- const QString& editFieldText /* = QString::null */)
+QLineEdit* makeLabeledEditField(Q3GroupBox *containingBox, QGridLayout *layout, int row,QLabel * &label, const QString& labelText, QLineEdit * &editField, const QString& editFieldText /* = QString::null */)
{
label = new QLabel(labelText, containingBox);
layout->addWidget(label, row, 0);
@@ -57,6 +58,25 @@
}
}
+void askNameForWidgetType(UMLWidget* &targetWidget, const QString& dialogTitle,
+ const QString& dialogPrompt, const QString& defaultName) {
+ bool pressedOK = false;
+ const QStringList list = QStringList() << "Reference" << "Option" << "Break" << "Loop" << "Negative" << "Critical" << "Assertion";
+ const QStringList select = QStringList() << "Reference" << "Option" << "Break" << "Loop" << "Negative" << "Critical" << "Assertion";;
+ QStringList result = KInputDialog::getItemList (dialogTitle, dialogPrompt, list, select, false, &pressedOK, UMLApp::app());
+
+ if (pressedOK) {
+ QString type = result.join("");
+ dynamic_cast<CombinedFragmentWidget*>(targetWidget)->setCombinedFragmentType(type);
+ if (type == "Reference" )
+ askNameForWidget(targetWidget, i18n("Enter the name of the diagram referenced"), i18n("Enter the name of the diagram referenced"), i18n("Diagram name"));
+ } else {
+ targetWidget->cleanup();
+ delete targetWidget;
+ targetWidget = NULL;
+ }
+}
+
} // end namespace Dialog_Utils
--- branches/work/isi-umbrello/umbrello/umbrello/dialog_utils.h #629348:629349
@@ -59,6 +59,8 @@
*/
void askNameForWidget(UMLWidget * &targetWidget, const QString& dialogTitle,
const QString& dialogPrompt, const QString& defaultName);
+void askNameForWidgetType(UMLWidget * &targetWidget, const QString& dialogTitle,
+ const QString& dialogPrompt, const QString& defaultName);
}
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstatemessages.cpp #629348:629349
@@ -156,7 +156,7 @@
m_firstObject = firstObject;
Uml::Sequence_Message_Type msgType = getMessageType();
int y = m_pMouseEvent->y();
- if (msgType == Uml::sequence_message_found) {
+ if (msgType == Uml::sequence_message_found && xclick!=0 && yclick!=0) {
MessageWidget* message = new MessageWidget(m_pUMLView, m_firstObject,m_firstObject, y, msgType);
message->setxclicked(xclick);
message->setyclicked(yclick);
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstateother.cpp #629348:629349
@@ -106,10 +106,6 @@
umlWidget = new ActivityWidget(m_pUMLView, ActivityWidget::Normal);
break;
- //case WorkToolBar::tbb_Seq_Precondition:
- // umlWidget = new PreconditionWidget(m_pUMLView,static_cast<ObjectWidget*>(getCurrentWidget()));
- // break;
-
case WorkToolBar::tbb_End_Activity:
umlWidget = new ActivityWidget(m_pUMLView, ActivityWidget::End);
break;
@@ -158,7 +154,7 @@
umlWidget, i18n("Enter Precondition Name"),
i18n("Enter the precondition"), i18n("new precondition"));
} else if (getButton() == WorkToolBar::tbb_Seq_Combined_Fragment) {
- Dialog_Utils::askNameForWidget(
+ Dialog_Utils::askNameForWidgetType(
umlWidget, i18n("Enter Combined Fragment Name"),
i18n("Enter the Combined Fragment"), i18n("new Combined Fragment"));
} else if (getButton() == WorkToolBar::tbb_State) {
More information about the umbrello-devel
mailing list