mirror of
https://github.com/YACReader/yacreader
synced 2025-09-21 12:45:03 -04:00
'current reading' list is working
This commit is contained in:
@ -284,7 +284,9 @@ void ComicModel::setupFolderModelData(unsigned long long int folderId,const QStr
|
|||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
||||||
{
|
{
|
||||||
QSqlQuery selectQuery(db);
|
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) where c.parentId = :parentId");
|
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) "
|
||||||
|
"WHERE c.parentId = :parentId");
|
||||||
selectQuery.bindValue(":parentId", folderId);
|
selectQuery.bindValue(":parentId", folderId);
|
||||||
selectQuery.exec();
|
selectQuery.exec();
|
||||||
setupModelData(selectQuery);
|
setupModelData(selectQuery);
|
||||||
@ -323,6 +325,56 @@ void ComicModel::setupLabelModelData(unsigned long long parentLabel, const QStri
|
|||||||
emit isEmpty();
|
emit isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComicModel::setupFavoritesModelData(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_default_reading_list cdrl ON (c.id == cdrl.comic_id) "
|
||||||
|
"WHERE cdrl.default_reading_list_id = :parentDefaultListId");
|
||||||
|
selectQuery.bindValue(":parentDefaultListId", 1);
|
||||||
|
selectQuery.exec();
|
||||||
|
setupModelData(selectQuery);
|
||||||
|
}
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
|
endResetModel();
|
||||||
|
|
||||||
|
if(_data.length()==0)
|
||||||
|
emit isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicModel::setupReadingModelData(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) "
|
||||||
|
"WHERE ci.hasBeenOpened = 1 AND ci.read = 0");
|
||||||
|
selectQuery.exec();
|
||||||
|
setupModelData(selectQuery);
|
||||||
|
}
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
|
endResetModel();
|
||||||
|
|
||||||
|
if(_data.length()==0)
|
||||||
|
emit isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void ComicModel::setupModelData(const SearchModifiers modifier, const QString &filter, const QString &databasePath)
|
void ComicModel::setupModelData(const SearchModifiers modifier, const QString &filter, const QString &databasePath)
|
||||||
{
|
{
|
||||||
//QFile f(QCoreApplication::applicationDirPath()+"/performance.txt");
|
//QFile f(QCoreApplication::applicationDirPath()+"/performance.txt");
|
||||||
|
@ -36,13 +36,15 @@ public:
|
|||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
void setupFolderModelData(unsigned long long int parentFolder,const QString & databasePath);
|
void setupFolderModelData(unsigned long long int parentFolder,const QString & databasePath);
|
||||||
void setupLabelModelData(unsigned long long int parentLabel, const QString & databasePath);
|
void setupLabelModelData(unsigned long long int parentLabel, const QString & databasePath);
|
||||||
|
void setupFavoritesModelData(const QString & databasePath);
|
||||||
|
void setupReadingModelData(const QString & databasePath);
|
||||||
//configures the model for showing the comics matching the filter criteria.
|
//configures the model for showing the comics matching the filter criteria.
|
||||||
void setupModelData(const SearchModifiers modifier, const QString & filter, const QString & databasePath);
|
void setupModelData(const SearchModifiers modifier, const QString & filter, const QString & databasePath);
|
||||||
|
|
||||||
//Métodos de conveniencia
|
//Métodos de conveniencia
|
||||||
QStringList getPaths(const QString & _source);
|
QStringList getPaths(const QString & _source);
|
||||||
QString getComicPath(QModelIndex mi);
|
QString getComicPath(QModelIndex mi);
|
||||||
QString getCurrentPath(){return QString(_databasePath).remove("/.yacreaderlibrary");};
|
QString getCurrentPath(){return QString(_databasePath).remove("/.yacreaderlibrary");}
|
||||||
ComicDB getComic(const QModelIndex & mi); //--> para la edición
|
ComicDB getComic(const QModelIndex & mi); //--> para la edición
|
||||||
//ComicDB getComic(int row);
|
//ComicDB getComic(int row);
|
||||||
QVector<YACReaderComicReadStatus> getReadList();
|
QVector<YACReaderComicReadStatus> getReadList();
|
||||||
|
@ -287,7 +287,7 @@ bool DataBaseManagement::createV8Tables(QSqlDatabase &database)
|
|||||||
queryInsertDefaultReadingList.prepare("INSERT INTO default_reading_list (name) VALUES (:name)");
|
queryInsertDefaultReadingList.prepare("INSERT INTO default_reading_list (name) VALUES (:name)");
|
||||||
|
|
||||||
//1 Favorites
|
//1 Favorites
|
||||||
queryInsertDefaultReadingList.bindValue(":name", tr("Favorites"));
|
queryInsertDefaultReadingList.bindValue(":name", "Favorites");
|
||||||
success = success && queryInsertDefaultReadingList.exec();
|
success = success && queryInsertDefaultReadingList.exec();
|
||||||
|
|
||||||
//Reading doesn't need its onw list
|
//Reading doesn't need its onw list
|
||||||
|
@ -100,20 +100,42 @@ void YACReaderNavigationController::loadListInfo(const QModelIndex &modelIndex)
|
|||||||
void YACReaderNavigationController::loadSpecialListInfo(const QModelIndex &modelIndex)
|
void YACReaderNavigationController::loadSpecialListInfo(const QModelIndex &modelIndex)
|
||||||
{
|
{
|
||||||
ReadingListModel::TypeSpecialList type = (ReadingListModel::TypeSpecialList)modelIndex.data(ReadingListModel::SpecialListTypeRole).toInt();
|
ReadingListModel::TypeSpecialList type = (ReadingListModel::TypeSpecialList)modelIndex.data(ReadingListModel::SpecialListTypeRole).toInt();
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case ReadingListModel::Favorites:
|
case ReadingListModel::Favorites:
|
||||||
|
libraryWindow->comicsModel->setupFavoritesModelData(libraryWindow->foldersModel->getDatabase());
|
||||||
libraryWindow->emptySpecialList->setPixmap(QPixmap(":/images/empty_favorites.png"));
|
|
||||||
libraryWindow->emptySpecialList->setText(tr("No favorites"));
|
|
||||||
break;
|
break;
|
||||||
case ReadingListModel::Reading:
|
case ReadingListModel::Reading:
|
||||||
libraryWindow->emptySpecialList->setPixmap(QPixmap(":/images/empty_current_readings.png"));
|
libraryWindow->comicsModel->setupReadingModelData(libraryWindow->foldersModel->getDatabase());
|
||||||
libraryWindow->emptySpecialList->setText(tr("You are not reading anything yet, come on!!"));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
libraryWindow->showEmptySpecialList();
|
|
||||||
libraryWindow->disableComicsActions(true);
|
libraryWindow->comicsView->setModel(libraryWindow->comicsModel);
|
||||||
|
|
||||||
|
if(libraryWindow->comicsModel->rowCount() > 0)
|
||||||
|
{
|
||||||
|
libraryWindow->showComicsView();
|
||||||
|
libraryWindow->disableComicsActions(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//setup empty special list widget
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case ReadingListModel::Favorites:
|
||||||
|
libraryWindow->emptySpecialList->setPixmap(QPixmap(":/images/empty_favorites.png"));
|
||||||
|
libraryWindow->emptySpecialList->setText(tr("No favorites"));
|
||||||
|
break;
|
||||||
|
case ReadingListModel::Reading:
|
||||||
|
libraryWindow->emptySpecialList->setPixmap(QPixmap(":/images/empty_current_readings.png"));
|
||||||
|
libraryWindow->emptySpecialList->setText(tr("You are not reading anything yet, come on!!"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
libraryWindow->showEmptySpecialList();
|
||||||
|
libraryWindow->disableComicsActions(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderNavigationController::loadLabelInfo(const QModelIndex &modelIndex)
|
void YACReaderNavigationController::loadLabelInfo(const QModelIndex &modelIndex)
|
||||||
|
Reference in New Issue
Block a user