From a272cd36307f9cd31b6dbbbe64beb84540ce2280 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 30 Jul 2018 21:13:54 +0200 Subject: [PATCH] Fixed #144 (description of salt packages isn't shown) Plus: the text color of the description now uses the palette and the color contrast better when the item is selected. --- Changelog | 3 +++ src/lay/lay/laySaltModel.cc | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index b6f4153e2..b69a0651f 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,9 @@ Issue with RBA::QHostAddress (ambiguous overload) on Qt5 * Bugfix: https://github.com/klayoutmatthias/klayout/issues/142 Issue with RBA::RecursiveShapeIterator#region= +* Bugfix: https://github.com/klayoutmatthias/klayout/issues/144 + The Salt package descriptions are not shown with Motif + style * Bugfix: https://github.com/klayoutmatthias/klayout/issues/148 Wrong font is used * Bugfix: 8 bit indexed GIF images can be used for package icons now diff --git a/src/lay/lay/laySaltModel.cc b/src/lay/lay/laySaltModel.cc index db9139800..3cce6c3a9 100644 --- a/src/lay/lay/laySaltModel.cc +++ b/src/lay/lay/laySaltModel.cc @@ -47,8 +47,15 @@ SaltItemDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, { QStyleOptionViewItemV4 optionV4 = option; initStyleOption (&optionV4, index); + // let the text take all the available space (fixes #144) + optionV4.showDecorationSelected = true; bool is_enabled = (optionV4.state & QStyle::State_Enabled); + if ((index.flags () & 0x10000) != 0) { + // the item wants to be drawn "disabled" + is_enabled = false; + } + optionV4.state |= QStyle::State_Enabled; QStyle *style = optionV4.widget ? optionV4.widget->style () : QApplication::style (); @@ -121,6 +128,11 @@ SaltModel::flags (const QModelIndex &index) const f &= ~Qt::ItemIsEnabled; } + if (g && (! is_enabled (g->name ()) || g->is_hidden ())) { + // We use a custom flag to indicate "disabled" display without actually disabling the item + f |= Qt::ItemFlags (0x10000); + } + return f; } @@ -134,15 +146,9 @@ SaltModel::data (const QModelIndex &index, int role) const return QVariant (tr ("

There are no items to show in this list

%1

").arg (m_empty_explanation)); } - bool en = is_enabled (g->name ()); bool hidden = g->is_hidden (); std::string text = ""; - if (! en || hidden) { - text += ""; - } else { - text += ""; - } if (hidden) { text += ""; } @@ -179,7 +185,6 @@ SaltModel::data (const QModelIndex &index, int role) const text += tl::to_string (tr ("This package is an auxiliary package for use with other packages.")); text += "

"; } - text += "
"; text += ""; return tl::to_qstring (text);