[Uml-devel] KDE/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sun Feb 19 22:56:53 UTC 2012
SVN commit 1281004 by okellogg:
UMLListView cleanup of item creation:
- createItem(UMLListViewItem *item, UMLListViewItem::ListViewType):
Remove 2nd arg, listview type can be retrieved using item->type()
- addNewItem(): Use m_editItem for the UMLListViewItem created.
Calling createItem() here is too early: We want to give the user a
chance to edit the new item name. Move call of createItem() to...
- slotItemChanged(): ... here.
If the new text is empty then use the lvitem->getSavedText() for
creating the document object.
M +22 -32 umllistview.cpp
M +1 -1 umllistview.h
--- trunk/KDE/kdesdk/umbrello/umbrello/umllistview.cpp #1281003:1281004
@@ -146,23 +146,20 @@
*/
void UMLListView::slotItemChanged(QTreeWidgetItem * item, int column)
{
+ UMLListViewItem *lvitem = dynamic_cast<UMLListViewItem*>(item);
+ if (lvitem == NULL || m_editItem == NULL)
+ return;
QString text = item->text(column);
- UMLListViewItem *lvitem = static_cast<UMLListViewItem*>(item);
-
if (lvitem->creating()) {
- DEBUG(DBG_SRC) << "creating text: " << text;
- UMLObject *o = lvitem->umlObject();
- if (o && !text.isEmpty()) {
- // addNewItem() already did the createItem(), therefore
- // we don't want any further signal or undo stack entry.
- // In fact, we _cannot_ have signals enabled here because
- // it gives an endless recursion.
- blockSignals(true);
- o->setNameCmd(text);
- blockSignals(false);
- }
lvitem->setCreating(false);
- } else if (m_editItem) {
+ m_editItem = NULL;
+ if (text.isEmpty()) {
+ text = lvitem->getSavedText();
+ lvitem->setText(text);
+ }
+ DEBUG(DBG_SRC) << "creating text: " << text;
+ createItem(lvitem);
+ } else {
DEBUG(DBG_SRC) << "text: " << text;
endRename(lvitem);
}
@@ -603,7 +600,6 @@
UMLApp::app()->docWindow()->updateDocumentation(false);
pView->umlScene()->showPropDialog();
UMLApp::app()->docWindow()->showDocumentation(pView, true);
-//:TODO:delete? currItem->cancelRename(0);
return;
}
@@ -667,7 +663,6 @@
} else {
uWarning() << "calling properties on unknown type";
}
-//:TODO:delete? currItem->cancelRename(0);
}
// Bug 268469: Changing the package of a class deletes the old widget.
// By reloading the current item we are sure to not use a destroyed object
@@ -1395,7 +1390,6 @@
UMLApp::app()->docWindow()->updateDocumentation(false);
pView->umlScene()->showPropDialog();
UMLApp::app()->docWindow()->showDocumentation(pView, true);
-//:TODO:delete? item->cancelRename(0);
return;
}
//else see if an object
@@ -1435,7 +1429,6 @@
if (object) {
object->showPropertiesPagedDialog(page);
}
-//:TODO:delete? item->cancelRename(0); //double click can cause it to go into rename mode.
}
/**
@@ -2247,7 +2240,6 @@
parentItem = m_datatypeFolder;
}
- UMLListViewItem * newItem = 0;
parentItem->setOpen(true);
Icon_Utils::IconType icon = Model_Utils::convert_LVT_IT(type);
@@ -2256,9 +2248,7 @@
if (Model_Utils::typeIsDiagram(type)) {
Uml::DiagramType dt = Model_Utils::convert_LVT_DT(type);
name = uniqueDiagramName(dt);
- newItem = new UMLListViewItem(parentItem, name, type, Uml::id_None);
- newItem->setIcon(icon);
- newItem->setOpen(true);
+ m_editItem = new UMLListViewItem(parentItem, name, type, Uml::id_None);
} else {
UMLObject::ObjectType ot = Model_Utils::convert_LVT_OT(type);
if (ot == UMLObject::ot_UMLObject) {
@@ -2278,13 +2268,14 @@
} else {
name = Model_Utils::uniqObjectName(ot, parentPkg);
}
- newItem = new UMLListViewItem(parentItem, name, type, (UMLObject *)0);
- newItem->setIcon(icon);
- newItem->setOpen(true);
- newItem->setCreating(true);
- editItem(newItem, 0);
- createItem(newItem, type);
+ m_editItem = new UMLListViewItem(parentItem, name, type, (UMLObject *)0);
}
+ blockSignals(true);
+ m_editItem->setIcon(icon);
+ m_editItem->setOpen(true);
+ blockSignals(false);
+ m_editItem->setCreating(true);
+ editItem(m_editItem, 0);
}
/**
@@ -2324,11 +2315,12 @@
return false;
}
}
- return createItem(renamedItem, type);
+ return createItem(renamedItem);
}
-bool UMLListView::createItem(UMLListViewItem *item, UMLListViewItem::ListViewType type)
+bool UMLListView::createItem(UMLListViewItem *item)
{
+ const UMLListViewItem::ListViewType type = item->type();
switch (type) {
case UMLListViewItem::lvt_Actor:
case UMLListViewItem::lvt_Class:
@@ -2369,12 +2361,10 @@
case UMLListViewItem::lvt_UniqueConstraint:
case UMLListViewItem::lvt_ForeignKeyConstraint:
case UMLListViewItem::lvt_CheckConstraint:
-
return createChildUMLObject(item, Model_Utils::convert_LVT_OT(type));
break;
case UMLListViewItem::lvt_PrimaryKeyConstraint: {
-
bool result = createChildUMLObject(item, Model_Utils::convert_LVT_OT(type));
UMLObject* obj = item->umlObject();
UMLUniqueConstraint* uuc = static_cast<UMLUniqueConstraint*>(obj);
--- trunk/KDE/kdesdk/umbrello/umbrello/umllistview.h #1281003:1281004
@@ -73,7 +73,7 @@
UMLListViewItem* createItem(UMLListViewItem& Data, IDChangeLog& IDChanges,
UMLListViewItem* parent = 0);
- bool createItem(UMLListViewItem *item, UMLListViewItem::ListViewType type);
+ bool createItem(UMLListViewItem *item);
UMLListViewItem* findFolderForDiagram(Uml::DiagramType dt);
More information about the umbrello-devel
mailing list