Improvement to the ServerWindow

- sorting of Roles
- resizeColumns voor zowel databases als roles
- boolean columns now display check mark and cross
This commit is contained in:
eelke 2021-03-31 16:06:45 +02:00
parent a3ba4d7c98
commit 9c9e78c54b
8 changed files with 71 additions and 44 deletions

View file

@ -1,4 +1,5 @@
#include "BaseTableModel.h"
#include "CustomDataRole.h"
#include "ResultTableModelUtil.h"
#include <QBrush>
#include "Pgsql_oids.h"
@ -11,23 +12,17 @@ QVariant BaseTableModel::data(const QModelIndex &index, int role) const
Oid oid = getType(index.column());
if (role == Qt::DisplayRole) {
v = getData(index);
if (oid == bool_oid) {
v = FormatBoolForDisplay(v.toBool());
}
}
else if (role == Qt::TextAlignmentRole) {
v = (int)GetDefaultAlignmentForType(oid);
}
else if (role == Qt::ForegroundRole) {
if (oid == bool_oid) {
QVariant d = getData(index);
if (d.type() == QVariant::Bool) {
v = QBrush(GetDefaultBoolColor(d.toBool()));
}
}
else {
v = QBrush(GetDefaultColorForType(oid));
}
}
return v;
else if (role == CustomDataTypeRole) {
v = oid;
}
else if (role == CustomDataMeaningRole) {
v = getDataMeaning(index);
}
return v;
}
QVariant BaseTableModel::getDataMeaning(const QModelIndex &index) const
{
return static_cast<int>(DataMeaningNormal);
}