[Uml-devel] branches/work/soc-umbrello/umbrello

Andi Fischer andi.fischer at hispeed.ch
Sat Oct 8 12:18:55 UTC 2011


SVN commit 1257942 by fischer:

Debug output improved, UMLListView with more comments.

 M  +11 -0     folder.cpp  
 M  +2 -0      folder.h  
 M  +1 -1      umldoc.cpp  
 M  +44 -25    umllistview.cpp  
 U             umllistview.h  
 M  +5 -3      umllistviewitem.cpp  
 U             umllistviewitem.h  
 M  +3 -2      umlobject.cpp  
 M  +1 -1      umlscene.cpp  


--- branches/work/soc-umbrello/umbrello/folder.cpp #1257941:1257942
@@ -526,4 +526,15 @@
     return totalSuccess;
 }
 
+/**
+ * Overloading operator for debugging output.
+ */
+QDebug operator<<(QDebug out, const UMLFolder& item)
+{
+    out.nospace() << "UMLFolder: localName=" << item.m_localName
+        << ", folderFile=" << item.m_folderFile
+        << ", diagrams=" << item.m_diagrams.count();
+    return out.space();
+}
+
 #include "folder.moc"
--- branches/work/soc-umbrello/umbrello/folder.h #1257941:1257942
@@ -62,6 +62,8 @@
 
     void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
 
+    friend QDebug operator<<(QDebug out, const UMLFolder& item);
+
 protected:
     void saveContents(QDomDocument& qDoc, QDomElement& qElement);
 
--- branches/work/soc-umbrello/umbrello/umldoc.cpp #1257941:1257942
@@ -175,6 +175,7 @@
         uError() << "view folder is not set";
         return;
     }
+    DEBUG(DBG_SRC) << "to folder " << *f;
     f->addView(view);
 
     UMLApp * pApp = UMLApp::app();
@@ -240,7 +241,6 @@
         }
 
         if ( firstView ) {
-            DEBUG(DBG_SRC) << "changing current view";  //:TODO:
             changeCurrentView( firstView->umlScene()->getID() );
             UMLApp::app()->setDiagramMenuItemsState(true);
         }
--- branches/work/soc-umbrello/umbrello/umllistview.cpp #1257941:1257942
@@ -146,8 +146,8 @@
  */
 void UMLListView::slotItemChanged(QTreeWidgetItem * item, int column)
 {
-    DEBUG(DBG_SRC) << item->text(column);  //:TODO:
     if (m_editItem) {
+        DEBUG(DBG_SRC) << item->text(column);
         endRename(static_cast<UMLListViewItem*>(item));
     }
 }
@@ -159,7 +159,7 @@
 {
     UMLListViewItem* currItem = static_cast<UMLListViewItem*>(currentItem());
     if (currItem && currItem->isSelected()) {
-        DEBUG(DBG_SRC) << currItem->text(0);  //:TODO:
+        DEBUG(DBG_SRC) << currItem->text(0);
         if (m_editItem) {
             if (m_editItem == currItem) {
                 // clicked on the item which is just edited
@@ -1239,12 +1239,12 @@
     } else {
         item = m_lv[Uml::ModelType::Logical];
     }
-    for (int i=0; i < item->childCount(); i++) {
-        UMLListViewItem* foundItem = recursiveSearchForView(item->childItem(i), type, id);
-        if (foundItem)
+    UMLListViewItem* foundItem = recursiveSearchForView(item, type, id);
+    if (foundItem) {
             return foundItem;
     }
     uWarning() << "returning 0";
+    DEBUG(DBG_SRC) << "but was looking for " << *item;
     return 0;
 }
 
@@ -1256,23 +1256,37 @@
 UMLListViewItem* UMLListView::recursiveSearchForView(UMLListViewItem* listViewItem,
         UMLListViewItem::ListViewType type, Uml::IDType id)
 {
-    if (!listViewItem)
-        return 0;
-    // 
-    //if (listViewItem->type() == type && listViewItem->getID() == id)
-    //    return listViewItem;
-
+    while (listViewItem) {
+        //DEBUG(DBG_SRC) << *listViewItem;
     if (Model_Utils::typeIsFolder(listViewItem->type())) {
         for (int i=0; i < listViewItem->childCount(); i++) {
             UMLListViewItem* child = listViewItem->childItem(i);
             UMLListViewItem* resultListViewItem = recursiveSearchForView(child, type, id);
-            if (resultListViewItem)
+                if (resultListViewItem) {
                 return resultListViewItem;
         }
+            }
     } else {
-        if (listViewItem->type() == type && listViewItem->getID() == id)
+            if (listViewItem->type() == type && listViewItem->getID() == id) {
             return listViewItem;
     }
+        }
+        // next sibling
+        QTreeWidgetItem* parent = listViewItem->parent();
+        if (parent) {
+            int index = parent->indexOfChild(listViewItem);
+            index++;
+            if (index < parent->childCount()) {
+                listViewItem = static_cast<UMLListViewItem*>(parent->child(index));
+            }
+            else {
+                break;
+            }
+        }
+        else {
+            break;
+        }
+    }
     return 0;
 }
 
@@ -1425,7 +1439,9 @@
 }
 
 /**
- *
+ * Event handler for accepting drag request.
+ * @param event   the drop event
+ * @return success state
  */
 bool UMLListView::acceptDrag(QDropEvent* event) const
 {
@@ -2106,7 +2122,8 @@
 }
 
 /**
- *
+ * Event handler for lost focus.
+ * @param fe   the focus event
  */
 void UMLListView::focusOutEvent(QFocusEvent * fe)
 {
@@ -2204,7 +2221,7 @@
 }
 
 /**
- *
+ * TODO: still in use?
  */
 void UMLListView::startUpdate()
 {
@@ -2212,7 +2229,7 @@
 }
 
 /**
- *
+ * TODO: still in use?
  */
 void UMLListView::endUpdate()
 {
@@ -2771,12 +2788,13 @@
 }
 
 /**
- *
+ * Renaming of an item has started.
+ * @param item   the item which will be renamed
  */
 void UMLListView::startRename(UMLListViewItem* item)
 {
     if (item) {
-        DEBUG(DBG_SRC) << item->text(0);  //:TODO:
+        DEBUG(DBG_SRC) << item->text(0);
         if (m_editItem) {
             cancelRename(m_editItem);
         }
@@ -2796,7 +2814,7 @@
 void UMLListView::cancelRename(UMLListViewItem* item)
 {
     if (item) {
-        DEBUG(DBG_SRC) << item->text(0);  //:TODO:
+        DEBUG(DBG_SRC) << item->text(0);
         // delete pointer first to lock slotItemChanged
         m_editItem = 0;
         closePersistentEditor(item, 0);
@@ -2810,12 +2828,13 @@
 }
 
 /**
- *
+ * Renaming of an item has ended.
+ * @param item   the item which was renamed or not
  */
 void UMLListView::endRename(UMLListViewItem* item)
 {
     if (item) {
-        DEBUG(DBG_SRC) << item->text(0);  //:TODO:
+        DEBUG(DBG_SRC) << item->text(0);
         // delete pointer first to lock slotItemChanged
         m_editItem = 0;
         closePersistentEditor(item, 0);
@@ -3188,7 +3207,7 @@
     if (!parent) {
         return;
     }
-    DEBUG(DBG_SRC) << parent->text(0) << ":";  //:TODO:
+    DEBUG(DBG_SRC) << parent->text(0) << ":";
     for (int i = parent->childCount() - 1; i >= 0; --i) {
         UMLListViewItem* child = static_cast<UMLListViewItem*>(parent->child(i));
         // if child has children, then delete them first
@@ -3199,7 +3218,7 @@
         if (child == m_datatypeFolder) {
             continue;
         }
-        DEBUG(DBG_SRC) << "removing " << child->text(0);  //:TODO:
+        DEBUG(DBG_SRC) << "removing " << child->text(0);
         parent->removeChild(child);
         delete child;
     }
@@ -3334,7 +3353,7 @@
     else {
         out << "<null>";
     }
-    return out;
+    return out.space();
 }
 
 #include "umllistview.moc"
--- branches/work/soc-umbrello/umbrello/umllistviewitem.cpp #1257941:1257942
@@ -1046,7 +1046,9 @@
  */
 QDebug operator<<(QDebug out, const UMLListViewItem& item)
 {
-    out << item.text(0) << ", type=" << item.type()
-        << ", id=" << ID2STR(item.getID()) << ", children=" << item.childCount();
-    return out;
+    out.nospace() << "UMLListViewItem: " << item.text(0)
+        << ", type=" << UMLListViewItem::toString(item.type())
+        << ", id=" << ID2STR(item.getID())
+        << ", children=" << item.childCount();
+    return out.space();
 }
--- branches/work/soc-umbrello/umbrello/umlobject.cpp #1257941:1257942
@@ -1059,8 +1059,9 @@
  */
 QDebug operator<<(QDebug out, const UMLObject& obj)
 {
-    out << obj.name();
-    return out;
+    out.nospace() << "UMLObject: name= " << obj.name()
+        << ", type= " << UMLObject::toString(obj.m_BaseType);
+    return out.space();
 }
 
 #include "umlobject.moc"
--- branches/work/soc-umbrello/umbrello/umlscene.cpp #1257941:1257942
@@ -567,7 +567,7 @@
     //check to see if we want the message
     //may be wanted by someone else e.g. list view
 
-    DEBUG(DBG_SRC) << "\t\tcalled";  //:TODO:
+    DEBUG(DBG_SRC) << "with " << *o;  //:TODO:
     if (!m_bCreateObject)  {
         return;
     }




More information about the umbrello-devel mailing list