Commit f2e34dbb authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Notifications] Have checkIndex check if the index is valid

Apparently by default it only considers "out of range" indices invalid but an invalid one as valid.

CCBUG: 418347

Differential Revision: https://phabricator.kde.org/D29297
parent ed0a5188
......@@ -92,7 +92,7 @@ bool JobsModel::isValid() const
QVariant JobsModel::data(const QModelIndex &index, int role) const
{
if (!checkIndex(index)) {
if (!checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
return QVariant();
}
......@@ -149,7 +149,7 @@ QVariant JobsModel::data(const QModelIndex &index, int role) const
bool JobsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!checkIndex(index)) {
if (!checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
return false;
}
......@@ -178,35 +178,35 @@ int JobsModel::rowCount(const QModelIndex &parent) const
void JobsModel::close(const QModelIndex &idx)
{
if (checkIndex(idx)) {
if (checkIndex(idx, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
d->removeAt(idx.row());
}
}
void JobsModel::expire(const QModelIndex &idx)
{
if (checkIndex(idx)) {
if (checkIndex(idx, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
d->m_jobViews.at(idx.row())->setExpired(true);
}
}
void JobsModel::suspend(const QModelIndex &idx)
{
if (checkIndex(idx)) {
if (checkIndex(idx, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
d->m_jobViews.at(idx.row())->suspend();
}
}
void JobsModel::resume(const QModelIndex &idx)
{
if (checkIndex(idx)) {
if (checkIndex(idx, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
d->m_jobViews.at(idx.row())->resume();
}
}
void JobsModel::kill(const QModelIndex &idx)
{
if (checkIndex(idx)) {
if (checkIndex(idx, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
d->m_jobViews.at(idx.row())->kill();
}
}
......
......@@ -253,7 +253,7 @@ void NotificationsModel::setLastRead(const QDateTime &lastRead)
QVariant NotificationsModel::data(const QModelIndex &index, int role) const
{
if (!checkIndex(index)) {
if (!checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
return QVariant();
}
......@@ -323,7 +323,7 @@ QVariant NotificationsModel::data(const QModelIndex &index, int role) const
bool NotificationsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!checkIndex(index)) {
if (!checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid)) {
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment