diff --git a/src/categorizedhistorymodel.cpp b/src/categorizedhistorymodel.cpp index d3c784d33e44ebba7273631847d5cc20ec22e248..88f9854efff5c93176aeed2ae98d4b27076a282f 100644 --- a/src/categorizedhistorymodel.cpp +++ b/src/categorizedhistorymodel.cpp @@ -564,12 +564,18 @@ void CategorizedHistoryModel::collectionAddedCallback(CollectionInterface* backe ///Call all collections that support clearing bool CategorizedHistoryModel::clearAllCollections() const { - foreach (CollectionInterface* backend, collections()) { //TODO use the filter API - if (backend->supportedFeatures() & CollectionInterface::SupportedFeatures::CLEAR) { - backend->clear(); - } - } - return true; + foreach (CollectionInterface* backend, collections(CollectionInterface::SupportedFeatures::CLEAR)) { + backend->clear(); + } + return true; +} + +///Delete all history and clear model +void CategorizedHistoryModel::clear() +{ + beginResetModel(); + clearAllCollections(); + endResetModel(); } bool CategorizedHistoryModel::addItemCallback(const Call* item) diff --git a/src/categorizedhistorymodel.h b/src/categorizedhistorymodel.h index 238b3d3b91ffdcf62e14e19c2e19560ba39059b4..69fb32be458e99db84aca5d952a1edbc255914f2 100644 --- a/src/categorizedhistorymodel.h +++ b/src/categorizedhistorymodel.h @@ -74,6 +74,7 @@ public: void setHistoryLimited(bool isLimited); void setHistoryLimit(int numberOfDays); void setHistoryEnabled(bool isEnabled); + void clear(); //Model implementation virtual bool setData ( const QModelIndex& index, const QVariant &value, int role ) override;