make activeTask a property

it can now be binded, besides being used in imperative code as it was

REVIEWED-BY:Eike Hein <hein@kde.org>
wilder-5.14
Marco Martin 10 years ago
parent 73f5302679
commit 17d3e13e0f
  1. 4
      libtaskmanager/tasksmodel.cpp
  2. 20
      libtaskmanager/tasksmodel.h

@ -197,6 +197,10 @@ void TasksModel::Private::initModels()
if (sortMode == SortActivity && roles.contains(AbstractTasksModel::Activities)) {
updateActivityTaskCounts();
}
if (roles.contains(AbstractTasksModel::IsActive)) {
emit q->activeTaskChanged();
}
}
);

@ -88,6 +88,7 @@ class TASKMANAGER_EXPORT TasksModel : public QSortFilterProxyModel, public Abstr
WRITE setGroupingAppIdBlacklist NOTIFY groupingAppIdBlacklistChanged)
Q_PROPERTY(QStringList groupingLauncherUrlBlacklist READ groupingLauncherUrlBlacklist
WRITE setGroupingLauncherUrlBlacklist NOTIFY groupingLauncherUrlBlacklistChanged)
Q_PROPERTY(QModelIndex activeTask READ activeTask NOTIFY activeTaskChanged)
public:
enum SortMode {
@ -509,6 +510,15 @@ public:
**/
void setGroupingLauncherUrlBlacklist(const QStringList &list);
/**
* Finds the first active (AbstractTasksModel::IsActive) task in the model
* and returns its QModelIndex, or a null QModelIndex if no active task is
* found.
*
* @returns the model index for the first active task, if any.
*/
QModelIndex activeTask() const;
/**
* Request adding a launcher with the given URL.
*
@ -737,15 +747,6 @@ public:
*/
Q_INVOKABLE void syncLaunchers();
/**
* Finds the first active (AbstractTasksModel::IsActive) task in the model
* and returns its QModelIndex, or a null QModelIndex if no active task is
* found.
*
* @returns the model index for the first active task, if any.
*/
Q_INVOKABLE QModelIndex activeTask() const;
/**
* Given a row in the model, returns a QModelIndex for it. To get an index
* for a child in a task group, an optional child row may be passed as well.
@ -779,6 +780,7 @@ Q_SIGNALS:
void groupingWindowTasksThresholdChanged() const;
void groupingAppIdBlacklistChanged() const;
void groupingLauncherUrlBlacklistChanged() const;
void activeTaskChanged() const;
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;

Loading…
Cancel
Save