Implemented as custom QFileIconProvider class, which (hopefully) is a bit faster than the original one.
This commit is contained in:
parent
ef4c8f3051
commit
3e0056d0fc
@ -37,11 +37,16 @@
|
||||
<file>icons/disk.png</file>
|
||||
<file>icons/door_out.png</file>
|
||||
<file>icons/door_in.png</file>
|
||||
<file>icons/drive.png</file>
|
||||
<file>icons/drive_cd.png</file>
|
||||
<file>icons/drive_disk.png</file>
|
||||
<file>icons/drive_link.png</file>
|
||||
<file>icons/drive_network.png</file>
|
||||
<file>icons/exclamation.png</file>
|
||||
<file>icons/error.png</file>
|
||||
<file>icons/error_big.png</file>
|
||||
<file>icons/feed.png</file>
|
||||
<file>icons/folder.png</file>
|
||||
<file>icons/folder_add.png</file>
|
||||
<file>icons/folder_go.png</file>
|
||||
<file>icons/folder_image.png</file>
|
||||
|
@ -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
|
||||
|
@ -20,28 +20,96 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Model_FileSystem.h"
|
||||
#include "Global.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileIconProvider>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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;
|
||||
}
|
||||
|
@ -23,9 +23,16 @@
|
||||
|
||||
#include <QFileSystemModel>
|
||||
|
||||
class QFileIconProviderEx;
|
||||
|
||||
class QFileSystemModelEx : public QFileSystemModel
|
||||
{
|
||||
public:
|
||||
QFileSystemModelEx();
|
||||
~QFileSystemModelEx();
|
||||
|
||||
virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
private:
|
||||
QFileIconProviderEx *m_myIconProvider;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user