diff --git a/CHANGELOG.md b/CHANGELOG.md index a1f12abd..9f42d6aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch) ### YACReaderLibrary * Avoid showing stale information in the server config dialog by updating the connection information when the dialog is opened. * Add new metadata support, it improves compatibility with ComicInfo.xml -* Add support for showing a "recently added/updated" indicator. +* Add support for showing a "recently added/updated" indicator. The number of days to consider something recent can be configured in the settings. * Improved comic metadata dialog. * Add textual tags support that can be queried through the search engine. * Make = in the search engine work as : does. @@ -15,6 +15,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch) * Support filtering by since/before dates in the search engine. e.g. `added > 7` means recent content added since 7 days ago, and `added < 30` means content added before the last 30 days. * Show the full library path in the dialog shown to warn about missing libraries. * Fix scroll bar in the info comics view in Qt6 builds. +* New `Recent` smart list, it will show recent comics added. ### All Apps * New icons for macos. diff --git a/YACReaderLibrary/db/comic_model.cpp b/YACReaderLibrary/db/comic_model.cpp index 844bcbeb..84c48800 100644 --- a/YACReaderLibrary/db/comic_model.cpp +++ b/YACReaderLibrary/db/comic_model.cpp @@ -623,6 +623,36 @@ void ComicModel::setupReadingModelData(const QString &databasePath) endResetModel(); } +void ComicModel::setupRecentModelData(const QString &databasePath) +{ + enableResorting = false; + mode = Recent; + sourceId = -1; + + beginResetModel(); + qDeleteAll(_data); + _data.clear(); + + _databasePath = databasePath; + + QString connectionName = ""; + { + QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath); + QSqlQuery selectQuery(db); + selectQuery.prepare("SELECT " COMIC_MODEL_QUERY_FIELDS " " + "FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) " + "WHERE ci.added > :limit " + "ORDER BY ci.added DESC"); + selectQuery.bindValue(":limit", QDateTime::currentDateTime().addDays(-recentDays).toSecsSinceEpoch()); + selectQuery.exec(); + + setupModelDataForList(selectQuery); + connectionName = db.connectionName(); + } + QSqlDatabase::removeDatabase(connectionName); + endResetModel(); +} + void ComicModel::setModelData(QList *data, const QString &databasePath) { _databasePath = databasePath; @@ -923,6 +953,9 @@ void ComicModel::reload() case Reading: setupReadingModelData(_databasePath); break; + case Recent: + setupRecentModelData(_databasePath); + break; case Label: setupLabelModelData(sourceId, _databasePath); break; @@ -1155,6 +1188,9 @@ void ComicModel::setRecentRange(int days) this->recentDays = days; emit dataChanged(index(0, 0), index(rowCount() - 1, 0), { ComicModel::RecentRangeRole }); + + if (mode == ComicModel::Recent) + reload(); } void ComicModel::updateRating(int rating, QModelIndex mi) diff --git a/YACReaderLibrary/db/comic_model.h b/YACReaderLibrary/db/comic_model.h index b7b6f854..4b155e7e 100644 --- a/YACReaderLibrary/db/comic_model.h +++ b/YACReaderLibrary/db/comic_model.h @@ -67,6 +67,7 @@ public: Folder, Favorites, Reading, + Recent, Label, ReadingList }; @@ -96,6 +97,7 @@ public: void setupReadingListModelData(unsigned long long int parentReadingList, const QString &databasePath); void setupFavoritesModelData(const QString &databasePath); void setupReadingModelData(const QString &databasePath); + void setupRecentModelData(const QString &databasePath); // Métodos de conveniencia QStringList getPaths(const QString &_source); diff --git a/YACReaderLibrary/db/reading_list_model.cpp b/YACReaderLibrary/db/reading_list_model.cpp index d731fcd3..8352ca09 100644 --- a/YACReaderLibrary/db/reading_list_model.cpp +++ b/YACReaderLibrary/db/reading_list_model.cpp @@ -82,7 +82,7 @@ QVariant ReadingListModel::data(const QModelIndex &index, int role) const if (role == ReadingListModel::SpecialListTypeRole && typeid(*item) == typeid(SpecialListItem)) { auto specialListItem = static_cast(item); - return QVariant(specialListItem->getType()); + return QVariant::fromValue(specialListItem->getType()); } if (typeid(*item) == typeid(ReadingListSeparatorItem)) @@ -196,7 +196,10 @@ bool ReadingListModel::canDropMimeData(const QMimeData *data, Qt::DropAction act if (row == -1) // no list return false; - if (row == 1) // reading is just an smart list + if (row == 1) // reading is just a smart list + return false; + + if (row == 2) // recent is just a smart list return false; if (rowIsSeparator(row, parent)) @@ -609,8 +612,8 @@ QList ReadingListModel::setupSpecialLists(QSqlDatabase &db) << selectQuery.value(id)); } - // Reading after Favorites, Why? Because I want to :P list.insert(1, new SpecialListItem(QList() << "Reading" << 0)); + list.insert(2, new SpecialListItem(QList() << "Recent" << 2)); return list; } diff --git a/YACReaderLibrary/db/reading_list_model.h b/YACReaderLibrary/db/reading_list_model.h index 1a743f87..f9da9c40 100644 --- a/YACReaderLibrary/db/reading_list_model.h +++ b/YACReaderLibrary/db/reading_list_model.h @@ -69,9 +69,10 @@ public: Separator }; - enum TypeSpecialList { - Reading, - Favorites + enum class TypeSpecialList : int { + Reading = 0, + Favorites, + Recent, }; signals: diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc index b6c66320..2685121c 100644 --- a/YACReaderLibrary/images.qrc +++ b/YACReaderLibrary/images.qrc @@ -96,6 +96,8 @@ ../images/lists/default_0.svg ../images/lists/default_1.svg + ../images/lists/default_2.svg + ../images/lists/label_blue.svg ../images/lists/label_cyan.svg ../images/lists/label_dark.svg diff --git a/YACReaderLibrary/yacreader_navigation_controller.cpp b/YACReaderLibrary/yacreader_navigation_controller.cpp index 65cb1171..9e477fe6 100644 --- a/YACReaderLibrary/yacreader_navigation_controller.cpp +++ b/YACReaderLibrary/yacreader_navigation_controller.cpp @@ -102,12 +102,15 @@ void YACReaderNavigationController::loadSpecialListInfo(const QModelIndex &model ReadingListModel::TypeSpecialList type = (ReadingListModel::TypeSpecialList)modelIndex.data(ReadingListModel::SpecialListTypeRole).toInt(); switch (type) { - case ReadingListModel::Favorites: + case ReadingListModel::TypeSpecialList::Favorites: libraryWindow->comicsModel->setupFavoritesModelData(libraryWindow->foldersModel->getDatabase()); break; - case ReadingListModel::Reading: + case ReadingListModel::TypeSpecialList::Reading: libraryWindow->comicsModel->setupReadingModelData(libraryWindow->foldersModel->getDatabase()); break; + case ReadingListModel::TypeSpecialList::Recent: + libraryWindow->comicsModel->setupRecentModelData(libraryWindow->foldersModel->getDatabase()); + break; } contentViewsManager->comicsView->setModel(libraryWindow->comicsModel); @@ -118,14 +121,18 @@ void YACReaderNavigationController::loadSpecialListInfo(const QModelIndex &model } else { // setup empty special list widget switch (type) { - case ReadingListModel::Favorites: + case ReadingListModel::TypeSpecialList::Favorites: contentViewsManager->emptySpecialList->setPixmap(QPixmap(":/images/empty_favorites.png")); contentViewsManager->emptySpecialList->setText(tr("No favorites")); break; - case ReadingListModel::Reading: + case ReadingListModel::TypeSpecialList::Reading: contentViewsManager->emptySpecialList->setPixmap(QPixmap(":/images/empty_current_readings.png")); contentViewsManager->emptySpecialList->setText(tr("You are not reading anything yet, come on!!")); break; + case ReadingListModel::TypeSpecialList::Recent: + contentViewsManager->emptySpecialList->setPixmap(QPixmap()); + contentViewsManager->emptySpecialList->setText(tr("There are no recent comics!")); + break; } contentViewsManager->showEmptySpecialList(); diff --git a/custom_widgets/whats_new_dialog.cpp b/custom_widgets/whats_new_dialog.cpp index e34ad4d8..d21f0b4d 100644 --- a/custom_widgets/whats_new_dialog.cpp +++ b/custom_widgets/whats_new_dialog.cpp @@ -56,6 +56,10 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent) " • Add textual tags support that can be queried through the search engine.
" " • Make '=' in the search engine work as ':' does.
" " • Add new operators to the search engine: exact match ==, <, >, <=, >=.
" + " • Support filtering by since/before dates in the search engine. e.g. `added > 7` means recent content added since 7 days ago, and `added < 30` means content added before the last 30 days." + " • Show the full library path in the dialog shown to warn about missing libraries." + " • Fix scroll bar in the info comics view in Qt6 builds." + " • New `Recent` smart list, it will show recent comics added." "
" "I hope you enjoy the new update. Please, if you like YACReader consider to become a patron in Patreon " "or donate some money using Pay-Pal and help keeping the project alive. " diff --git a/images/lists/default_2.svg b/images/lists/default_2.svg new file mode 100644 index 00000000..88ab6868 --- /dev/null +++ b/images/lists/default_2.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file