mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-29 05:10:20 +02:00
Split set creation into a separate function for readability
Signed-off-by: QazCetelic <qaz.cetelic@protonmail.com>
This commit is contained in:
parent
a58e81d744
commit
b675406b1a
@ -157,6 +157,16 @@ QString formatName(const QDir& iconsDir, const QFileInfo& file)
|
|||||||
return relativePathWithoutExtension.replace(QDir::separator(), delimiter);
|
return relativePathWithoutExtension.replace(QDir::separator(), delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSet<QString> toStringSet(const QList<QString>& list) // Split into a separate function because the preprocessing impedes readability
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
QSet<QString> set(list.begin(), list.end());
|
||||||
|
#else
|
||||||
|
auto set = list.toSet();
|
||||||
|
#endif
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
void IconList::directoryChanged(const QString& path)
|
void IconList::directoryChanged(const QString& path)
|
||||||
{
|
{
|
||||||
QDir new_dir(path);
|
QDir new_dir(path);
|
||||||
@ -171,31 +181,23 @@ void IconList::directoryChanged(const QString& path)
|
|||||||
if (!FS::ensureFolderPathExists(m_dir.absolutePath()))
|
if (!FS::ensureFolderPathExists(m_dir.absolutePath()))
|
||||||
return;
|
return;
|
||||||
m_dir.refresh();
|
m_dir.refresh();
|
||||||
QStringList newFileNamesList = getIconFilePaths();
|
const QStringList newFileNamesList = getIconFilePaths();
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
const QSet<QString> newSet = toStringSet(newFileNamesList);
|
||||||
QSet<QString> new_set(newFileNamesList.begin(), newFileNamesList.end());
|
|
||||||
#else
|
|
||||||
auto new_set = new_file_names_list.toSet();
|
|
||||||
#endif
|
|
||||||
QList<QString> current_list;
|
QList<QString> current_list;
|
||||||
for (auto& it : icons) {
|
for (auto& it : icons) {
|
||||||
if (!it.has(IconType::FileBased))
|
if (!it.has(IconType::FileBased))
|
||||||
continue;
|
continue;
|
||||||
current_list.push_back(it.m_images[IconType::FileBased].filename);
|
current_list.push_back(it.m_images[IconType::FileBased].filename);
|
||||||
}
|
}
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
const QSet<QString> currentSet = toStringSet(current_list);
|
||||||
QSet<QString> current_set(current_list.begin(), current_list.end());
|
|
||||||
#else
|
|
||||||
QSet<QString> current_set = current_list.toSet();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QSet<QString> to_remove = current_set;
|
QSet<QString> toRemove = currentSet;
|
||||||
to_remove -= new_set;
|
toRemove -= newSet;
|
||||||
|
|
||||||
QSet<QString> toAdd = new_set;
|
QSet<QString> toAdd = newSet;
|
||||||
toAdd -= current_set;
|
toAdd -= currentSet;
|
||||||
|
|
||||||
for (const auto& remove : to_remove) {
|
for (const auto& remove : toRemove) {
|
||||||
qDebug() << "Removing " << remove;
|
qDebug() << "Removing " << remove;
|
||||||
QFileInfo removedFile(remove);
|
QFileInfo removedFile(remove);
|
||||||
QString key = m_dir.relativeFilePath(removedFile.absoluteFilePath());
|
QString key = m_dir.relativeFilePath(removedFile.absoluteFilePath());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user