mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -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:
parent
af772f8aee
commit
8807a3b509
@ -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;
|
||||
}
|
||||
|
@ -27,12 +27,15 @@ public:
|
||||
void selectIndex(int index);
|
||||
|
||||
public slots:
|
||||
void updateInfoForIndex(int index);
|
||||
void setShowMarks(bool show);
|
||||
void selectAll();
|
||||
|
||||
protected:
|
||||
QQuickView *view;
|
||||
QWidget *container;
|
||||
QObject *flow;
|
||||
QObject *list;
|
||||
};
|
||||
|
||||
#endif // INFOCOMICSVIEW_H
|
||||
|
@ -17,6 +17,7 @@ Rectangle {
|
||||
|
||||
FlowView {
|
||||
id: flow
|
||||
objectName: "flow"
|
||||
height: 256 //TODO dynamic size?
|
||||
|
||||
anchors.top: parent.top
|
||||
|
Loading…
x
Reference in New Issue
Block a user