kde-workspace/libs/taskmanager/tasksmodel.h

105 lines
3.8 KiB
C
Raw Normal View History

2014-11-13 19:30:51 +02:00
/*****************************************************************
Copyright 2010 Aaron Seigo <aseigo@kde.org>
Copyright 2012-2013 Eike Hein <hein@kde.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************/
#ifndef TASKSMODEL_H
#define TASKSMODEL_H
#include <QAbstractItemModel>
#include "taskmanager_export.h"
namespace TaskManager
{
class GroupManager;
class TaskGroup;
class TasksModelPrivate;
class TASKMANAGER_EXPORT TasksModel : public QAbstractItemModel
{
Q_OBJECT
Q_ENUMS(DisplayRoles)
Q_PROPERTY(int count READ rowCount() NOTIFY countChanged())
Q_PROPERTY(int launcherCount READ launcherCount NOTIFY launcherCountChanged)
public:
enum DisplayRoles {
Id = Qt::UserRole + 1,
GenericName = Qt::UserRole + 2,
IsStartup = Qt::UserRole + 3,
IsLauncher = Qt::UserRole + 4,
OnAllDesktops = Qt::UserRole + 5,
Desktop = Qt::UserRole + 6,
DesktopName = Qt::UserRole + 7,
Shaded = Qt::UserRole + 8,
Maximized = Qt::UserRole + 9,
Minimized = Qt::UserRole + 10,
FullScreen = Qt::UserRole + 11,
BelowOthers = Qt::UserRole + 12,
AlwaysOnTop = Qt::UserRole + 13,
Active = Qt::UserRole + 14,
DemandsAttention = Qt::UserRole + 15,
LauncherUrl = Qt::UserRole + 16,
WindowList = Qt::UserRole + 17,
MimeType = Qt::UserRole + 18,
MimeData = Qt::UserRole + 19
2014-11-13 19:30:51 +02:00
};
explicit TasksModel(GroupManager *groupManager, QObject *parent = 0);
~TasksModel();
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const;
Q_INVOKABLE int launcherCount() const;
Q_INVOKABLE int activeTaskId(TaskGroup *group = 0) const;
Q_INVOKABLE QVariant taskIdList(const QModelIndex &parent = QModelIndex(), bool recursive = true) const;
signals:
void countChanged();
void launcherCountChanged();
private:
friend class TasksModelPrivate;
TasksModelPrivate * const d;
Q_PRIVATE_SLOT(d, void populateModel())
Q_PRIVATE_SLOT(d, void itemAboutToBeAdded(AbstractGroupableItem *, int))
Q_PRIVATE_SLOT(d, void itemAdded(AbstractGroupableItem *))
Q_PRIVATE_SLOT(d, void itemAboutToBeRemoved(AbstractGroupableItem *))
Q_PRIVATE_SLOT(d, void itemRemoved(AbstractGroupableItem *))
Q_PRIVATE_SLOT(d, void itemAboutToMove(AbstractGroupableItem *, int, int))
Q_PRIVATE_SLOT(d, void itemMoved(AbstractGroupableItem *))
Q_PRIVATE_SLOT(d, void itemChanged(::TaskManager::TaskChanges))
};
} // namespace TaskManager
#endif