mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Allow history to be cleared for one provider only
This commit is contained in:
parent
5f83b84c4e
commit
ea58fd747f
@ -158,7 +158,7 @@ The optional ``providerId`` and ``backends`` arguments can be used to filter ent
|
||||
Returns the path to user's local history database.
|
||||
%End
|
||||
|
||||
bool clearHistory( Qgis::HistoryProviderBackend backend );
|
||||
bool clearHistory( Qgis::HistoryProviderBackend backend, const QString &providerId = QString() );
|
||||
%Docstring
|
||||
Clears the history for the specified ``backend``.
|
||||
|
||||
@ -181,10 +181,13 @@ Emitted when an ``entry`` is updated.
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
void historyCleared( Qgis::HistoryProviderBackend backend );
|
||||
void historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId );
|
||||
%Docstring
|
||||
Emitted when the history is cleared for a ``backend``.
|
||||
|
||||
If ``providerId`` is non-empty then the history has only been cleared for the
|
||||
specified provider.
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
|
@ -250,12 +250,15 @@ void QgsHistoryEntryModel::entryUpdated( long long id, const QVariantMap &entry,
|
||||
}
|
||||
}
|
||||
|
||||
void QgsHistoryEntryModel::historyCleared( Qgis::HistoryProviderBackend backend )
|
||||
void QgsHistoryEntryModel::historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId )
|
||||
{
|
||||
// ignore entries we don't care about
|
||||
if ( !( mBackends & backend ) )
|
||||
return;
|
||||
|
||||
if ( !mProviderId.isEmpty() && !providerId.isEmpty() && providerId != mProviderId )
|
||||
return;
|
||||
|
||||
beginResetModel();
|
||||
mRootNode->clear();
|
||||
mIdToNodeHash.clear();
|
||||
|
@ -80,7 +80,7 @@ class GUI_EXPORT QgsHistoryEntryModel : public QAbstractItemModel
|
||||
|
||||
void entryAdded( long long id, const QgsHistoryEntry &entry, Qgis::HistoryProviderBackend backend );
|
||||
void entryUpdated( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend );
|
||||
void historyCleared( Qgis::HistoryProviderBackend backend );
|
||||
void historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId );
|
||||
|
||||
private:
|
||||
|
||||
|
@ -267,15 +267,21 @@ QString QgsHistoryProviderRegistry::userHistoryDbPath()
|
||||
return QgsApplication::qgisSettingsDirPath() + QStringLiteral( "user-history.db" );
|
||||
}
|
||||
|
||||
bool QgsHistoryProviderRegistry::clearHistory( Qgis::HistoryProviderBackend backend )
|
||||
bool QgsHistoryProviderRegistry::clearHistory( Qgis::HistoryProviderBackend backend, const QString &providerId )
|
||||
{
|
||||
switch ( backend )
|
||||
{
|
||||
case Qgis::HistoryProviderBackend::LocalProfile:
|
||||
runEmptyQuery( QStringLiteral( "DELETE from history;" ) );
|
||||
{
|
||||
if ( providerId.isEmpty() )
|
||||
runEmptyQuery( QStringLiteral( "DELETE from history;" ) );
|
||||
else
|
||||
runEmptyQuery( QStringLiteral( "DELETE from history WHERE provider_id='%1'" )
|
||||
.arg( providerId ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
emit historyCleared( backend );
|
||||
emit historyCleared( backend, providerId );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ class GUI_EXPORT QgsHistoryProviderRegistry : public QObject
|
||||
*
|
||||
* \see historyCleared()
|
||||
*/
|
||||
bool clearHistory( Qgis::HistoryProviderBackend backend );
|
||||
bool clearHistory( Qgis::HistoryProviderBackend backend, const QString &providerId = QString() );
|
||||
|
||||
signals:
|
||||
|
||||
@ -206,9 +206,12 @@ class GUI_EXPORT QgsHistoryProviderRegistry : public QObject
|
||||
/**
|
||||
* Emitted when the history is cleared for a \a backend.
|
||||
*
|
||||
* If \a providerId is non-empty then the history has only been cleared for the
|
||||
* specified provider.
|
||||
*
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
void historyCleared( Qgis::HistoryProviderBackend backend );
|
||||
void historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId );
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user