[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim] bf6b345: Clear the selection when the filter hides the curr
From:       George Metaxas <gmetal31 () gmail ! com>
Date:       2010-12-26 14:38:31
Message-ID: 20101226143831.684FBA6090 () git ! kde ! org
[Download RAW message or body]

commit bf6b3458e747a52be8e4daf12d07c744c499ab96
branch master
Author: George Metaxas <gmetal31@gmail.com>
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic