diff --git a/src/ExtendedTableWidget.cpp b/src/ExtendedTableWidget.cpp index fd0cfe58..a50067ff 100644 --- a/src/ExtendedTableWidget.cpp +++ b/src/ExtendedTableWidget.cpp @@ -88,6 +88,8 @@ void ExtendedTableWidget::copy() SqliteTableModel* m = qobject_cast(model()); + m_buffer.clear(); + // If a single cell is selected, copy it to clipboard if (indices.size() == 1) { QImage img; @@ -97,13 +99,23 @@ void ExtendedTableWidget::copy() qApp->clipboard()->setImage(img); return; } else { - qApp->clipboard()->setText(data.toString()); + QString text = data.toString(); + if (text.isEmpty()) { + // NULL and empty single-cells are handled via inner buffer + qApp->clipboard()->clear(); + QByteArrayList lst; + lst << data.toByteArray(); + m_buffer.push_back(lst); + return; + } + + if (text.contains('\n')) + text = QString("\"%1\"").arg(text); + qApp->clipboard()->setText(text); return; } } - m_buffer.clear(); - // If any of the cells contain binary data - we use inner buffer bool containsBinary = false; foreach (const QModelIndex& index, indices)