Current comic view only makes sense for folders and reading lists.

This commit is contained in:
Luis Ángel San Martín 2018-05-22 18:45:12 +02:00
parent 4be84c6845
commit 450997762e
2 changed files with 53 additions and 45 deletions

View File

@ -21,6 +21,50 @@ class ComicModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum Columns {
Number = 0,
Title = 1,
FileName = 2,
NumPages = 3,
Id = 4,
Parent_Id = 5,
Path = 6,
Hash = 7,
ReadColumn = 8,
IsBis = 9,
CurrentPage = 10,
Rating = 11,
HasBeenOpened = 12
};
enum Roles {
NumberRole = Qt::UserRole + 1,
TitleRole,
FileNameRole,
NumPagesRole,
IdRole,
Parent_IdRole,
PathRole,
HashRole,
ReadColumnRole,
IsBisRole,
CurrentPageRole,
RatingRole,
HasBeenOpenedRole,
CoverPathRole
};
enum Mode {
Folder,
Favorites,
Reading,
Label,
ReadingList
};
public:
ComicModel(QObject *parent = 0);
ComicModel( QSqlQuery &sqlquery, QObject *parent = 0);
@ -86,52 +130,10 @@ public:
bool isFavorite(const QModelIndex &index);
ComicModel::Mode getMode() {return mode;}
QHash<int, QByteArray> roleNames() const;
enum Columns {
Number = 0,
Title = 1,
FileName = 2,
NumPages = 3,
Id = 4,
Parent_Id = 5,
Path = 6,
Hash = 7,
ReadColumn = 8,
IsBis = 9,
CurrentPage = 10,
Rating = 11,
HasBeenOpened = 12
};
enum Roles {
NumberRole = Qt::UserRole + 1,
TitleRole,
FileNameRole,
NumPagesRole,
IdRole,
Parent_IdRole,
PathRole,
HashRole,
ReadColumnRole,
IsBisRole,
CurrentPageRole,
RatingRole,
HasBeenOpenedRole,
CoverPathRole
};
enum Mode {
Folder,
Favorites,
Reading,
Label,
ReadingList
};
public slots:
void remove(int row);
void startTransaction();

View File

@ -455,7 +455,13 @@ void GridComicsView::setCurrentComicIfNeeded()
QQmlContext *ctxt = view->rootContext();
if (found && filterEnabled == false) {
ComicModel::Mode mode = model->getMode();
bool showCurrentComic = found &&
filterEnabled == false &&
(mode == ComicModel::Mode::Folder || mode == ComicModel::Mode::ReadingList);
if (showCurrentComic) {
ctxt->setContextProperty("currentComic", &currentComic);
ctxt->setContextProperty("currentComicInfo", &(currentComic.info));
ctxt->setContextProperty("showCurrentComic", true);