filemanager/src/filemanager/src/fmfindresultmodel.h
changeset 46 d58987eac7e8
parent 37 15bc28c9dd51
equal deleted inserted replaced
37:15bc28c9dd51 46:d58987eac7e8
    23 
    23 
    24 #include <QPair>
    24 #include <QPair>
    25 #include <QFileInfo>
    25 #include <QFileInfo>
    26 #include <QStringList>
    26 #include <QStringList>
    27 #include <QAbstractListModel>
    27 #include <QAbstractListModel>
       
    28 #include <QTimer>
       
    29 #include <QEventLoop>
    28 
    30 
    29 class FmFindThread;
    31 class FmFindThread;
    30 class FmFileIconProvider;
    32 class FmFileIconProvider;
    31 
    33 
    32 class FmFindResultModel : public QAbstractListModel
    34 class FmFindResultModel : public QAbstractListModel
    55 	bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
    57 	bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
    56     QString filePath ( const QModelIndex & index ) const;
    58     QString filePath ( const QModelIndex & index ) const;
    57 
    59 
    58     QFileInfo fileInfo( const QModelIndex &index ) const;
    60     QFileInfo fileInfo( const QModelIndex &index ) const;
    59 
    61 
    60     QString findPath() const;
    62     void find( const QRegExp &regExp, const QStringList &pathList );
    61     void setFindPath( const QString &path );
    63     void stopFind();
    62 
       
    63     QRegExp pattern() const;
       
    64     void setPattern( const QRegExp &regExp );
       
    65 
       
    66     void find();
       
    67     void stop();
       
    68     bool isFinding() const;
    64     bool isFinding() const;
    69 
    65 
    70     virtual void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder );
    66     virtual void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder );
    71 
    67 
    72     static bool caseNameLessThan( const QPair<QString,int> &s1,
    68     static bool caseNameLessThan( const QPair<QString,int> &s1,
    77                                   const QPair<QString,int> &s2 );
    73                                   const QPair<QString,int> &s2 );
    78     static bool caseTypeLessThan( const QPair<QString,int> &s1,
    74     static bool caseTypeLessThan( const QPair<QString,int> &s1,
    79                                   const QPair<QString,int> &s2 );
    75                                   const QPair<QString,int> &s2 );
    80 
    76 
    81 signals:
    77 signals:
    82     void finished();
    78 
       
    79     // pass modelCountChanged signal to parent widget
       
    80     // so parent widget could change contentWiget between emptyTipsWidget and listWidget
    83     void modelCountChanged( int count );
    81     void modelCountChanged( int count );
       
    82 
       
    83     // emit when start find thread. view can set empty menu for itself(sort).
       
    84     // because sort while search inprogress may cause data synchornous problem in model.
       
    85     void findStarted();
       
    86 
       
    87     // emit when finished find thread. view can set normal menu for itself(sort).
       
    88     void findFinished();
    84 
    89 
    85 private slots:
    90 private slots:
    86     void on_findThread_found( const QStringList &dataList );
    91     void on_findThread_found( const QStringList &dataList );
       
    92     void startFind();
       
    93     void onThreadFinished();
    87 
    94 
    88 private:
    95 private:
    89     bool indexValid( const QModelIndex &index ) const;
    96     bool indexValid( const QModelIndex &index ) const;
    90     void init();
    97     void init();
       
    98     
    91 
    99 
    92     FmFindThread *mFindThread;
   100     FmFindThread *mFindThread;
    93     QStringList mFindResult;
   101     QStringList mFindResult;
    94     FmFileIconProvider *mIconProvider;
   102     FmFileIconProvider *mIconProvider;
       
   103 
       
   104     QStringList mFindPath;
       
   105     QRegExp     mRegExp;
       
   106     bool        mIsFindRequestPending;
       
   107     QTimer      mTimer;
       
   108 
       
   109     QEventLoop  mStopEventLoop;
       
   110 
    95 };
   111 };
    96 
   112 
    97 #endif
   113 #endif