Fix explain colors in dark mode
This commit is contained in:
parent
2e516c9284
commit
05e9b982cd
4 changed files with 32 additions and 9 deletions
|
|
@ -16,6 +16,7 @@ const int c_NumberOfColumns = 8;
|
||||||
QueryExplainModel::QueryExplainModel(QObject *parent, ExplainRoot::SPtr exp)
|
QueryExplainModel::QueryExplainModel(QObject *parent, ExplainRoot::SPtr exp)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
, explain(std::move(exp))
|
, explain(std::move(exp))
|
||||||
|
, theme(GetColorTheme())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QVariant QueryExplainModel::data(const QModelIndex &index, int role) const
|
QVariant QueryExplainModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
@ -67,35 +68,35 @@ if (role == Qt::DisplayRole) {
|
||||||
if (tt > 0.000000001f) {
|
if (tt > 0.000000001f) {
|
||||||
float f = t / tt;
|
float f = t / tt;
|
||||||
if (f > 0.9f) {
|
if (f > 0.9f) {
|
||||||
result = QColor(255, 192, 192);
|
result = theme.explainTime[0];
|
||||||
}
|
}
|
||||||
else if (f > 0.63f) {
|
else if (f > 0.63f) {
|
||||||
result = QColor(255, 224, 192);
|
result = theme.explainTime[1];
|
||||||
}
|
}
|
||||||
else if (f > 0.36f) {
|
else if (f > 0.36f) {
|
||||||
result = QColor(255, 255, 192);
|
result = theme.explainTime[2];
|
||||||
}
|
}
|
||||||
else if (f > 0.09f) {
|
else if (f > 0.09f) {
|
||||||
result = QColor(255, 255, 224);
|
result = theme.explainTime[3];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = QColor(Qt::white);
|
result = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (col == c_ColumnEstErr) {
|
if (col == c_ColumnEstErr) {
|
||||||
float e = std::fabs(item->estimateError());
|
float e = std::fabs(item->estimateError());
|
||||||
if (e > 1000.0f) {
|
if (e > 1000.0f) {
|
||||||
result = QColor(255, 192, 192);
|
result = theme.explainEstError[0];
|
||||||
}
|
}
|
||||||
else if (e > 100.0f) {
|
else if (e > 100.0f) {
|
||||||
result = QColor(255, 224, 192);
|
result = theme.explainEstError[1];
|
||||||
}
|
}
|
||||||
else if (e > 10.0f) {
|
else if (e > 10.0f) {
|
||||||
result = QColor(255, 255, 192);
|
result = theme.explainEstError[2];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = QColor(Qt::white);
|
result = {}; //QColor(Qt::white);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <util/Colors.h>
|
||||||
#include "ExplainTreeModelItem.h"
|
#include "ExplainTreeModelItem.h"
|
||||||
|
|
||||||
/** \brief Model class for displaying the explain of a query in a tree like format.
|
/** \brief Model class for displaying the explain of a query in a tree like format.
|
||||||
|
|
@ -30,4 +31,5 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExplainRoot::SPtr explain;
|
ExplainRoot::SPtr explain;
|
||||||
|
const ColorTheme &theme;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,15 @@ ColorTheme GetLightMode()
|
||||||
t.dateTimeTypeColor = Qt::darkMagenta;
|
t.dateTimeTypeColor = Qt::darkMagenta;
|
||||||
t.stringTypeColor = Qt::darkYellow;
|
t.stringTypeColor = Qt::darkYellow;
|
||||||
|
|
||||||
|
t.explainTime[0] = QColor(255, 192, 192);
|
||||||
|
t.explainTime[1] = QColor(255, 224, 192);
|
||||||
|
t.explainTime[2] = QColor(255, 255, 192);
|
||||||
|
t.explainTime[3] = QColor(255, 255, 224);
|
||||||
|
|
||||||
|
t.explainEstError[0] = QColor(255, 192, 192);
|
||||||
|
t.explainEstError[1] = QColor(255, 224, 192);
|
||||||
|
t.explainEstError[2] = QColor(255, 255, 192);
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,6 +100,15 @@ ColorTheme GetDarkMode()
|
||||||
t.dateTimeTypeColor = QColor(Qt::magenta);
|
t.dateTimeTypeColor = QColor(Qt::magenta);
|
||||||
t.stringTypeColor = QColor(Qt::yellow);
|
t.stringTypeColor = QColor(Qt::yellow);
|
||||||
|
|
||||||
|
t.explainTime[0] = QColor(120, 20, 20);
|
||||||
|
t.explainTime[1] = QColor(110, 40, 20);
|
||||||
|
t.explainTime[2] = QColor(90, 50, 20);
|
||||||
|
t.explainTime[3] = QColor(70, 70, 20);
|
||||||
|
|
||||||
|
t.explainEstError[0] = QColor(120, 20, 20);
|
||||||
|
t.explainEstError[1] = QColor(90, 50, 20);
|
||||||
|
t.explainEstError[2] = QColor(70, 70, 20);
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ struct ColorTheme
|
||||||
|
|
||||||
QColor GetColorForType(Oid oid) const;
|
QColor GetColorForType(Oid oid) const;
|
||||||
|
|
||||||
|
QColor explainTime[4];
|
||||||
|
QColor explainEstError[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
const ColorTheme& GetColorTheme();
|
const ColorTheme& GetColorTheme();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue