Got rid of some more legacy compatibility code in the FileSystemModelEx class.
This commit is contained in:
parent
cb3f50e5f3
commit
2190c254f8
@ -34,7 +34,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 9
|
#define VER_LAMEXP_MINOR_LO 9
|
||||||
#define VER_LAMEXP_TYPE Alpha
|
#define VER_LAMEXP_TYPE Alpha
|
||||||
#define VER_LAMEXP_PATCH 2
|
#define VER_LAMEXP_PATCH 2
|
||||||
#define VER_LAMEXP_BUILD 1371
|
#define VER_LAMEXP_BUILD 1372
|
||||||
#define VER_LAMEXP_CONFG 1348
|
#define VER_LAMEXP_CONFG 1348
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -35,8 +35,6 @@
|
|||||||
#define IS_DIR(ATTR) (((ATTR) & FILE_ATTRIBUTE_DIRECTORY) && (!((ATTR) & FILE_ATTRIBUTE_HIDDEN)))
|
#define IS_DIR(ATTR) (((ATTR) & FILE_ATTRIBUTE_DIRECTORY) && (!((ATTR) & FILE_ATTRIBUTE_HIDDEN)))
|
||||||
#define NO_DOT_OR_DOTDOT(STR) (wcscmp((STR), L".") && wcscmp((STR), L".."))
|
#define NO_DOT_OR_DOTDOT(STR) (wcscmp((STR), L".") && wcscmp((STR), L".."))
|
||||||
|
|
||||||
typedef HANDLE (WINAPI *FindFirstFileExFun)(LPCWSTR lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, LPVOID lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, LPVOID lpSearchFilter, DWORD dwAdditionalFlags);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Dummy QFileIconProvider class
|
// Dummy QFileIconProvider class
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -93,7 +91,7 @@ QFileIconProviderEx::QFileIconProviderEx()
|
|||||||
m_installDir(QDir::fromNativeSeparators(qApp->applicationDirPath())),
|
m_installDir(QDir::fromNativeSeparators(qApp->applicationDirPath())),
|
||||||
m_folderType("Folder")
|
m_folderType("Folder")
|
||||||
{
|
{
|
||||||
/* Nothing to do! */
|
/*nothing to do*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon QFileIconProviderEx::icon(const QFileInfo &info) const
|
QIcon QFileIconProviderEx::icon(const QFileInfo &info) const
|
||||||
@ -234,10 +232,7 @@ void QFileSystemModelEx::flushCache(void)
|
|||||||
|
|
||||||
QHash<const QString, bool> QFileSystemModelEx::s_hasSubfolderCache;
|
QHash<const QString, bool> QFileSystemModelEx::s_hasSubfolderCache;
|
||||||
QMutex QFileSystemModelEx::s_hasSubfolderMutex;
|
QMutex QFileSystemModelEx::s_hasSubfolderMutex;
|
||||||
|
int QFileSystemModelEx::s_findFirstFileExInfoLevel = INT_MAX;
|
||||||
void *QFileSystemModelEx::FindFirstFileExPtr = NULL;
|
|
||||||
bool QFileSystemModelEx::FindFirstFileExInitialized = false;
|
|
||||||
bool QFileSystemModelEx::FindFirstFileExInfoBasicOK = false;
|
|
||||||
|
|
||||||
bool QFileSystemModelEx::hasSubfoldersCached(const QString &path)
|
bool QFileSystemModelEx::hasSubfoldersCached(const QString &path)
|
||||||
{
|
{
|
||||||
@ -267,24 +262,16 @@ void QFileSystemModelEx::removeAllFromCache(void)
|
|||||||
|
|
||||||
bool QFileSystemModelEx::hasSubfolders(const QString &path)
|
bool QFileSystemModelEx::hasSubfolders(const QString &path)
|
||||||
{
|
{
|
||||||
if(!FindFirstFileExInitialized)
|
if(s_findFirstFileExInfoLevel == INT_MAX)
|
||||||
{
|
{
|
||||||
QLibrary kernel32Lib("kernel32.dll");
|
const lamexp_os_version_t *osVersionNo = lamexp_get_os_version();
|
||||||
if(kernel32Lib.load())
|
s_findFirstFileExInfoLevel = LAMEXP_MIN_OS_VER(osVersionNo, 6, 1) ? FindExInfoBasic : FindExInfoStandard;
|
||||||
{
|
|
||||||
FindFirstFileExPtr = kernel32Lib.resolve("FindFirstFileExW");
|
|
||||||
const lamexp_os_version_t *osVersionNo = lamexp_get_os_version();
|
|
||||||
FindFirstFileExInfoBasicOK = LAMEXP_MIN_OS_VER(osVersionNo, 6, 1);
|
|
||||||
}
|
|
||||||
FindFirstFileExInitialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WIN32_FIND_DATAW findData;
|
WIN32_FIND_DATAW findData;
|
||||||
bool bChildren = false;
|
bool bChildren = false;
|
||||||
|
|
||||||
HANDLE h = (FindFirstFileExPtr)
|
HANDLE h = FindFirstFileEx(QWCHAR(QDir::toNativeSeparators(path + "/*")), ((FINDEX_INFO_LEVELS)s_findFirstFileExInfoLevel), &findData, FindExSearchLimitToDirectories, NULL, 0);
|
||||||
? reinterpret_cast<FindFirstFileExFun>(FindFirstFileExPtr)(QWCHAR(QDir::toNativeSeparators(path + "/*")), (FindFirstFileExInfoBasicOK ? FindExInfoBasic : FindExInfoStandard), &findData, FindExSearchLimitToDirectories, NULL, 0)
|
|
||||||
: FindFirstFileW(QWCHAR(QDir::toNativeSeparators(path + "/*")), &findData);
|
|
||||||
|
|
||||||
if(h != INVALID_HANDLE_VALUE)
|
if(h != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -306,7 +293,7 @@ bool QFileSystemModelEx::hasSubfolders(const QString &path)
|
|||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
if((err == ERROR_NOT_SUPPORTED) || (err == ERROR_INVALID_PARAMETER))
|
if((err == ERROR_NOT_SUPPORTED) || (err == ERROR_INVALID_PARAMETER))
|
||||||
{
|
{
|
||||||
qWarning("%s failed with error code #%u", FindFirstFileExPtr ? "FindFirstFileEx" : "FindFirstFile", err);
|
qWarning("FindFirstFileEx failed with error code #%u", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ public:
|
|||||||
~QFileSystemModelEx();
|
~QFileSystemModelEx();
|
||||||
|
|
||||||
virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
|
virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
|
||||||
//virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
||||||
virtual void fetchMore(const QModelIndex &parent);
|
virtual void fetchMore(const QModelIndex &parent);
|
||||||
virtual QModelIndex index(const QString &path, int column = 0) const;
|
virtual QModelIndex index(const QString &path, int column = 0) const;
|
||||||
virtual void flushCache(void);
|
virtual void flushCache(void);
|
||||||
@ -43,10 +42,7 @@ private:
|
|||||||
|
|
||||||
static QHash<const QString, bool> s_hasSubfolderCache;
|
static QHash<const QString, bool> s_hasSubfolderCache;
|
||||||
static QMutex s_hasSubfolderMutex;
|
static QMutex s_hasSubfolderMutex;
|
||||||
|
static int s_findFirstFileExInfoLevel;
|
||||||
static void *FindFirstFileExPtr;
|
|
||||||
static bool FindFirstFileExInitialized;
|
|
||||||
static bool FindFirstFileExInfoBasicOK;
|
|
||||||
|
|
||||||
static bool hasSubfolders(const QString &path);
|
static bool hasSubfolders(const QString &path);
|
||||||
static bool hasSubfoldersCached(const QString &path);
|
static bool hasSubfoldersCached(const QString &path);
|
||||||
|
Loading…
Reference in New Issue
Block a user