commit 7810224b93472261efe9cd7cfdb94c73d2541f50
parent dfaa6a4df6b64333f2b65beb1a533b8e9794b0af
Author: cfillion <cfillion@users.noreply.github.com>
Date: Fri, 4 Mar 2016 21:35:41 -0800
use the same format in the report dialog as in the package history
Diffstat:
3 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/src/about.cpp b/src/about.cpp
@@ -304,21 +304,6 @@ void History::fillReport()
if(stream().tellp())
stream() << NL;
- stream() << 'v' << ver->name();
-
- if(!ver->author().empty())
- stream() << " by " << ver->author();
-
- const string &date = ver->formattedDate();
- if(!date.empty())
- stream() << " – " << date;
-
- stream() << NL;
-
- const string &changelog = ver->changelog();
- if(changelog.empty())
- printChangelog("No changelog");
- else
- printChangelog(changelog);
+ printVersion(ver);
}
}
diff --git a/src/report.cpp b/src/report.cpp
@@ -53,12 +53,29 @@ void ReportDialog::printHeader(const char *title)
m_stream << SEP << ' ' << title << ": " << SEP << NL << NL;
}
-void ReportDialog::printChangelog(const string &changelog)
+void ReportDialog::printVersion(const Version *ver)
{
- istringstream input(changelog);
+ stream() << 'v' << ver->name();
+
+ if(!ver->author().empty())
+ stream() << " by " << ver->author();
+
+ const string &date = ver->formattedDate();
+ if(!date.empty())
+ stream() << " – " << date;
+
+ stream() << NL;
+
+ const string &changelog = ver->changelog();
+ printIndented(changelog.empty() ? "No changelog" : changelog);
+}
+
+void ReportDialog::printIndented(const string &text)
+{
+ istringstream stream(text);
string line;
- while(getline(input, line, '\n'))
+ while(getline(stream, line, '\n'))
m_stream << "\x20\x20" << line.substr(line.find_first_not_of('\x20')) << NL;
}
@@ -122,15 +139,16 @@ void Report::printUpdates()
const auto &queryRes = entry.second;
const VersionSet &versions = pkg->versions();
+ stream() << pkg->fullName() << ':' << NL;
+
for(const Version *ver : versions | boost::adaptors::reversed) {
if(ver->code() <= queryRes.entry.version)
break;
- stream() << ver->fullName() << NL;
-
- if(!ver->changelog().empty())
- printChangelog(ver->changelog());
+ printVersion(ver);
}
+
+ stream() << NL;
}
}
@@ -138,8 +156,11 @@ void Report::printErrors()
{
printHeader("Errors");
- for(const Transaction::Error &err : m_transaction->errors())
- stream() << err.title << ": " << err.message << NL;
+ for(const Transaction::Error &err : m_transaction->errors()) {
+ stream() << err.title << ':' << NL;
+ printIndented(err.message);
+ stream() << "\n";
+ }
}
void Report::printRemovals()
diff --git a/src/report.hpp b/src/report.hpp
@@ -38,7 +38,8 @@ protected:
std::ostringstream &stream() { return m_stream; }
void printHeader(const char *);
- void printChangelog(const std::string &);
+ void printVersion(const Version *);
+ void printIndented(const std::string &);
private:
std::ostringstream m_stream;