From kde-commits Sun Dec 26 14:38:31 2010 From: George Metaxas Date: Sun, 26 Dec 2010 14:38:31 +0000 To: kde-commits Subject: [kdepim] bf6b345: Clear the selection when the filter hides the curr Message-Id: <20101226143831.684FBA6090 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129337436709457 commit bf6b3458e747a52be8e4daf12d07c744c499ab96 branch master Author: George Metaxas Date: Sun Dec 26 15:35:51 2010 +0100 Clear the selection when the filter hides the current message. Thanks to George Metaxas for the patch! BUG: 130247 REVIEW: 6126 diff --git a/kmail/kmmainwidget.cpp b/kmail/kmmainwidget.cpp index 5027a2b..0f356d3 100644 --- a/kmail/kmmainwidget.cpp +++ b/kmail/kmmainwidget.cpp @@ -4151,15 +4151,21 @@ void KMMainWidget::slotMessageSelected(const Akonadi::Item &item) delete mShowBusySplashTimer; mShowBusySplashTimer = 0; if ( mMsgView ) { - mShowBusySplashTimer = new QTimer( this ); - mShowBusySplashTimer->setSingleShot( true ); - connect( mShowBusySplashTimer, SIGNAL( timeout() ), this, SLOT( slotShowBusySplash() ) ); - mShowBusySplashTimer->start( GlobalSettings::self()->folderLoadingTimeout() ); //TODO: check if we need a different timeout setting for this - - Akonadi::ItemFetchJob *itemFetchJob = MessageViewer::Viewer::createFetchJob( item ); - connect( itemFetchJob, SIGNAL(itemsReceived(Akonadi::Item::List)), - SLOT(itemsReceived(Akonadi::Item::List)) ); - connect( itemFetchJob, SIGNAL(result(KJob *)), SLOT(itemsFetchDone(KJob *)) ); + // The current selection was cleared, so we'll remove the previously + // selected message from the preview pane + if ( !item.isValid() ) { + mMsgView->clear(); + } else { + mShowBusySplashTimer = new QTimer( this ); + mShowBusySplashTimer->setSingleShot( true ); + connect( mShowBusySplashTimer, SIGNAL( timeout() ), this, SLOT( slotShowBusySplash() ) ); + mShowBusySplashTimer->start( GlobalSettings::self()->folderLoadingTimeout() ); //TODO: check if we need a different timeout setting for this + + Akonadi::ItemFetchJob *itemFetchJob = MessageViewer::Viewer::createFetchJob( item ); + connect( itemFetchJob, SIGNAL(itemsReceived(Akonadi::Item::List)), + SLOT(itemsReceived(Akonadi::Item::List)) ); + connect( itemFetchJob, SIGNAL(result(KJob *)), SLOT(itemsFetchDone(KJob *)) ); + } } } diff --git a/messagelist/core/view.cpp b/messagelist/core/view.cpp index 7da1d52..1163dc4 100644 --- a/messagelist/core/view.cpp +++ b/messagelist/core/view.cpp @@ -2593,4 +2593,23 @@ QString View::currentFilterSearchString() const return d->mWidget->currentFilterSearchString(); } +void View::setRowHidden( int row, const QModelIndex & parent, bool hide ) +{ + const QModelIndex rowModelIndex = model()->index( row, 0, parent ); + const Item* const rowItem = static_cast< Item * >( rowModelIndex.internalPointer() ); + + if ( rowItem ) { + const bool currentlyHidden = isRowHidden( row, parent ); + + if ( currentlyHidden != hide ) { + if ( currentMessageItem() == rowItem ) { + selectionModel()->clear(); + selectionModel()->clearSelection(); + } + } + } + + QTreeView::setRowHidden( row, parent, hide ); +} + #include "view.moc" diff --git a/messagelist/core/view.h b/messagelist/core/view.h index fa7fa25..4bae802 100644 --- a/messagelist/core/view.h +++ b/messagelist/core/view.h @@ -349,6 +349,12 @@ public: */ QString currentFilterSearchString() const; + /** + * Called to hide or show the specified row from the view. + * @reimp + */ + virtual void setRowHidden( int row, const QModelIndex & parent, bool hide ); + protected: /** * Reimplemented in order to catch QHelpEvent