Slightly changed cache handling.

This commit is contained in:
LoRd_MuldeR 2012-03-31 22:20:07 +02:00
parent 17278fb7a6
commit 6dca891474
4 changed files with 19 additions and 19 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 4 #define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 11 #define VER_LAMEXP_PATCH 11
#define VER_LAMEXP_BUILD 944 #define VER_LAMEXP_BUILD 947
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!) // Tool versions (minimum expected versions!)

View File

@ -94,7 +94,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
m_qaacEncoderAvailable(lamexp_check_tool("qaac.exe") && lamexp_check_tool("libsoxrate.dll")), m_qaacEncoderAvailable(lamexp_check_tool("qaac.exe") && lamexp_check_tool("libsoxrate.dll")),
m_accepted(false), m_accepted(false),
m_firstTimeShown(true), m_firstTimeShown(true),
m_outputFolderViewInitialized(3), m_outputFolderViewInitialized(4),
m_outputFolderViewCentering(false) m_outputFolderViewCentering(false)
{ {
//Init the dialog, from the .ui file //Init the dialog, from the .ui file

View File

@ -160,27 +160,16 @@ bool QFileSystemModelEx::hasChildren(const QModelIndex &parent) const
{ {
if(parent.isValid()) if(parent.isValid())
{ {
return /*(QFileSystemModel::rowCount(parent) > 0) ||*/ hasSubfoldersCached(filePath(parent)); return hasSubfoldersCached(filePath(parent).toLower()); //return (QDir(QFileSystemModel::filePath(parent)).entryList(QDir::Dirs | QDir::NoDotAndDotDot).count() > 0);
} }
return true; return true;
} }
int QFileSystemModelEx::rowCount(const QModelIndex &parent) const
{
if(parent.isValid())
{
removeFromCache(filePath(parent));
}
return QFileSystemModel::rowCount(parent);
}
void QFileSystemModelEx::fetchMore(const QModelIndex &parent) void QFileSystemModelEx::fetchMore(const QModelIndex &parent)
{ {
if(parent.isValid()) if(parent.isValid())
{ {
removeFromCache(filePath(parent)); removeFromCache(filePath(parent).toLower());
} }
QFileSystemModel::fetchMore(parent); QFileSystemModel::fetchMore(parent);
@ -191,7 +180,8 @@ QModelIndex QFileSystemModelEx::index(const QString &path, int column) const
QFileInfo info(path); QFileInfo info(path);
if(info.exists() && info.isDir()) if(info.exists() && info.isDir())
{ {
QStringList parts = QDir::fromNativeSeparators(info.canonicalFilePath()).split('/', QString::SkipEmptyParts); QString fullPath = QDir::fromNativeSeparators(info.canonicalFilePath());
QStringList parts = fullPath.split('/', QString::SkipEmptyParts);
for(int i = 2; i <= parts.count(); i++) for(int i = 2; i <= parts.count(); i++)
{ {
QFileInfo currentPath(((QStringList) parts.mid(0, i)).join("/")); QFileInfo currentPath(((QStringList) parts.mid(0, i)).join("/"));
@ -200,7 +190,17 @@ QModelIndex QFileSystemModelEx::index(const QString &path, int column) const
return QModelIndex(); return QModelIndex();
} }
} }
return QFileSystemModel::index(path, column); QModelIndex index = QFileSystemModel::index(fullPath, column);
if(index.isValid())
{
QModelIndex temp = index;
while(temp.isValid())
{
removeFromCache(filePath(temp).toLower());
temp = temp.parent();
}
return index;
}
} }
return QModelIndex(); return QModelIndex();
} }
@ -219,7 +219,7 @@ bool QFileSystemModelEx::FindFirstFileExInfoBasicOK = false;
bool QFileSystemModelEx::hasSubfoldersCached(const QString &path) bool QFileSystemModelEx::hasSubfoldersCached(const QString &path)
{ {
QMutexLocker lock(&s_hasSubfolderMutex); QMutexLocker lock(&s_hasSubfolderMutex);
if(s_hasSubfolderCache.contains(path)) if(s_hasSubfolderCache.contains(path))
{ {
return s_hasSubfolderCache.value(path); return s_hasSubfolderCache.value(path);

View File

@ -33,7 +33,7 @@ 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 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;