mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-09-14 22:46:06 -04:00
Refactoring
Signed-off-by: QazCetelic <qaz.cetelic@protonmail.com>
This commit is contained in:
parent
e74592fa09
commit
6ca18c6266
@ -108,28 +108,6 @@ bool IconList::addPathRecursively(const QString& path)
|
|||||||
return watching;
|
return watching;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconList::removePathRecursively(const QString& path)
|
|
||||||
{
|
|
||||||
QFileInfo file_info(path);
|
|
||||||
if (file_info.isFile()) {
|
|
||||||
// Remove the icon belonging to the file
|
|
||||||
QString key = m_dir.relativeFilePath(file_info.absoluteFilePath());
|
|
||||||
int idx = getIconIndex(key);
|
|
||||||
if (idx == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
} else if (file_info.isDir()) {
|
|
||||||
// Remove the directory itself
|
|
||||||
m_watcher->removePath(path);
|
|
||||||
|
|
||||||
const QDir dir(path);
|
|
||||||
// Remove all files within the directory
|
|
||||||
for (const QFileInfo& file : dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
|
||||||
removePathRecursively(file.absoluteFilePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList IconList::getIconFilePaths() const
|
QStringList IconList::getIconFilePaths() const
|
||||||
{
|
{
|
||||||
QStringList iconFiles{};
|
QStringList iconFiles{};
|
||||||
@ -179,9 +157,8 @@ void IconList::directoryChanged(const QString& path)
|
|||||||
stopWatching();
|
stopWatching();
|
||||||
startWatching();
|
startWatching();
|
||||||
}
|
}
|
||||||
if (!m_dir.exists())
|
if (!m_dir.exists() && !FS::ensureFolderPathExists(m_dir.absolutePath()))
|
||||||
if (!FS::ensureFolderPathExists(m_dir.absolutePath()))
|
return;
|
||||||
return;
|
|
||||||
m_dir.refresh();
|
m_dir.refresh();
|
||||||
const QStringList newFileNamesList = getIconFilePaths();
|
const QStringList newFileNamesList = getIconFilePaths();
|
||||||
const QSet<QString> newSet = toStringSet(newFileNamesList);
|
const QSet<QString> newSet = toStringSet(newFileNamesList);
|
||||||
|
@ -93,7 +93,6 @@ class IconList : public QAbstractListModel {
|
|||||||
void reindex();
|
void reindex();
|
||||||
void sortIconList();
|
void sortIconList();
|
||||||
bool addPathRecursively(const QString& path);
|
bool addPathRecursively(const QString& path);
|
||||||
void removePathRecursively(const QString& path);
|
|
||||||
QStringList getIconFilePaths() const;
|
QStringList getIconFilePaths() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user