filemanager/src/filemanager/src/fmfindresultmodel.h
changeset 46 d58987eac7e8
parent 37 15bc28c9dd51
--- a/filemanager/src/filemanager/src/fmfindresultmodel.h	Tue Aug 24 10:24:14 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfindresultmodel.h	Wed Sep 29 10:37:03 2010 +0800
@@ -25,6 +25,8 @@
 #include <QFileInfo>
 #include <QStringList>
 #include <QAbstractListModel>
+#include <QTimer>
+#include <QEventLoop>
 
 class FmFindThread;
 class FmFileIconProvider;
@@ -57,14 +59,8 @@
 
     QFileInfo fileInfo( const QModelIndex &index ) const;
 
-    QString findPath() const;
-    void setFindPath( const QString &path );
-
-    QRegExp pattern() const;
-    void setPattern( const QRegExp &regExp );
-
-    void find();
-    void stop();
+    void find( const QRegExp &regExp, const QStringList &pathList );
+    void stopFind();
     bool isFinding() const;
 
     virtual void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder );
@@ -79,19 +75,39 @@
                                   const QPair<QString,int> &s2 );
 
 signals:
-    void finished();
+
+    // pass modelCountChanged signal to parent widget
+    // so parent widget could change contentWiget between emptyTipsWidget and listWidget
     void modelCountChanged( int count );
 
+    // emit when start find thread. view can set empty menu for itself(sort).
+    // because sort while search inprogress may cause data synchornous problem in model.
+    void findStarted();
+
+    // emit when finished find thread. view can set normal menu for itself(sort).
+    void findFinished();
+
 private slots:
     void on_findThread_found( const QStringList &dataList );
+    void startFind();
+    void onThreadFinished();
 
 private:
     bool indexValid( const QModelIndex &index ) const;
     void init();
+    
 
     FmFindThread *mFindThread;
     QStringList mFindResult;
     FmFileIconProvider *mIconProvider;
+
+    QStringList mFindPath;
+    QRegExp     mRegExp;
+    bool        mIsFindRequestPending;
+    QTimer      mTimer;
+
+    QEventLoop  mStopEventLoop;
+
 };
 
 #endif