You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.6 KiB
60 lines
1.6 KiB
/* |
|
* QtQuick friendly list model of Tasks |
|
* Copyright (C) 2014 David Edmundson <david@davidedmundson.co.uk> |
|
* |
|
* This library is free software; you can redistribute it and/or |
|
* modify it under the terms of the GNU Lesser General Public |
|
* License as published by the Free Software Foundation; either |
|
* version 2.1 of the License, or (at your option) any later version. |
|
* |
|
* This library is distributed in the hope that it will be useful, |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
* Lesser General Public License for more details. |
|
* |
|
* You should have received a copy of the GNU Lesser General Public |
|
* License along with this library; if not, write to the Free Software |
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
* |
|
*/ |
|
|
|
#ifndef TASKLISTMODEL_H |
|
#define TASKLISTMODEL_H |
|
|
|
#include <QAbstractListModel> |
|
|
|
namespace SystemTray |
|
{ |
|
|
|
class Task; |
|
|
|
class TaskListModel : public QAbstractListModel |
|
{ |
|
Q_OBJECT |
|
Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
|
|
public: |
|
TaskListModel(QObject *parent = 0); |
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |
|
virtual int rowCount(const QModelIndex &parent= QModelIndex()) const; |
|
virtual QHash< int, QByteArray > roleNames() const; |
|
|
|
QList<Task*> tasks() const; |
|
|
|
void addTask(Task *task); |
|
void removeTask(Task *task); |
|
|
|
int count() const |
|
{ |
|
return rowCount(); |
|
} |
|
|
|
Q_SIGNALS: |
|
void countChanged(); |
|
|
|
private: |
|
QList<Task*> m_tasks; |
|
}; |
|
} |
|
|
|
#endif // TASKLISTMODEL_H
|
|
|