void ComicsModel::loadAll() { clear(); QStringList comicsList = idLoadList(); Comic *comic; beginInsertRows(QModelIndex(), 0, comicsList.count() - 1); for (int i = 0; i < comicsList.size(); ++i) { comic = factory->create(comicsList.at(i), this); if (comic == NULL) return; comic->load(); connect(comic, SIGNAL(favoriteChanged(Comic*)), this, SLOT(emitFavoriteChanged(Comic*))); connect(comic, SIGNAL(newStripChanged(Comic*)), this, SLOT(emitNewStripChanged(Comic*))); connect(comic, SIGNAL(errorChanged(Comic*)), this, SLOT(emitErrorChanged(Comic*))); connect(comic, SIGNAL(fetchingChanged(Comic*)), this, SLOT(emitFetchingChanged(Comic*))); connect(comic, SIGNAL(fetchingProgressChanged(Comic*)), this, SLOT(emitFetchingProgressChanged(Comic*))); m_list.append(comic); } endInsertRows(); // hack to fix the initialization of the cover... emit countChanged(); }
int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QString filepath = app.arguments().value(1, "./why_are_you_reading_this.png"); filepath = QDir().absoluteFilePath(filepath); Comic comic; if (QFile(filepath).exists()) { comic.load(QImage(filepath)); } else { qDebug() << "File does not exist:" << filepath; } QtQuick2ApplicationViewer viewer; viewer.engine()->addImageProvider("comicimageprovider", new ComicImageProvider(comic)); QQmlContext* context = viewer.rootContext(); context->setContextProperty("comic", &comic); viewer.setMainQmlFile(QStringLiteral("qml/quick/main.qml")); viewer.showExpanded(); return app.exec(); }