From f674e179d602d3ccb9818d28fe06f371059449dc Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Sun, 22 Jun 2025 16:54:02 +0200 Subject: parse and insert feeds and items --- src/atomchannel.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/atomchannel.h (limited to 'src/atomchannel.h') 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 +#include +#include +#include + +#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 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 items; +}; + +QDebug operator<<(QDebug debug, const AtomChannel &channel); -- cgit v1.2.3-70-g09d2