summaryrefslogtreecommitdiff
path: root/src/designer/src/components/propertyeditor/paletteeditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/designer/src/components/propertyeditor/paletteeditor.cpp')
-rw-r--r--src/designer/src/components/propertyeditor/paletteeditor.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/designer/src/components/propertyeditor/paletteeditor.cpp b/src/designer/src/components/propertyeditor/paletteeditor.cpp
index ddf49245e..c15b3cf01 100644
--- a/src/designer/src/components/propertyeditor/paletteeditor.cpp
+++ b/src/designer/src/components/propertyeditor/paletteeditor.cpp
@@ -3,6 +3,7 @@
#include "paletteeditor.h"
+#include <qdesigner_utils_p.h>
#include <iconloader_p.h>
#include <qtcolorbutton.h>
@@ -357,6 +358,11 @@ void PaletteEditor::load()
}
//////////////////////
+// Column 0: Role name and reset button. Uses a boolean value indicating
+// whether the role is modified for the edit role.
+// Column 1: Color group Active
+// Column 2: Color group Inactive (visibility depending on m_compute/detail radio group)
+// Column 3: Color group Disabled
PaletteModel::PaletteModel(QObject *parent) :
QAbstractTableModel(parent)
@@ -388,6 +394,12 @@ QBrush PaletteModel::brushAt(const QModelIndex &index) const
return m_palette.brush(columnToGroup(index.column()), roleAt(index.row()));
}
+// Palette resolve mask with all group bits for a row/role
+quint64 PaletteModel::rowMask(const QModelIndex &index) const
+{
+ return paletteResolveMask(roleAt(index.row()));
+}
+
QVariant PaletteModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
@@ -397,15 +409,11 @@ QVariant PaletteModel::data(const QModelIndex &index, int role) const
if (index.column() < 0 || index.column() >= 4)
return QVariant();
- if (index.column() == 0) {
+ if (index.column() == 0) { // Role name/bold print if changed
if (role == Qt::DisplayRole)
return m_roleEntries.at(index.row()).name;
- if (role == Qt::EditRole) {
- const uint mask = m_palette.resolveMask();
- if (mask & (1 << int(roleAt(index.row()))))
- return true;
- return false;
- }
+ if (role == Qt::EditRole)
+ return (rowMask(index) & m_palette.resolveMask()) != 0;
return QVariant();
}
if (role == Qt::ToolTipRole)
@@ -466,7 +474,7 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int
if (index.column() == 0 && role == Qt::EditRole) {
auto mask = m_palette.resolveMask();
const bool isMask = qvariant_cast<bool>(value);
- const auto bitMask = 1ull << quint64(colorRole);
+ const auto bitMask = rowMask(index);
if (isMask) {
mask |= bitMask;
} else {