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

Sharan Rao sharanrao at gmail.com
Tue Oct 2 10:07:40 UTC 2007


SVN commit 720071 by sharan:

More polishing for the UniqueConstraint and ForeignKeyConstraint dialog boxes.
(Enabling/Disabling Widgets when they ought not to be clicked)



 M  +26 -2     umlforeignkeyconstraintdialog.cpp  
 M  +7 -0      umlforeignkeyconstraintdialog.h  
 M  +34 -3     umluniqueconstraintdialog.cpp  
 M  +8 -0      umluniqueconstraintdialog.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umlforeignkeyconstraintdialog.cpp #720070:720071
@@ -99,6 +99,7 @@
 
     m_ColumnWidgets.mappingTW->addTopLevelItem( mapping );
 
+    slotResetWidgetState();
 }
 
 void UMLForeignKeyConstraintDialog::slotDeletePair(){
@@ -130,6 +131,8 @@
         uDebug()<<( pair.first )->getName()<<" "<< ( pair.first )->getBaseType()<<" "
                 <<( pair.second )->getName()<<" "<< ( pair.second )->getBaseType()<<endl;
     }
+
+    slotResetWidgetState();
 }
 
 bool UMLForeignKeyConstraintDialog::apply(){
@@ -289,9 +292,9 @@
     columnsLayout->addWidget( m_ColumnWidgets.referencedColumnCB, 1, 1 );
 
     KDialogButtonBox* buttonBox = new KDialogButtonBox( page );
-    buttonBox->addButton( i18n( "&Add" ), KDialogButtonBox::ActionRole, this,
+    m_ColumnWidgets.addPB = buttonBox->addButton( i18n( "&Add" ), KDialogButtonBox::ActionRole, this,
                           SLOT(slotAddPair()) );
-    buttonBox->addButton( i18n( "&Delete" ), KDialogButtonBox::ActionRole, this,
+    m_ColumnWidgets.removePB = buttonBox->addButton( i18n( "&Delete" ), KDialogButtonBox::ActionRole, this,
                           SLOT(slotDeletePair()) );
 
     columnsLayout->addWidget( buttonBox , 2, 1 );
@@ -336,7 +339,9 @@
 
     }
 
+    slotResetWidgetState();
 
+    connect( m_ColumnWidgets.mappingTW, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ), this, SLOT( slotResetWidgetState() ) );
 
 }
 
@@ -413,5 +418,24 @@
 
 }
 
+void UMLForeignKeyConstraintDialog::slotResetWidgetState() {
+    m_ColumnWidgets.addPB->setEnabled( true );
+    m_ColumnWidgets.removePB->setEnabled( true );
+    m_ColumnWidgets.localColumnCB->setEnabled( true );
+    m_ColumnWidgets.referencedColumnCB->setEnabled( true );
+
+    // If one of the Combo Boxes is empty , then disable the Combo Box
+    if ( m_ColumnWidgets.localColumnCB->count()==0 || m_ColumnWidgets.referencedColumnCB->count()==0 ) {
+        m_ColumnWidgets.localColumnCB->setEnabled( false );
+        m_ColumnWidgets.referencedColumnCB->setEnabled( false );
+        m_ColumnWidgets.addPB->setEnabled( false );
+    }
+
+    // get index of selected Attribute in List Box
+    if ( m_ColumnWidgets.mappingTW->currentItem() == NULL ) {
+        m_ColumnWidgets.removePB->setEnabled( false );
+    }
+}
+
 #include "umlforeignkeyconstraintdialog.moc"
 
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umlforeignkeyconstraintdialog.h #720070:720071
@@ -119,6 +119,8 @@
 
         QLabel* localColumnL;
         QLabel* referencedColumnL;
+
+        QPushButton* addPB,*removePB;
     }
     ; // end column widgets
 
@@ -144,6 +146,11 @@
 public slots:
 
     /**
+     * Enable/Disable the widgets in the Dialog Box
+     */
+    void slotResetWidgetState();
+     
+    /**
      * Used when the Apply button is clicked
      */
     void slotApply();
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umluniqueconstraintdialog.cpp #720070:720071
@@ -103,9 +103,9 @@
 
     //the action buttons
     KDialogButtonBox* buttonBox = new KDialogButtonBox(m_pAttributeListGB);
-    buttonBox->addButton( i18n( "&Add" ), KDialogButtonBox::ActionRole, this,
+    m_pAddPB = buttonBox->addButton( i18n( "&Add" ), KDialogButtonBox::ActionRole, this,
                           SLOT(slotAddAttribute()) );
-    buttonBox->addButton( i18n( "&Delete" ), KDialogButtonBox::ActionRole, this,
+    m_pRemovePB = buttonBox->addButton( i18n( "&Delete" ), KDialogButtonBox::ActionRole, this,
                           SLOT(slotDeleteAttribute()) );
 
     comboButtonHBoxLayout->addWidget( buttonBox );
@@ -137,6 +137,14 @@
 
     // set text of label
     m_pNameLE->setText( m_pUniqueConstraint->getName() );
+
+    // select firstItem
+    if ( m_pAttributeListLB->count()!=0 )
+        m_pAttributeListLB->setSelected( 0, true );
+
+    slotResetWidgetState();
+
+    connect( m_pAttributeListLB, SIGNAL( clicked( Q3ListBoxItem* ) ), this, SLOT( slotResetWidgetState() ) );
 }
 
 
@@ -164,7 +172,7 @@
     int count = m_pAttributeListLB->count();
     m_pAttributeListLB->insertItem( entAtt->toString( Uml::st_SigNoVis ), count );
 
-
+    slotResetWidgetState();
 }
 
 void UMLUniqueConstraintDialog::slotDeleteAttribute(){
@@ -189,6 +197,7 @@
     int count = m_pAttributeCB->count();
     m_pAttributeCB->insertItem( count, entAtt->toString(Uml::st_SigNoVis ) );
 
+    slotResetWidgetState();
 }
 
 
@@ -228,5 +237,27 @@
 
 
 
+void UMLUniqueConstraintDialog::slotResetWidgetState() {
+
+    m_pAttributeCB->setEnabled( true );
+    m_pAddPB->setEnabled( true );
+    m_pRemovePB->setEnabled( true );
+
+    // get index of selected Attribute in List Box
+    int index = m_pAttributeListLB->currentItem();
+    // if index is not invalid ( -1 ), then activate the Remove Button
+    if ( index == -1 ) {
+        m_pRemovePB->setEnabled( false );
+    }
+
+    // check for number of items in ComboBox
+    int count = m_pAttributeCB->count();
+    // if count is 0 disable Combo Box and Add Button
+    if ( count == 0 ) {
+        m_pAttributeCB->setEnabled( false );
+        m_pAddPB->setEnabled( false );
+    }
+}
+
 #include "umluniqueconstraintdialog.moc"
 
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umluniqueconstraintdialog.h #720070:720071
@@ -19,6 +19,7 @@
 #include <q3listbox.h>
 #include <q3textedit.h>
 #include <qlineedit.h>
+#include <qpushbutton.h>
 
 //kde includes
 #include <karrowbutton.h>
@@ -85,6 +86,7 @@
     QLineEdit* m_pNameLE;
     Q3ListBox* m_pAttributeListLB;
     KComboBox* m_pAttributeCB; 
+    QPushButton* m_pAddPB,*m_pRemovePB;
 
     /* local cache */
     UMLEntityAttributeList m_pEntityAttributeList;
@@ -93,6 +95,12 @@
  
 public slots:
 
+    /** 
+     * Enable or Disable the widgets
+     *
+     */
+    void slotResetWidgetState();
+
     /**
      * Used when the Apply Button is clicked
      */




More information about the umbrello-devel mailing list