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
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString title READ title)
|
||||
Q_PROPERTY(QString title READ title CONSTANT)
|
||||
Q_PROPERTY(QString feedTitle READ feedTitle)
|
||||
Q_PROPERTY(QString id READ id)
|
||||
Q_PROPERTY(QString feedId READ feedId)
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
TinyTinyRSS::TinyTinyRSS(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
qRegisterMetaType<QList<Post *> >();
|
||||
|
||||
mNetworkManager = new QNetworkAccessManager(this);
|
||||
mPosts = QList<Post *>();
|
||||
}
|
||||
|
@ -87,3 +89,18 @@ void TinyTinyRSS::reply()
|
|||
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 <QNetworkReply>
|
||||
#include <QList>
|
||||
#include <QQmlListProperty>
|
||||
|
||||
#include "post.h"
|
||||
|
||||
class TinyTinyRSS : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QList<Post *> posts READ posts NOTIFY postsChanged)
|
||||
Q_PROPERTY(QQmlListProperty<Post> posts READ posts NOTIFY postsChanged)
|
||||
|
||||
public:
|
||||
TinyTinyRSS(QObject *parent = 0);
|
||||
~TinyTinyRSS();
|
||||
QList<Post *> posts() const { return mPosts; }
|
||||
|
||||
Q_INVOKABLE void initialize(const QString serverUrl, const QString sessionId);
|
||||
Q_INVOKABLE void reload();
|
||||
|
||||
QQmlListProperty<Post> posts();
|
||||
int postsCount() const;
|
||||
Post *post(int) const;
|
||||
|
||||
signals:
|
||||
void postsChanged(QList<Post *>);
|
||||
|
||||
|
@ -32,7 +36,7 @@ private:
|
|||
|
||||
QString mServerUrl;
|
||||
QString mSessionId;
|
||||
QList<Post *> mPosts;
|
||||
QList<Post*> mPosts;
|
||||
QNetworkAccessManager *mNetworkManager;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue