diff --git a/src/backends/basepersonsdatasource.h b/src/backends/basepersonsdatasource.h --- a/src/backends/basepersonsdatasource.h +++ b/src/backends/basepersonsdatasource.h @@ -78,6 +78,7 @@ BasePersonsDataSourceV2(QObject *parent, const QVariantList &args = QVariantList()); virtual bool addContact(const QVariantMap &properties) = 0; + virtual bool deleteContact(const QString &uri) = 0; }; } diff --git a/src/declarative/peopleqmlplugin.cpp b/src/declarative/peopleqmlplugin.cpp --- a/src/declarative/peopleqmlplugin.cpp +++ b/src/declarative/peopleqmlplugin.cpp @@ -51,6 +51,9 @@ Q_SCRIPTABLE bool addContact(const QVariantMap &properties) { return KPeople::PersonPluginManager::addContact(properties); } + Q_SCRIPTABLE bool deleteContact(const QString &uri) { + return KPeople::PersonPluginManager::deleteContact(uri); + } }; void PeopleQMLPlugin::registerTypes(const char *uri) diff --git a/src/personpluginmanager.h b/src/personpluginmanager.h --- a/src/personpluginmanager.h +++ b/src/personpluginmanager.h @@ -77,6 +77,14 @@ * @since 5.62 */ static bool addContact(const QVariantMap &properties); + + /** + * Deletes a contact with the specified &p uri + * @returns if it could be done successfully + * + * @since 5.62 + */ + static bool deleteContact(const QString &uri); }; } diff --git a/src/personpluginmanager.cpp b/src/personpluginmanager.cpp --- a/src/personpluginmanager.cpp +++ b/src/personpluginmanager.cpp @@ -148,3 +148,16 @@ } return ret; } + +bool KPeople::PersonPluginManager::deleteContact(const QString &uri) +{ + bool ret = false; + for (auto p : qAsConst(s_instance->dataSourcePlugins)) { + auto v2 = dynamic_cast(p); + if (!v2) + continue; + const bool deleted = v2->deleteContact(uri); + ret |= deleted; + } + return ret; +}