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

Oliver Kellogg okellogg at users.sourceforge.net
Wed May 9 20:06:29 UTC 2007


SVN commit 663009 by okellogg:

Apply r657605 from trunk. Many thanks to Sharan.


 M  +1 -0      THANKS  
 M  +78 -8     umbrello/dialogs/activitypage.cpp  
 M  +3 -1      umbrello/dialogs/activitypage.h  


--- branches/KDE/3.5/kdesdk/umbrello/THANKS #663008:663009
@@ -64,6 +64,7 @@
 Ivan Porres <iporres @abo.fi>
 Maciej Puzio <maciek @work.swmed.edu>
 Ruediger Ranft <kdebugs @rranft1.mail.htwm.de>
+Sharan Rao <sharanrao @gmail.com>
 John Ratke <jratke @comcast.net>
 Vincent Ricard <magic @magicninja.org>
 Daniel Richard G. <skunk @iskunk.org>
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/activitypage.cpp #663008:663009
@@ -31,17 +31,30 @@
 
 void ActivityPage::setupPage() {
     int margin = fontMetrics().height();
-    QHBoxLayout * mainLayout = new QHBoxLayout( this );
+    
+    QVBoxLayout * mainLayout = new QVBoxLayout( this );
     mainLayout -> setSpacing(10);
 
     m_pActivityGB = new QGroupBox(i18n("Activities"), this );
-    QGridLayout* activityLayout = new QGridLayout( m_pActivityGB, 2, 2 );
+
+    // vertical box layout for the activity lists, arrow buttons and the button box
+    QVBoxLayout* listVBoxLayout = new QVBoxLayout( m_pActivityGB );
+    listVBoxLayout -> setMargin(margin);
+    listVBoxLayout -> setSpacing ( 10 );
+
+    //horizontal box contains the list box and the move up/down buttons
+    QHBoxLayout* listHBoxLayout = new QHBoxLayout( listVBoxLayout );
+    
     m_pActivityLB = new QListBox(m_pActivityGB );
-    activityLayout -> setMargin(margin);
-    activityLayout -> setSpacing ( 10 );
-    activityLayout -> addWidget(m_pActivityLB, 0, 0);
+   
+    listHBoxLayout -> addWidget(m_pActivityLB);
 
-    QVBoxLayout * buttonLayout = new QVBoxLayout( activityLayout );
+    QVBoxLayout * buttonLayout = new QVBoxLayout( listHBoxLayout );
+
+    m_pTopArrowB = new KArrowButton( m_pActivityGB );
+    m_pTopArrowB -> setEnabled( false );
+    buttonLayout -> addWidget( m_pTopArrowB );
+
     m_pUpArrowB = new KArrowButton( m_pActivityGB );
     m_pUpArrowB -> setEnabled( false );
     buttonLayout -> addWidget( m_pUpArrowB );
@@ -50,12 +63,17 @@
     m_pDownArrowB -> setEnabled( false );
     buttonLayout -> addWidget( m_pDownArrowB );
 
+    m_pBottomArrowB = new KArrowButton( m_pActivityGB, Qt::DownArrow );
+    m_pBottomArrowB -> setEnabled( false );
+    buttonLayout -> addWidget( m_pBottomArrowB );
+
+   
     KButtonBox* buttonBox = new KButtonBox(m_pActivityGB);
     buttonBox->addButton( i18n("New Activity..."), this, SLOT(slotNewActivity()) );
     m_pDeleteActivityButton = buttonBox->addButton( i18n("Delete"),
                               this, SLOT(slotDelete()) );
     m_pRenameButton = buttonBox->addButton( i18n("Rename"), this, SLOT(slotRename()) );
-    activityLayout->addMultiCellWidget(buttonBox, 1, 1, 0, 1);
+    listVBoxLayout->addWidget(buttonBox);
 
     mainLayout -> addWidget( m_pActivityGB );
 
@@ -75,8 +93,11 @@
     connect(m_pActivityLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
             this, SLOT(slotRightButtonClicked(QListBoxItem *, const QPoint &)));
 
+    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_pActivityLB, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( slotDoubleClicked( QListBoxItem* ) ) );
 
     enableWidgets(false);
@@ -165,6 +186,25 @@
     connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotMenuSelection(int)));
 }
 
+
+void ActivityPage::slotTopClicked() {
+    int count = m_pActivityLB->count();
+    int index = m_pActivityLB->currentItem();
+    //shouldn't occur, but just in case
+    if( count <= 1 || index <= 0 )
+        return;
+
+    //swap the text around in the ListBox
+    QString currentString = m_pActivityLB->text( index );
+    m_pActivityLB->removeItem( index );
+    m_pActivityLB->insertItem( currentString, 0 );
+    //set the moved item selected
+    QListBoxItem* item = m_pActivityLB->item( 0 );
+    m_pActivityLB->setSelected( item, true );
+
+    slotClicked(item);
+}
+
 void ActivityPage::slotUpClicked() {
     int count = m_pActivityLB -> count();
     int index = m_pActivityLB -> currentItem();
@@ -203,6 +243,26 @@
     slotClicked(item);
 }
 
+
+void ActivityPage::slotBottomClicked() {
+    int count = m_pActivityLB->count();
+    int index = m_pActivityLB->currentItem();
+    //shouldn't occur, but just in case
+    if( count <= 1 || index >= count - 1 )
+        return;
+   
+    //swap the text around in the ListBox
+    QString currentString = m_pActivityLB->text( index );
+    m_pActivityLB->removeItem( index );
+    m_pActivityLB->insertItem( currentString, m_pActivityLB->count() );
+    //set the moved item selected
+    QListBoxItem* item = m_pActivityLB->item( m_pActivityLB->count() - 1 );
+    m_pActivityLB->setSelected( item, true );
+
+   slotClicked( item );
+}
+
+
 void ActivityPage::slotClicked(QListBoxItem *item) {
     //make sure clicked on an item
     if(!item) {
@@ -221,8 +281,10 @@
 
 void ActivityPage::enableWidgets(bool state) {
     if( !state ) {
+        m_pTopArrowB->setEnabled( false );
         m_pUpArrowB->setEnabled( false );
         m_pDownArrowB->setEnabled( false );
+        m_pBottomArrowB->setEnabled( false );
         m_pDeleteActivityButton->setEnabled(false);
         m_pRenameButton->setEnabled(false);
         return;
@@ -235,17 +297,25 @@
     */
     int index = m_pActivityLB->currentItem();
     if( m_pActivityLB->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_pActivityLB->count() - 1 ) {
+        m_pTopArrowB->setEnabled(true);
         m_pUpArrowB->setEnabled(true);
         m_pDownArrowB->setEnabled(false);
-    } else {
+        m_pBottomArrowB->setEnabled(false); 
+   } else {
+        m_pTopArrowB->setEnabled(true);
         m_pUpArrowB->setEnabled(true);
         m_pDownArrowB->setEnabled(true);
+        m_pBottomArrowB->setEnabled(true);
     }
     m_pDeleteActivityButton->setEnabled(true);
     m_pRenameButton->setEnabled(true);
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/activitypage.h #663008:663009
@@ -69,7 +69,7 @@
     //GUI widgets
     QListBox * m_pActivityLB;
     QGroupBox * m_pActivityGB;
-    KArrowButton * m_pUpArrowB, * m_pDownArrowB;
+    KArrowButton * m_pUpArrowB, * m_pDownArrowB, * m_pTopArrowB, *m_pBottomArrowB;
     QPushButton* m_pDeleteActivityButton;
     QPushButton* m_pRenameButton;
 
@@ -82,8 +82,10 @@
     void slotDoubleClicked( QListBoxItem* item );
     void slotRightButtonClicked(QListBoxItem* item, const QPoint& p);
     void slotRightButtonPressed(QListBoxItem* item, const QPoint& p);
+    void slotTopClicked();
     void slotUpClicked();
     void slotDownClicked();
+    void slotBottomClicked();
     void slotNewActivity();
     void slotDelete();
     void slotRename();




More information about the umbrello-devel mailing list