mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Pass comic and comicInfo to the QML context when the current index is updated, so the ComicInfo view becomes functional.
This commit is contained in:
parent
1612402456
commit
939a52dd6e
@ -8,9 +8,10 @@
|
|||||||
#include "QsLog.h"
|
#include "QsLog.h"
|
||||||
|
|
||||||
InfoComicsView::InfoComicsView(QWidget *parent)
|
InfoComicsView::InfoComicsView(QWidget *parent)
|
||||||
:ComicsView(parent)
|
:ComicsView(parent), comicDB(0)
|
||||||
{
|
{
|
||||||
qmlRegisterType<ComicModel>("com.yacreader.ComicModel",1,0,"ComicModel");
|
qmlRegisterType<ComicModel>("com.yacreader.ComicModel",1,0,"ComicModel");
|
||||||
|
qmlRegisterType<ComicDB>("com.yacreader.ComicDB",1,0,"ComicDB");
|
||||||
qmlRegisterType<ComicInfo>("com.yacreader.ComicInfo",1,0,"ComicInfo");
|
qmlRegisterType<ComicInfo>("com.yacreader.ComicInfo",1,0,"ComicInfo");
|
||||||
|
|
||||||
view = new QQuickView();
|
view = new QQuickView();
|
||||||
@ -80,7 +81,10 @@ void InfoComicsView::setModel(ComicModel *model)
|
|||||||
updateBackgroundConfig();*/
|
updateBackgroundConfig();*/
|
||||||
|
|
||||||
if(model->rowCount()>0)
|
if(model->rowCount()>0)
|
||||||
|
{
|
||||||
setCurrentIndex(model->index(0,0));
|
setCurrentIndex(model->index(0,0));
|
||||||
|
updateInfoForIndex(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoComicsView::setCurrentIndex(const QModelIndex &index)
|
void InfoComicsView::setCurrentIndex(const QModelIndex &index)
|
||||||
@ -91,6 +95,14 @@ void InfoComicsView::setCurrentIndex(const QModelIndex &index)
|
|||||||
|
|
||||||
void InfoComicsView::updateInfoForIndex(int index)
|
void InfoComicsView::updateInfoForIndex(int index)
|
||||||
{
|
{
|
||||||
|
QQmlContext *ctxt = view->rootContext();
|
||||||
|
|
||||||
|
if(comicDB) delete comicDB;
|
||||||
|
|
||||||
|
comicDB = new ComicDB(model->getComic(this->model->index(index, 0)));
|
||||||
|
ComicInfo *comicInfo = &(comicDB->info);
|
||||||
|
ctxt->setContextProperty("comic", comicDB);
|
||||||
|
ctxt->setContextProperty("comicInfo", comicInfo);
|
||||||
int FIXME;
|
int FIXME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ protected:
|
|||||||
QWidget *container;
|
QWidget *container;
|
||||||
QObject *flow;
|
QObject *flow;
|
||||||
QObject *list;
|
QObject *list;
|
||||||
|
ComicDB *comicDB;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INFOCOMICSVIEW_H
|
#endif // INFOCOMICSVIEW_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user