pgLab/pglab/ResultTableModelUtil.cpp

93 lines
1.8 KiB
C++
Raw Normal View History

#include "ResultTableModelUtil.h"
#include <QTableView>
#include <QHeaderView>
using namespace Pgsql;
int GetDefaultAlignmentForType(Oid o)
{
int r;
switch (o) {
case INT2OID:
case INT4OID:
case INT8OID:
case FLOAT4OID:
case FLOAT8OID:
case NUMERICOID:
case OIDOID:
r = GetDefaultNumberAlignment();
break;
case BOOLOID:
r = GetDefaultBoolAlignment(); // Qt::AlignCenter;
break;
default:
r = GetDefaultAlignment();
}
return r;
}
QColor GetDefaultColorForType(Oid o)
{
QColor c;
switch (o) {
case INT2OID:
case INT4OID:
case INT8OID:
c = GetDefaultIntegerColor();
break;
case FLOAT4OID:
case FLOAT8OID:
c = GetDefaultFloatColor();
break;
case NUMERICOID:
c = GetDefaultNumericColor();
break;
case OIDOID:
case BOOLOID:
default:
c = Qt::black;
}
return c;
}
QString FormatBoolForDisplay(bool v)
{
return v ? "TRUE" : "FALSE";
}
//<widget class="QTableView" name="ResultView">
// <property name="font">
// <font>
// <family>Source Sans Pro</family>
// <pointsize>10</pointsize>
// </font>
// </property>
// <property name="editTriggers">
// <set>QAbstractItemView::NoEditTriggers</set>
// </property>
// <property name="verticalScrollMode">
// <enum>QAbstractItemView::ScrollPerPixel</enum>
// </property>
// <property name="horizontalScrollMode">
// <enum>QAbstractItemView::ScrollPerPixel</enum>
// </property>
// <property name="wordWrap">
// <bool>false</bool>
// </property>
// <attribute name="verticalHeaderDefaultSectionSize">
// <number>20</number>
// </attribute>
// <attribute name="verticalHeaderMinimumSectionSize">
// <number>16</number>
// </attribute>
//</widget>
void SetTableViewDefault(QTableView *tv)
{
tv->setAlternatingRowColors(true);
tv->verticalHeader()->setMinimumSectionSize(16);
tv->verticalHeader()->setDefaultSectionSize(20);
}