first data showing up in qml
This commit is contained in:
parent
923d514dff
commit
2efb4a4fb9
3 changed files with 25 additions and 4 deletions
2
post.h
2
post.h
|
@ -9,7 +9,7 @@
|
||||||
class Post : public QObject
|
class Post : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString title READ title)
|
Q_PROPERTY(QString title READ title CONSTANT)
|
||||||
Q_PROPERTY(QString feedTitle READ feedTitle)
|
Q_PROPERTY(QString feedTitle READ feedTitle)
|
||||||
Q_PROPERTY(QString id READ id)
|
Q_PROPERTY(QString id READ id)
|
||||||
Q_PROPERTY(QString feedId READ feedId)
|
Q_PROPERTY(QString feedId READ feedId)
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
TinyTinyRSS::TinyTinyRSS(QObject *parent) :
|
TinyTinyRSS::TinyTinyRSS(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
|
qRegisterMetaType<QList<Post *> >();
|
||||||
|
|
||||||
mNetworkManager = new QNetworkAccessManager(this);
|
mNetworkManager = new QNetworkAccessManager(this);
|
||||||
mPosts = QList<Post *>();
|
mPosts = QList<Post *>();
|
||||||
}
|
}
|
||||||
|
@ -87,3 +89,18 @@ void TinyTinyRSS::reply()
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QQmlListProperty<Post> TinyTinyRSS::posts()
|
||||||
|
{
|
||||||
|
return QQmlListProperty<Post>(this, mPosts);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TinyTinyRSS::postsCount() const
|
||||||
|
{
|
||||||
|
return mPosts.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
Post *TinyTinyRSS::post(int index) const
|
||||||
|
{
|
||||||
|
return mPosts.at(index);
|
||||||
|
}
|
||||||
|
|
|
@ -5,22 +5,26 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QQmlListProperty>
|
||||||
|
|
||||||
#include "post.h"
|
#include "post.h"
|
||||||
|
|
||||||
class TinyTinyRSS : public QObject
|
class TinyTinyRSS : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QList<Post *> posts READ posts NOTIFY postsChanged)
|
Q_PROPERTY(QQmlListProperty<Post> posts READ posts NOTIFY postsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TinyTinyRSS(QObject *parent = 0);
|
TinyTinyRSS(QObject *parent = 0);
|
||||||
~TinyTinyRSS();
|
~TinyTinyRSS();
|
||||||
QList<Post *> posts() const { return mPosts; }
|
|
||||||
|
|
||||||
Q_INVOKABLE void initialize(const QString serverUrl, const QString sessionId);
|
Q_INVOKABLE void initialize(const QString serverUrl, const QString sessionId);
|
||||||
Q_INVOKABLE void reload();
|
Q_INVOKABLE void reload();
|
||||||
|
|
||||||
|
QQmlListProperty<Post> posts();
|
||||||
|
int postsCount() const;
|
||||||
|
Post *post(int) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void postsChanged(QList<Post *>);
|
void postsChanged(QList<Post *>);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue