filemanager/src/filemanager/src/fmfindthread.cpp
changeset 29 b3155376f2b4
parent 14 1957042d8c7e
child 32 39cf9ced4cc4
equal deleted inserted replaced
24:1d0c87b42e2e 29:b3155376f2b4
    21 #include <QDir>
    21 #include <QDir>
    22 
    22 
    23 FmFindThread::FmFindThread( QStringList *r, QObject *parent )
    23 FmFindThread::FmFindThread( QStringList *r, QObject *parent )
    24     : QThread( parent )
    24     : QThread( parent )
    25 {
    25 {
       
    26     setPriority( LowPriority );
    26     mResult = r;
    27     mResult = r;
    27 }
    28 }
    28 
    29 
    29 FmFindThread::~FmFindThread()
    30 FmFindThread::~FmFindThread()
    30 {
    31 {
    56 }
    57 }
    57 
    58 
    58 void FmFindThread::run()
    59 void FmFindThread::run()
    59 {
    60 {
    60     mStop = false;
    61     mStop = false;
    61     setPriority( LowPriority );
       
    62     if (findPattern.isEmpty() || !findPattern.isValid())
    62     if (findPattern.isEmpty() || !findPattern.isValid())
    63         return;
    63         return;
    64 
    64 
    65     QDir dir( mFindPath );
    65     QDir dir( mFindPath );
    66     if (!dir.exists())
    66     if (!dir.exists())
   103         }
   103         }
   104 
   104 
   105         findDirs.removeFirst();
   105         findDirs.removeFirst();
   106     }
   106     }
   107     
   107     
   108     if( count > 0 ) {
   108     emitFound();
   109         emitFound();
       
   110     }
       
   111 }
   109 }
   112 
   110 
   113 void FmFindThread::emitFound()
   111 void FmFindThread::emitFound()
   114 {
   112 {
   115     emit found( count );
   113     emit found( count );
   123 }
   121 }
   124 
   122 
   125 void FmFindThread::findInResult()
   123 void FmFindThread::findInResult()
   126 {
   124 {
   127     if( mFindPath.isEmpty() ){
   125     if( mFindPath.isEmpty() ){
   128         int count = mLastResult.count();
   126         int count = mResult->count();
   129         for (QStringList::Iterator it = mLastResult.begin(); it != mLastResult.end(); ++it) { 
   127         for (QStringList::Iterator it = mLastResult.begin(); it != mLastResult.end(); ++it) { 
   130             if (mStop){
   128             if (mStop){
   131                 return;
   129                 return;
   132             }
   130             }
   133             QString absolutPath = (*it);
   131             QString absolutPath = (*it);
   142                 if (time.elapsed() > 500 && count > 0)
   140                 if (time.elapsed() > 500 && count > 0)
   143                    emitFound();
   141                    emitFound();
   144             }
   142             }
   145         }    
   143         }    
   146     }
   144     }
       
   145     emitFound();
   147 }
   146 }