]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Clear services model after KNS entries changed
authorAlexander Lohnau <alexander.lohnau@gmx.de>
Sat, 5 Sep 2020 17:32:48 +0000 (17:32 +0000)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sat, 5 Sep 2020 17:32:48 +0000 (17:32 +0000)
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

src/settings/servicemodel.cpp
src/settings/servicemodel.h
src/settings/services/servicessettingspage.cpp

index 81810b0a03ffe83c58b7422fba2d8b47a116577b..41c00a95823c06896de227b2d29ff07de4fb72d3 100644 (file)
@@ -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();
+}
+
index 92dd43ddabf750b23f0735abda7f1f62803ac12e..150159137ce221774c6010a1cb3922b0252f8398 100644 (file)
@@ -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
index b7a9624b6a7bf75ac9981d579a542eb83e9fb274..6ce5e1fc95a033382b3ae0987fcf11a9c4f72c38 100644 (file)
@@ -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);