Refactoring

Signed-off-by: QazCetelic <qaz.cetelic@protonmail.com>
This commit is contained in:
QazCetelic 2024-11-18 19:19:02 +01:00
parent e74592fa09
commit 6ca18c6266
2 changed files with 2 additions and 26 deletions

View File

@ -108,28 +108,6 @@ bool IconList::addPathRecursively(const QString& path)
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 iconFiles{};
@ -179,8 +157,7 @@ void IconList::directoryChanged(const QString& path)
stopWatching();
startWatching();
}
if (!m_dir.exists())
if (!FS::ensureFolderPathExists(m_dir.absolutePath()))
if (!m_dir.exists() && !FS::ensureFolderPathExists(m_dir.absolutePath()))
return;
m_dir.refresh();
const QStringList newFileNamesList = getIconFilePaths();

View File

@ -93,7 +93,6 @@ class IconList : public QAbstractListModel {
void reindex();
void sortIconList();
bool addPathRecursively(const QString& path);
void removePathRecursively(const QString& path);
QStringList getIconFilePaths() const;
public slots: