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 <QtQuick>
|
||||||
|
|
||||||
#include "comic_model.h"
|
#include "comic_model.h"
|
||||||
|
#include "comic_db.h"
|
||||||
|
|
||||||
#include "QsLog.h"
|
#include "QsLog.h"
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ InfoComicsView::InfoComicsView(QWidget *parent)
|
|||||||
:ComicsView(parent)
|
:ComicsView(parent)
|
||||||
{
|
{
|
||||||
qmlRegisterType<ComicModel>("com.yacreader.ComicModel",1,0,"ComicModel");
|
qmlRegisterType<ComicModel>("com.yacreader.ComicModel",1,0,"ComicModel");
|
||||||
|
qmlRegisterType<ComicInfo>("com.yacreader.ComicInfo",1,0,"ComicInfo");
|
||||||
|
|
||||||
view = new QQuickView();
|
view = new QQuickView();
|
||||||
container = QWidget::createWindowContainer(view, this);
|
container = QWidget::createWindowContainer(view, this);
|
||||||
@ -18,6 +20,13 @@ InfoComicsView::InfoComicsView(QWidget *parent)
|
|||||||
|
|
||||||
view->setSource(QUrl("qrc:/qml/InfoComicsView.qml"));
|
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;
|
QVBoxLayout * l = new QVBoxLayout;
|
||||||
l->addWidget(container);
|
l->addWidget(container);
|
||||||
this->setLayout(l);
|
this->setLayout(l);
|
||||||
@ -71,6 +80,12 @@ void InfoComicsView::setModel(ComicModel *model)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InfoComicsView::setCurrentIndex(const QModelIndex &index)
|
void InfoComicsView::setCurrentIndex(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
QQmlProperty(list, "currentIndex").write(index.row());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InfoComicsView::updateInfoForIndex(int index)
|
||||||
{
|
{
|
||||||
int FIXME;
|
int FIXME;
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,15 @@ public:
|
|||||||
void selectIndex(int index);
|
void selectIndex(int index);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void updateInfoForIndex(int index);
|
||||||
void setShowMarks(bool show);
|
void setShowMarks(bool show);
|
||||||
void selectAll();
|
void selectAll();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QQuickView *view;
|
QQuickView *view;
|
||||||
QWidget *container;
|
QWidget *container;
|
||||||
|
QObject *flow;
|
||||||
|
QObject *list;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INFOCOMICSVIEW_H
|
#endif // INFOCOMICSVIEW_H
|
||||||
|
@ -17,6 +17,7 @@ Rectangle {
|
|||||||
|
|
||||||
FlowView {
|
FlowView {
|
||||||
id: flow
|
id: flow
|
||||||
|
objectName: "flow"
|
||||||
height: 256 //TODO dynamic size?
|
height: 256 //TODO dynamic size?
|
||||||
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
Loading…
x
Reference in New Issue
Block a user