Revision: 7291
Author: nogu.dev
Date: Sat Sep 10 18:09:47 2011
Log: * qt4/pref/customwidgets.cpp
- (TableEditForm::TableEditForm): Add connection for m_table.
- (TableEditForm::slotItemSelectionChanged): New function.
* qt4/pref/customwidgets.h
- (TableEditForm): Add TableEditForm::m_removeButton
and TableEditForm::slotItemSelectionChanged().
http://code.google.com/p/uim/source/detail?r=7291
Modified:
/trunk/qt4/pref/customwidgets.cpp
/trunk/qt4/pref/customwidgets.h
=======================================
--- /trunk/qt4/pref/customwidgets.cpp Sat Sep 10 18:09:37 2011
+++ /trunk/qt4/pref/customwidgets.cpp Sat Sep 10 18:09:47 2011
@@ -1269,16 +1269,19 @@
m_table->setSelectionMode( QAbstractItemView::SingleSelection );
m_table->horizontalHeader()->setVisible( false );
m_table->verticalHeader()->setVisible( false );
+ connect( m_table, SIGNAL( itemSelectionChanged() ),
+ this, SLOT( slotItemSelectionChanged() ) );
QPushButton *addButton = new QPushButton;
addButton->setText( _("Add") );
- connect( addButton, SIGNAL(clicked()),
- this, SLOT(slotAddClicked()) );
-
- QPushButton *removeButton = new QPushButton;
- removeButton->setText( _("Remove") );
- connect( removeButton, SIGNAL(clicked()),
- this, SLOT(slotRemoveClicked()) );
+ connect( addButton, SIGNAL( clicked() ),
+ this, SLOT( slotAddClicked() ) );
+
+ m_removeButton = new QPushButton;
+ m_removeButton->setEnabled( false );
+ m_removeButton->setText( _("Remove") );
+ connect( m_removeButton, SIGNAL( clicked() ),
+ this, SLOT( slotRemoveClicked() ) );
QPushButton *okButton = new QPushButton;
okButton->setText( _("OK") );
@@ -1290,7 +1293,7 @@
QVBoxLayout *buttonLayout = new QVBoxLayout;
buttonLayout->addWidget( addButton );
- buttonLayout->addWidget( removeButton );
+ buttonLayout->addWidget( m_removeButton );
buttonLayout->addStretch();
buttonLayout->addWidget( okButton );
buttonLayout->addWidget( cancelButton );
@@ -1361,6 +1364,12 @@
return custom_table;
}
+
+void TableEditForm::slotItemSelectionChanged()
+{
+ bool itemSelected = ( m_table->selectedItems().count() == 1 );
+ m_removeButton->setEnabled( itemSelected );
+}
void TableEditForm::slotAddClicked()
{
=======================================
--- /trunk/qt4/pref/customwidgets.h Sat Sep 10 18:09:37 2011
+++ /trunk/qt4/pref/customwidgets.h Sat Sep 10 18:09:47 2011
@@ -328,7 +328,9 @@
private:
QTableWidget *m_table;
+ QPushButton *m_removeButton;
private slots:
+ void slotItemSelectionChanged();
void slotAddClicked();
void slotRemoveClicked();
};