pgLab/pglab/BaseTableModel.cpp

32 lines
706 B
C++

#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) {
v = GetDefaultAlignmentForType(oid);
}
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;
}