Skip to content
Snippets Groups Projects
Commit a3f86438 authored by Stepan Salenikovich's avatar Stepan Salenikovich
Browse files

history: add method to clear the model and the backends

clearAllBackends() only deletes the file, but does not reset the
model; the new clear() method does both.

Change-Id: I39f37276b650b9511d08d8bd4f7c7b52a33a142a
Tuleap: #925
parent f9cd6bf9
No related branches found
No related tags found
No related merge requests found
...@@ -564,14 +564,20 @@ void CategorizedHistoryModel::collectionAddedCallback(CollectionInterface* backe ...@@ -564,14 +564,20 @@ void CategorizedHistoryModel::collectionAddedCallback(CollectionInterface* backe
///Call all collections that support clearing ///Call all collections that support clearing
bool CategorizedHistoryModel::clearAllCollections() const bool CategorizedHistoryModel::clearAllCollections() const
{ {
foreach (CollectionInterface* backend, collections()) { //TODO use the filter API foreach (CollectionInterface* backend, collections(CollectionInterface::SupportedFeatures::CLEAR)) {
if (backend->supportedFeatures() & CollectionInterface::SupportedFeatures::CLEAR) {
backend->clear(); backend->clear();
} }
}
return true; return true;
} }
///Delete all history and clear model
void CategorizedHistoryModel::clear()
{
beginResetModel();
clearAllCollections();
endResetModel();
}
bool CategorizedHistoryModel::addItemCallback(const Call* item) bool CategorizedHistoryModel::addItemCallback(const Call* item)
{ {
d_ptr->add(const_cast<Call*>(item)); d_ptr->add(const_cast<Call*>(item));
......
...@@ -74,6 +74,7 @@ public: ...@@ -74,6 +74,7 @@ public:
void setHistoryLimited(bool isLimited); void setHistoryLimited(bool isLimited);
void setHistoryLimit(int numberOfDays); void setHistoryLimit(int numberOfDays);
void setHistoryEnabled(bool isEnabled); void setHistoryEnabled(bool isEnabled);
void clear();
//Model implementation //Model implementation
virtual bool setData ( const QModelIndex& index, const QVariant &value, int role ) override; virtual bool setData ( const QModelIndex& index, const QVariant &value, int role ) override;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment