Correctly disable buttons if no item of a listview is selected. Patch by Tobias Schaefer.

Explanation: Apparently the QListView::selectionChanged( QListViewItem * ) signal is completely useless since it's not emitted when no item is selected (i.e. if the selection is cleared). Therefore one always has to connect to the QListView::selectionChanged() signal. But if one is already connected to this signal then also connecting to the QListView::selectionChanged( QListViewItem * ) signal doesn't make any sense IMO. I've asked TrollTech to change this for Qt 4.

svn path=/trunk/kdepim/; revision=317868
wilder-work
Ingo Klcker 22 years ago
parent 0d8745a46f
commit 4beac68bd2
  1. 21
      configuredialog.cpp
  2. 9
      configuredialog_p.cpp
  3. 4
      configuredialog_p.h

@ -263,8 +263,8 @@ IdentityPage::IdentityPage( QWidget * parent, const char * name )
QHBoxLayout * hlay = new QHBoxLayout( this, 0, KDialog::spacingHint() );
mIdentityList = new IdentityListView( this );
connect( mIdentityList, SIGNAL(selectionChanged(QListViewItem*)),
SLOT(slotIdentitySelectionChanged(QListViewItem*)) );
connect( mIdentityList, SIGNAL(selectionChanged()),
SLOT(slotIdentitySelectionChanged()) );
connect( mIdentityList, SIGNAL(itemRenamed(QListViewItem*,const QString&,int)),
SLOT(slotRenameIdentity(QListViewItem*,const QString&,int)) );
connect( mIdentityList, SIGNAL(doubleClicked(QListViewItem*,const QPoint&,int)),
@ -500,12 +500,10 @@ void IdentityPage::refreshList() {
emit changed(true);
}
void IdentityPage::slotIdentitySelectionChanged( QListViewItem * i ) {
kdDebug(5006) << "IdentityPage::slotIdentitySelectionChanged( " << i << " )" << endl;
IdentityListViewItem * item = dynamic_cast<IdentityListViewItem*>( i );
if ( !item ) return;
void IdentityPage::slotIdentitySelectionChanged()
{
IdentityListViewItem *item =
dynamic_cast<IdentityListViewItem*>( mIdentityList->selectedItem() );
mRemoveButton->setEnabled( item && mIdentityList->childCount() > 1 );
mModifyButton->setEnabled( item );
@ -707,7 +705,7 @@ NetworkPageSendingTab::NetworkPageSendingTab( QWidget * parent, const char * nam
void NetworkPage::SendingTab::slotTransportSelected()
{
QListViewItem *cur = mTransportList->currentItem();
QListViewItem *cur = mTransportList->selectedItem();
mModifyTransportButton->setEnabled( cur );
mRemoveTransportButton->setEnabled( cur );
mTransportDownButton->setEnabled( cur && cur->itemBelow() );
@ -799,7 +797,7 @@ void NetworkPage::SendingTab::slotAddTransport()
void NetworkPage::SendingTab::slotModifySelectedTransport()
{
QListViewItem *item = mTransportList->currentItem();
QListViewItem *item = mTransportList->selectedItem();
if ( !item ) return;
QPtrListIterator<KMTransportInfo> it( mTransportInfoList );
@ -837,7 +835,7 @@ void NetworkPage::SendingTab::slotModifySelectedTransport()
void NetworkPage::SendingTab::slotRemoveSelectedTransport()
{
QListViewItem *item = mTransportList->currentItem();
QListViewItem *item = mTransportList->selectedItem();
if ( !item ) return;
QPtrListIterator<KMTransportInfo> it( mTransportInfoList );
@ -1605,7 +1603,6 @@ void AppearancePage::FontsTab::load() {
mCustomFontCheck->setChecked( !fonts.readBoolEntry( "defaultFonts", true ) );
mFontLocationCombo->setCurrentItem( 0 );
// ### FIXME: possible Qt bug: setCurrentItem doesn't emit activated(int).
slotFontSelectorChanged( 0 );
}

@ -304,8 +304,8 @@ ProfileDialog::ProfileDialog( QWidget * parent, const char * name, bool modal )
setup();
connect( mListView, SIGNAL(selectionChanged(QListViewItem*)),
SLOT(slotSelectionChanged(QListViewItem*)) );
connect( mListView, SIGNAL(selectionChanged()),
SLOT(slotSelectionChanged()) );
connect( mListView, SIGNAL(doubleClicked ( QListViewItem *, const QPoint &, int ) ),
SLOT(slotOk()) );
@ -314,8 +314,9 @@ ProfileDialog::ProfileDialog( QWidget * parent, const char * name, bool modal )
enableButtonOK( false );
}
void ProfileDialog::slotSelectionChanged( QListViewItem * item ) {
enableButtonOK( item );
void ProfileDialog::slotSelectionChanged()
{
enableButtonOK( mListView->selectedItem() );
}
void ProfileDialog::setup() {

@ -143,7 +143,7 @@ signals:
void profileSelected( KConfig * profile );
private slots:
void slotSelectionChanged( QListViewItem * );
void slotSelectionChanged();
void slotOk();
private:
@ -258,7 +258,7 @@ protected slots:
void slotRenameIdentity( QListViewItem *, const QString &, int );
void slotContextMenu( KListView*, QListViewItem *, const QPoint & );
void slotSetAsDefault();
void slotIdentitySelectionChanged( QListViewItem * );
void slotIdentitySelectionChanged();
protected: // methods
void refreshList();

Loading…
Cancel
Save