aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorConfuSomu2022-12-26 18:18:21 -0500
committerConfuSomu2022-12-26 18:18:21 -0500
commit8b3b17f03ed8a3bfc9d72978f8b0134807132ee0 (patch)
treebafdd7cba619b16e3478eb10107e0d2235be9b51 /src
parent477a7257e3aaec13dac7096ab91749399543502e (diff)
downloadActorViewer-8b3b17f03ed8a3bfc9d72978f8b0134807132ee0.tar
ActorViewer-8b3b17f03ed8a3bfc9d72978f8b0134807132ee0.tar.gz
ActorViewer-8b3b17f03ed8a3bfc9d72978f8b0134807132ee0.zip
Implement initial list of statuses
Diffstat (limited to 'src')
-rw-r--r--src/archive_parser.cpp23
-rw-r--r--src/archive_parser.h5
-rw-r--r--src/mainwindow.cpp7
-rw-r--r--src/mainwindow.h9
-rw-r--r--src/types.h9
5 files changed, 44 insertions, 9 deletions
diff --git a/src/archive_parser.cpp b/src/archive_parser.cpp
index 09b8cef..61b5f14 100644
--- a/src/archive_parser.cpp
+++ b/src/archive_parser.cpp
@@ -1,4 +1,5 @@
#include "archive_parser.h"
+#include "src/types.h"
#include <QFile>
#include <QJsonParseError>
@@ -44,3 +45,25 @@ Archive::~Archive() {
delete outbox_json; outbox_json = nullptr;
delete outbox_items; outbox_items = nullptr;
}
+
+QStringList Archive::get_status_list(ViewTootTypes types) {
+ QStringList statuses;
+
+ for (auto&& item : *outbox_items) {
+ if (item.isObject()){
+ QJsonObject obj = item.toObject();
+
+ // TODO: check the status type
+
+ if (obj.value("object").isObject()) {
+ QJsonObject activity = obj.value("object").toObject();
+
+ if (activity.value("content").isString()) {
+ statuses.append(activity.value("content").toString());
+ }
+ }
+ }
+ }
+
+ return statuses;
+}
diff --git a/src/archive_parser.h b/src/archive_parser.h
index ac9a7f0..e2d70df 100644
--- a/src/archive_parser.h
+++ b/src/archive_parser.h
@@ -1,10 +1,13 @@
#pragma once
#include <QString>
+#include <QStringList>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
+#include "types.h"
+
enum ArchiveType {
MASTODON
};
@@ -24,6 +27,8 @@ public:
Archive(QString outbox_filename, ArchiveType archive_type);
~Archive();
InitError init();
+
+ QStringList get_status_list(ViewTootTypes types);
private:
QString outbox_filename;
ArchiveType archive_type;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 8f4ebfe..326c3e4 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -36,7 +36,6 @@ void MainWindow::on_actionOpen_triggered(bool checked) {
QApplication::setOverrideCursor(Qt::WaitCursor);
data_archive = new Archive(outbox_filename, ArchiveType::MASTODON);
auto parse_error = data_archive->init();
- QApplication::restoreOverrideCursor();
switch (parse_error) {
case Archive::FailedOpeningFile:
@@ -51,6 +50,12 @@ void MainWindow::on_actionOpen_triggered(bool checked) {
case Archive::NoError:
break;
}
+
+ if (parse_error == Archive::NoError) {
+ ui->listWidget->addItems(data_archive->get_status_list(view_filters));
+ }
+
+ QApplication::restoreOverrideCursor();
}
void MainWindow::on_actionQuit_triggered(bool checked) {
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 2cbb9df..8a14bf8 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -5,14 +5,7 @@
#include <qobjectdefs.h>
#include "archive_parser.h"
-
-struct ViewTootTypes {
- bool includePublic = true;
- bool includeUnlisted = true;
- bool includePrivate = true;
- bool includeDirect = true;
- bool onlyWithAttachment = false;
-};
+#include "types.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
diff --git a/src/types.h b/src/types.h
new file mode 100644
index 0000000..e193216
--- /dev/null
+++ b/src/types.h
@@ -0,0 +1,9 @@
+#pragma once
+
+struct ViewTootTypes {
+ bool includePublic = true;
+ bool includeUnlisted = true;
+ bool includePrivate = true;
+ bool includeDirect = true;
+ bool onlyWithAttachment = false;
+};