1 /****************************************************************************
3 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
5 ** This file is part of the QtGui module of the Qt Toolkit.
7 ** This file may be used under the terms of the GNU General Public
8 ** License version 2.0 as published by the Free Software Foundation
9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 ** this file. Please review the following information to ensure GNU
11 ** General Public Licensing requirements will be met:
12 ** http://www.trolltech.com/products/qt/opensource.html
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 ****************************************************************************/
24 #ifndef QFILEINFOGATHERER_H
25 #define QFILEINFOGATHERER_H
29 #include <qwaitcondition.h>
30 #include <qfilesystemwatcher.h>
31 #if QT_VERSION >= 0x040300
32 #include <qfileiconprovider.h>
34 #include <qdirmodel.h>
37 #include <qdatetime.h>
41 class QExtendedInformation
{
43 enum Type
{ Dir
, File
, System
};
45 QExtendedInformation() : size(0), fileType(System
), isHidden(false),
46 isSymLink(false), caseSensitive(true) {}
51 QDateTime lastModified
;
52 QFile::Permissions permissions
;
56 bool caseSensitive
: 1;
58 inline bool isDir() { return fileType
== Dir
; }
59 inline bool isFile() { return fileType
== File
; }
60 inline bool isSystem() { return fileType
== System
; }
62 bool operator ==(const QExtendedInformation
&fileInfo
) const {
63 return fileInfo
.size
== size
64 && fileInfo
.displayType
== displayType
65 && fileInfo
.lastModified
== lastModified
66 && fileInfo
.permissions
== permissions
67 && fileInfo
.fileType
== fileType
68 && fileInfo
.isHidden
== isHidden
69 && fileInfo
.isSymLink
== isSymLink
70 && fileInfo
.caseSensitive
== caseSensitive
;
72 void operator =(const QExtendedInformation
&fileInfo
) {
74 displayType
= fileInfo
.displayType
;
76 lastModified
= fileInfo
.lastModified
;
77 permissions
= fileInfo
.permissions
;
78 fileType
= fileInfo
.fileType
;
79 isHidden
= fileInfo
.isHidden
;
80 isSymLink
= fileInfo
.isSymLink
;
81 caseSensitive
= fileInfo
.caseSensitive
;
85 class QFileIconProvider
;
87 class Q_AUTOTEST_EXPORT QFileInfoGatherer
: public QThread
92 void updates(const QString
&directory
, const QList
<QPair
<QString
, QExtendedInformation
> > &updates
);
93 void newListOfFiles(const QString
&directory
, const QStringList
&listOfFiles
) const;
94 void nameResolved(const QString
&fileName
, const QString
&resolvedName
) const;
97 QFileInfoGatherer(QObject
*parent
= 0);
101 QExtendedInformation
getInfo(const QFileInfo
&info
) const;
104 void list(const QString
&directoryPath
);
105 void fetchExtendedInformation(const QString
&path
, const QStringList
&files
);
106 void updateFile(const QString
&path
);
107 void setResolveSymlinks(bool enable
);
108 bool resolveSymlinks() const;
109 void setIconProvider(QFileIconProvider
*provider
);
110 QFileIconProvider
*iconProvider() const;
114 void getFileInfos(const QString
&path
, const QStringList
&files
);
117 void fetch(const QFileInfo
&info
, QTime
&base
, bool &firstTime
, QList
<QPair
<QString
,QExtendedInformation
> > &updatedFiles
, const QString
&path
);
118 QString
translateDriveName(const QFileInfo
&drive
) const;
119 QFile::Permissions
translatePermissions(const QFileInfo
&fileInfo
) const;
122 QWaitCondition condition
;
125 QStack
<QString
> path
;
126 QStack
<QStringList
> files
;
128 QFileSystemWatcher
*watcher
;
129 bool m_resolveSymlinks
;
130 QFileIconProvider
*m_iconProvider
;
131 QFileIconProvider defaultProvider
;
138 #endif // QFILEINFOGATHERER_H