Data Browser: use font style to indicate keys · sqlitebrowser/sqlitebrowser@b6c5024 (original) (raw)
`@@ -205,7 +205,7 @@ static QString toSuperScript(T number)
`
205
205
``
206
206
`QVariant SqliteTableModel::headerData(int section, Qt::Orientation orientation, int role) const
`
207
207
`{
`
208
``
`-
if (role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::DecorationRole)
`
``
208
`+
if (role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::FontRole)
`
209
209
`return QVariant();
`
210
210
``
211
211
`if (orientation == Qt::Horizontal)
`
`@@ -218,16 +218,22 @@ QVariant SqliteTableModel::headerData(int section, Qt::Orientation orientation,
`
218
218
`switch (role) {
`
219
219
`case Qt::EditRole:
`
220
220
`return QString::fromStdString(plainHeader);
`
221
``
`-
case Qt::DecorationRole: {
`
222
``
`-
bool is_key = false;
`
``
221
`+
case Qt::FontRole: {
`
``
222
`+
bool is_pk = false;
`
``
223
`+
bool is_fk = getForeignKeyClause(column-1).isSet();
`
``
224
+
223
225
`if (contains(m_query.rowIdColumns(), m_headers.at(column))) {
`
224
``
`-
is_key = true;
`
``
226
`+
is_pk = true;
`
225
227
` } else if (m_table_of_query) {
`
226
228
`auto field = sqlb::findField(m_table_of_query, m_headers.at(column));
`
227
229
`const auto pk = m_table_of_query->primaryKey();
`
228
``
`-
is_key = pk && contains(pk->columnList(), field->name());
`
``
230
`+
is_pk = pk && contains(pk->columnList(), field->name());
`
229
231
` }
`
230
``
`-
return is_key ? QImage(":/icons/field_key") : QVariant();
`
``
232
+
``
233
`+
QFont font;
`
``
234
`+
font.setUnderline(is_pk);
`
``
235
`+
font.setItalic(is_fk);
`
``
236
`+
return font;
`
231
237
` }
`
232
238
`default:
`
233
239
` QString sortIndicator;
`