[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello
Thomas Gallinari
tg8187 at yahoo.fr
Wed Mar 21 11:15:44 UTC 2007
SVN commit 644949 by gallinari:
Save and load floatingdashline of combined fragment and allow to change the text of the alternative
M +45 -52 combinedfragmentwidget.cpp
M +1 -1 combinedfragmentwidget.h
M +36 -9 floatingdashlinewidget.cpp
M +1 -2 floatingdashlinewidget.h
M +1 -0 listpopupmenu.cpp
M +1 -1 umlview.cpp
--- branches/work/isi-umbrello/umbrello/umbrello/combinedfragmentwidget.cpp #644948:644949
@@ -41,7 +41,11 @@
updateComponentSize();
}
-CombinedFragmentWidget::~CombinedFragmentWidget() {}
+CombinedFragmentWidget::~CombinedFragmentWidget() {
+ for(QList<FloatingDashLineWidget*>::iterator it=m_dashLines.begin() ; it!=m_dashLines.end() ; ++it) {
+ delete(*it);
+ }
+}
void CombinedFragmentWidget::draw(QPainter & p, int offsetX, int offsetY) {
int w = width();
@@ -115,7 +119,8 @@
p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "alt");
// dash lines
- for(QList<FloatingDashLineWidget*>::iterator it=m_dashLines->begin() ; it!=m_dashLines->end() ; it++) {
+ m_dashLines.first()->draw(p,getX(),getY());
+ for(QList<FloatingDashLineWidget*>::iterator it=m_dashLines.begin() ; it!=m_dashLines.end() ; ++it) {
(*it)->setX(getX());
old_Y = (*it)->getYMin();
(*it)->setYMin(getY());
@@ -130,7 +135,7 @@
p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "parallel");
// dash lines
- for(QList<FloatingDashLineWidget*>::iterator it=m_dashLines->begin() ; it!=m_dashLines->end() ; it++) {
+ for(QList<FloatingDashLineWidget*>::iterator it=m_dashLines.begin() ; it!=m_dashLines.end() ; ++it) {
(*it)->setX(getX());
old_Y = (*it)->getYMin();
(*it)->setYMin(getY());
@@ -178,20 +183,19 @@
UMLWidget::m_bResizable = true ; //(m_CombinedFragment == Normal);
// creates a dash line if the combined fragment type is alternative or parallel
- if(m_CombinedFragment == Alt || m_CombinedFragment == Par)
+ if((m_CombinedFragment == Alt || m_CombinedFragment == Par) && m_dashLines.isEmpty())
{
- m_dashLines = new QList<FloatingDashLineWidget*>();
- m_dashLines->push_back(new FloatingDashLineWidget(m_pView));
+ m_dashLines.push_back(new FloatingDashLineWidget(m_pView));
if(m_CombinedFragment == Alt)
{
- m_dashLines->back()->setText("else");
+ m_dashLines.back()->setText("else");
}
- m_dashLines->back()->setX(getX());
- m_dashLines->back()->setYMin(getY());
- m_dashLines->back()->setYMax(getY() + getHeight());
- m_dashLines->back()->setY(getY() + getHeight() / 2);
- m_dashLines->back()->setSize(getWidth(), 0);
- m_pView->setupNewWidget(m_dashLines->back());
+ m_dashLines.back()->setX(getX());
+ m_dashLines.back()->setYMin(getY());
+ m_dashLines.back()->setYMax(getY() + getHeight());
+ m_dashLines.back()->setY(getY() + getHeight() / 2);
+ m_dashLines.back()->setSize(getWidth(), 0);
+ m_pView->setupNewWidget(m_dashLines.back());
}
}
@@ -267,13 +271,9 @@
combinedFragmentElement.setAttribute( "CombinedFragmenttype", m_CombinedFragment );
// save the corresponding floating dash lines
- /*QString dashlineId("dashlineId");
- int i=1;
- for (list<FloatingDashLineWidget*>::iterator it = m_dashLines->begin() ; it != m_dashLines->end() ; it++) {
- combinedFragmentElement.setAttribute( dashlineId.append(i), ID2STR((*it)->getID()) );
- (*it) -> saveToXMI( qDoc, combinedFragmentElement );
- i++;
- }*/
+ for (QList<FloatingDashLineWidget*>::iterator it = m_dashLines.begin() ; it != m_dashLines.end() ; ++it) {
+ (*it)-> saveToXMI( qDoc, combinedFragmentElement );
+ }
qElement.appendChild( combinedFragmentElement );
}
@@ -284,42 +284,35 @@
m_Text = qElement.attribute( "combinedFragmentname", "" );
m_Doc = qElement.attribute( "documentation", "" );
QString type = qElement.attribute( "CombinedFragmenttype", "");
+ Uml::IDType dashlineId;
+ QList<FloatingDashLineWidget*> listline;
- // TODO : load floating dash lines of the combined fragment
- /*QString dashlineId("dashlineId");
- int i=1;
- for (list<FloatingDashLineWidget>::iterator it = m_dashLines->begin() ; it != m_dashLines->end() ; it++) {
- QString dashId = qElement.attribute( dashlineId.append(i), "");
- Uml::IDType dashlineId = STR2ID(dashId);
- if (dashlineId != Uml::id_None) {
- UMLWidget *floatdashline = m_pView -> findWidget( dashlineId );
- if (floatdashline != NULL) {
- it = static_cast<FloatingDashLineWidget*>(floatdashline);
- return true;
- }
- }
- i++;
- }*/
-
//now load child elements
QDomNode node = qElement.firstChild();
QDomElement element = node.toElement();
- if ( !element.isNull() ) {
+ while ( !element.isNull() ) {
QString tag = element.tagName();
if (tag == "floatingdashlinewidget") {
- /*m_dashLines.push_back(new FloatingDashLineWidget( m_pView , dashlineId ));
- if( ! m_dashLine->loadFromXMI(element) ) {
- // Most likely cause: The FloatingTextWidget is empty.
- delete m_dashLine;
- m_dashLine = NULL;
- }*/
+ FloatingDashLineWidget * fdlwidget = new FloatingDashLineWidget(m_pView);
+ m_dashLines.push_back(fdlwidget);
+ if( !fdlwidget->loadFromXMI(element) ) {
+ // Most likely cause: The FloatingTextWidget is empty.
+ delete m_dashLines.back();
+ return false;
+ }
+ else {
+ m_pView->setupNewWidget(fdlwidget);
+ }
} else {
kError() << "MessageWidget::loadFromXMI: unknown tag "
<< tag << endl;
}
+ node = node.nextSibling();
+ element = node.toElement();
}
+ // m_dashLines = listline;
setCombinedFragmentType( (CombinedFragmentType)type.toInt() );
-
+
return true;
}
@@ -328,17 +321,17 @@
switch (sel) {
// for alternative or parallel combined fragments
case ListPopupMenu::mt_AddInteractionOperand:
- m_dashLines->push_back(new FloatingDashLineWidget(m_pView));
+ m_dashLines.push_back(new FloatingDashLineWidget(m_pView));
if(m_CombinedFragment == Alt)
{
- m_dashLines->back()->setText("else");
+ m_dashLines.back()->setText("else");
}
- m_dashLines->back()->setX(getX());
- m_dashLines->back()->setYMin(getY());
- m_dashLines->back()->setYMax(getY() + getHeight());
- m_dashLines->back()->setY(getY() + getHeight() / 2);
- m_dashLines->back()->setSize(getWidth(), 0);
- m_pView->setupNewWidget(m_dashLines->back());
+ m_dashLines.back()->setX(getX());
+ m_dashLines.back()->setYMin(getY());
+ m_dashLines.back()->setYMax(getY() + getHeight());
+ m_dashLines.back()->setY(getY() + getHeight() / 2);
+ m_dashLines.back()->setSize(getWidth(), 0);
+ m_pView->setupNewWidget(m_dashLines.back());
break;
default:
break;
--- branches/work/isi-umbrello/umbrello/umbrello/combinedfragmentwidget.h #644948:644949
@@ -123,7 +123,7 @@
/**
* Dash lines of an alternative or parallel combined fragment
*/
- QList<FloatingDashLineWidget*> *m_dashLines ;
+ QList<FloatingDashLineWidget*> m_dashLines ;
};
#endif
--- branches/work/isi-umbrello/umbrello/umbrello/floatingdashlinewidget.cpp #644948:644949
@@ -8,11 +8,18 @@
* copyright (C) 2002-2006 *
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
-
// own header
#include "floatingdashlinewidget.h"
+
+//kde includes
+#include "kdebug.h"
+#include "kinputdialog.h"
+#include "klocale.h"
+
+//app includes
#include "umlview.h"
#include "widget_utils.h"
+#include "listpopupmenu.h"
// qt includes
#include <qpainter.h>
@@ -22,7 +29,7 @@
{
UMLWidget::setBaseType(Uml::wt_FloatingDashLine);
m_bResizable = false;
- m_text = "";
+ m_Text = "";
updateComponentSize();
}
@@ -35,7 +42,7 @@
p.setPen(Qt::black);
p.setFont(UMLWidget::getFont());
p.drawText(getX() + FLOATING_DASH_LINE_TEXT_MARGIN, getY(),
- getWidth() - FLOATING_DASH_LINE_TEXT_MARGIN * 2, fontHeight, Qt::AlignLeft, m_text);
+ getWidth() - FLOATING_DASH_LINE_TEXT_MARGIN * 2, fontHeight, Qt::AlignLeft, m_Text);
p.setPen(*(new QPen(UMLWidget::getLineColor(), 0, Qt::DashLine)));
p.drawLine(getX(), getY(), getX() + getWidth(), getY());
if(m_bSelected)
@@ -44,7 +51,7 @@
void FloatingDashLineWidget::setText(QString text)
{
- m_text = text;
+ m_Text = text;
}
bool FloatingDashLineWidget::onLine(const QPoint &point) {
@@ -56,6 +63,24 @@
return false;
}
+void FloatingDashLineWidget::slotMenuSelection(int sel) {
+ bool done = false;
+
+ bool ok = false;
+ QString name = m_Text;
+
+ switch( sel ) {
+ case ListPopupMenu::mt_Rename:
+ name = KInputDialog::getText( i18n("Enter alternative Name"), i18n("Enter the alternative :"), m_Text, &ok );
+ if( ok && name.length() > 0 )
+ m_Text = name;
+ done = true;
+ break;
+ }
+ if( !done )
+ UMLWidget::slotMenuSelection( sel );
+}
+
void FloatingDashLineWidget::setY(int y)
{
if(y >= m_yMin + FLOATING_DASH_LINE_MARGIN && y <= m_yMax - FLOATING_DASH_LINE_MARGIN)
@@ -86,7 +111,7 @@
QDomElement textElement = qDoc.createElement( "floatingdashlinewidget" );
UMLWidget::saveToXMI( qDoc, textElement );
textElement.setAttribute( "text", m_Text );
- textElement.setAttribute( "y", m_y );
+ textElement.setAttribute( "y", getY() );
textElement.setAttribute( "minY", m_yMin );
textElement.setAttribute( "maxY", m_yMax );
@@ -94,14 +119,16 @@
}
bool FloatingDashLineWidget::loadFromXMI( QDomElement & qElement ) {
- if( !UMLWidget::loadFromXMI( qElement ) )
+ if( !UMLWidget::loadFromXMI( qElement ) ) {
return false;
-
+ }
+ kDebug() <<"load......." <<endl;
m_yMax = qElement.attribute( "maxY", "" ).toInt();
m_yMin = qElement.attribute( "minY", "" ).toInt();
- m_y = qElement.attribute( "y", "" ).toInt();
+ setY(qElement.attribute( "y", "" ).toInt());
m_Text = qElement.attribute( "text", "" );
-
+ kDebug() <<"m_y......." <<m_y <<endl;
+ return true;
}
#include "floatingdashlinewidget.moc"
--- branches/work/isi-umbrello/umbrello/umbrello/floatingdashlinewidget.h #644948:644949
@@ -13,7 +13,6 @@
#define FLOATINGDASHLINEWIDGET_H
#include "umlwidget.h"
-
#define FLOATING_DASH_LINE_MARGIN 25
#define FLOATING_DASH_LINE_TEXT_MARGIN 5
@@ -53,7 +52,7 @@
*/
void draw(QPainter & p, int offsetX, int offsetY);
-
+ void slotMenuSelection(int sel);
/**
* Returns true if the given point is near the floatingdashline
*/
--- branches/work/isi-umbrello/umbrello/umbrello/listpopupmenu.cpp #644948:644949
@@ -431,6 +431,7 @@
}
break;
+ case Uml::wt_FloatingDashLine:
case Uml::wt_Precondition:
setupColor( object -> getUseFillColour() );
insertSeparator();
--- branches/work/isi-umbrello/umbrello/umbrello/umlview.cpp #644948:644949
@@ -3070,7 +3070,7 @@
// We DONT want to record any text widgets which are belonging
// to associations as they are recorded later in the "associations"
// section when each owning association is dumped. -b.t.
- if (widget->getBaseType() != wt_Text || widget->getBaseType() != wt_FloatingDashLine ||
+ if ((widget->getBaseType() != wt_Text && widget->getBaseType() != wt_FloatingDashLine ) ||
static_cast<FloatingTextWidget*>(widget)->getLink() == NULL)
widget->saveToXMI( qDoc, widgetElement );
}
More information about the umbrello-devel
mailing list