From 2190c254f824ee9fe93ef5004e2ee2f78b0f9aee Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Thu, 10 Oct 2013 01:46:30 +0200 Subject: [PATCH] Got rid of some more legacy compatibility code in the FileSystemModelEx class. --- src/Config.h | 2 +- src/Model_FileSystem.cpp | 27 +++++++-------------------- src/Model_FileSystem.h | 6 +----- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/Config.h b/src/Config.h index 1f65f67a..8dd42355 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,7 +34,7 @@ #define VER_LAMEXP_MINOR_LO 9 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 2 -#define VER_LAMEXP_BUILD 1371 +#define VER_LAMEXP_BUILD 1372 #define VER_LAMEXP_CONFG 1348 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Model_FileSystem.cpp b/src/Model_FileSystem.cpp index 3f138830..d66dbb52 100644 --- a/src/Model_FileSystem.cpp +++ b/src/Model_FileSystem.cpp @@ -35,8 +35,6 @@ #define IS_DIR(ATTR) (((ATTR) & FILE_ATTRIBUTE_DIRECTORY) && (!((ATTR) & FILE_ATTRIBUTE_HIDDEN))) #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 /////////////////////////////////////////////////////////////////////////////// @@ -93,7 +91,7 @@ QFileIconProviderEx::QFileIconProviderEx() m_installDir(QDir::fromNativeSeparators(qApp->applicationDirPath())), m_folderType("Folder") { - /* Nothing to do! */ + /*nothing to do*/ } QIcon QFileIconProviderEx::icon(const QFileInfo &info) const @@ -234,10 +232,7 @@ void QFileSystemModelEx::flushCache(void) QHash QFileSystemModelEx::s_hasSubfolderCache; QMutex QFileSystemModelEx::s_hasSubfolderMutex; - -void *QFileSystemModelEx::FindFirstFileExPtr = NULL; -bool QFileSystemModelEx::FindFirstFileExInitialized = false; -bool QFileSystemModelEx::FindFirstFileExInfoBasicOK = false; +int QFileSystemModelEx::s_findFirstFileExInfoLevel = INT_MAX; bool QFileSystemModelEx::hasSubfoldersCached(const QString &path) { @@ -267,24 +262,16 @@ void QFileSystemModelEx::removeAllFromCache(void) bool QFileSystemModelEx::hasSubfolders(const QString &path) { - if(!FindFirstFileExInitialized) + if(s_findFirstFileExInfoLevel == INT_MAX) { - QLibrary kernel32Lib("kernel32.dll"); - if(kernel32Lib.load()) - { - FindFirstFileExPtr = kernel32Lib.resolve("FindFirstFileExW"); - const lamexp_os_version_t *osVersionNo = lamexp_get_os_version(); - FindFirstFileExInfoBasicOK = LAMEXP_MIN_OS_VER(osVersionNo, 6, 1); - } - FindFirstFileExInitialized = true; + const lamexp_os_version_t *osVersionNo = lamexp_get_os_version(); + s_findFirstFileExInfoLevel = LAMEXP_MIN_OS_VER(osVersionNo, 6, 1) ? FindExInfoBasic : FindExInfoStandard; } WIN32_FIND_DATAW findData; bool bChildren = false; - HANDLE h = (FindFirstFileExPtr) - ? reinterpret_cast(FindFirstFileExPtr)(QWCHAR(QDir::toNativeSeparators(path + "/*")), (FindFirstFileExInfoBasicOK ? FindExInfoBasic : FindExInfoStandard), &findData, FindExSearchLimitToDirectories, NULL, 0) - : FindFirstFileW(QWCHAR(QDir::toNativeSeparators(path + "/*")), &findData); + HANDLE h = FindFirstFileEx(QWCHAR(QDir::toNativeSeparators(path + "/*")), ((FINDEX_INFO_LEVELS)s_findFirstFileExInfoLevel), &findData, FindExSearchLimitToDirectories, NULL, 0); if(h != INVALID_HANDLE_VALUE) { @@ -306,7 +293,7 @@ bool QFileSystemModelEx::hasSubfolders(const QString &path) DWORD err = GetLastError(); 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); } } diff --git a/src/Model_FileSystem.h b/src/Model_FileSystem.h index eb2fa36a..ea40c435 100644 --- a/src/Model_FileSystem.h +++ b/src/Model_FileSystem.h @@ -33,7 +33,6 @@ public: ~QFileSystemModelEx(); virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const; - //virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual void fetchMore(const QModelIndex &parent); virtual QModelIndex index(const QString &path, int column = 0) const; virtual void flushCache(void); @@ -43,10 +42,7 @@ private: static QHash s_hasSubfolderCache; static QMutex s_hasSubfolderMutex; - - static void *FindFirstFileExPtr; - static bool FindFirstFileExInitialized; - static bool FindFirstFileExInfoBasicOK; + static int s_findFirstFileExInfoLevel; static bool hasSubfolders(const QString &path); static bool hasSubfoldersCached(const QString &path);