Seems like it was no good idea to use the same signal for new searches and for the update

from added messages. But as Till kept annoying me this should be fixed now ;-)

svn path=/trunk/kdepim/; revision=359518
wilder-work
Carsten Burghardt 22 years ago
parent e5bb181e32
commit 5b706099c9
  1. 6
      folderstorage.cpp
  2. 1
      folderstorage.h
  3. 53
      kmfolderimap.cpp
  4. 2
      kmfolderimap.h
  5. 20
      kmfoldersearch.cpp
  6. 2
      kmfoldersearch.h

@ -1018,11 +1018,11 @@ void FolderStorage::search( KMSearchPattern* pattern )
//-----------------------------------------------------------------------------
void FolderStorage::search( KMSearchPattern* pattern, Q_UINT32 serNum )
{
QValueList<Q_UINT32> serNums;
Q_UINT32 mySerNum = 0;
if ( pattern->matches( serNum ) )
serNums.append( serNum );
mySerNum = serNum;
emit searchDone( folder(), serNums );
emit searchDone( folder(), mySerNum );
}
#include "folderstorage.moc"

@ -465,6 +465,7 @@ signals:
* The matching serial numbers are included
*/
void searchDone( KMFolder*, QValueList<Q_UINT32> serNums );
void searchDone( KMFolder*, Q_UINT32 serNum );
public slots:
/** Incrementally update the index if possible else call writeIndex */

@ -1931,8 +1931,7 @@ void KMFolderImap::search( KMSearchPattern* pattern, Q_UINT32 serNum )
if ( !pattern )
{
// not much to do here
QValueList<Q_UINT32> serNums;
emit searchDone( folder(), serNums );
emit searchDone( folder(), 0 );
return;
}
QString searchString = searchStringFromPattern( pattern );
@ -1941,26 +1940,23 @@ void KMFolderImap::search( KMSearchPattern* pattern, Q_UINT32 serNum )
// download the message and search local
int idx = -1;
KMFolder *aFolder = 0;
kmkernel->msgDict()->getLocation(serNum, &aFolder, &idx);
kmkernel->msgDict()->getLocation( serNum, &aFolder, &idx );
mSearchSerNums.clear();
KMMessage * msg = getMsg( idx );
ImapJob *job = new ImapJob( msg );
job->setParentFolder( this );
connect( job, SIGNAL(messageRetrieved(KMMessage*)),
this, SLOT(slotSearchMessageArrived(KMMessage*)) );
mRemainingMsgs = 1;
mImapSearchData = "";
this, SLOT(slotSearchSingleMessage(KMMessage*)) );
job->start();
} else
{
// imap search
// remember the serNum
// remember the serNum so that we don't have to reconstruct it later
mSearchSerNums.clear();
mSearchSerNums.append( serNum );
int idx = -1;
KMFolder *aFolder = 0;
kmkernel->msgDict()->getLocation(serNum, &aFolder, &idx);
kmkernel->msgDict()->getLocation( serNum, &aFolder, &idx );
assert(aFolder && (idx != -1));
KMMsgBase *mb = getMsgBase( idx );
@ -1974,7 +1970,7 @@ void KMFolderImap::search( KMSearchPattern* pattern, Q_UINT32 serNum )
KIO::SimpleJob *job = KIO::special( url, packedArgs, false );
KIO::Scheduler::assignJobToSlave(mAccount->slave(), job);
connect( job, SIGNAL(infoMessage(KIO::Job*,const QString&)),
SLOT(slotSearchData(KIO::Job*,const QString&)) );
SLOT(slotSearchDataSingleMessage(KIO::Job*,const QString&)) );
connect( job, SIGNAL(result(KIO::Job *)),
SLOT(slotSearchResult(KIO::Job *)) );
}
@ -1990,6 +1986,7 @@ void KMFolderImap::slotSearch()
return slotSearchData( 0, QString::null );
// do the IMAP search
mSearchSerNums.clear();
KURL url = mAccount->getUrl();
url.setPath( imapPath() + ";SECTION=" + searchString );
QByteArray packedArgs;
@ -2071,12 +2068,6 @@ void KMFolderImap::slotSearchData( KIO::Job* job, const QString& data )
if ( mLocalSearchPattern->isEmpty() )
{
if ( !mSearchSerNums.empty() && !data.isEmpty() )
{
// we directly searched for these sernums
emit searchDone( folder(), mSearchSerNums );
return;
}
// search for the serial number of the UIDs
// data contains all found uids separated by blank
QValueList<Q_UINT32> serNums;
@ -2094,7 +2085,6 @@ void KMFolderImap::slotSearchData( KIO::Job* job, const QString& data )
{
// we have search patterns that can not be handled by the server
// so we need to download all messages and check
mSearchSerNums.clear();
mRemainingMsgs = 0;
QString question = i18n("To execute your search all messages of the folder %1 "
"have to be downloaded from the server. This may take some time. "
@ -2122,6 +2112,27 @@ void KMFolderImap::slotSearchData( KIO::Job* job, const QString& data )
}
//-----------------------------------------------------------------------------
void KMFolderImap::slotSearchDataSingleMessage( KIO::Job* job, const QString& data )
{
if ( job && job->error() )
return;
if ( !data.isEmpty() )
emit searchDone( folder(), mSearchSerNums.first() );
else
emit searchDone( folder(), 0 );
}
//-----------------------------------------------------------------------------
void KMFolderImap::slotSearchSingleMessage( KMMessage* msg )
{
if ( mLocalSearchPattern->matches( msg ) )
emit searchDone( folder(), msg->getMsgSerNum() );
else
emit searchDone( folder(), 0 );
}
//-----------------------------------------------------------------------------
void KMFolderImap::slotSearchMessageArrived( KMMessage* msg )
{
@ -2163,9 +2174,13 @@ void KMFolderImap::slotSearchResult( KIO::Job *job )
{
if ( job->error() )
{
QValueList<Q_UINT32> serNums;
mAccount->handleJobError( job, i18n("Error while searching.") );
emit searchDone( folder(), serNums );
if ( mSearchSerNums.empty() )
{
QValueList<Q_UINT32> serNums;
emit searchDone( folder(), serNums );
} else
emit searchDone( folder(), 0 );
}
}

@ -446,12 +446,14 @@ protected slots:
* Is called when the search is done
*/
void slotSearchData( KIO::Job * job, const QString& data );
void slotSearchDataSingleMessage( KIO::Job * job, const QString& data );
void slotSearchResult( KIO::Job * job );
/**
* Called when a msg was downloaded for local search
*/
void slotSearchMessageArrived( KMMessage* msg );
void slotSearchSingleMessage( KMMessage* msg );
protected:
QString mImapPath;

@ -916,33 +916,29 @@ void KMFolderSearch::examineAddedMessage(KMFolder *aFolder, Q_UINT32 serNum)
folder->open();
connect( folder->storage(),
SIGNAL( searchDone( KMFolder*, QValueList<Q_UINT32> ) ),
SIGNAL( searchDone( KMFolder*, Q_UINT32 ) ),
this,
SLOT( slotSearchExamineMsgDone( KMFolder*, QValueList<Q_UINT32> ) ) );
SLOT( slotSearchExamineMsgDone( KMFolder*, Q_UINT32 ) ) );
folder->storage()->search( search()->searchPattern(), serNum );
}
void KMFolderSearch::slotSearchExamineMsgDone( KMFolder* folder, QValueList<Q_UINT32> serNums )
void KMFolderSearch::slotSearchExamineMsgDone( KMFolder* folder, Q_UINT32 serNum )
{
kdDebug(5006) << k_funcinfo << folder->label() << " found " << serNums.count() << endl;
kdDebug(5006) << k_funcinfo << folder->label() << " found " << serNum << endl;
disconnect( folder->storage(),
SIGNAL( searchDone( KMFolder*, QValueList<Q_UINT32> ) ),
SIGNAL( searchDone( KMFolder*, Q_UINT32 ) ),
this,
SLOT( slotSearchExamineMsgDone( KMFolder*, QValueList<Q_UINT32> ) ) );
SLOT( slotSearchExamineMsgDone( KMFolder*, Q_UINT32 ) ) );
folder->close();
if ( serNums.empty() )
if ( serNum == 0 )
return;
if (mSearch->running()) {
mSearch->stop();
mExecuteSearchTimer->start( 0, true );
} else {
QValueListIterator<Q_UINT32> it;
for ( it = serNums.begin(); it != serNums.end(); ++it )
{
addSerNum( *it );
}
addSerNum( serNum );
}
}

@ -140,7 +140,7 @@ public slots:
virtual int updateIndex();
// Examine the added message
void slotSearchExamineMsgDone( KMFolder*, QValueList<Q_UINT32> );
void slotSearchExamineMsgDone( KMFolder*, Q_UINT32 serNum );
public:
//See base class for documentation

Loading…
Cancel
Save