MCPcopy Create free account
hub / github.com/YACReader/yacreader / setModel

Method setModel

YACReaderLibrary/grid_comics_view.cpp:153–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void 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
200void GridComicsView::updateBackgroundConfig()
201{

Callers 1

GridComicsViewMethod · 0.45

Calls 4

selectionModelMethod · 0.45
clearMethod · 0.45
rowCountMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected