| 57 | } |
| 58 | |
| 59 | void InfoComicsView::setModel(ComicModel *model) |
| 60 | { |
| 61 | if (model == NULL) |
| 62 | return; |
| 63 | |
| 64 | selectionHelper->setModel(model); |
| 65 | comicInfoHelper->setModel(model); |
| 66 | |
| 67 | ComicsView::setModel(model); |
| 68 | |
| 69 | QQmlContext *ctxt = view->rootContext(); |
| 70 | |
| 71 | /*if(_selectionModel != NULL) |
| 72 | delete _selectionModel; |
| 73 | |
| 74 | _selectionModel = new QItemSelectionModel(model);*/ |
| 75 | |
| 76 | ctxt->setContextProperty("comicsList", model); |
| 77 | if (model->rowCount() > 0) |
| 78 | ctxt->setContextProperty("backgroundImage", this->model->data(this->model->index(0, 0), ComicModel::CoverPathRole)); |
| 79 | else |
| 80 | ctxt->setContextProperty("backgroundImage", QUrl()); |
| 81 | |
| 82 | ctxt->setContextProperty("comicsSelection", selectionHelper->selectionModel()); |
| 83 | ctxt->setContextProperty("contextMenuHelper", this); |
| 84 | ctxt->setContextProperty("currentIndexHelper", this); |
| 85 | ctxt->setContextProperty("comicInfoHelper", comicInfoHelper); |
| 86 | /*ctxt->setContextProperty("comicsSelectionHelper", this); |
| 87 | ctxt->setContextProperty("dragManager", this);*/ |
| 88 | ctxt->setContextProperty("dropManager", this); |
| 89 | |
| 90 | if (model->rowCount() > 0) { |
| 91 | setCurrentIndex(model->index(0, 0)); |
| 92 | updateInfoForIndex(0); |
| 93 | } |
| 94 | |
| 95 | if (flow != nullptr) { |
| 96 | flow->disconnect(); |
| 97 | } |
| 98 | |
| 99 | if (list != nullptr) { |
| 100 | list->disconnect(); |
| 101 | } |
| 102 | |
| 103 | if (auto *rootObject = view->rootObject()) { |
| 104 | flow = rootObject->findChild<QQuickItem *>("flow", Qt::FindChildrenRecursively); |
| 105 | list = rootObject->findChild<QQuickItem *>("list", Qt::FindChildrenRecursively); |
| 106 | } |
| 107 | |
| 108 | if (flow) { |
| 109 | // QML signals only work with old style signal slot syntax |
| 110 | connect(flow, SIGNAL(currentCoverChanged(int)), this, SLOT(updateInfoForIndex(int))); // clazy:exclude=old-style-connect |
| 111 | connect(flow, SIGNAL(currentCoverChanged(int)), this, SLOT(setCurrentIndex(int))); // clazy:exclude=old-style-connect |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | void InfoComicsView::setCurrentIndex(const QModelIndex &index) |
| 116 | { |
nothing calls this directly
no test coverage detected