Make pre-defined highlight columns unselectable

Fixes #1539.
This commit is contained in:
Leon Richardt 2020-02-20 00:10:10 +01:00
parent 6229b2f434
commit d0839ac36e
No known key found for this signature in database
GPG key ID: AD8BDD6273FE8FC5
2 changed files with 16 additions and 10 deletions

View file

@ -63,10 +63,10 @@ void HighlightModel::afterInit()
usernameRow[Column::CaseSensitive]->setFlags(0);
QUrl selfSound = QUrl(getSettings()->selfHighlightSoundUrl.getValue());
setFilePathItem(usernameRow[Column::SoundPath], selfSound);
setFilePathItem(usernameRow[Column::SoundPath], selfSound, false);
auto selfColor = ColorProvider::instance().color(ColorType::SelfHighlight);
setColorItem(usernameRow[Column::Color], *selfColor);
setColorItem(usernameRow[Column::Color], *selfColor, false);
this->insertCustomRow(usernameRow, 0);
@ -86,10 +86,10 @@ void HighlightModel::afterInit()
QUrl whisperSound =
QUrl(getSettings()->whisperHighlightSoundUrl.getValue());
setFilePathItem(whisperRow[Column::SoundPath], whisperSound);
setFilePathItem(whisperRow[Column::SoundPath], whisperSound, false);
auto whisperColor = ColorProvider::instance().color(ColorType::Whisper);
setColorItem(whisperRow[Column::Color], *whisperColor);
setColorItem(whisperRow[Column::Color], *whisperColor, false);
this->insertCustomRow(whisperRow, 1);
@ -107,10 +107,10 @@ void HighlightModel::afterInit()
subRow[Column::CaseSensitive]->setFlags(0);
QUrl subSound = QUrl(getSettings()->subHighlightSoundUrl.getValue());
setFilePathItem(subRow[Column::SoundPath], subSound);
setFilePathItem(subRow[Column::SoundPath], subSound, false);
auto subColor = ColorProvider::instance().color(ColorType::Subscription);
setColorItem(subRow[Column::Color], *subColor);
setColorItem(subRow[Column::Color], *subColor, false);
this->insertCustomRow(subRow, 2);
}

View file

@ -22,17 +22,23 @@ static void setStringItem(QStandardItem *item, const QString &value,
(editable ? (Qt::ItemIsEditable) : 0)));
}
static void setFilePathItem(QStandardItem *item, const QUrl &value)
static void setFilePathItem(QStandardItem *item, const QUrl &value,
bool selectable = true)
{
item->setData(value, Qt::UserRole);
item->setData(value.fileName(), Qt::DisplayRole);
item->setFlags(Qt::ItemFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable));
item->setFlags(
Qt::ItemFlags(Qt::ItemIsEnabled |
(selectable ? Qt::ItemIsSelectable : Qt::NoItemFlags)));
}
static void setColorItem(QStandardItem *item, const QColor &value)
static void setColorItem(QStandardItem *item, const QColor &value,
bool selectable = true)
{
item->setData(value, Qt::DecorationRole);
item->setFlags(Qt::ItemFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable));
item->setFlags(
Qt::ItemFlags(Qt::ItemIsEnabled |
(selectable ? Qt::ItemIsSelectable : Qt::NoItemFlags)));
}
static QStandardItem *emptyItem()