Skip to content

Commit

Permalink
Add dismissAll API
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 15, 2019
1 parent a8fdcc0 commit da60198
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/core/auto_generated/qgsnewsfeedparser.sip.in
Expand Up @@ -68,6 +68,15 @@ Returns a list of existing entries in the feed.
Dismisses an entry with matching ``key``.

This removes the entry from the local store, ensuring it will never be present again.

.. seealso:: :py:func:`dismissAll`
%End

void dismissAll();
%Docstring
Dismisses all current news items.

.. seealso:: :py:func:`dismissEntry`
%End

QString authcfg() const;
Expand Down
9 changes: 9 additions & 0 deletions src/core/qgsnewsfeedparser.cpp
Expand Up @@ -91,6 +91,15 @@ void QgsNewsFeedParser::dismissEntry( int key )
emit entryDismissed( dismissed );
}

void QgsNewsFeedParser::dismissAll()
{
const QList< QgsNewsFeedParser::Entry > entries = mEntries;
for ( const Entry &entry : entries )
{
dismissEntry( entry.key );
}
}

QString QgsNewsFeedParser::authcfg() const
{
return mAuthCfg;
Expand Down
8 changes: 8 additions & 0 deletions src/core/qgsnewsfeedparser.h
Expand Up @@ -83,9 +83,17 @@ class CORE_EXPORT QgsNewsFeedParser : public QObject
* Dismisses an entry with matching \a key.
*
* This removes the entry from the local store, ensuring it will never be present again.
*
* \see dismissAll()
*/
void dismissEntry( int key );

/**
* Dismisses all current news items.
* \see dismissEntry()
*/
void dismissAll();

/**
* Returns the authentication configuration for the parser.
*/
Expand Down
6 changes: 6 additions & 0 deletions tests/src/core/testqgsnewsfeedparser.cpp
Expand Up @@ -176,6 +176,12 @@ void TestQgsNewsFeedParser::testFetch()
QCOMPARE( parser4.entries().at( 1 ).title, QStringLiteral( "Null Island QGIS Meeting" ) );
QCOMPARE( parser4.entries().at( 2 ).title, QStringLiteral( "QGIS Italian Meeting" ) );

// dismiss all
parser4.dismissAll();
QCOMPARE( parser4.entries().count(), 0 );

QgsNewsFeedParser parser5( url );
QCOMPARE( parser5.entries().count(), 0 );
}

void TestQgsNewsFeedParser::testModel()
Expand Down

0 comments on commit da60198

Please sign in to comment.