| 151 | } |
| 152 | |
| 153 | void GridComicsView::setModel(ComicModel *model) |
| 154 | { |
| 155 | if (model == NULL) |
| 156 | return; |
| 157 | |
| 158 | ComicsView::setModel(model); |
| 159 | |
| 160 | setCurrentComicIfNeeded(); |
| 161 | |
| 162 | selectionHelper->setModel(model); |
| 163 | comicInfoHelper->setModel(model); |
| 164 | |
| 165 | QQmlContext *ctxt = view->rootContext(); |
| 166 | |
| 167 | ctxt->setContextProperty("comicsList", model); |
| 168 | ctxt->setContextProperty("comicsSelection", selectionHelper->selectionModel()); |
| 169 | ctxt->setContextProperty("contextMenuHelper", this); |
| 170 | ctxt->setContextProperty("comicsSelectionHelper", selectionHelper); |
| 171 | ctxt->setContextProperty("currentIndexHelper", this); |
| 172 | ctxt->setContextProperty("comicRatingHelper", this); |
| 173 | ctxt->setContextProperty("dummyValue", true); |
| 174 | ctxt->setContextProperty("dragManager", this); |
| 175 | ctxt->setContextProperty("dropManager", this); |
| 176 | ctxt->setContextProperty("comicInfoHelper", comicInfoHelper); |
| 177 | |
| 178 | auto *root = view->rootObject(); |
| 179 | auto grid = root ? root->findChild<QQuickItem *>(QStringLiteral("grid")) : nullptr; |
| 180 | |
| 181 | if (grid != nullptr) { |
| 182 | grid->setProperty("currentIndex", 0); |
| 183 | } |
| 184 | |
| 185 | updateBackgroundConfig(); |
| 186 | |
| 187 | selectionHelper->clear(); |
| 188 | |
| 189 | if (model->rowCount() > 0) { |
| 190 | setCurrentIndex(model->index(0, 0)); |
| 191 | if (showInfoAction->isChecked()) |
| 192 | updateInfoForIndex(0); |
| 193 | } |
| 194 | |
| 195 | // If the currentComicView was hidden before showing it sometimes the scroll view doesn't show it |
| 196 | // this is a hacky solution... |
| 197 | QTimer::singleShot(0, this, &GridComicsView::resetScroll); |
| 198 | } |
| 199 | |
| 200 | void GridComicsView::updateBackgroundConfig() |
| 201 | { |
no test coverage detected