diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 8be8be79..8d9d2aa4 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -171,7 +171,7 @@ void MainWindowViewer::setupUI() QString pathFile = QCoreApplication::arguments().at(1); currentDirectory = pathFile; quint64 comicId = QCoreApplication::arguments().at(2).toULongLong(); - quint64 libraryId = QCoreApplication::arguments().at(3).toULongLong(); + libraryId = QCoreApplication::arguments().at(3).toULongLong(); int page = QCoreApplication::arguments().at(4).toULongLong(); enableActions(); @@ -848,7 +848,7 @@ void MainWindowViewer::closeEvent ( QCloseEvent * event ) currentComicDB.info.currentPage = viewer->getCurrentPageNumber()+1; currentComicDB.info.hasBeenOpened = true; //viewer->getBookmarks(); - client.sendComicInfo(0,currentComicDB); + client.sendComicInfo(libraryId,currentComicDB); } viewer->save(); @@ -865,8 +865,18 @@ void MainWindowViewer::closeEvent ( QCloseEvent * event ) void MainWindowViewer::openPreviousComic() { + YACReaderLocalClient client; if(!siblingComics.isEmpty()) { + + if(isClient) + { + currentComicDB.info.currentPage = viewer->getCurrentPageNumber()+1; + currentComicDB.info.hasBeenOpened = true; + //viewer->getBookmarks(); + client.sendComicInfo(libraryId,currentComicDB); + } + int currentIndex = siblingComics.indexOf(currentComicDB); if (currentIndex == -1) return; @@ -889,8 +899,17 @@ void MainWindowViewer::openPreviousComic() void MainWindowViewer::openNextComic() { + YACReaderLocalClient client; if(!siblingComics.isEmpty()) { + if(isClient) + { + currentComicDB.info.currentPage = viewer->getCurrentPageNumber()+1; + currentComicDB.info.hasBeenOpened = true; + //viewer->getBookmarks(); + client.sendComicInfo(libraryId,currentComicDB); + } + int currentIndex = siblingComics.indexOf(currentComicDB); if (currentIndex == -1) return; diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index ea762dca..cf832924 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -122,6 +122,7 @@ class YACReaderSliderAction; ComicDB currentComicDB; QList siblingComics; bool isClient; + quint64 libraryId; signals: void closed(); protected: diff --git a/YACReaderLibrary/comic_flow_widget.cpp b/YACReaderLibrary/comic_flow_widget.cpp index 2a2263c6..4e2b101a 100644 --- a/YACReaderLibrary/comic_flow_widget.cpp +++ b/YACReaderLibrary/comic_flow_widget.cpp @@ -47,7 +47,7 @@ void ComicFlowWidgetSW::setShowMarks(bool value) { flow->setShowMarks(value); } -void ComicFlowWidgetSW::setMarks(QVector marks) +void ComicFlowWidgetSW::setMarks(QVector marks) { flow->setMarks(marks); } @@ -55,9 +55,9 @@ void ComicFlowWidgetSW::setMarkImage(QImage & image) { flow->setMarkImage(image); } -void ComicFlowWidgetSW::markSlide(int index) +void ComicFlowWidgetSW::markSlide(int index, YACReaderComicReadStatus status) { - flow->markSlide(index); + flow->markSlide(index,status); } void ComicFlowWidgetSW::unmarkSlide(int index) { @@ -181,7 +181,7 @@ void ComicFlowWidgetGL::setShowMarks(bool value) { flow->setShowMarks(value); } -void ComicFlowWidgetGL::setMarks(QVector marks) +void ComicFlowWidgetGL::setMarks(QVector marks) { flow->setMarks(marks); } @@ -189,9 +189,9 @@ void ComicFlowWidgetGL::setMarkImage(QImage & image) { flow->setMarkImage(image); } -void ComicFlowWidgetGL::markSlide(int index) +void ComicFlowWidgetGL::markSlide(int index, YACReaderComicReadStatus status) { - flow->markSlide(index); + flow->markSlide(index,status); } void ComicFlowWidgetGL::unmarkSlide(int index) { diff --git a/YACReaderLibrary/comic_flow_widget.h b/YACReaderLibrary/comic_flow_widget.h index bbea3503..028d9177 100644 --- a/YACReaderLibrary/comic_flow_widget.h +++ b/YACReaderLibrary/comic_flow_widget.h @@ -16,9 +16,9 @@ public: public slots: virtual void setShowMarks(bool value) = 0; - virtual void setMarks(QVector marks) = 0; + virtual void setMarks(QVector marks) = 0; virtual void setMarkImage(QImage & image) = 0; - virtual void markSlide(int index) = 0; + virtual void markSlide(int index, YACReaderComicReadStatus status) = 0; virtual void unmarkSlide(int index) = 0; virtual void setSlideSize(QSize size) = 0; virtual void clear() = 0; @@ -46,9 +46,9 @@ public: ComicFlowWidgetSW(QWidget * parent = 0); void setShowMarks(bool value); - void setMarks(QVector marks); + void setMarks(QVector marks); void setMarkImage(QImage & image); - void markSlide(int index); + void markSlide(int index, YACReaderComicReadStatus status); void unmarkSlide(int index); void setSlideSize(QSize size); void clear(); @@ -82,9 +82,9 @@ public: ComicFlowWidgetGL(QWidget * parent = 0); void setShowMarks(bool value); - void setMarks(QVector marks); + void setMarks(QVector marks); void setMarkImage(QImage & image); - void markSlide(int index); + void markSlide(int index, YACReaderComicReadStatus status); void unmarkSlide(int index); void setSlideSize(QSize size); void clear(); diff --git a/YACReaderLibrary/db/tablemodel.cpp b/YACReaderLibrary/db/tablemodel.cpp index 01b72710..b8154751 100644 --- a/YACReaderLibrary/db/tablemodel.cpp +++ b/YACReaderLibrary/db/tablemodel.cpp @@ -10,19 +10,22 @@ #include "db_helper.h" //ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read -#define NUMBER 0 -#define TITLE 1 -#define FILE_NAME 2 -#define NUM_PAGES 3 -#define ID 4 -#define PARENT_ID 5 -#define PATH 6 -#define HASH 7 -#define READ 8 -#define IS_BIS 9 -#define CURRENT_PAGE 10 -#define RATING 11 -#define HAS_BEEN_OPENED 12 +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 +}; + TableModel::TableModel(QObject *parent) : QAbstractItemModel(parent) @@ -61,7 +64,7 @@ QVariant TableModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); - if (index.column() == RATING && role == Qt::DecorationRole) + if (index.column() == Columns::Rating && role == Qt::DecorationRole) { TableItem *item = static_cast(index.internalPointer()); return QPixmap(QString(":/images/rating%1.png").arg(item->data(index.column()).toInt())); @@ -82,7 +85,7 @@ QVariant TableModel::data(const QModelIndex &index, int role) const return QVariant(Qt::AlignRight | Qt::AlignVCenter); case 7: return QVariant(Qt::AlignRight | Qt::AlignVCenter); - case CURRENT_PAGE: + case Columns::CurrentPage: return QVariant(Qt::AlignRight | Qt::AlignVCenter); default: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); @@ -94,14 +97,14 @@ QVariant TableModel::data(const QModelIndex &index, int role) const return QVariant(); TableItem *item = static_cast(index.internalPointer()); - if(index.column() == HASH) + if(index.column() == Columns::Hash) return QString::number(item->data(index.column()).toString().right(item->data(index.column()).toString().length()-40).toInt()/1024.0/1024.0,'f',2)+"Mb"; - if(index.column() == READ) - return item->data(index.column()).toBool()?QVariant(tr("yes")):QVariant(tr("no")); - if(index.column() == CURRENT_PAGE) - return item->data(HAS_BEEN_OPENED).toBool()?item->data(index.column()):QVariant("-"); + if(index.column() == Columns::ReadColumn) + return (item->data(Columns::CurrentPage).toInt()==item->data(Columns::NumPages).toInt() || item->data(Columns::ReadColumn).toBool())?QVariant(tr("yes")):QVariant(tr("no")); + if(index.column() == Columns::CurrentPage) + return item->data(Columns::HasBeenOpened).toBool()?item->data(index.column()):QVariant("-"); - if (index.column() == RATING) + if (index.column() == Columns::Rating) return QVariant(); return item->data(index.column()); @@ -138,9 +141,9 @@ QVariant TableModel::headerData(int section, Qt::Orientation orientation, return QVariant(QString(tr("Size"))); case 8: return QVariant(QString(tr("Read"))); - case CURRENT_PAGE: + case Columns::CurrentPage: return QVariant(QString(tr("Current Page"))); - case RATING: + case Columns::Rating: return QVariant(QString(tr("Rating"))); } } @@ -155,7 +158,7 @@ QVariant TableModel::headerData(int section, Qt::Orientation orientation, return QVariant(Qt::AlignRight | Qt::AlignVCenter); case 7: return QVariant(Qt::AlignRight | Qt::AlignVCenter); - case CURRENT_PAGE: + case Columns::CurrentPage: return QVariant(Qt::AlignRight | Qt::AlignVCenter); default: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); @@ -165,7 +168,7 @@ QVariant TableModel::headerData(int section, Qt::Orientation orientation, if(orientation == Qt::Vertical && role == Qt::DecorationRole) { - QString fileName = _data.value(section)->data(FILE_NAME).toString(); + QString fileName = _data.value(section)->data(Columns::FileName).toString(); QFileInfo fi(fileName); QString ext = fi.suffix(); @@ -233,7 +236,7 @@ QStringList TableModel::getPaths(const QString & _source) QList::ConstIterator itr; for(itr = _data.constBegin();itr != _data.constEnd();itr++) { - QString hash = (*itr)->data(HASH).toString(); + QString hash = (*itr)->data(Columns::Hash).toString(); paths << source+ hash +".jpg"; } @@ -276,7 +279,7 @@ void TableModel::setupModelData(unsigned long long int folderId,const QString & QString TableModel::getComicPath(QModelIndex mi) { if(mi.isValid()) - return _data.at(mi.row())->data(PATH).toString(); + return _data.at(mi.row())->data(Columns::Path).toString(); return ""; } #define NUMBER_MAX 99999999 @@ -297,16 +300,16 @@ void TableModel::setupModelData(QSqlQuery &sqlquery) else { TableItem * last = _data.back(); - QString nameLast = last->data(FILE_NAME).toString(); - QString nameCurrent = currentItem->data(FILE_NAME).toString(); + QString nameLast = last->data(Columns::FileName).toString(); + QString nameCurrent = currentItem->data(Columns::FileName).toString(); int numberLast,numberCurrent; numberLast = numberCurrent = NUMBER_MAX; //TODO change by std limit - if(!last->data(NUMBER).isNull()) - numberLast = last->data(NUMBER).toInt(); + if(!last->data(Columns::Number).isNull()) + numberLast = last->data(Columns::Number).toInt(); - if(!currentItem->data(NUMBER).isNull()) - numberCurrent = currentItem->data(NUMBER).toInt(); + if(!currentItem->data(Columns::Number).isNull()) + numberCurrent = currentItem->data(Columns::Number).toInt(); QList::iterator i; i = _data.end(); @@ -319,8 +322,8 @@ void TableModel::setupModelData(QSqlQuery &sqlquery) i--; numberLast = NUMBER_MAX; //TODO change by std limit - if(!(*i)->data(NUMBER).isNull()) - numberLast = (*i)->data(NUMBER).toInt(); + if(!(*i)->data(Columns::Number).isNull()) + numberLast = (*i)->data(Columns::Number).toInt(); } } else @@ -328,11 +331,11 @@ void TableModel::setupModelData(QSqlQuery &sqlquery) while ((lessThan = naturalSortLessThanCI(nameCurrent,nameLast)) && i != _data.begin() && numberLast == 99999999) { i--; - nameLast = (*i)->data(FILE_NAME).toString(); + nameLast = (*i)->data(Columns::FileName).toString(); numberLast = NUMBER_MAX; //TODO change by std limit - if(!(*i)->data(NUMBER).isNull()) - numberLast = (*i)->data(NUMBER).toInt(); + if(!(*i)->data(Columns::Number).isNull()) + numberLast = (*i)->data(Columns::Number).toInt(); } } @@ -341,7 +344,7 @@ void TableModel::setupModelData(QSqlQuery &sqlquery) if(numberCurrent != NUMBER_MAX) { if(numberCurrent == numberLast) - if(currentItem->data(IS_BIS).toBool()) + if(currentItem->data(Columns::IsBis).toBool()) { _data.insert(++i,currentItem); } @@ -365,7 +368,7 @@ void TableModel::setupModelData(QSqlQuery &sqlquery) ComicDB TableModel::getComic(const QModelIndex & mi) { QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); - ComicDB c = DBHelper::loadComic(_data.at(mi.row())->data(ID).toULongLong(),db); + ComicDB c = DBHelper::loadComic(_data.at(mi.row())->data(Columns::Id).toULongLong(),db); db.close(); QSqlDatabase::removeDatabase(_databasePath); @@ -375,7 +378,7 @@ ComicDB TableModel::getComic(const QModelIndex & mi) ComicDB TableModel::_getComic(const QModelIndex & mi) { QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); - ComicDB c = DBHelper::loadComic(_data.at(mi.row())->data(ID).toULongLong(),db); + ComicDB c = DBHelper::loadComic(_data.at(mi.row())->data(Columns::Id).toULongLong(),db); db.close(); QSqlDatabase::removeDatabase(_databasePath); @@ -383,36 +386,53 @@ ComicDB TableModel::_getComic(const QModelIndex & mi) } -QVector TableModel::getReadList() +QVector TableModel::getReadList() { int numComics = _data.count(); - QVector readList(numComics); + QVector readList(numComics); for(int i=0;idata(READ).toBool(); + if(_data.value(i)->data(Columns::ReadColumn).toBool()) + readList[i] = YACReaderComicReadStatus::Read; + else if (_data.value(i)->data(Columns::CurrentPage).toInt() == _data.value(i)->data(Columns::NumPages).toInt()) + readList[i] = YACReaderComicReadStatus::Read; + else if (_data.value(i)->data(Columns::HasBeenOpened).toBool()) + readList[i] = YACReaderComicReadStatus::Opened; + else + readList[i] = YACReaderComicReadStatus::Unread; } return readList; } - -QVector TableModel::setAllComicsRead(bool read) +//TODO check other read status +QVector TableModel::setAllComicsRead(YACReaderComicReadStatus read) { QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); db.transaction(); int numComics = _data.count(); - QVector readList(numComics); + QVector readList(numComics); for(int i=0;isetData(READ,QVariant(read)); - ComicDB c = DBHelper::loadComic(_data.value(i)->data(ID).toULongLong(),db); - c.info.read = read; - DBHelper::update(&(c.info),db); + readList[i] = read; + if(read == YACReaderComicReadStatus::Read) + { + _data.value(i)->setData(Columns::ReadColumn,QVariant(true)); + ComicDB c = DBHelper::loadComic(_data.value(i)->data(Columns::Id).toULongLong(),db); + c.info.read = true; + DBHelper::update(&(c.info),db); + } + if(read == YACReaderComicReadStatus::Unread) + { + _data.value(i)->setData(Columns::ReadColumn,QVariant(false)); + ComicDB c = DBHelper::loadComic(_data.value(i)->data(Columns::Id).toULongLong(),db); + c.info.read = false; + DBHelper::update(&(c.info),db); + } } db.commit(); db.close(); QSqlDatabase::removeDatabase(_databasePath); - emit dataChanged(index(0,READ),index(numComics-1,READ)); + emit dataChanged(index(0,Columns::ReadColumn),index(numComics-1,Columns::ReadColumn)); return readList; } @@ -426,7 +446,7 @@ QList TableModel::getAllComics() int numComics = _data.count(); for(int i=0;idata(ID).toULongLong(),db)); + comics.append(DBHelper::loadComic(_data.value(i)->data(Columns::Id).toULongLong(),db)); } db.commit(); @@ -452,23 +472,33 @@ QList TableModel::getComics(QList list) QSqlDatabase::removeDatabase(_databasePath); return comics; } - -QVector TableModel::setComicsRead(QList list,bool read) +//TODO +QVector TableModel::setComicsRead(QList list,YACReaderComicReadStatus read) { QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); db.transaction(); foreach (QModelIndex mi, list) { - _data.value(mi.row())->setData(READ, QVariant(read)); - ComicDB c = DBHelper::loadComic(_data.value(mi.row())->data(ID).toULongLong(),db); - c.info.read = read; + if(read == YACReaderComicReadStatus::Read) + { + _data.value(mi.row())->setData(Columns::ReadColumn, QVariant(true)); + ComicDB c = DBHelper::loadComic(_data.value(mi.row())->data(Columns::Id).toULongLong(),db); + c.info.read = true; DBHelper::update(&(c.info),db); + } + if(read == YACReaderComicReadStatus::Unread) + { + _data.value(mi.row())->setData(Columns::ReadColumn, QVariant(false)); + ComicDB c = DBHelper::loadComic(_data.value(mi.row())->data(Columns::Id).toULongLong(),db); + c.info.read = false; + DBHelper::update(&(c.info),db); + } } db.commit(); db.close(); QSqlDatabase::removeDatabase(_databasePath); - emit dataChanged(index(list.first().row(),READ),index(list.last().row(),READ)); + emit dataChanged(index(list.first().row(),Columns::ReadColumn),index(list.last().row(),Columns::ReadColumn)); return getReadList(); } @@ -476,11 +506,11 @@ qint64 TableModel::asignNumbers(QList list,int startingNumber) { QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); db.transaction(); - qint64 idFirst = _data.value(list[0].row())->data(ID).toULongLong(); + qint64 idFirst = _data.value(list[0].row())->data(Columns::Id).toULongLong(); int i = 0; foreach (QModelIndex mi, list) { - ComicDB c = DBHelper::loadComic(_data.value(mi.row())->data(ID).toULongLong(),db); + ComicDB c = DBHelper::loadComic(_data.value(mi.row())->data(Columns::Id).toULongLong(),db); c.info.setNumber(startingNumber+i); c.info.edited = true; DBHelper::update(&(c.info),db); @@ -501,7 +531,7 @@ QModelIndex TableModel::getIndexFromId(quint64 id) int i=0; for(itr = _data.constBegin();itr != _data.constEnd();itr++) { - if((*itr)->data(ID).toULongLong() == id) + if((*itr)->data(Columns::Id).toULongLong() == id) break; i++; } @@ -527,7 +557,7 @@ void TableModel::finishTransaction() void TableModel::removeInTransaction(int row) { - ComicDB c = DBHelper::loadComic(_data.at(row)->data(ID).toULongLong(),dbTransaction); + ComicDB c = DBHelper::loadComic(_data.at(row)->data(Columns::Id).toULongLong(),dbTransaction); DBHelper::removeFromDB(&c,dbTransaction); beginRemoveRows(QModelIndex(),row,row); @@ -570,16 +600,16 @@ void TableModel::reload(const ComicDB & comic) bool found = false; foreach(TableItem * item,_data) { - if(item->data(ID).toULongLong() == comic.id) + if(item->data(Columns::Id).toULongLong() == comic.id) { found = true; - item->setData(CURRENT_PAGE,comic.info.currentPage); - item->setData(HAS_BEEN_OPENED,true); + item->setData(Columns::CurrentPage,comic.info.currentPage); + item->setData(Columns::HasBeenOpened,true); break; } row++; } if(found) - emit dataChanged(index(row,CURRENT_PAGE),index(row,CURRENT_PAGE)); + emit dataChanged(index(row,Columns::CurrentPage),index(row,Columns::CurrentPage)); } \ No newline at end of file diff --git a/YACReaderLibrary/db/tablemodel.h b/YACReaderLibrary/db/tablemodel.h index 90902009..76dd4e9b 100644 --- a/YACReaderLibrary/db/tablemodel.h +++ b/YACReaderLibrary/db/tablemodel.h @@ -7,6 +7,8 @@ #include #include +#include "yacreader_global.h" + class ComicDB; class TableItem; @@ -38,15 +40,15 @@ public: QString getComicPath(QModelIndex mi); ComicDB getComic(const QModelIndex & mi); //--> para la edición ComicDB getComic(int row); - QVector getReadList(); - QVector setAllComicsRead(bool read); + QVector getReadList(); + QVector setAllComicsRead(YACReaderComicReadStatus readStatus); QList getComics(QList list); //--> recupera la información común a los comics seleccionados QList getAllComics(); QModelIndex getIndexFromId(quint64 id); //setcomicInfo(QModelIndex & mi); --> inserta en la base datos //setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez. //setComicInfoForSelectedComis(QList list); -->inserta la información común para los comics seleccionados - QVector setComicsRead(QList list,bool read); + QVector setComicsRead(QList list,YACReaderComicReadStatus read); qint64 asignNumbers(QList list,int startingNumber); void remove(ComicDB * comic, int row); void removeInTransaction(int row); diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc index 7014df9d..1ca334b3 100644 --- a/YACReaderLibrary/images.qrc +++ b/YACReaderLibrary/images.qrc @@ -53,6 +53,7 @@ ../images/clearSearch.png ../images/iconSearch.png ../images/readRibbon.png + ../images/readingRibbon.png ../images/shownCovers.png ../images/hiddenCovers.png ../images/trash.png diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index e7d516f8..5c1507b8 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1017,42 +1017,47 @@ void LibraryWindow::openComic() #ifdef Q_OS_MAC QProcess::startDetached("open", QStringList() << "-n" << QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app") << "--args" << path << comicId << libraryId << page);//,QStringList() << path); - //Comic is readed #else QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\" \"%2\" \"%3\" \"%4\"").arg(path).arg(comicId).arg(libraryId).arg(page),QStringList()); #endif //Comic is readed - setCurrentComicReaded(); + //setCurrentComicReaded(); + setCurrentComicOpened(); } } -void LibraryWindow::setCurrentComicsStatusReaded(bool readed) +void LibraryWindow::setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus) { - comicFlow->setMarks(dmCV->setComicsRead(getSelectedComics(),readed)); + comicFlow->setMarks(dmCV->setComicsRead(getSelectedComics(),readStatus)); comicFlow->updateMarks(); } void LibraryWindow::setCurrentComicReaded() { - this->setCurrentComicsStatusReaded(true); + this->setCurrentComicsStatusReaded(YACReaderComicReadStatus::Read); +} + +void LibraryWindow::setCurrentComicOpened() +{ + } void LibraryWindow::setComicsReaded() { - comicFlow->setMarks(dmCV->setAllComicsRead(true)); + comicFlow->setMarks(dmCV->setAllComicsRead(YACReaderComicReadStatus::Read)); comicFlow->updateMarks(); } void LibraryWindow::setCurrentComicUnreaded() { - this->setCurrentComicsStatusReaded(false); + this->setCurrentComicsStatusReaded(YACReaderComicReadStatus::Unread); } void LibraryWindow::setComicsUnreaded() { - comicFlow->setMarks(dmCV->setAllComicsRead(false)); + comicFlow->setMarks(dmCV->setAllComicsRead(YACReaderComicReadStatus::Unread)); comicFlow->updateMarks(); } @@ -1689,7 +1694,12 @@ void LibraryWindow::importLibraryPackage() importLibraryDialog->show(libraries); } -void LibraryWindow::updateComicsView(const ComicDB & comic) +void LibraryWindow::updateComicsView(quint64 libraryId, const ComicDB & comic) { - dmCV->reload(comic); + //TODO comprobar la biblioteca.... + if(libraryId == selectedLibrary->currentIndex()) + { + dmCV->reload(comic); + comicFlow->setMarks(dmCV->getReadList()); + } } \ No newline at end of file diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index cd570b98..7081302b 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -5,6 +5,7 @@ #include #include #include +#include "yacreader_global.h" class QTreeView; class QDirModel; @@ -238,7 +239,7 @@ public: void exportLibrary(QString destPath); void importLibrary(QString clc,QString destPath,QString name); void reloadOptions(); - void setCurrentComicsStatusReaded(bool readed); + void setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus); void setCurrentComicReaded(); void setCurrentComicUnreaded(); void setComicsReaded(); @@ -261,7 +262,8 @@ public: void updateHistory(const QModelIndex & mi); void libraryAlreadyExists(const QString & name); void importLibraryPackage(); - void updateComicsView(const ComicDB & comic); + void updateComicsView(quint64 libraryId, const ComicDB & comic); + void setCurrentComicOpened(); }; diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 0f5f6e31..22875a11 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -49,7 +49,7 @@ int main( int argc, char ** argv ) LibraryWindow * mw = new LibraryWindow(); - mw->connect(localServer,SIGNAL(comicUpdated(const ComicDB &)),mw,SLOT(updateComicsView(const ComicDB &))); + mw->connect(localServer,SIGNAL(comicUpdated(quint64, const ComicDB &)),mw,SLOT(updateComicsView(quint64, const ComicDB &))); //connections to localServer diff --git a/YACReaderLibrary/yacreader_local_server.cpp b/YACReaderLibrary/yacreader_local_server.cpp index eab24fa8..52e18ca7 100644 --- a/YACReaderLibrary/yacreader_local_server.cpp +++ b/YACReaderLibrary/yacreader_local_server.cpp @@ -97,7 +97,7 @@ void YACReaderLocalServer::getComicInfo(quint64 libraryId, ComicDB & comic, QLis void YACReaderLocalServer::updateComic(quint64 libraryId, ComicDB & comic) { DBHelper::update(DBHelper::getLibrariesNames().at(libraryId), comic.info); - emit comicUpdated(comic); + emit comicUpdated(libraryId, comic); } bool YACReaderLocalServer::isRunning() diff --git a/YACReaderLibrary/yacreader_local_server.h b/YACReaderLibrary/yacreader_local_server.h index b6b65a7f..9d7225c1 100644 --- a/YACReaderLibrary/yacreader_local_server.h +++ b/YACReaderLibrary/yacreader_local_server.h @@ -13,7 +13,7 @@ public: explicit YACReaderLocalServer(QObject *parent = 0); signals: - void comicUpdated(const ComicDB & comic); + void comicUpdated(quint64 libraryId, const ComicDB & comic); public slots: bool isListening(); void sendResponse(); diff --git a/common/pictureflow.cpp b/common/pictureflow.cpp index 351543eb..3946d08c 100644 --- a/common/pictureflow.cpp +++ b/common/pictureflow.cpp @@ -192,7 +192,7 @@ public: PictureFlow::ReflectionEffect reflectionEffect; QVector slideImages; - QVector marks; + QVector marks; bool showMarks; QImage mark; @@ -1076,7 +1076,7 @@ void PictureFlow::addSlide(const QImage& image) d->state->slideImages.resize(c+1); d->state->slideImages[c] = new QImage(image); d->state->marks.resize(c+1); - d->state->marks[c] = false; + d->state->marks[c] = YACReaderComicReadStatus::Unread; triggerRender(); } @@ -1345,10 +1345,10 @@ void PictureFlow::setMarkImage(const QImage & m) d->state->mark = m; } -void PictureFlow::markSlide(int index) +void PictureFlow::markSlide(int index, YACReaderComicReadStatus readStatus) { if(indexstate->marks.size()) - d->state->marks[index] = true; + d->state->marks[index] = readStatus; } void PictureFlow::updateMarks() @@ -1361,10 +1361,10 @@ void PictureFlow::updateMarks() void PictureFlow::unmarkSlide(int index) { if(indexstate->marks.size()) - d->state->marks[index] = false; + d->state->marks[index] = YACReaderComicReadStatus::Unread; } -void PictureFlow::setMarks(const QVector & m) +void PictureFlow::setMarks(const QVector & m) { d->state->marks = m; updateMarks(); @@ -1376,7 +1376,7 @@ void PictureFlow::setShowMarks(bool enable) updateMarks(); } -QVector PictureFlow::getMarks() +QVector PictureFlow::getMarks() { return d->state->marks; } diff --git a/common/pictureflow.h b/common/pictureflow.h index 51cfe257..28c05307 100644 --- a/common/pictureflow.h +++ b/common/pictureflow.h @@ -189,17 +189,17 @@ public slots: void setMarkImage(const QImage & mark); - void markSlide(int index); + void markSlide(int index, YACReaderComicReadStatus readStatus = Read); void updateMarks(); void unmarkSlide(int index); - void setMarks(const QVector & marks); + void setMarks(const QVector & marks); void setShowMarks(bool enable); - QVector getMarks(); + QVector getMarks(); signals: @@ -218,7 +218,6 @@ private slots: private: PictureFlowPrivate* d; QImage mark; - QVector marks; int framesSkip; }; diff --git a/common/yacreader_flow_gl.cpp b/common/yacreader_flow_gl.cpp index 16e2d4b1..801af4a2 100644 --- a/common/yacreader_flow_gl.cpp +++ b/common/yacreader_flow_gl.cpp @@ -280,7 +280,7 @@ void YACReaderFlowGL::initializeGL() defaultTexture = bindTexture(QImage(":/images/defaultCover.png"),GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); markTexture = bindTexture(QImage(":/images/readRibbon.png"),GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); - + readingTexture = bindTexture(QImage(":/images/readingRibbon.png"),GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); if(lazyPopulateObjects!=-1) populate(lazyPopulateObjects); @@ -454,10 +454,13 @@ void YACReaderFlowGL::drawCover(CFImage *CF) glEnd(); glDisable(GL_TEXTURE_2D); - if(showMarks && loaded[CF->index] && marks[CF->index]) + if(showMarks && loaded[CF->index] && marks[CF->index] != Unread) { glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, markTexture); + if(marks[CF->index] == Read) + glBindTexture(GL_TEXTURE_2D, markTexture); + else + glBindTexture(GL_TEXTURE_2D, readingTexture); glBegin(GL_QUADS); //esquina inferior izquierda @@ -866,7 +869,7 @@ void YACReaderFlowGL::setShowMarks(bool value) { showMarks = value; } -void YACReaderFlowGL::setMarks(QVector marks) +void YACReaderFlowGL::setMarks(QVector marks) { this->marks = marks; } @@ -876,13 +879,13 @@ void YACReaderFlowGL::setMarkImage(QImage & image) //deleteTexture(markTexture); //markTexture = bindTexture(image,GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); } -void YACReaderFlowGL::markSlide(int index) +void YACReaderFlowGL::markSlide(int index, YACReaderComicReadStatus status) { - marks[index] = true; + marks[index] = status; } void YACReaderFlowGL::unmarkSlide(int index) { - marks[index] = false; + marks[index] = YACReaderComicReadStatus::Unread; } void YACReaderFlowGL::setSlideSize(QSize size) { diff --git a/common/yacreader_flow_gl.h b/common/yacreader_flow_gl.h index 323db5a5..9be46610 100644 --- a/common/yacreader_flow_gl.h +++ b/common/yacreader_flow_gl.h @@ -127,6 +127,7 @@ protected: GLuint defaultTexture; GLuint markTexture; + GLuint readingTexture; void initializeGL(); void paintGL(); void timerEvent(QTimerEvent *); @@ -136,7 +137,7 @@ protected: int lazyPopulateObjects; bool showMarks; QVector loaded; - QVector marks; + QVector marks; QList paths; CFImage * cfImages; bool hasBeenInitialized; @@ -247,9 +248,9 @@ public: //interface with yacreaderlibrary, compatibility void setShowMarks(bool value); - void setMarks(QVector marks); + void setMarks(QVector marks); void setMarkImage(QImage & image); - void markSlide(int index); + void markSlide(int index, YACReaderComicReadStatus status); void unmarkSlide(int index); void setSlideSize(QSize size); void clear(); diff --git a/common/yacreader_global.h b/common/yacreader_global.h index 9186a716..d9975cb9 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -67,5 +67,12 @@ SendComicInfo, }; + enum YACReaderComicReadStatus + { + Unread = 0, + Read = 1, + Opened = 2 + }; + #endif diff --git a/images/readRibbon.png b/images/readRibbon.png index f1a862c0..43bbdf7a 100644 Binary files a/images/readRibbon.png and b/images/readRibbon.png differ diff --git a/images/readingRibbon.png b/images/readingRibbon.png new file mode 100644 index 00000000..816f2d81 Binary files /dev/null and b/images/readingRibbon.png differ