Commit ed2d41c4 authored by Bea Lam's avatar Bea Lam

[systemsettings] Reload the AboutSettings storage models when items are...

[systemsettings] Reload the AboutSettings storage models when items are added/removed. Fixes JB#44031
parent a0754ba8
......@@ -42,6 +42,7 @@
#include <QTextStream>
#include <QVariant>
#include <QSettings>
#include <QTimer>
namespace
{
......@@ -126,6 +127,11 @@ AboutSettings::AboutSettings(QObject *parent)
m_vendorVersion = settings.value(QStringLiteral("Version")).toString();
refreshStorageModels();
connect(&m_partitionManager, &PartitionManager::partitionAdded,
this, &AboutSettings::partitionCountChanged);
connect(&m_partitionManager, &PartitionManager::partitionRemoved,
this, &AboutSettings::partitionCountChanged);
}
AboutSettings::~AboutSettings()
......@@ -227,12 +233,24 @@ QString AboutSettings::vendorVersion() const
}
void AboutSettings::refreshStorageModels()
{
m_partitionManager.refresh();
partitionCountChanged();
}
void AboutSettings::partitionCountChanged()
{
// Queue the method invocation in case several list changes are made consecutively, so that
// the list is only reloaded once.
QTimer::singleShot(0, this, &AboutSettings::reloadStorageLists);
}
void AboutSettings::reloadStorageLists()
{
m_internalStorage.clear();
m_externalStorage.clear();
m_partitionManager.refresh();
for (auto partition : m_partitionManager.partitions()) {
QVariantMap row;
row[QStringLiteral("mounted")] = partition.status() == Partition::Mounted;
......
......@@ -92,6 +92,9 @@ signals:
void storageChanged();
private:
void partitionCountChanged();
void reloadStorageLists();
QNetworkInfo *m_netinfo;
QDeviceInfo *m_devinfo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment