summaryrefslogtreecommitdiff
path: root/widgets/DecodeHighlightingListView.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
commit059831534c7e884f0a607ed86b582fd00d821731 (patch)
tree76bcb67a78f8aa2654fd34c2ad801a62136b0170 /widgets/DecodeHighlightingListView.cpp
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'widgets/DecodeHighlightingListView.cpp')
-rw-r--r--widgets/DecodeHighlightingListView.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/widgets/DecodeHighlightingListView.cpp b/widgets/DecodeHighlightingListView.cpp
index cfb14fc5..2997017a 100644
--- a/widgets/DecodeHighlightingListView.cpp
+++ b/widgets/DecodeHighlightingListView.cpp
@@ -15,6 +15,10 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
addAction (fg_colour_action);
connect (fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
auto const& index = currentIndex ();
+ if (!model () || !index.isValid ())
+ {
+ return;
+ }
auto colour = QColorDialog::getColor (model ()->data (index, Qt::ForegroundRole).value<QBrush> ().color ()
, this
, tr ("Choose %1 Foreground Color")
@@ -28,13 +32,21 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
auto * unset_fg_colour_action = new QAction {tr ("&Unset foreground color"), this};
addAction (unset_fg_colour_action);
connect (unset_fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
- model ()->setData (currentIndex (), QBrush {}, Qt::ForegroundRole);
+ auto const& index = currentIndex ();
+ if (model () && index.isValid ())
+ {
+ model ()->setData (index, QBrush {}, Qt::ForegroundRole);
+ }
});
auto * bg_colour_action = new QAction {tr ("&Background color ..."), this};
addAction (bg_colour_action);
connect (bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
auto const& index = currentIndex ();
+ if (!model () || !index.isValid ())
+ {
+ return;
+ }
auto colour = QColorDialog::getColor (model ()->data (index, Qt::BackgroundRole).value<QBrush> ().color ()
, this
, tr ("Choose %1 Background Color")
@@ -48,13 +60,21 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
auto * unset_bg_colour_action = new QAction {tr ("U&nset background color"), this};
addAction (unset_bg_colour_action);
connect (unset_bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
- model ()->setData (currentIndex (), QBrush {}, Qt::BackgroundRole);
+ auto const& index = currentIndex ();
+ if (model () && index.isValid ())
+ {
+ model ()->setData (index, QBrush {}, Qt::BackgroundRole);
+ }
});
auto * defaults_action = new QAction {tr ("&Reset this item to defaults"), this};
addAction (defaults_action);
connect (defaults_action, &QAction::triggered, [this] (bool /*checked*/) {
auto const& index = currentIndex ();
+ if (!model () || !index.isValid ())
+ {
+ return;
+ }
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::EnabledDefaultRole).toBool () ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::ForegroundDefaultRole), Qt::ForegroundRole);
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::BackgroundDefaultRole), Qt::BackgroundRole);