Do not show more than 512 characters in DB Structure tooltips

Truncate the SQL create sentence when it is longer than 512 characters
and pad with "...".

See issue #1659
This commit is contained in:
mgrojo
2018-12-14 00:29:23 +01:00
parent 1af7b031ea
commit 256ae36a13

View File

@@ -51,8 +51,16 @@ QVariant DbStructureModel::data(const QModelIndex& index, int role) const
else
return Settings::getValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
case Qt::EditRole:
case Qt::ToolTipRole: // Don't modify the text when it's supposed to be shown in a tooltip
return item->text(index.column());
case Qt::ToolTipRole: {
// Show the original text but limited, when it's supposed to be shown in a tooltip
QString text = item->text(index.column());
if (text.length() > 512) {
text.truncate(509);
text.append("...");
}
return text;
}
case Qt::DecorationRole:
return item->icon(index.column());
default: