From 82b26444a456d4d5ddf5f483b7766977659bee35 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 7 May 2019 17:49:32 +0200 Subject: Change QTextMarkdownWriter to pass by const pointer and QAIM - QObjects are always passed by pointer not by reference, by convention - writeTable() takes QAIM rather than QATM to make testing via QStandardItemModel possible in the future Change-Id: I5bc6b8cd9709da4fb5d57d98fa22e0cb34360944 Reviewed-by: Gatis Paeglis --- src/gui/text/qtextmarkdownwriter.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/gui/text/qtextmarkdownwriter.cpp') diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index 0634d324b1..a445ee7e83 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -63,26 +63,26 @@ QTextMarkdownWriter::QTextMarkdownWriter(QTextStream &stream, QTextDocument::Mar { } -bool QTextMarkdownWriter::writeAll(const QTextDocument &document) +bool QTextMarkdownWriter::writeAll(const QTextDocument *document) { - writeFrame(document.rootFrame()); + writeFrame(document->rootFrame()); return true; } -void QTextMarkdownWriter::writeTable(const QAbstractTableModel &table) +void QTextMarkdownWriter::writeTable(const QAbstractItemModel *table) { - QVector tableColumnWidths(table.columnCount()); - for (int col = 0; col < table.columnCount(); ++col) { - tableColumnWidths[col] = table.headerData(col, Qt::Horizontal).toString().length(); - for (int row = 0; row < table.rowCount(); ++row) { + QVector tableColumnWidths(table->columnCount()); + for (int col = 0; col < table->columnCount(); ++col) { + tableColumnWidths[col] = table->headerData(col, Qt::Horizontal).toString().length(); + for (int row = 0; row < table->rowCount(); ++row) { tableColumnWidths[col] = qMax(tableColumnWidths[col], - table.data(table.index(row, col)).toString().length()); + table->data(table->index(row, col)).toString().length()); } } // write the header and separator - for (int col = 0; col < table.columnCount(); ++col) { - QString s = table.headerData(col, Qt::Horizontal).toString(); + for (int col = 0; col < table->columnCount(); ++col) { + QString s = table->headerData(col, Qt::Horizontal).toString(); m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); } m_stream << "|" << Qt::endl; @@ -91,9 +91,9 @@ void QTextMarkdownWriter::writeTable(const QAbstractTableModel &table) m_stream << '|'<< Qt::endl; // write the body - for (int row = 0; row < table.rowCount(); ++row) { - for (int col = 0; col < table.columnCount(); ++col) { - QString s = table.data(table.index(row, col)).toString(); + for (int row = 0; row < table->rowCount(); ++row) { + for (int col = 0; col < table->columnCount(); ++col) { + QString s = table->data(table->index(row, col)).toString(); m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); } m_stream << '|'<< Qt::endl; -- cgit v1.2.3