summaryrefslogtreecommitdiff
path: root/widgets/DecodeHighlightingListView.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
commit69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch)
treeebc98370a697a9bbd6b973a14fa5113c475c6db7 /widgets/DecodeHighlightingListView.cpp
parent3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff)
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg' with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
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);