Commit 0775faf2 authored by Marco Martin's avatar Marco Martin

expose IncludeUsage to QML api

Summary:
RecentUsageModel can list all aps and docs,
only aps or only docs. make possible to control that from QML

Test Plan: the api works, all existing code has the same behavior as before

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27782
parent 16ff0ba6
......@@ -138,7 +138,19 @@ RecentUsageModel::~RecentUsageModel()
{
}
RecentUsageModel::IncludeUsage RecentUsageModel::usage() const
void RecentUsageModel::setShownItems(IncludeUsage usage)
{
if (m_usage == usage) {
return;
}
m_usage = usage;
emit shownItemsChanged();
refresh();
}
RecentUsageModel::IncludeUsage RecentUsageModel::shownItems() const
{
return m_usage;
}
......
......@@ -66,9 +66,16 @@ class RecentUsageModel : public ForwardingModel, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(int ordering READ ordering WRITE setOrdering NOTIFY orderingChanged)
Q_PROPERTY(IncludeUsage shownItems READ shownItems WRITE setShownItems NOTIFY shownItemsChanged)
public:
enum IncludeUsage { AppsAndDocs, OnlyApps, OnlyDocs };
enum IncludeUsage {
AppsAndDocs,
OnlyApps,
OnlyDocs
};
Q_ENUM(IncludeUsage)
enum Ordering { Recent, Popular };
explicit RecentUsageModel(
......@@ -86,7 +93,8 @@ class RecentUsageModel : public ForwardingModel, public QQmlParserStatus
bool hasActions() const override;
QVariantList actions() const override;
IncludeUsage usage() const;
void setShownItems(IncludeUsage usage);
IncludeUsage shownItems() const;
void setOrdering(int ordering);
int ordering() const;
......@@ -96,6 +104,7 @@ class RecentUsageModel : public ForwardingModel, public QQmlParserStatus
Q_SIGNALS:
void orderingChanged(int ordering);
void shownItemsChanged();
private Q_SLOTS:
void refresh() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment