Skip to content

Commit 256ae36

Browse files
committed
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
1 parent 1af7b03 commit 256ae36

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/DbStructureModel.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,16 @@ QVariant DbStructureModel::data(const QModelIndex& index, int role) const
5151
else
5252
return Settings::getValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
5353
case Qt::EditRole:
54-
case Qt::ToolTipRole: // Don't modify the text when it's supposed to be shown in a tooltip
5554
return item->text(index.column());
55+
case Qt::ToolTipRole: {
56+
// Show the original text but limited, when it's supposed to be shown in a tooltip
57+
QString text = item->text(index.column());
58+
if (text.length() > 512) {
59+
text.truncate(509);
60+
text.append("...");
61+
}
62+
return text;
63+
}
5664
case Qt::DecorationRole:
5765
return item->icon(index.column());
5866
default:

0 commit comments

Comments
 (0)