Allow disabling filtering by SkipTaskbar.

Summary:
This makes TaskFilterProxyModel useful for filtering a source tasks
model (e.g. WindowTasksModel) without implicitly filtering out tasks
that don't want to be shown on a 'task bar'.

Reviewers: #plasma, mart, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D2380
wilder-5.14
Eike Hein 10 years ago
parent acfbcb4fa5
commit b58f6ee2a3
  1. 19
      libtaskmanager/taskfilterproxymodel.cpp
  2. 22
      libtaskmanager/taskfilterproxymodel.h

@ -39,6 +39,7 @@ public:
bool filterByScreen = false;
bool filterByActivity = false;
bool filterNotMinimized = false;
bool filterSkipTaskbar = true;
private:
TaskFilterProxyModel *q;
@ -184,6 +185,22 @@ void TaskFilterProxyModel::setFilterNotMinimized(bool filter)
}
}
bool TaskFilterProxyModel::filterSkipTaskbar() const
{
return d->filterSkipTaskbar;
}
void TaskFilterProxyModel::setFilterSkipTaskbar(bool filter)
{
if (d->filterSkipTaskbar != filter) {
d->filterSkipTaskbar = filter;
invalidateFilter();
emit filterSkipTaskbarChanged();
}
}
void TaskFilterProxyModel::requestActivate(const QModelIndex &index)
{
if (d->sourceTasksModel && index.isValid() && index.model() == this) {
@ -289,7 +306,7 @@ bool TaskFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &so
const QModelIndex &sourceIdx = sourceModel()->index(sourceRow, 0);
// Filter tasks that are not to be shown on the task bar.
if (sourceIdx.data(AbstractTasksModel::SkipTaskbar).toBool()) {
if (d->filterSkipTaskbar && sourceIdx.data(AbstractTasksModel::SkipTaskbar).toBool()) {
return false;
}

@ -53,6 +53,7 @@ class TASKMANAGER_EXPORT TaskFilterProxyModel : public QSortFilterProxyModel, pu
Q_PROPERTY(bool filterByScreen READ filterByScreen WRITE setFilterByScreen NOTIFY filterByScreenChanged)
Q_PROPERTY(bool filterByActivity READ filterByActivity WRITE setFilterByActivity NOTIFY filterByActivityChanged)
Q_PROPERTY(bool filterNotMinimized READ filterNotMinimized WRITE setFilterNotMinimized NOTIFY filterNotMinimizedChanged)
Q_PROPERTY(bool filterSkipTaskbar READ filterSkipTaskbar WRITE setFilterSkipTaskbar NOTIFY filterSkipTaskbarChanged)
public:
explicit TaskFilterProxyModel(QObject *parent = 0);
@ -209,6 +210,26 @@ public:
**/
void setFilterNotMinimized(bool filter);
/**
* Whether tasks which indicate they want to be omitted from 'task bars'
* should be filtered. Defaults to @c true.
*
* @see setFilterSkipTaskbar
* @returns @c true if tasks which want to skip the 'task bar' should be
* filtered.
**/
bool filterSkipTaskbar() const;
/**
* Set whether tasks which indicate they want to be omitted from 'task bars'
* should be filtered.
*
* @see filterSkipTaskbar
* @param filter Whether tasks which want to skip the 'task bar' should be
* filtered.
**/
void setFilterSkipTaskbar(bool filter);
/**
* Request activation of the task at the given index. Derived classes are
* free to interpret the meaning of "activate" themselves depending on
@ -360,6 +381,7 @@ Q_SIGNALS:
void filterByScreenChanged() const;
void filterByActivityChanged() const;
void filterNotMinimizedChanged() const;
void filterSkipTaskbarChanged() const;
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;

Loading…
Cancel
Save