NotificationsModel::NotificationsModel(QObject* parent)
    : QAbstractListModel(parent)
    , m_dbusInterface(0)
{

    //new ModelTest(this, this);

    connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)),
            this, SIGNAL(rowsChanged()));
    connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)),
            this, SIGNAL(rowsChanged()));

    connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
            this, SIGNAL(anyDismissableChanged()));


    QDBusServiceWatcher* watcher = new QDBusServiceWatcher(DaemonDbusInterface::activatedService(),
            QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
    connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &NotificationsModel::refreshNotificationList);
    connect(watcher, &QDBusServiceWatcher::serviceUnregistered, this, &NotificationsModel::clearNotifications);
}
NotificationsModel::NotificationsModel(QObject* parent)
    : QAbstractListModel(parent)
    , m_dbusInterface(0)
{

    //new ModelTest(this, this);

    connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)),
            this, SIGNAL(rowsChanged()));
    connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)),
            this, SIGNAL(rowsChanged()));

    connect(this, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
            this, SIGNAL(anyDismissableChanged()));

    //Role names for QML
    QHash<int, QByteArray> names = roleNames();
    names.insert(DbusInterfaceRole, "dbusInterface");
    names.insert(AppNameModelRole, "appName");
    names.insert(DismissableModelRole, "dismissable");
    setRoleNames(names);

}