Add IsLastRow role to FieldModel
This commit is contained in:
parent
f7a3c7fd01
commit
d9dd05f488
|
@ -59,6 +59,7 @@ QHash<int, QByteArray> FieldModel::roleNames() const
|
||||||
{ FieldModelRoles::Value, "value" },
|
{ FieldModelRoles::Value, "value" },
|
||||||
{ FieldModelRoles::IsPassword, "isPassword" },
|
{ FieldModelRoles::IsPassword, "isPassword" },
|
||||||
{ FieldModelRoles::AlwaysActualValue, "actualValue" },
|
{ FieldModelRoles::AlwaysActualValue, "actualValue" },
|
||||||
|
{ FieldModelRoles::IsLastRow, "isLastRow" },
|
||||||
};
|
};
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +118,8 @@ QVariant FieldModel::data(const QModelIndex &index, int role) const
|
||||||
return QString::fromStdString((*m_fields)[static_cast<size_t>(index.row())].value());
|
return QString::fromStdString((*m_fields)[static_cast<size_t>(index.row())].value());
|
||||||
case IsPassword:
|
case IsPassword:
|
||||||
return (*m_fields)[static_cast<size_t>(index.row())].type() == FieldType::Password;
|
return (*m_fields)[static_cast<size_t>(index.row())].type() == FieldType::Password;
|
||||||
|
case IsLastRow:
|
||||||
|
return false;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,14 +226,14 @@ bool FieldModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
||||||
m_fields->emplace_back(m_accountEntry);
|
m_fields->emplace_back(m_accountEntry);
|
||||||
m_fields->back().setName(value.toString().toStdString());
|
m_fields->back().setName(value.toString().toStdString());
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
roles << Qt::DisplayRole << Qt::EditRole;
|
roles << Qt::DisplayRole << Qt::EditRole << IsLastRow;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
beginInsertRows(index.parent(), rowCount(), rowCount());
|
beginInsertRows(index.parent(), rowCount(), rowCount());
|
||||||
m_fields->emplace_back(m_accountEntry);
|
m_fields->emplace_back(m_accountEntry);
|
||||||
m_fields->back().setValue(value.toString().toStdString());
|
m_fields->back().setValue(value.toString().toStdString());
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
roles << Qt::DisplayRole << Qt::EditRole;
|
roles << Qt::DisplayRole << Qt::EditRole << IsLastRow;
|
||||||
break;
|
break;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ enum FieldModelRoles {
|
||||||
Value,
|
Value,
|
||||||
IsPassword,
|
IsPassword,
|
||||||
AlwaysActualValue,
|
AlwaysActualValue,
|
||||||
|
IsLastRow,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in New Issue