QueryResultModel no longer truncates long strings to improve display performance.

Optimization of display is now done by PgLabItemDelegate. This also makes it easier in future commit
to enabled showing complete string and correctly exporting the data.
This commit is contained in:
eelke 2019-02-07 16:48:30 +01:00
parent be2ffd7ef9
commit db735363f7
2 changed files with 9 additions and 19 deletions

View file

@ -99,9 +99,14 @@ void PgLabItemDelegate::initStyleOption(QStyleOptionViewItem *option,
option->palette.setBrush(QPalette::Text, QBrush(forground_color));
option->features |= QStyleOptionViewItem::HasDisplay;
option->text = oid == Pgsql::bool_oid
? FormatBoolForDisplay(value.toBool())
: displayText(value, option->locale);
if (oid == Pgsql::bool_oid)
option->text = FormatBoolForDisplay(value.toBool());
else {
auto str = value.toString();
auto s = str.leftRef(100);
auto f = s.indexOf('\n');
option->text = ((f > 0) ? s.left(f) : s).toString();
}
}
else {
option->palette.setBrush(QPalette::Text, QBrush(GetDefaultNullColor()));

View file

@ -28,19 +28,6 @@ int QueryResultModel::columnCount(const QModelIndex &) const
return r;
}
//Oid QueryResultModel::getType(int column) const
//{
// return result->type(column);
//}
//QVariant QueryResultModel::getData(const QModelIndex &index) const
//{
// QVariant r;
// int rij = index.row();
// int col = index.column();
// return r;
//}
QVariant QueryResultModel::data(const QModelIndex &index, int role) const
{
// static const QString null_str("null");
@ -61,9 +48,6 @@ QVariant QueryResultModel::data(const QModelIndex &index, int role) const
}
else {
QString s = value;
if (s.length() > 256) {
s.truncate(256);
}
v = s;
}
}
@ -72,6 +56,7 @@ QVariant QueryResultModel::data(const QModelIndex &index, int role) const
v = oid;
}
return v;
}