From: Alexander Lohnau Date: Sat, 5 Sep 2020 17:32:48 +0000 (+0000) Subject: Clear services model after KNS entries changed X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/8e2f0a1d5b88f9ac6e06a0ac7a64d7080198f678 Clear services model after KNS entries changed We can not know if a service got deleted, so we clear the model and reload the services. The issue that the entries are not uninstalled has already been solved, this is just a patch to fix the state of the UI. CCBUG: 420312 --- diff --git a/src/settings/servicemodel.cpp b/src/settings/servicemodel.cpp index 81810b0a0..41c00a958 100644 --- a/src/settings/servicemodel.cpp +++ b/src/settings/servicemodel.cpp @@ -92,3 +92,10 @@ int ServiceModel::rowCount(const QModelIndex& parent) const return m_items.count(); } +void ServiceModel::clear() +{ + beginRemoveRows(QModelIndex(), 0, m_items.count()); + m_items.clear(); + endRemoveRows(); +} + diff --git a/src/settings/servicemodel.h b/src/settings/servicemodel.h index 92dd43dda..150159137 100644 --- a/src/settings/servicemodel.h +++ b/src/settings/servicemodel.h @@ -38,6 +38,7 @@ public: bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; + void clear(); private: struct ServiceItem diff --git a/src/settings/services/servicessettingspage.cpp b/src/settings/services/servicessettingspage.cpp index b7a9624b6..6ce5e1fc9 100644 --- a/src/settings/services/servicessettingspage.cpp +++ b/src/settings/services/servicessettingspage.cpp @@ -73,7 +73,13 @@ ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) : auto *downloadButton = new KNS3::Button(i18nc("@action:button", "Download New Services..."), QStringLiteral("servicemenu.knsrc"), this); - connect(downloadButton, &KNS3::Button::dialogFinished, this, &ServicesSettingsPage::loadServices); + connect(downloadButton, &KNS3::Button::dialogFinished, this, [this](const KNS3::Entry::List &changedEntries) { + if (!changedEntries.isEmpty()) { + m_serviceModel->clear(); + loadServices(); + } + }); + #endif topLayout->addWidget(label);