summaryrefslogtreecommitdiff
path: root/src/atomchannel.h
diff options
context:
space:
mode:
authorNikita Kostovsky <nikita@kostovsky.me>2025-06-22 16:54:02 +0200
committerNikita Kostovsky <nikita@kostovsky.me>2025-06-22 16:54:02 +0200
commitf674e179d602d3ccb9818d28fe06f371059449dc (patch)
tree996fb624986512de91581a18332f004d34220ba2 /src/atomchannel.h
parse and insert feeds and items
Diffstat (limited to 'src/atomchannel.h')
-rw-r--r--src/atomchannel.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/atomchannel.h b/src/atomchannel.h
new file mode 100644
index 0000000..0498a64
--- /dev/null
+++ b/src/atomchannel.h
@@ -0,0 +1,69 @@
+#pragma once
+
+#include <QDateTime>
+#include <QDebug>
+#include <QList>
+#include <QString>
+
+#include "atomchannelimage.h"
+#include "atomitem.h"
+
+class QXmlStreamReader;
+
+class AtomChannel
+{
+public:
+ // TODO: move to interface
+ static inline const QString xmlTag{"channel"};
+
+public:
+ explicit AtomChannel(QXmlStreamReader *xmlReader);
+
+public:
+ /*!
+ * \brief getDbId - check if channel with corresponding `link` exists in db
+ * and return db id if any
+ * \return id on success, 0 otherwise
+ */
+ int getDbId();
+
+ /*!
+ * \brief createInDb - create channel in db
+ * \return new channel id on success, 0 otherwise
+ */
+ int createInDb();
+
+ /*!
+ * \brief getOrInsertDbId - get existing channel id or try to create a new
+ * channel and get its id
+ * \return existing or new channel id on success, 0 otherwise
+ */
+ int getOrInsertDbId();
+
+ /*!
+ * \brief syncDbItems - create items in db if not exist
+ * \return list of new items ids
+ */
+ QList<int> syncDbItems();
+
+public:
+ /*!
+ * \brief dbId - cache db id
+ */
+ int dbId{0};
+
+ QString title;
+ /*!
+ * \brief link - field called `link` in atom xml. Points to feed itself
+ */
+ QUrl link;
+ QString description;
+ QDateTime lastBuildDate;
+ QLocale::Language language;
+ // ...
+ // TODO: shared_ptr
+ AtomChannelImage image;
+ QList<AtomItem> items;
+};
+
+QDebug operator<<(QDebug debug, const AtomChannel &channel);