From 256ae36a132e126c1a9f3b0925317477bffc840a Mon Sep 17 00:00:00 2001 From: mgrojo Date: Fri, 14 Dec 2018 00:29:23 +0100 Subject: [PATCH] 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 --- src/DbStructureModel.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/DbStructureModel.cpp b/src/DbStructureModel.cpp index 7b526f6a..06f72ee1 100644 --- a/src/DbStructureModel.cpp +++ b/src/DbStructureModel.cpp @@ -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: