diff --git a/YACReaderLibrary/db/comic_model.cpp b/YACReaderLibrary/db/comic_model.cpp index 2e991a51..53f0c5e5 100644 --- a/YACReaderLibrary/db/comic_model.cpp +++ b/YACReaderLibrary/db/comic_model.cpp @@ -325,6 +325,29 @@ void ComicModel::setupLabelModelData(unsigned long long parentLabel, const QStri emit isEmpty();*/ } +void ComicModel::setupReadingListModelData(unsigned long long parentReadingList, const QString &databasePath) +{ + beginResetModel(); + qDeleteAll(_data); + _data.clear(); + + _databasePath = databasePath; + QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath); + { + QSqlQuery selectQuery(db); + selectQuery.prepare("SELECT ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read,ci.isBis,ci.currentPage,ci.rating,ci.hasBeenOpened " + "FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) " + "INNER JOIN comic_reading_list crl ON (c.id == crl.comic_id) " + "WHERE crl.reading_list_id = :parentReadingList"); + selectQuery.bindValue(":parentReadingList", parentReadingList); + selectQuery.exec(); + setupModelData(selectQuery); + } + db.close(); + QSqlDatabase::removeDatabase(_databasePath); + endResetModel(); +} + void ComicModel::setupFavoritesModelData(const QString &databasePath) { beginResetModel(); diff --git a/YACReaderLibrary/db/comic_model.h b/YACReaderLibrary/db/comic_model.h index 694a000e..7f6c9a03 100644 --- a/YACReaderLibrary/db/comic_model.h +++ b/YACReaderLibrary/db/comic_model.h @@ -36,6 +36,7 @@ public: int columnCount(const QModelIndex &parent = QModelIndex()) const; void setupFolderModelData(unsigned long long int parentFolder,const QString & databasePath); void setupLabelModelData(unsigned long long int parentLabel, const QString & databasePath); + void setupReadingListModelData(unsigned long long int parentReadingList, const QString & databasePath); void setupFavoritesModelData(const QString & databasePath); void setupReadingModelData(const QString & databasePath); //configures the model for showing the comics matching the filter criteria. diff --git a/YACReaderLibrary/yacreader_navigation_controller.cpp b/YACReaderLibrary/yacreader_navigation_controller.cpp index e228b964..d0bec71c 100644 --- a/YACReaderLibrary/yacreader_navigation_controller.cpp +++ b/YACReaderLibrary/yacreader_navigation_controller.cpp @@ -166,8 +166,22 @@ void YACReaderNavigationController::loadLabelInfo(const QModelIndex &modelIndex) void YACReaderNavigationController::loadReadingListInfo(const QModelIndex &modelIndex) { - libraryWindow->showEmptyReadingListWidget(); - libraryWindow->disableComicsActions(true); + qulonglong id = modelIndex.data(ReadingListModel::IDRole).toULongLong(); + //check comics in label with id = id + libraryWindow->comicsModel->setupReadingListModelData(id,libraryWindow->foldersModel->getDatabase()); + libraryWindow->comicsView->setModel(libraryWindow->comicsModel); + + //configure views + if(libraryWindow->comicsModel->rowCount() > 0) + { + //updateView + libraryWindow->showComicsView(); + libraryWindow->disableComicsActions(false); + } + else{ + libraryWindow->showEmptyReadingListWidget(); + libraryWindow->disableComicsActions(true); + } } void YACReaderNavigationController::selectedList(const QModelIndex &mi)