Fix, display and rendering of booleans by QueryResultModel.
This commit is contained in:
parent
ad9ed1b698
commit
c6dbe72170
1 changed files with 12 additions and 8 deletions
|
|
@ -4,6 +4,8 @@
|
|||
#include <QBrush>
|
||||
#include <QColor>
|
||||
|
||||
using namespace Pgsql;
|
||||
|
||||
QueryResultModel::QueryResultModel(QObject *parent, std::shared_ptr<Pgsql::Result> r)
|
||||
: BaseTableModel(parent)
|
||||
, result(std::move(r))
|
||||
|
|
@ -36,18 +38,20 @@ QVariant QueryResultModel::getData(const QModelIndex &index) const
|
|||
r = "null";
|
||||
}
|
||||
else {
|
||||
// Oid o = result->type(col);
|
||||
QString s(result->val(col, rij));
|
||||
// switch (o) {
|
||||
// case BOOLOID:
|
||||
// s = (s == "t") ? "TRUE" : "FALSE";
|
||||
// // intentional fall through
|
||||
// default:
|
||||
Oid o = result->type(col);
|
||||
auto value = result->get(col, rij);
|
||||
switch (o) {
|
||||
case BOOLOID:
|
||||
r = bool(value); //s = (s == "t") ? "TRUE" : "FALSE";
|
||||
break;
|
||||
default: {
|
||||
QString s = value;
|
||||
if (s.length() > 256) {
|
||||
s.truncate(256);
|
||||
}
|
||||
r = s;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue