[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sat Jan 21 09:04:01 UTC 2006
SVN commit 500952 by okellogg:
Prepare for fixing http://bugs.debian.org/348940 -
compare(): Defaulting to alphaOrder makes no sense in the presence of
classifier list item reordering (ClassifierListPage::slot{Up,Down}Clicked).
Instead, listview item insertion reflects the UMLClassifierListItem insertion
behavior of the UMLClassifier.
M +51 -9 umllistviewitem.cpp
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistviewitem.cpp #500951:500952
@@ -336,9 +336,13 @@
UMLDoc* doc = s_pListView->getDocument();
if (m_bCreating) {
m_bCreating = false;
+ QString savedLabel = m_Label;
+ m_Label = text(col);
if ( s_pListView->slotItemRenamed( this, col ) ) {
- m_Label = text(col);
+ s_pListView->ensureItemVisible(this);
doc->setModified(true);
+ } else {
+ m_Label = savedLabel;
}
return;
}
@@ -534,7 +538,7 @@
}
// Sort the listview items by type and position within the corresponding list
-// of UMLObjects. If the item does not have an UMLObject then sort alphabetically.
+// of UMLObjects. If the item does not have an UMLObject then place it last.
int UMLListViewItem::compare(QListViewItem *other, int col, bool ascending) const
{
UMLListViewItem *ulvi = static_cast<UMLListViewItem*>(other);
@@ -546,21 +550,59 @@
if ( ourType > otherType )
return 1;
// ourType == otherType
- const int alphaOrder = key(col, ascending).compare(other->key(col, ascending));
UMLObject *otherObj = ulvi->getUMLObject();
- if (m_pObject == NULL || otherObj == NULL)
- return alphaOrder;
+ if (m_pObject == NULL) {
+ kdDebug() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return 1 because (m_pObject==NULL)" << endl;
+ return 1;
+ }
+ if (otherObj == NULL) {
+ kdDebug() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return -1 because (otherObj==NULL)" << endl;
+ return -1;
+ }
UMLClassifier *ourParent = dynamic_cast<UMLClassifier*>(m_pObject->parent());
UMLClassifier *otherParent = dynamic_cast<UMLClassifier*>(otherObj->parent());
- if (ourParent == NULL || otherParent == NULL || ourParent != otherParent)
- return alphaOrder;
+ if (ourParent == NULL) {
+ kdDebug() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return 1 because (ourParent==NULL)" << endl;
+ return 1;
+ }
+ if (otherParent == NULL) {
+ kdDebug() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return -1 because (otherParent==NULL)" << endl;
+ return -1;
+ }
+ if (ourParent != otherParent) {
+ kdDebug() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return 0 because (ourParent != otherParentL)" << endl;
+ return 0;
+ }
UMLClassifierListItem *thisUmlItem = dynamic_cast<UMLClassifierListItem*>(m_pObject);
UMLClassifierListItem *otherUmlItem = dynamic_cast<UMLClassifierListItem*>(otherObj);
- if (thisUmlItem == NULL || otherUmlItem == NULL)
- return alphaOrder;
+ if (thisUmlItem == NULL) {
+ kdDebug() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return 1 because (thisUmlItem==NULL)" << endl;
+ return 1;
+ }
+ if (otherUmlItem == NULL) {
+ kdDebug() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return -1 because (otherUmlItem==NULL)" << endl;
+ return -1;
+ }
UMLClassifierListItemList items = ourParent->getFilteredList(thisUmlItem->getBaseType());
int myIndex = items.findRef(thisUmlItem);
int otherIndex = items.findRef(otherUmlItem);
+ if (myIndex < 0) {
+ kdError() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return -1 because (myIndex < 0)" << endl;
+ return -1;
+ }
+ if (otherIndex < 0) {
+ kdError() << "compare(self=" << getText() << ", other=" << ulvi->getText()
+ << "): return 1 because (otherIndex < 0)" << endl;
+ return 1;
+ }
return (myIndex < otherIndex ? -1 : myIndex > otherIndex ? 1 : 0);
}
More information about the umbrello-devel
mailing list