From 70ee786102c8436c7f8f9e8a5d2ea71035d8d572 Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Sun, 24 Nov 2019 22:19:23 -0500
Subject: changed loot report to webengine with markdown support
---
src/resources/markdown.html | 299 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 299 insertions(+)
create mode 100644 src/resources/markdown.html
(limited to 'src/resources')
diff --git a/src/resources/markdown.html b/src/resources/markdown.html
new file mode 100644
index 00000000..a09b2209
--- /dev/null
+++ b/src/resources/markdown.html
@@ -0,0 +1,299 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
cgit v1.3.1
From 64304a6368cf8357bb04d1c0057aec637ebb479a Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Sun, 24 Nov 2019 23:23:15 -0500
Subject: tweaked css, finished markdown report copy markdown.html to
resources/
---
src/CMakeLists.txt | 4 +-
src/loot.cpp | 139 ++++++++++++
src/loot.h | 13 +-
src/lootdialog.cpp | 44 +---
src/resources/markdown.html | 528 ++++++++++++++++++++++----------------------
5 files changed, 424 insertions(+), 304 deletions(-)
(limited to 'src/resources')
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index db3bda73..5a510806 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -676,4 +676,6 @@ INSTALL(
)
# qdds.dll needs installing manually as Qt no longer ships with it by default.
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../qdds.dll DESTINATION bin/dlls/imageformats)
\ No newline at end of file
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../qdds.dll DESTINATION bin/dlls/imageformats)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/markdown.html DESTINATION bin/resources)
diff --git a/src/loot.cpp b/src/loot.cpp
index 5d75eeaa..2faf9c2e 100644
--- a/src/loot.cpp
+++ b/src/loot.cpp
@@ -34,6 +34,99 @@ log::Levels levelFromLoot(lootcli::LogLevels level)
}
+QString Loot::Report::toMarkdown() const
+{
+ QString s;
+
+ if (!messages.empty()) {
+ s += "### " + QObject::tr("General messages") + "\n";
+
+ for (auto&& m : messages) {
+ s += " - " + m.toMarkdown() + "\n";
+ }
+ }
+
+ if (!plugins.empty()) {
+ if (!s.isEmpty()) {
+ s += "\n";
+ }
+
+ s += "### " + QObject::tr("Plugins") + "\n";
+
+ for (auto&& p : plugins) {
+ const auto ps = p.toMarkdown();
+ if (!ps.isEmpty()) {
+ s += ps + "\n";
+ }
+ }
+ }
+
+ if (s.isEmpty()) {
+ s += "**" + QObject::tr("No messages.") + "**";
+ }
+
+ s += stats.toMarkdown();
+
+ return s;
+}
+
+QString Loot::Stats::toMarkdown() const
+{
+ return QString("`stats: %1s, lootcli %2, loot %3`")
+ .arg(QString::number(time / 1000.0, 'f', 2))
+ .arg(lootcliVersion)
+ .arg(lootVersion);
+}
+
+QString Loot::Plugin::toMarkdown() const
+{
+ QString s;
+
+ if (!incompatibilities.empty()) {
+ s += " - **" + QObject::tr("Incompatibilities") + ": ";
+
+ QString fs;
+ for (auto&& f : incompatibilities) {
+ if (!fs.isEmpty()) {
+ fs += ", ";
+ }
+
+ fs += f.displayName.isEmpty() ? f.name : f.displayName;
+ }
+
+ s += fs + "**\n";
+ }
+
+ if (!missingMasters.empty()) {
+ s += " - **" + QObject::tr("Missing masters") + ": ";
+
+ QString ms;
+ for (auto&& m : missingMasters) {
+ if (!ms.isEmpty()) {
+ ms += ", ";
+ }
+
+ ms += m;
+ }
+
+ s += ms + "**\n";
+ }
+
+ for (auto&& m : messages) {
+ s += " - " + m.toMarkdown() + "\n";
+ }
+
+ for (auto&& d : dirty) {
+ s += " - " + d.toMarkdown(false) + "\n";
+ }
+
+ if (!s.isEmpty()) {
+ s = "#### " + name + "\n" + s;
+ }
+
+ return s;
+}
+
QString Loot::Dirty::toString(bool isClean) const
{
if (isClean) {
@@ -50,6 +143,11 @@ QString Loot::Dirty::toString(bool isClean) const
return s;
}
+QString Loot::Dirty::toMarkdown(bool isClean) const
+{
+ return toString(isClean);
+}
+
QString Loot::Dirty::cleaningString() const
{
return QObject::tr("%1 found %2 ITM record(s), %3 deleted reference(s) and %4 deleted navmesh(es).")
@@ -59,6 +157,35 @@ QString Loot::Dirty::cleaningString() const
.arg(deletedNavmesh);
}
+QString Loot::Message::toMarkdown() const
+{
+ QString s;
+
+ switch (type)
+ {
+ case log::Error:
+ {
+ s += "**" + QObject::tr("Error") + "**: ";
+ break;
+ }
+
+ case log::Warning:
+ {
+ s += "**" + QObject::tr("Warning") + "**: ";
+ break;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
+
+ s += text;
+
+ return s;
+}
+
Loot::Loot()
: m_thread(nullptr), m_cancel(false), m_result(false)
@@ -348,6 +475,7 @@ Loot::Report Loot::createReport(const QJsonDocument& doc) const
r.messages = reportMessages(getOpt(object, "messages"));
r.plugins = reportPlugins(getOpt(object, "plugins"));
+ r.stats = reportStats(getWarn(object, "stats"));
return r;
}
@@ -407,6 +535,17 @@ Loot::Plugin Loot::reportPlugin(const QJsonObject& plugin) const
return p;
}
+Loot::Stats Loot::reportStats(const QJsonObject& stats) const
+{
+ Stats s;
+
+ s.time = getWarn(stats, "time");
+ s.lootcliVersion = getWarn(stats, "lootcliVersion");
+ s.lootVersion = getWarn(stats, "lootVersion");
+
+ return s;
+}
+
std::vector Loot::reportMessages(const QJsonArray& array) const
{
std::vector v;
diff --git a/src/loot.h b/src/loot.h
index 3a7c6aa9..30ef4b60 100644
--- a/src/loot.h
+++ b/src/loot.h
@@ -21,6 +21,8 @@ public:
{
MOBase::log::Levels type;
QString text;
+
+ QString toMarkdown() const;
};
struct File
@@ -39,6 +41,7 @@ public:
QString info;
QString toString(bool isClean) const;
+ QString toMarkdown(bool isClean) const;
QString cleaningString() const;
};
@@ -52,12 +55,17 @@ public:
bool loadsArchive = false;
bool isMaster = false;
bool isLightMaster = false;
+
+ QString toMarkdown() const;
};
struct Stats
{
qint64 time = 0;
- QString version;
+ QString lootcliVersion;
+ QString lootVersion;
+
+ QString toMarkdown() const;
};
struct Report
@@ -65,6 +73,8 @@ public:
std::vector messages;
std::vector plugins;
Stats stats;
+
+ QString toMarkdown() const;
};
@@ -107,6 +117,7 @@ private:
Message reportMessage(const QJsonObject& message) const;
std::vector reportPlugins(const QJsonArray& plugins) const;
Loot::Plugin reportPlugin(const QJsonObject& plugin) const;
+ Loot::Stats reportStats(const QJsonObject& stats) const;
std::vector reportMessages(const QJsonArray& array) const;
std::vector reportFiles(const QJsonArray& array) const;
diff --git a/src/lootdialog.cpp b/src/lootdialog.cpp
index 9c7b482e..c7cdfecd 100644
--- a/src/lootdialog.cpp
+++ b/src/lootdialog.cpp
@@ -226,49 +226,19 @@ void LootDialog::log(log::Levels lv, const QString& s)
void LootDialog::handleReport()
{
- const auto& report = m_loot.report();
+ const auto& lootReport = m_loot.report();
- if (!report.messages.empty()) {
+ if (!lootReport.messages.empty()) {
addLineOutput("");
}
- QString md;
-
- if (!report.messages.empty()) {
- for (auto&& m : report.messages) {
- log(m.type, m.text);
-
- md += " - ";
-
- switch (m.type)
- {
- case log::Error:
- {
- md += "**" + QObject::tr("Error") + "**: ";
- break;
- }
-
- case log::Warning:
- {
- md += "**" + QObject::tr("Warning") + "**: ";
- break;
- }
-
- default:
- {
- break;
- }
- }
-
- md += m.text + "\n";
- }
- } else {
- md += QObject::tr("**No messages.**");
+ for (auto&& m : lootReport.messages) {
+ log(m.type, m.text);
}
- m_report.setText(md);
-
- for (auto&& p : report.plugins) {
+ for (auto&& p : lootReport.plugins) {
m_core.pluginList()->addLootReport(p.name, p);
}
+
+ m_report.setText(lootReport.toMarkdown());
}
diff --git a/src/resources/markdown.html b/src/resources/markdown.html
index a09b2209..1ecaf1b9 100644
--- a/src/resources/markdown.html
+++ b/src/resources/markdown.html
@@ -2,278 +2,276 @@
-
-
-
--
cgit v1.3.1
From 48fcf9521f796bc3b6e536545877a9ea2e37360d Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Sun, 24 Nov 2019 23:47:59 -0500
Subject: removed max-width, larger dialog removed messages in output now that
there's a full report
---
src/lootdialog.cpp | 10 +---------
src/resources/markdown.html | 5 -----
2 files changed, 1 insertion(+), 14 deletions(-)
(limited to 'src/resources')
diff --git a/src/lootdialog.cpp b/src/lootdialog.cpp
index c7cdfecd..80664415 100644
--- a/src/lootdialog.cpp
+++ b/src/lootdialog.cpp
@@ -171,7 +171,7 @@ void LootDialog::createUI()
connect(ui->buttons, &QDialogButtonBox::clicked, [&](auto* b){ onButton(b); });
- resize(480, 275);
+ resize(650, 450);
}
void LootDialog::closeEvent(QCloseEvent* e)
@@ -228,14 +228,6 @@ void LootDialog::handleReport()
{
const auto& lootReport = m_loot.report();
- if (!lootReport.messages.empty()) {
- addLineOutput("");
- }
-
- for (auto&& m : lootReport.messages) {
- log(m.type, m.text);
- }
-
for (auto&& p : lootReport.plugins) {
m_core.pluginList()->addLootReport(p.name, p);
}
diff --git a/src/resources/markdown.html b/src/resources/markdown.html
index 1ecaf1b9..bd6d0f4d 100644
--- a/src/resources/markdown.html
+++ b/src/resources/markdown.html
@@ -18,7 +18,6 @@
font-family: Sans-serif;
color: #F1F1F1;
line-height: 1;
- max-width: 960px;
padding-left: 10px;
padding-top: 0px;
}
@@ -72,11 +71,9 @@
p, ul, ol {
font-size: 14px;
line-height: 24px;
- max-width: 540px;
}
pre {
padding: 0px 24px;
- max-width: 800px;
white-space: pre-wrap;
}
code {
@@ -93,7 +90,6 @@
border-left:.5em solid #eee;
padding: 0 2em;
margin-left:0;
- max-width: 476px;
}
blockquote cite {
font-size:14px;
@@ -106,7 +102,6 @@
blockquote p {
color: #666;
- max-width: 460px;
}
hr {
width: 540px;
--
cgit v1.3.1