diff --git a/res/Icons.qrc b/res/Icons.qrc index 51cf126b..f5ebc549 100644 --- a/res/Icons.qrc +++ b/res/Icons.qrc @@ -37,11 +37,16 @@ icons/disk.png icons/door_out.png icons/door_in.png + icons/drive.png icons/drive_cd.png + icons/drive_disk.png + icons/drive_link.png + icons/drive_network.png icons/exclamation.png icons/error.png icons/error_big.png icons/feed.png + icons/folder.png icons/folder_add.png icons/folder_go.png icons/folder_image.png diff --git a/src/Config.h b/src/Config.h index e3af479e..d6bfff63 100644 --- a/src/Config.h +++ b/src/Config.h @@ -29,8 +29,8 @@ #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_TYPE Beta -#define VER_LAMEXP_PATCH 6 -#define VER_LAMEXP_BUILD 562 +#define VER_LAMEXP_PATCH 7 +#define VER_LAMEXP_BUILD 564 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/Model_FileSystem.cpp b/src/Model_FileSystem.cpp index 5dc4de9a..14738e58 100644 --- a/src/Model_FileSystem.cpp +++ b/src/Model_FileSystem.cpp @@ -20,28 +20,96 @@ /////////////////////////////////////////////////////////////////////////////// #include "Model_FileSystem.h" +#include "Global.h" #include +#include + +/////////////////////////////////////////////////////////////////////////////// +// Dummy QFileIconProvider class +/////////////////////////////////////////////////////////////////////////////// + +class QFileIconProviderEx : public QFileIconProvider +{ +public: + QFileIconProviderEx(); + virtual QIcon icon(IconType type) const { return (type == Drive) ? m_driveIcon : m_folderIcon; } + virtual QIcon icon(const QFileInfo &info) const; + virtual QString type (const QFileInfo &info) const { return info.isDir() ? m_folderType : m_emptyType; } + +private: + const QIcon m_driveIcon; + const QIcon m_cdromIcon; + const QIcon m_networkIcon; + const QIcon m_floppyIcon; + const QIcon m_folderIcon; + const QIcon m_emptyIcon; + const QString m_folderType; + const QString m_emptyType; +}; + +QFileIconProviderEx::QFileIconProviderEx() +: + m_folderIcon(":/icons/folder.png"), + m_driveIcon(":/icons/drive.png"), + m_cdromIcon(":/icons/drive_cd.png"), + m_networkIcon(":/icons/drive_link.png"), + m_floppyIcon(":/icons/drive_disk.png"), + m_folderType("Folder") +{ + /* Nothing to do! */ +} + +QIcon QFileIconProviderEx::icon(const QFileInfo &info) const +{ + if(info.isRoot()) + { + switch(GetDriveType(QWCHAR(QDir::toNativeSeparators(info.absoluteFilePath())))) + { + case DRIVE_CDROM: + return m_cdromIcon; + break; + case DRIVE_REMOVABLE: + return m_floppyIcon; + break; + case DRIVE_REMOTE: + return m_networkIcon; + break; + default: + return m_driveIcon; + break; + } + } + + return info.isFile() ? m_emptyIcon : m_folderIcon; +} + +/////////////////////////////////////////////////////////////////////////////// +// Modified QFileSystemModel class +/////////////////////////////////////////////////////////////////////////////// QFileSystemModelEx::QFileSystemModelEx() : QFileSystemModel() { + this->m_myIconProvider = new QFileIconProviderEx(); + this->setIconProvider(m_myIconProvider); this->setFilter(QDir::Dirs | QDir::NoDotAndDotDot); + this->setNameFilterDisables(false); +} + +QFileSystemModelEx::~QFileSystemModelEx() +{ + LAMEXP_DELETE(m_myIconProvider); } bool QFileSystemModelEx::hasChildren(const QModelIndex &parent) const { - bool result = QFileSystemModel::hasChildren(parent); - - if(parent.isValid() && result) + if(parent.isValid()) { - QFileInfo fileInfo = QFileSystemModel::fileInfo(parent); - if(fileInfo.isDir()) - { - result = (QDir(fileInfo.absoluteFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot).count() > 0); - } + QDir dir = QDir(QFileSystemModel::filePath(parent)); + return dir.exists() && (dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot).count() > 0); } - return result; + return true; } diff --git a/src/Model_FileSystem.h b/src/Model_FileSystem.h index f1d6ff88..2df5d945 100644 --- a/src/Model_FileSystem.h +++ b/src/Model_FileSystem.h @@ -23,9 +23,16 @@ #include +class QFileIconProviderEx; + class QFileSystemModelEx : public QFileSystemModel { public: QFileSystemModelEx(); + ~QFileSystemModelEx(); + virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const; + +private: + QFileIconProviderEx *m_myIconProvider; };