Don't make the top-left square of the logging grid checkable

This commit is contained in:
Adam Higerd 2021-08-10 18:06:34 -05:00 committed by Vicki Pfau
parent ee5c4d49a4
commit a3b9988108
1 changed files with 9 additions and 3 deletions

View File

@ -27,6 +27,9 @@ QVariant LogConfigModel::data(const QModelIndex& index, int role) const {
} }
int levels; int levels;
if (index.row() == 0) { if (index.row() == 0) {
if (index.column() == 0) {
return QVariant();
}
levels = m_levels; levels = m_levels;
} else { } else {
levels = m_cache[index.row() - 1].levels; levels = m_cache[index.row() - 1].levels;
@ -46,6 +49,9 @@ bool LogConfigModel::setData(const QModelIndex& index, const QVariant& value, in
} }
int levels; int levels;
if (index.row() == 0) { if (index.row() == 0) {
if (index.column() == 0) {
return false;
}
levels = m_levels; levels = m_levels;
} else { } else {
levels = m_cache[index.row() - 1].levels; levels = m_cache[index.row() - 1].levels;
@ -60,7 +66,7 @@ bool LogConfigModel::setData(const QModelIndex& index, const QVariant& value, in
if (value.value<Qt::CheckState>() == Qt::Unchecked) { if (value.value<Qt::CheckState>() == Qt::Unchecked) {
levels &= ~bit; levels &= ~bit;
} else { } else {
levels |= bit; levels |= bit;
} }
} }
if (index.row() == 0) { if (index.row() == 0) {
@ -132,10 +138,10 @@ int LogConfigModel::rowCount(const QModelIndex& parent) const {
} }
Qt::ItemFlags LogConfigModel::flags(const QModelIndex& index) const { Qt::ItemFlags LogConfigModel::flags(const QModelIndex& index) const {
if (!index.isValid()) { if (!index.isValid() || (index.row() == 0 && index.column() == 0)) {
return 0; return 0;
} }
return Qt::ItemIsUserCheckable | Qt::ItemIsEditable | Qt::ItemIsEnabled; return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
} }
void LogConfigModel::reset() { void LogConfigModel::reset() {