From 1fcc20c3f6c7d913cb61e9fd7c72f3f6d53090c6 Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Sat, 12 Aug 2006 18:38:25 +0000 Subject: [PATCH] Fix bug where the count of the number of messages searched was always zero. Includes some minor string changes. GUI: svn path=/branches/KDE/3.5/kdepim/; revision=572453 --- kmfoldersearch.cpp | 16 ++++++++++------ kmfoldersearch.h | 4 +++- searchwindow.cpp | 28 ++++++++++++++-------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/kmfoldersearch.cpp b/kmfoldersearch.cpp index 5f8279441..024ab7727 100644 --- a/kmfoldersearch.cpp +++ b/kmfoldersearch.cpp @@ -78,6 +78,7 @@ KMSearch::KMSearch(QObject * parent, const char * name) mRoot = 0; mSearchPattern = 0; mFoundCount = 0; + mSearchCount = 0; mProcessNextBatchTimer = new QTimer(); connect(mProcessNextBatchTimer, SIGNAL(timeout()), this, SLOT(slotProcessNextBatch())); @@ -154,6 +155,7 @@ void KMSearch::start() } mFoundCount = 0; + mSearchCount = 0; mRunning = true; mRunByIndex = false; // check if this query can be done with the index @@ -217,6 +219,7 @@ void KMSearch::stop() account->ignoreJobsForFolder( folder ); } folder->storage()->search( 0 ); + mSearchCount += folder->count(); folder->close(); } } @@ -282,6 +285,7 @@ void KMSearch::slotSearchFolderResult( KMFolder* folder, SLOT( slotSearchFolderResult( KMFolder*, QValueList, const KMSearchPattern*, bool ) ) ); --mRemainingFolders; + mSearchCount += folder->count(); folder->close(); mOpenedFolders.remove( folder ); if ( mRemainingFolders <= 0 ) @@ -940,18 +944,18 @@ void KMFolderSearch::examineAddedMessage(KMFolder *aFolder, Q_UINT32 serNum) unsigned int count = mFoldersCurrentlyBeingSearched[folder]; mFoldersCurrentlyBeingSearched.replace( folder, count+1 ); } else { - connect( folder->storage(), + connect( folder->storage(), SIGNAL( searchDone( KMFolder*, Q_UINT32, const KMSearchPattern*, bool ) ), this, - SLOT( slotSearchExamineMsgDone( KMFolder*, Q_UINT32, + SLOT( slotSearchExamineMsgDone( KMFolder*, Q_UINT32, const KMSearchPattern*, bool ) ) ); mFoldersCurrentlyBeingSearched.insert( folder, 1 ); } folder->storage()->search( search()->searchPattern(), serNum ); } -void KMFolderSearch::slotSearchExamineMsgDone( KMFolder* folder, - Q_UINT32 serNum, +void KMFolderSearch::slotSearchExamineMsgDone( KMFolder* folder, + Q_UINT32 serNum, const KMSearchPattern* pattern, bool matches ) { @@ -1103,10 +1107,10 @@ void KMFolderSearch::propagateHeaderChanged(KMFolder *aFolder, int idx) unsigned int count = mFoldersCurrentlyBeingSearched[aFolder]; mFoldersCurrentlyBeingSearched.replace( aFolder, count+1 ); } else { - connect( aFolder->storage(), + connect( aFolder->storage(), SIGNAL( searchDone( KMFolder*, Q_UINT32, const KMSearchPattern*, bool ) ), this, - SLOT( slotSearchExamineMsgDone( KMFolder*, Q_UINT32, + SLOT( slotSearchExamineMsgDone( KMFolder*, Q_UINT32, const KMSearchPattern*, bool ) ) ); mFoldersCurrentlyBeingSearched.insert( aFolder, 1 ); } diff --git a/kmfoldersearch.h b/kmfoldersearch.h index 297df5127..77be60151 100644 --- a/kmfoldersearch.h +++ b/kmfoldersearch.h @@ -71,6 +71,7 @@ public: bool running() const { return mRunning; } void stop(); int foundCount() const { return mFoundCount; } + int searchCount() const { return mSearchCount; } QString currentFolder() const { return mLastFolder; } public slots: @@ -101,6 +102,7 @@ private: SerNumList mSerNums; QString mLastFolder; int mFoundCount; + int mSearchCount; QTimer *mProcessNextBatchTimer; }; @@ -162,7 +164,7 @@ public slots: virtual int updateIndex(); // Examine the message - void slotSearchExamineMsgDone( KMFolder*, Q_UINT32 serNum, + void slotSearchExamineMsgDone( KMFolder*, Q_UINT32 serNum, const KMSearchPattern*, bool ); public: diff --git a/searchwindow.cpp b/searchwindow.cpp index 48254e3b9..9b9e2a9c8 100644 --- a/searchwindow.cpp +++ b/searchwindow.cpp @@ -339,33 +339,33 @@ void SearchWindow::setEnabledSearchButton(bool) //----------------------------------------------------------------------------- void SearchWindow::updStatus(void) { - QString genMsg, detailMsg; - int numMatches = 0, count = 0; + QString genMsg, detailMsg, procMsg; + int numMatches = 0, numProcessed = 0; KMSearch const *search = (mFolder) ? (mFolder->search()) : 0; QString folderName; if (search) { numMatches = search->foundCount(); + numProcessed = search->searchCount(); folderName = search->currentFolder(); } if (mFolder && mFolder->search() && !mFolder->search()->running()) { + procMsg = i18n("%n message searched", "%n messages searched", + numProcessed); if(!mStopped) { - genMsg = i18n("Done"); - detailMsg = i18n("%n match (%1)", "%n matches (%1)", numMatches) - .arg(i18n("%n message processed", - "%n messages processed", count)); + genMsg = i18n("Done."); + detailMsg = i18n("%n match in %1", "%n matches in %1", + numMatches).arg(procMsg); } else { - genMsg = i18n("Search canceled"); - detailMsg = i18n("%n match so far (%1)", - "%n matches so far (%1)", numMatches) - .arg(i18n("%n message processed", - "%n messages processed", count)); + genMsg = i18n("Search canceled."); + detailMsg = i18n("%n match so far in %1", "%n matches so far in %1", + numMatches).arg(procMsg); } } else { + procMsg = i18n("%n message", "%n messages", numProcessed); genMsg = i18n("%n match", "%n matches", numMatches); - detailMsg = i18n("Searching in %1 (message %2)") - .arg(folderName) - .arg(count); + detailMsg = i18n("Searching in %1. %2 searched so far") + .arg(folderName).arg(procMsg); } mStatusBar->changeItem(genMsg, 0);