From caa6947ff984bce1c82f8b7ecb1b4428230b4555 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 12 Jul 2016 03:06:58 +0200 Subject: [PATCH] refs #707, added line number to HTML output --- src/blackgui/components/modelmatcherlogcomponent.cpp | 2 +- src/blackmisc/propertyindex.h | 2 +- src/blackmisc/statusmessagelist.cpp | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/blackgui/components/modelmatcherlogcomponent.cpp b/src/blackgui/components/modelmatcherlogcomponent.cpp index 10961a995..6abb25af2 100644 --- a/src/blackgui/components/modelmatcherlogcomponent.cpp +++ b/src/blackgui/components/modelmatcherlogcomponent.cpp @@ -84,7 +84,7 @@ namespace BlackGui void CModelMatcherLogComponent::ps_callsignEntered() { if (!sGui || !ui->cb_LogReverseLookup->isChecked()) { return; } - static const CPropertyIndexList properties({ CStatusMessage::IndexMessage }); + static const CPropertyIndexList properties({ CPropertyIndex::GlobalIndexLineNumber, CStatusMessage::IndexMessage }); const CCallsign cs(ui->le_Callsign->text().trimmed().toUpper()); const CStatusMessageList msgs = sGui->getIContextNetwork()->getReverseLookupMessages(cs); const QString html = msgs.toHtml(properties); diff --git a/src/blackmisc/propertyindex.h b/src/blackmisc/propertyindex.h index 414d74102..0cba03021 100644 --- a/src/blackmisc/propertyindex.h +++ b/src/blackmisc/propertyindex.h @@ -138,7 +138,7 @@ namespace BlackMisc GlobalIndexCSettingsDockWidget = 14200, GlobalIndexCSettingsNavigator = 14300, GlobalIndexCSettingsReaders = 14400, - GlobalIndexAbuseMode = 20000 // property index abused as map key or otherwise, to be removed if no longer needed + GlobalIndexLineNumber = 20000, //!< pseudo index for line numbers }; //! Default constructor. diff --git a/src/blackmisc/statusmessagelist.cpp b/src/blackmisc/statusmessagelist.cpp index ad84c7cc0..7eb765647 100644 --- a/src/blackmisc/statusmessagelist.cpp +++ b/src/blackmisc/statusmessagelist.cpp @@ -169,10 +169,19 @@ namespace BlackMisc { if (indexes.isEmpty() || this->isEmpty()) { return ""; } QString html; + int line = 1; + const bool withLineNumbers = indexes.contains(CPropertyIndex::GlobalIndexLineNumber); + CPropertyIndexList usedIndexes(indexes); + if (withLineNumbers) { usedIndexes.remove(CPropertyIndex::GlobalIndexLineNumber); } for (const CStatusMessage &statusMessage : *this) { QString rowHtml; - for (const CPropertyIndex index : indexes) + if (withLineNumbers) + { + rowHtml += "" + QString::number(line++) + ""; + } + + for (const CPropertyIndex index : usedIndexes) { rowHtml += "" + statusMessage.propertyByIndex(index).toQString(true) + ""; }