From 80a658f062328ab8b47dc6b2557d274f51278b3a Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Tue, 12 Sep 2023 10:08:19 -0400 Subject: Define archive item ref type for Archive classes This type allows extension and the implementation of a more complete archive item reference system in the future as it allows going beyond ints. --- src/archive/base_archive.h | 7 ++++--- src/archive/mastodon.cpp | 8 ++++---- src/archive/mastodon.h | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/archive/base_archive.h b/src/archive/base_archive.h index a6bf98f..7d52cd5 100644 --- a/src/archive/base_archive.h +++ b/src/archive/base_archive.h @@ -22,6 +22,8 @@ public: JsonNotActivityStream // for ActivityPub archives }; + typedef int ArchiveItemRef; + struct Hinting_t { StatusType status_type = UNKNOWN; }; @@ -32,9 +34,8 @@ public: static Archive* create_archive(ArchiveType archive_type, const QString& main_filename); virtual void update_status_list(ViewStatusTypes allowed_types, QListWidget *parent) = 0; - // TODO: use a index type instead of a bare int as the former can be extended - virtual APActivity* get_activity(int index, Hinting_t hinting) = 0; - virtual const QString get_html_status_text(int status_index) = 0; + virtual APActivity* get_activity(ArchiveItemRef index, Hinting_t hinting) = 0; + virtual const QString get_html_status_text(ArchiveItemRef status_index) = 0; virtual const QString get_instance_address(); protected: diff --git a/src/archive/mastodon.cpp b/src/archive/mastodon.cpp index 238b861..50253c6 100644 --- a/src/archive/mastodon.cpp +++ b/src/archive/mastodon.cpp @@ -237,9 +237,9 @@ std::vector MastodonArchive::get_status_attachments_list(QJs return list; } -APActivity* MastodonArchive::get_activity(int status_index, Hinting_t hinting) { +APActivity* MastodonArchive::get_activity(ArchiveItemRef index, Hinting_t hinting) { // the JSON AP Activity - QJsonObject activity = outbox_items->at(status_index).toObject(); + QJsonObject activity = outbox_items->at(index).toObject(); APActivityFields act_fields = { .visibility = hinting.status_type @@ -334,9 +334,9 @@ APActivity* MastodonArchive::get_activity(int status_index, Hinting_t hinting) { } // TODO: make this use an APActivity object that will be present as an StatusListItem member. -const QString MastodonArchive::get_html_status_text(int status_index) { +const QString MastodonArchive::get_html_status_text(ArchiveItemRef index) { QString text(""); - QJsonObject obj = outbox_items->at(status_index).toObject(); + QJsonObject obj = outbox_items->at(index).toObject(); if (obj["object"].isObject()) { QJsonObject activity = obj["object"].toObject(); diff --git a/src/archive/mastodon.h b/src/archive/mastodon.h index bc9da3e..0d57d7a 100644 --- a/src/archive/mastodon.h +++ b/src/archive/mastodon.h @@ -18,8 +18,8 @@ public: std::variant init(); void update_status_list(ViewStatusTypes allowed_types, QListWidget *parent); - APActivity* get_activity(int index, Hinting_t hinting = {}); - const QString get_html_status_text(int status_index); + APActivity* get_activity(ArchiveItemRef index, Hinting_t hinting = {}); + const QString get_html_status_text(ArchiveItemRef status_index); const QString get_instance_address(); private: QDir archive_root_dir; -- cgit v1.2.3-54-g00ecf