2017-12-09 10:45:13 +01:00
|
|
|
|
#include "BaseTableModel.h"
|
|
|
|
|
|
#include "ResultTableModelUtil.h"
|
|
|
|
|
|
#include <QBrush>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace Pgsql;
|
|
|
|
|
|
|
|
|
|
|
|
QVariant BaseTableModel::data(const QModelIndex &index, int role) const
|
|
|
|
|
|
{
|
|
|
|
|
|
QVariant v;
|
|
|
|
|
|
Oid oid = getType(index.column());
|
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
|
|
|
|
|
v = getData(index);
|
|
|
|
|
|
if (oid == BOOLOID) {
|
|
|
|
|
|
v = FormatBoolForDisplay(v.toBool());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (role == Qt::TextAlignmentRole) {
|
2018-01-15 13:32:18 +01:00
|
|
|
|
v = (int)GetDefaultAlignmentForType(oid);
|
2017-12-09 10:45:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
else if (role == Qt::ForegroundRole) {
|
|
|
|
|
|
if (oid == BOOLOID) {
|
|
|
|
|
|
QVariant d = getData(index);
|
|
|
|
|
|
if (d.type() == QVariant::Bool) {
|
|
|
|
|
|
v = QBrush(GetDefaultBoolColor(d.toBool()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
v = QBrush(GetDefaultColorForType(oid));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return v;
|
|
|
|
|
|
}
|