summaryrefslogtreecommitdiff
path: root/src/loot.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-11-23 22:35:08 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2019-11-23 22:35:08 -0500
commit3a085212c939ae8c5e6022a4c9bddfb7df95400f (patch)
tree9d327e5a539d1394505e9350867b577d4313575e /src/loot.cpp
parent5c9de17b6376ce94b1cdff4f4edbba798e9bfd08 (diff)
added loot report to the plugin list, not used yet
split PluginList::data() into individual functions disabled loot message processing, will use report instead
Diffstat (limited to 'src/loot.cpp')
-rw-r--r--src/loot.cpp131
1 files changed, 44 insertions, 87 deletions
diff --git a/src/loot.cpp b/src/loot.cpp
index 88ea8ce8..66e8a01d 100644
--- a/src/loot.cpp
+++ b/src/loot.cpp
@@ -58,10 +58,6 @@ public:
[&](auto&& lv, auto&& s){ log(lv, s); }, Qt::QueuedConnection);
QObject::connect(
- &m_loot, &Loot::information, this,
- [&](auto&& mod, auto&& i){ setInfo(mod, i); }, Qt::QueuedConnection);
-
- QObject::connect(
&m_loot, &Loot::finished, this,
[&]{ onFinished(); }, Qt::QueuedConnection);
}
@@ -116,11 +112,6 @@ public:
}
}
- void setInfo(const QString& mod, const QString& info)
- {
- m_core.pluginList()->addInformation(mod.toStdString().c_str(), info);
- }
-
bool result() const
{
return m_loot.result();
@@ -237,6 +228,7 @@ private:
if (m_cancelling) {
close();
} else {
+ handleReport();
m_report->setEnabled(true);
m_buttons->setStandardButtons(QDialogButtonBox::Close);
}
@@ -252,83 +244,55 @@ private:
addLineOutput(QString("[%1] %2").arg(log::levelToString(lv)).arg(s));
}
}
-};
-
-
-struct Loot::Message
-{
- QString type;
- QString text;
-};
-
-struct Loot::File
-{
- QString name;
- QString displayName;
-};
-
-struct Loot::Dirty
-{
- qint64 crc=0;
- qint64 itm=0;
- qint64 deletedReferences=0;
- qint64 deletedNavmesh=0;
- QString cleaningUtility;
- QString info;
- QString toString(bool isClean) const
+ void handleReport()
{
- if (isClean) {
- return QObject::tr("Verified clean by %1")
- .arg(cleaningUtility.isEmpty() ? "?" : cleaningUtility);
- }
-
- QString s = cleaningString();
+ const auto& report = m_loot.report();
- if (!info.isEmpty()) {
- s += " " + info;
+ if (!report.messages.empty()) {
+ addLineOutput("");
}
- return s;
- }
+ for (auto&& m : report.messages) {
+ log(levelFromLoot(
+ lootcli::logLevelFromString(m.type.toStdString())),
+ m.text);
+ }
- QString cleaningString() const
- {
- return QObject::tr("%1 found %2 ITM record(s), %3 deleted reference(s) and %4 deleted navmesh(es).")
- .arg(cleaningUtility.isEmpty() ? "?" : cleaningUtility)
- .arg(itm)
- .arg(deletedReferences)
- .arg(deletedNavmesh);
+ for (auto&& p : report.plugins) {
+ for (auto&& d : p.dirty) {
+ m_core.pluginList()->addInformation(p.name, d.toString(false));
+ }
+ }
}
};
-struct Loot::Plugin
-{
- QString name;
- std::vector<File> incompatibilities;
- std::vector<Message> messages;
- std::vector<Dirty> dirty, clean;
- std::vector<QString> missingMasters;
- bool loadsArchive = false;
- bool isMaster = false;
- bool isLightMaster = false;
-};
-struct Loot::Stats
+QString Loot::Dirty::toString(bool isClean) const
{
- qint64 time = 0;
- QString version;
-};
+ if (isClean) {
+ return QObject::tr("Verified clean by %1")
+ .arg(cleaningUtility.isEmpty() ? "?" : cleaningUtility);
+ }
-struct Loot::Report
-{
- std::vector<Message> messages;
- std::vector<Plugin> plugins;
- Stats stats;
-};
+ QString s = cleaningString();
+ if (!info.isEmpty()) {
+ s += " " + info;
+ }
+
+ return s;
+}
+
+QString Loot::Dirty::cleaningString() const
+{
+ return QObject::tr("%1 found %2 ITM record(s), %3 deleted reference(s) and %4 deleted navmesh(es).")
+ .arg(cleaningUtility.isEmpty() ? "?" : cleaningUtility)
+ .arg(itm)
+ .arg(deletedReferences)
+ .arg(deletedNavmesh);
+}
-class ReportFailed {};
Loot::Loot()
: m_thread(nullptr), m_cancel(false), m_result(false)
@@ -437,6 +401,11 @@ const QString& Loot::outPath() const
return m_outPath;
}
+const Loot::Report& Loot::report() const
+{
+ return m_report;
+}
+
void Loot::lootThread()
{
try {
@@ -558,7 +527,7 @@ void Loot::processStdout(const std::string &lootOut)
void Loot::processMessage(const lootcli::Message& m)
{
- static const std::regex exRequires("\"([^\"]*)\" requires \"([^\"]*)\", but it is missing\\.");
+ /*static const std::regex exRequires("\"([^\"]*)\" requires \"([^\"]*)\", but it is missing\\.");
static const std::regex exIncompatible("\"([^\"]*)\" is incompatible with \"([^\"]*)\", but both are present\\.");
switch (m.type)
@@ -595,7 +564,7 @@ void Loot::processMessage(const lootcli::Message& m)
emit progress(m.progress);
break;
}
- }
+ }*/
}
void Loot::processOutputFile()
@@ -623,19 +592,7 @@ void Loot::processOutputFile()
return;
}
- const auto report = createReport(doc);
-
- for (auto&& m : report.messages) {
- emit log(levelFromLoot(
- lootcli::logLevelFromString(m.type.toStdString())),
- m.text);
- }
-
- for (auto&& p : report.plugins) {
- for (auto&& d : p.dirty) {
- emit information(p.name, d.toString(false));
- }
- }
+ m_report = createReport(doc);
}
Loot::Report Loot::createReport(const QJsonDocument& doc) const