Usability improvements for Extended Table Widget and SQL

results pane

Copy for multi-line text data surrounds the text with the
<pre> tag in the HTML version for avoiding line white-space
adjustments in the pasted text. See #1058

Do not use binary data in the "Use as Filter" option.

Indicate the existence of an error in the background of the
SQL results frame. The error-indicators is reused for
disabling this functionality.

When nothing is shown, a placeholder text hints the
objective of the results pane.

The preference label for the font size of this pane is
modified for consistency (SQL Log is another widget).
This commit is contained in:
mgrojo
2017-11-19 00:57:42 +01:00
parent e60e9ffc75
commit 87e1b9bc7c
6 changed files with 36 additions and 9 deletions

View File

@@ -260,10 +260,14 @@ void ExtendedTableWidget::copy(const bool withHeaders)
QVariant data = index.data(Qt::EditRole);
// Table cell data
htmlResult.append(data.toString().toHtmlEscaped());
// non-NULL data is enquoted, whilst NULL isn't
QString text = data.toString();
if (text.contains('\n'))
htmlResult.append("<pre>" + data.toString().toHtmlEscaped() + "</pre>");
else
htmlResult.append(data.toString().toHtmlEscaped());
// non-NULL data is enquoted in plain text format, whilst NULL isn't
if (!data.isNull()) {
QString text = data.toString();
text.replace("\"", "\"\"");
result.append(QString("\"%1\"").arg(text));
}
@@ -409,9 +413,10 @@ void ExtendedTableWidget::paste()
void ExtendedTableWidget::useAsFilter()
{
QModelIndex index = selectionModel()->currentIndex();
SqliteTableModel* m = qobject_cast<SqliteTableModel*>(model());
// Abort if there's nothing to filter
if (!index.isValid() || !selectionModel()->hasSelection())
if (!index.isValid() || !selectionModel()->hasSelection() || m->isBinary(index))
return;
QVariant data = model()->data(index, Qt::EditRole);