[Uml-devel] KDE/kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Thu Sep 14 19:11:00 UTC 2006


SVN commit 584413 by okellogg:

sync with branches/KDE/3.5 (r581960:583979)

 M  +99 -24    dialogs/classifierlistpage.cpp  
 M  +18 -0     dialogs/classifierlistpage.h  
 M  +1 -0      model_utils.cpp  
 M  +2 -0      uml.cpp  
 M  +0 -1      umldoc.cpp  
 M  +3 -2      umllistviewitem.cpp  
 M  +11 -7     umlobject.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/classifierlistpage.cpp #584412:584413
@@ -80,6 +80,10 @@
 
     //the move up/down buttons (another vertical box)
     QVBoxLayout* buttonLayout = new QVBoxLayout( listHBoxLayout );
+    m_pTopArrowB = new KArrowButton( m_pItemListGB );
+    m_pTopArrowB->setEnabled( false );
+    buttonLayout->addWidget( m_pTopArrowB );
+
     m_pUpArrowB = new KArrowButton( m_pItemListGB );
     m_pUpArrowB->setEnabled( false );
     buttonLayout->addWidget( m_pUpArrowB );
@@ -88,6 +92,10 @@
     m_pDownArrowB->setEnabled( false );
     buttonLayout->addWidget( m_pDownArrowB );
 
+    m_pBottomArrowB = new KArrowButton( m_pItemListGB, Qt::DownArrow );
+    m_pBottomArrowB->setEnabled( false );
+    buttonLayout->addWidget( m_pBottomArrowB );
+
     //the action buttons
     KButtonBox* buttonBox = new KButtonBox(m_pItemListGB);
     buttonBox->addButton( newItemType, this, SLOT(slotNewListItem()) );
@@ -127,8 +135,10 @@
             this, SLOT(slotRightButtonClicked(Q3ListBoxItem*, const QPoint&)));
     connect(m_pDoc, SIGNAL(sigObjectCreated(UMLObject*)), this, SLOT(slotListItemCreated(UMLObject*)));
 
+    connect( m_pTopArrowB, SIGNAL( clicked() ), this, SLOT( slotTopClicked() ) );
     connect( m_pUpArrowB, SIGNAL( clicked() ), this, SLOT( slotUpClicked() ) );
     connect( m_pDownArrowB, SIGNAL( clicked() ), this, SLOT( slotDownClicked() ) );
+    connect( m_pBottomArrowB, SIGNAL( clicked() ), this, SLOT( slotBottomClicked() ) );
     connect( m_pItemListLB, SIGNAL( doubleClicked( Q3ListBoxItem* ) ),
              this, SLOT( slotDoubleClick( Q3ListBoxItem* ) ) );
 }
@@ -142,8 +152,10 @@
     //if disabled clear contents
     if( !state ) {
         m_pDocTE->setText( "" );
+        m_pTopArrowB->setEnabled( false );
         m_pUpArrowB->setEnabled( false );
         m_pDownArrowB->setEnabled( false );
+        m_pBottomArrowB->setEnabled( false );
         m_pDeleteListItemButton->setEnabled(false);
         m_pPropertiesButton->setEnabled(false);
         return;
@@ -156,17 +168,25 @@
     */
     int index = m_pItemListLB->currentItem();
     if( m_pItemListLB->count() == 1 || index == -1 ) {
+        m_pTopArrowB->setEnabled( false );
         m_pUpArrowB->setEnabled( false );
         m_pDownArrowB->setEnabled( false );
+        m_pBottomArrowB->setEnabled( false );
     } else if( index == 0 ) {
+        m_pTopArrowB->setEnabled( false );
         m_pUpArrowB->setEnabled( false );
         m_pDownArrowB->setEnabled( true );
+        m_pBottomArrowB->setEnabled( true );
     } else if( index == (int)m_pItemListLB->count() - 1 ) {
+        m_pTopArrowB->setEnabled( true );
         m_pUpArrowB->setEnabled( true );
         m_pDownArrowB->setEnabled( false );
+        m_pBottomArrowB->setEnabled( false );
     } else {
+        m_pTopArrowB->setEnabled( true );
         m_pUpArrowB->setEnabled( true );
         m_pDownArrowB->setEnabled( true );
+        m_pBottomArrowB->setEnabled( true );
     }
     m_pDeleteListItemButton->setEnabled(true);
     m_pPropertiesButton->setEnabled(true);
@@ -332,6 +352,48 @@
     }
 }
 
+void ClassifierListPage::printItemList(QString prologue) {
+#ifdef VERBOSE_DEBUGGING
+    UMLClassifierListItem* item;
+    QString buf;
+    UMLClassifierListItemList itemList = getItemList();
+    for (UMLClassifierListItemListIt it(itemList); (item = it.current()) != NULL; ++it)
+        buf.append(" " + item->getName());
+    kDebug() << prologue << buf << endl;
+#endif
+}
+
+void ClassifierListPage::slotTopClicked() {
+    int count = m_pItemListLB->count();
+    int index = m_pItemListLB->currentItem();
+    //shouldn't occur, but just in case
+    if( count <= 1 || index <= 0 )
+        return;
+    m_pOldListItem = NULL;
+
+    //swap the text around in the ListBox
+    QString currentString = m_pItemListLB->text( index );
+    m_pItemListLB->removeItem( index );
+    m_pItemListLB->insertItem( currentString, 0 );
+    //set the moved item selected
+    Q3ListBoxItem* item = m_pItemListLB->item( 0 );
+    m_pItemListLB->setSelected( item, true );
+
+    //now change around in the list
+    printItemList("itemList before change: ");
+    UMLClassifierListItem* currentAtt = getItemList().at(index);
+    // NB: The index in the m_pItemListLB is not necessarily the same
+    //     as the index in the UMLClassifier::m_List.
+    //     Reason: getItemList() returns only a subset of all entries
+    //     in UMLClassifier::m_List.
+    takeItem(currentAtt, true, index);  // now we index the UMLClassifier::m_List
+    kDebug() << "ClassifierListPage::slotTopClicked(" << currentAtt->getName()
+            << "): peer index in UMLCanvasItem::m_List is " << index << endl;
+    addClassifier(currentAtt, 0);
+    printItemList("itemList after change: ");
+    slotClicked(item);
+}
+
 void ClassifierListPage::slotUpClicked() {
     int count = m_pItemListLB->count();
     int index = m_pItemListLB->currentItem();
@@ -350,13 +412,8 @@
     m_pItemListLB->setSelected( item, true );
 
     //now change around in the list
-    UMLClassifierListItemList itemList = getItemList();
-    UMLClassifierListItem* currentAtt;
-    QString buf;
-    for (UMLClassifierListItemListIt it0(itemList); (currentAtt = it0.current()); ++it0)
-        buf.append(" " + currentAtt->getName());
-    kDebug() << "itemList before change: " << buf << endl;
-    currentAtt = itemList.at( index );
+    printItemList("itemList before change: ");
+    UMLClassifierListItem* currentAtt = getItemList().at(index);
     // NB: The index in the m_pItemListLB is not necessarily the same
     //     as the index in the UMLClassifier::m_List.
     //     Reason: getItemList() returns only a subset of all entries
@@ -367,11 +424,7 @@
     if (index == -1)
         index = 0;
     addClassifier(currentAtt, index);
-    itemList = getItemList();
-    buf = QString::null;
-    for (UMLClassifierListItemListIt it1(itemList); (currentAtt = it1.current()); ++it1)
-        buf.append(" " + currentAtt->getName());
-    kDebug() << "itemList after change: " << buf << endl;
+    printItemList("itemList after change: ");
     slotClicked( item );
 }
 
@@ -392,13 +445,8 @@
     Q3ListBoxItem* item = m_pItemListLB->item( index + 1 );
     m_pItemListLB->setSelected( item, true );
     //now change around in the list
-    UMLClassifierListItemList itemList = getItemList();
-    UMLClassifierListItem* currentAtt;
-    QString buf;
-    for (UMLClassifierListItemListIt it0(itemList); (currentAtt = it0.current()); ++it0)
-        buf.append(" " + currentAtt->getName());
-    kDebug() << "itemList before change: " << buf << endl;
-    currentAtt = getItemList().at( index );
+    printItemList("itemList before change: ");
+    UMLClassifierListItem* currentAtt = getItemList().at(index);
     // NB: The index in the m_pItemListLB is not necessarily the same
     //     as the index in the UMLClassifier::m_List.
     //     Reason: getItemList() returns only a subset of all entries
@@ -409,14 +457,41 @@
     if (index != -1)
         index++;   // because we want to go _after_ the following peer item
     addClassifier(currentAtt, index);
-    itemList = getItemList();
-    buf = QString::null;
-    for (UMLClassifierListItemListIt it1(itemList); (currentAtt = it1.current()); ++it1)
-        buf.append(" " + currentAtt->getName());
-    kDebug() << "itemList after change: " << buf << endl;
+    printItemList("itemList after change: ");
     slotClicked( item );
 }
 
+void ClassifierListPage::slotBottomClicked() {
+    int count = m_pItemListLB->count();
+    int index = m_pItemListLB->currentItem();
+    //shouldn't occur, but just in case
+    if( count <= 1 || index >= count - 1 )
+        return;
+    m_pOldListItem = NULL;
+
+    //swap the text around in the ListBox
+    QString currentString = m_pItemListLB->text( index );
+    m_pItemListLB->removeItem( index );
+    m_pItemListLB->insertItem( currentString, m_pItemListLB->count() );
+    //set the moved item selected
+    Q3ListBoxItem* item = m_pItemListLB->item( m_pItemListLB->count() - 1 );
+    m_pItemListLB->setSelected( item, true );
+
+    //now change around in the list
+    printItemList("itemList before change: ");
+    UMLClassifierListItem* currentAtt = getItemList().at(index);
+    // NB: The index in the m_pItemListLB is not necessarily the same
+    //     as the index in the UMLClassifier::m_List.
+    //     Reason: getItemList() returns only a subset of all entries
+    //     in UMLClassifier::m_List.
+    takeItem(currentAtt, false, index);  // now we index the UMLClassifier::m_List
+    kdDebug() << "ClassifierListPage::slotDownClicked(" << currentAtt->getName()
+            << "): peer index in UMLCanvasItem::m_List is " << index << endl;
+    addClassifier(currentAtt, getItemList().count());
+    printItemList("itemList after change: ");
+    slotClicked( item );
+}
+
 void ClassifierListPage::slotDoubleClick( Q3ListBoxItem* item ) {
     if( !item )
         return;
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/classifierlistpage.h #584412:584413
@@ -102,6 +102,12 @@
     bool takeItem(UMLClassifierListItem* listitem,
                   bool seekPeerBefore, int &peerIndex);
 
+    /**
+     * Utility for debugging, prints the current item list.
+     * Only effective if VERBOSE_DEBUGGING is defined.
+     */
+    void printItemList(QString prologue);
+
     UMLClassifier* m_pClassifier;
     Q3GroupBox* m_pDocGB;
     Q3GroupBox* m_pItemListGB;
@@ -109,8 +115,10 @@
     Q3TextEdit* m_pDocTE;
     Uml::Object_Type m_itemType;
 
+    KArrowButton* m_pTopArrowB;
     KArrowButton* m_pUpArrowB;
     KArrowButton* m_pDownArrowB;
+    KArrowButton* m_pBottomArrowB;
     QPushButton* m_pDeleteListItemButton;
     QPushButton* m_pPropertiesButton;
 
@@ -143,6 +151,11 @@
 
 
     /**
+     * moves selected attribute to the top of the list
+     */
+    void slotTopClicked();
+
+    /**
      * moves selected attribute up in list
      */
     void slotUpClicked();
@@ -153,6 +166,11 @@
     void slotDownClicked();
 
     /**
+     * moved selected attribute to the bottom of the list
+     */
+    void slotBottomClicked();
+
+    /**
      * shows dialog for new attribute
      */
     void slotNewListItem();
--- trunk/KDE/kdesdk/umbrello/umbrello/model_utils.cpp #584412:584413
@@ -172,6 +172,7 @@
                     return obj;
                 }
                 if (foundType != Uml::ot_Package &&
+                    foundType != Uml::ot_Folder &&
                     foundType != Uml::ot_Class &&
                     foundType != Uml::ot_Interface &&
                     foundType != Uml::ot_Component) {
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #584412:584413
@@ -765,6 +765,8 @@
         if(!m_doc->openDocument(url)) {
             fileOpenRecent->removeUrl(url);
             fileOpenRecent->setCurrentItem( -1 );
+        } else {
+            fileOpenRecent->addUrl(url);
         }
         enablePrint(true);
         setCaption(m_doc->url().fileName(), false);
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #584412:584413
@@ -1172,7 +1172,6 @@
                 << endl;
             return;
         }
-        emit sigObjectRemoved(umlobject);
         if (type == ot_Operation) {
             parent->removeOperation(static_cast<UMLOperation*>(umlobject));
         } else if (type == ot_EnumLiteral) {
--- trunk/KDE/kdesdk/umbrello/umbrello/umllistviewitem.cpp #584412:584413
@@ -634,8 +634,9 @@
     UMLDoc *umldoc = s_pListView->getDocument();
     UMLFolder *extFolder = NULL;
     if (m_pObject == NULL) {
-        kError() << "UMLListViewItem::saveToXMI(" << m_Label
-            << "): m_pObject is NULL" << endl;
+        if (! Model_Utils::typeIsDiagram(m_Type))
+            kError() << "UMLListViewItem::saveToXMI(" << m_Label
+                << "): m_pObject is NULL" << endl;
         itemElement.setAttribute( "label", m_Label );
     } else if (m_pObject->getID() == Uml::id_None) {
         if (m_Label.isEmpty()) {
--- trunk/KDE/kdesdk/umbrello/umbrello/umlobject.cpp #584412:584413
@@ -306,16 +306,20 @@
     UMLObject *pkgObj = NULL;
     if (!_name.isEmpty()) {
         UMLDoc* umldoc = UMLApp::app()->getDocument();
-        if (umldoc == NULL) {
-            kError() << "UMLObject::setPackage: cannot set package name on "
-            << m_Name << endl;
-            return;
-        }
-        pkgObj = umldoc->findUMLObject(_name, Uml::ot_Package);
+        pkgObj = umldoc->findUMLObject(_name);
         if (pkgObj == NULL) {
             kDebug() << "UMLObject::setPackage: creating UMLPackage "
-            << _name << " for " << m_Name << endl;
+                << _name << " for " << m_Name << endl;
             pkgObj = Import_Utils::createUMLObject(Uml::ot_Package, _name);
+        } else {
+            const Uml::Object_Type ot = pkgObj->getBaseType();
+            if (ot != Uml::ot_Package && ot != Uml::ot_Folder && ot != Uml::ot_Component) {
+                kError() << "UMLObject::setPackage(" << m_Name << "): "
+                    << "existing " << _name << " is not a container" << endl;
+                // This should not happen - if it does, there may be further problems.
+                // A container name should not overlap with another name in the same scope.
+                pkgObj = Import_Utils::createUMLObject(Uml::ot_Package, _name);
+            }
         }
     }
     setUMLPackage( static_cast<UMLPackage *>(pkgObj) );




More information about the umbrello-devel mailing list