mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
Link the FlowView in QML with the c++ view controller, so the comic info can be updated whenever the selected comic changes.
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include <QtQuick>
|
||||
|
||||
#include "comic_model.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
@ -10,6 +11,7 @@ InfoComicsView::InfoComicsView(QWidget *parent)
|
||||
:ComicsView(parent)
|
||||
{
|
||||
qmlRegisterType<ComicModel>("com.yacreader.ComicModel",1,0,"ComicModel");
|
||||
qmlRegisterType<ComicInfo>("com.yacreader.ComicInfo",1,0,"ComicInfo");
|
||||
|
||||
view = new QQuickView();
|
||||
container = QWidget::createWindowContainer(view, this);
|
||||
@ -18,6 +20,13 @@ InfoComicsView::InfoComicsView(QWidget *parent)
|
||||
|
||||
view->setSource(QUrl("qrc:/qml/InfoComicsView.qml"));
|
||||
|
||||
|
||||
QObject *rootObject = dynamic_cast<QObject*>(view->rootObject());
|
||||
flow = rootObject->findChild<QObject*>("flow");
|
||||
list = rootObject->findChild<QObject*>("list");
|
||||
|
||||
connect(flow, SIGNAL(currentCoverChanged(int)), this, SLOT(updateInfoForIndex(int)));
|
||||
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
l->addWidget(container);
|
||||
this->setLayout(l);
|
||||
@ -71,6 +80,12 @@ void InfoComicsView::setModel(ComicModel *model)
|
||||
}
|
||||
|
||||
void InfoComicsView::setCurrentIndex(const QModelIndex &index)
|
||||
{
|
||||
QQmlProperty(list, "currentIndex").write(index.row());
|
||||
}
|
||||
|
||||
|
||||
void InfoComicsView::updateInfoForIndex(int index)
|
||||
{
|
||||
int FIXME;
|
||||
}
|
||||
|
Reference in New Issue
Block a user