Expose Fetcher as QML Singleton
This commit is contained in:
parent
d68d44faa8
commit
a8fb481631
@ -104,11 +104,6 @@ void EntryListModel::fetch()
|
||||
Fetcher::instance().fetch(QUrl(m_feed));
|
||||
}
|
||||
|
||||
QString EntryListModel::image(QString url)
|
||||
{
|
||||
return Fetcher::instance().image(url);
|
||||
}
|
||||
|
||||
QString EntryListModel::baseUrl(QString url)
|
||||
{
|
||||
return QUrl(url).adjusted(QUrl::RemovePath).toString();
|
||||
|
@ -45,7 +45,6 @@ public:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
Q_INVOKABLE void fetch();
|
||||
Q_INVOKABLE QString image(QString url);
|
||||
Q_INVOKABLE QString baseUrl(QString url);
|
||||
|
||||
QString feed() const;
|
||||
|
@ -79,8 +79,3 @@ void FeedListModel::removeFeed(int index)
|
||||
Database::instance().execute(query);
|
||||
select();
|
||||
}
|
||||
|
||||
QString FeedListModel::image(QString url)
|
||||
{
|
||||
return Fetcher::instance().image(url);
|
||||
}
|
||||
|
@ -43,5 +43,4 @@ public:
|
||||
|
||||
Q_INVOKABLE void addFeed(QString url);
|
||||
Q_INVOKABLE void removeFeed(int index);
|
||||
Q_INVOKABLE QString image(QString url);
|
||||
};
|
||||
|
@ -35,9 +35,9 @@ public:
|
||||
return _instance;
|
||||
}
|
||||
void fetch(QUrl);
|
||||
QString image(QString);
|
||||
Q_INVOKABLE QString image(QString);
|
||||
void removeImage(QString);
|
||||
void download(QString url);
|
||||
Q_INVOKABLE void download(QString url);
|
||||
|
||||
private:
|
||||
Fetcher();
|
||||
|
@ -57,6 +57,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
qmlRegisterType<FeedListModel>("org.kde.alligator", 1, 0, "FeedListModel");
|
||||
qmlRegisterType<EntryListModel>("org.kde.alligator", 1, 0, "EntryListModel");
|
||||
qmlRegisterSingletonType<Fetcher>("org.kde.alligator", 1, 0, "Fetcher", [](QQmlEngine *engine, QJSEngine *) -> QObject * {
|
||||
engine->setObjectOwnership(&Fetcher::instance(), QQmlEngine::CppOwnership);
|
||||
return &Fetcher::instance();
|
||||
});
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
|
@ -77,7 +77,7 @@ Kirigami.ScrollablePage {
|
||||
height: root.height * 0.2
|
||||
visible: !all
|
||||
Kirigami.Icon {
|
||||
source: entryListModel.image(page.image)
|
||||
source: Fetcher.image(page.image)
|
||||
width: height
|
||||
height: parent.height
|
||||
Component.onCompleted: console.log("Height: " + page.height)
|
||||
|
@ -102,7 +102,7 @@ Kirigami.ScrollablePage {
|
||||
Item {
|
||||
Kirigami.Icon {
|
||||
id: icon
|
||||
source: feedListModel.image(model.image)
|
||||
source: Fetcher.image(model.image)
|
||||
width: height
|
||||
height: parent.height
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user