1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * Zhiqiang Yang <zhiqiang.yang@nokia.com> |
|
14 * |
|
15 * Description: |
|
16 * The find result model header file of file manager |
|
17 */ |
|
18 |
|
19 #ifndef FMFINDRESULTMODEL_H |
|
20 #define FMFINDRESULTMODEL_H |
|
21 |
|
22 #include "fmcommon.h" |
|
23 |
|
24 #include <QPair> |
|
25 #include <QFileInfo> |
|
26 #include <QStringList> |
|
27 #include <QAbstractListModel> |
|
28 |
|
29 class FmFindThread; |
|
30 class FmFileIconProvider; |
|
31 |
|
32 class FmFindResultModel : public QAbstractListModel |
|
33 { |
|
34 Q_OBJECT |
|
35 public: |
|
36 enum Roles { |
|
37 FileIconRole = Qt::DecorationRole |
|
38 }; |
|
39 |
|
40 enum SortFlag { |
|
41 Name = 0, |
|
42 Time = 1, |
|
43 Size = 2, |
|
44 Type = 3 |
|
45 }; |
|
46 |
|
47 FmFindResultModel( QObject *parent = 0 ); |
|
48 ~FmFindResultModel(); |
|
49 |
|
50 int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
|
51 int columnCount( const QModelIndex &parent = QModelIndex() ) const; |
|
52 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; |
|
53 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; |
|
54 bool insertRows( int row, const QStringList &dataList, const QModelIndex &parent = QModelIndex() ); |
|
55 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ); |
|
56 QString filePath ( const QModelIndex & index ) const; |
|
57 |
|
58 QFileInfo fileInfo( const QModelIndex &index ) const; |
|
59 |
|
60 QString findPath() const; |
|
61 void setFindPath( const QString &path ); |
|
62 |
|
63 QRegExp pattern() const; |
|
64 void setPattern( const QRegExp ®Exp ); |
|
65 |
|
66 void find(); |
|
67 void stop(); |
|
68 bool isFinding() const; |
|
69 |
|
70 virtual void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder ); |
|
71 |
|
72 static bool caseNameLessThan( const QPair<QString,int> &s1, |
|
73 const QPair<QString,int> &s2 ); |
|
74 static bool caseTimeLessThan( const QPair<QString,int> &s1, |
|
75 const QPair<QString,int> &s2 ); |
|
76 static bool caseSizeLessThan( const QPair<QString,int> &s1, |
|
77 const QPair<QString,int> &s2 ); |
|
78 static bool caseTypeLessThan( const QPair<QString,int> &s1, |
|
79 const QPair<QString,int> &s2 ); |
|
80 |
|
81 signals: |
|
82 void finished(); |
|
83 void modelCountChanged( int count ); |
|
84 |
|
85 private slots: |
|
86 void on_findThread_found( const QStringList &dataList ); |
|
87 |
|
88 private: |
|
89 bool indexValid( const QModelIndex &index ) const; |
|
90 void init(); |
|
91 |
|
92 FmFindThread *mFindThread; |
|
93 QStringList mFindResult; |
|
94 FmFileIconProvider *mIconProvider; |
|
95 }; |
|
96 |
|
97 #endif |
|