summaryrefslogtreecommitdiff
path: root/src/atomchannel.h
diff options
context:
space:
mode:
authorNikita Kostovsky <nikita@kostovsky.me>2025-08-13 19:24:57 +0200
committerNikita Kostovsky <nikita@kostovsky.me>2025-08-13 19:24:57 +0200
commit6d7eaf0c724b976325f4c46b2ff4c452c09a24ea (patch)
treec28e24742a9711ecc5ad467460b32bc03862c5b5 /src/atomchannel.h
parentb91bddfbc588dedffda4b129c5e2c2fd9afe7bfd (diff)
refactorHEADmaster
Diffstat (limited to 'src/atomchannel.h')
-rw-r--r--src/atomchannel.h46
1 files changed, 35 insertions, 11 deletions
diff --git a/src/atomchannel.h b/src/atomchannel.h
index e52048a..e88c05f 100644
--- a/src/atomchannel.h
+++ b/src/atomchannel.h
@@ -32,11 +32,14 @@ public: \
protected: \
type m_##name
-class DbItem
+class DbItem : public QObject
{
- Q_GADGET
+ // Q_GADGET
+ Q_OBJECT
- GADGET_PROPERTY(std::optional<qlonglong>, id);
+public:
+ using DbId = std::optional<qlonglong>;
+ GADGET_PROPERTY(DbId, id);
static constexpr auto dateFormat = Qt::DateFormat::RFC2822Date;
@@ -44,28 +47,44 @@ public:
explicit DbItem(const QDomNode &node);
public:
- void init(const QMetaObject &mo, const QDomNode &node);
+ virtual bool isValid() const = 0;
+
+ virtual void init(const QDomNode &node);
+
+ // TODO: sync list of items, thus minimizing amount of db queries
+ virtual DbId syncWithDb();
+
+ virtual QStringList propertyNames() const;
+ virtual QList<QMetaProperty> properties() const;
+
+ virtual const QStringList &uniqueFields() const = 0;
};
-class Channel : public DbItem
+class Feed : public DbItem
{
- Q_GADGET
+ Q_OBJECT
GADGET_PROPERTY(QString, title);
GADGET_PROPERTY(QUrl, link);
+ GADGET_PROPERTY(QUrl, image_url);
public:
- explicit Channel(const QDomNode &node);
+ explicit Feed(const QDomNode &node);
public:
- bool isValid() const;
+ bool isValid() const override;
+
+ const QStringList &uniqueFields() const override;
+
+private:
+ static inline QStringList m_uniqueFields{{"link"}};
};
// TODO: <image>
class Item : public DbItem
{
- Q_GADGET
+ Q_OBJECT
GADGET_PROPERTY(QString, title);
GADGET_PROPERTY(QUrl, link);
@@ -79,7 +98,12 @@ public:
explicit Item(const QDomNode &node);
public:
- bool isValid() const;
+ bool isValid() const override;
+
+ const QStringList &uniqueFields() const override;
+
+private:
+ static inline QStringList m_uniqueFields{{"link"}};
};
class AtomChannel
@@ -140,5 +164,5 @@ public:
};
QDebug operator<<(QDebug debug, const AtomChannel &channel);
-QDebug operator<<(QDebug debug, const Channel &channel);
+QDebug operator<<(QDebug debug, const Feed &feed);
QDebug operator<<(QDebug debug, const Item &item);