diff options
| author | Christoph Berg <myon@debian.org> | 2026-04-07 19:04:48 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-04-07 19:04:48 +0200 |
| commit | 9b9d6a272fa4204d45956828da3f20b7be49f675 (patch) | |
| tree | b611f981259a12a2bfd4d7305843929447f1bb74 /widgets/DecodeHighlightingListView.cpp | |
| parent | 2f7ab3ab46786fa2a5931dae22a1b119b5cfdafa (diff) | |
| parent | f647d78463c1250ce9c99af664615fafccf5e959 (diff) | |
Update upstream source from tag 'upstream/3.0.0'
Update to upstream version '3.0.0'
with Debian dir 3b764e9a4be12ad8351230b538640dd98ddb9d05
Diffstat (limited to 'widgets/DecodeHighlightingListView.cpp')
| -rw-r--r--[-rwxr-xr-x] | widgets/DecodeHighlightingListView.cpp | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/widgets/DecodeHighlightingListView.cpp b/widgets/DecodeHighlightingListView.cpp index 4847f1e6..cfb14fc5 100755..100644 --- a/widgets/DecodeHighlightingListView.cpp +++ b/widgets/DecodeHighlightingListView.cpp @@ -1,74 +1,74 @@ -#include "DecodeHighlightingListView.hpp"
-
-#include <QAction>
-#include <QColorDialog>
-
-#include "models/DecodeHighlightingModel.hpp"
-#include "MessageBox.hpp"
-
-#include "moc_DecodeHighlightingListView.cpp"
-
-DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
- : QListView {parent}
-{
- auto * fg_colour_action = new QAction {tr ("&Foreground color ..."), this};
- addAction (fg_colour_action);
- connect (fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
- auto const& index = currentIndex ();
- auto colour = QColorDialog::getColor (model ()->data (index, Qt::ForegroundRole).value<QBrush> ().color ()
- , this
- , tr ("Choose %1 Foreground Color")
- .arg (model ()->data (index).toString ()));
- if (colour.isValid ())
- {
- model ()->setData (index, QBrush {colour}, Qt::ForegroundRole);
- }
- });
-
- 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 * 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 ();
- auto colour = QColorDialog::getColor (model ()->data (index, Qt::BackgroundRole).value<QBrush> ().color ()
- , this
- , tr ("Choose %1 Background Color")
- .arg (model ()->data (index).toString ()));
- if (colour.isValid ())
- {
- model ()->setData (index, QBrush {colour}, Qt::BackgroundRole);
- }
- });
-
- 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 * 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 ();
- 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);
- });
-}
-
-QSize DecodeHighlightingListView::sizeHint () const
-{
- auto item_height = sizeHintForRow (0);
- if (item_height >= 0)
- {
- // set the height hint to exactly the space required for all the
- // items
- return {width (), (model ()->rowCount () * (item_height + 2 * spacing ())) + 2 * frameWidth ()};
- }
- return QListView::sizeHint ();
-}
+#include "DecodeHighlightingListView.hpp" + +#include <QAction> +#include <QColorDialog> + +#include "models/DecodeHighlightingModel.hpp" +#include "MessageBox.hpp" + +#include "moc_DecodeHighlightingListView.cpp" + +DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent) + : QListView {parent} +{ + auto * fg_colour_action = new QAction {tr ("&Foreground color ..."), this}; + addAction (fg_colour_action); + connect (fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { + auto const& index = currentIndex (); + auto colour = QColorDialog::getColor (model ()->data (index, Qt::ForegroundRole).value<QBrush> ().color () + , this + , tr ("Choose %1 Foreground Color") + .arg (model ()->data (index).toString ())); + if (colour.isValid ()) + { + model ()->setData (index, QBrush {colour}, Qt::ForegroundRole); + } + }); + + 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 * 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 (); + auto colour = QColorDialog::getColor (model ()->data (index, Qt::BackgroundRole).value<QBrush> ().color () + , this + , tr ("Choose %1 Background Color") + .arg (model ()->data (index).toString ())); + if (colour.isValid ()) + { + model ()->setData (index, QBrush {colour}, Qt::BackgroundRole); + } + }); + + 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 * 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 (); + 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); + }); +} + +QSize DecodeHighlightingListView::sizeHint () const +{ + auto item_height = sizeHintForRow (0); + if (item_height >= 0) + { + // set the height hint to exactly the space required for all the + // items + return {width (), (model ()->rowCount () * (item_height + 2 * spacing ())) + 2 * frameWidth ()}; + } + return QListView::sizeHint (); +} |
