[Uml-devel] [Bug 126467] Properties menu: move to top/bottom buttons

Oliver Kellogg okellogg at users.sourceforge.net
Sun Sep 10 12:16:27 UTC 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=126467         
okellogg users sourceforge net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From okellogg users sourceforge net  2006-09-10 14:16 -------
SVN commit 582766 by okellogg:

Attachment 17687 from Vincent Ricard adds methods slot{Top,Bottom}Clicked().
printItemList(): New method factors out the item list printing from the
slot*Clicked() methods.
BUG:126467


 M  +1 -0      ChangeLog  
 M  +1 -0      THANKS  
 M  +99 -24    umbrello/dialogs/classifierlistpage.cpp  
 M  +18 -0     umbrello/dialogs/classifierlistpage.h  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #582765:582766
 @ -5,6 +5,7  @
 * Bugs/wishes from http://bugs.kde.org:
 * "role A properties" should give class name (69244)
 * Sharing designs, Folders, 3rd Party imports (87252, reimplementation)
+* Properties menu: move to top/bottom buttons (126467)
 * Java import - importing interfaces - absent visibility treated as package
   instead of public (131327)
 * Python code generation not independent of diagram view (131790)
--- branches/KDE/3.5/kdesdk/umbrello/THANKS #582765:582766
 @ -61,6 +61,7  @
 Maciej Puzio <maciek  work swmed edu>
 Ruediger Ranft <kdebugs  rranft1 mail htwm de>
 John Ratke <jratke  comcast net>
+Vincent Ricard <magic  magicninja org>
 Daniel Richard G. <skunk  iskunk org>
 Jonathan Riddell <jr  jriddell org>
 Peeter Russak <pezz  tkwcy ee>
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/classifierlistpage.cpp #582765:582766
 @ -77,6 +77,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 );
 @ -85,6 +89,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()) );
 @ -124,8 +132,10  @
             this, SLOT(slotRightButtonClicked(QListBoxItem*, 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( QListBoxItem* ) ),
              this, SLOT( slotDoubleClick( QListBoxItem* ) ) );
 }
 @ -139,8 +149,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;
 @ -153,17 +165,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);
 @ -329,6 +349,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());
+    kdDebug() << 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
+    QListBoxItem* 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
+    kdDebug() << "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();
 @ -347,13 +409,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());
-    kdDebug() << "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
 @ -364,11 +421,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());
-    kdDebug() << "itemList after change: " << buf << endl;
+    printItemList("itemList after change: ");
     slotClicked( item );
 }
 
 @ -389,13 +442,8  @
     QListBoxItem* 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());
-    kdDebug() << "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
 @ -406,14 +454,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());
-    kdDebug() << "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
+    QListBoxItem* 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( QListBoxItem* item ) {
     if( !item )
         return;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/classifierlistpage.h #582765:582766
 @ -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;
     QGroupBox* m_pDocGB;
     QGroupBox* m_pItemListGB;
 @ -109,8 +115,10  @
     QTextEdit* 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();




More information about the umbrello-devel mailing list