diff --git a/YACReaderLibrary/classic_comics_view.cpp b/YACReaderLibrary/classic_comics_view.cpp index 772149f7..d3b7ea9e 100644 --- a/YACReaderLibrary/classic_comics_view.cpp +++ b/YACReaderLibrary/classic_comics_view.cpp @@ -135,6 +135,7 @@ void ClassicComicsView::setModel(ComicModel *model) } else { connect(model, &QAbstractItemModel::dataChanged, this, &ClassicComicsView::applyModelChanges, Qt::UniqueConnection); connect(model, &QAbstractItemModel::rowsRemoved, this, &ClassicComicsView::removeItemsFromFlow, Qt::UniqueConnection); + connect(model, &QAbstractItemModel::rowsInserted, this, &ClassicComicsView::addItemsToFlow, Qt::UniqueConnection); // TODO: Missing method resortCovers? connect(model, &ComicModel::resortedIndexes, comicFlow, &ComicFlowWidget::resortCovers, Qt::UniqueConnection); connect(model, &ComicModel::newSelectedIndex, this, &ClassicComicsView::setCurrentIndex, Qt::UniqueConnection); @@ -341,6 +342,15 @@ void ClassicComicsView::removeItemsFromFlow(const QModelIndex &parent, int from, comicFlow->remove(i); } +void ClassicComicsView::addItemsToFlow(const QModelIndex &parent, int from, int to) +{ + Q_UNUSED(parent); + for (int i = from; i <= to; i++) { + auto coverPath = model->index(i, 0).data(ComicModel::CoverPathRole).toString(); + comicFlow->add(coverPath.remove("file:"), i); // TODO: find a better way to get the path, file:+the_path is the way the URL is created for QML + } +} + void ClassicComicsView::closeEvent(QCloseEvent *event) { toolbar->removeAction(startSeparatorAction); diff --git a/YACReaderLibrary/classic_comics_view.h b/YACReaderLibrary/classic_comics_view.h index 6307b4bb..2f0a8c1a 100644 --- a/YACReaderLibrary/classic_comics_view.h +++ b/YACReaderLibrary/classic_comics_view.h @@ -42,6 +42,7 @@ public slots: void saveSplitterStatus(); void applyModelChanges(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); void removeItemsFromFlow(const QModelIndex &parent, int from, int to); + void addItemsToFlow(const QModelIndex &parent, int from, int to); // ComicsView void setShowMarks(bool show) override; void selectAll() override;