mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Reading status added
sending comic info to yacreaderlibrary on openNext/openPrevious
This commit is contained in:
parent
020219a3a4
commit
79fe9a3f2d
@ -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;
|
||||
|
@ -122,6 +122,7 @@ class YACReaderSliderAction;
|
||||
ComicDB currentComicDB;
|
||||
QList<ComicDB> siblingComics;
|
||||
bool isClient;
|
||||
quint64 libraryId;
|
||||
signals:
|
||||
void closed();
|
||||
protected:
|
||||
|
@ -47,7 +47,7 @@ void ComicFlowWidgetSW::setShowMarks(bool value)
|
||||
{
|
||||
flow->setShowMarks(value);
|
||||
}
|
||||
void ComicFlowWidgetSW::setMarks(QVector<bool> marks)
|
||||
void ComicFlowWidgetSW::setMarks(QVector<YACReaderComicReadStatus> 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<bool> marks)
|
||||
void ComicFlowWidgetGL::setMarks(QVector<YACReaderComicReadStatus> 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)
|
||||
{
|
||||
|
@ -16,9 +16,9 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual void setShowMarks(bool value) = 0;
|
||||
virtual void setMarks(QVector<bool> marks) = 0;
|
||||
virtual void setMarks(QVector<YACReaderComicReadStatus> 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<bool> marks);
|
||||
void setMarks(QVector<YACReaderComicReadStatus> 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<bool> marks);
|
||||
void setMarks(QVector<YACReaderComicReadStatus> 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();
|
||||
|
@ -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<TableItem*>(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<TableItem*>(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<TableItem *>::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<TableItem *>::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<bool> TableModel::getReadList()
|
||||
QVector<YACReaderComicReadStatus> TableModel::getReadList()
|
||||
{
|
||||
int numComics = _data.count();
|
||||
QVector<bool> readList(numComics);
|
||||
QVector<YACReaderComicReadStatus> readList(numComics);
|
||||
for(int i=0;i<numComics;i++)
|
||||
{
|
||||
readList[i] = _data.value(i)->data(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<bool> TableModel::setAllComicsRead(bool read)
|
||||
//TODO check other read status
|
||||
QVector<YACReaderComicReadStatus> TableModel::setAllComicsRead(YACReaderComicReadStatus read)
|
||||
{
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
db.transaction();
|
||||
int numComics = _data.count();
|
||||
QVector<bool> readList(numComics);
|
||||
QVector<YACReaderComicReadStatus> readList(numComics);
|
||||
for(int i=0;i<numComics;i++)
|
||||
{
|
||||
readList[i] = read;
|
||||
_data.value(i)->setData(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<ComicDB> TableModel::getAllComics()
|
||||
int numComics = _data.count();
|
||||
for(int i=0;i<numComics;i++)
|
||||
{
|
||||
comics.append(DBHelper::loadComic(_data.value(i)->data(ID).toULongLong(),db));
|
||||
comics.append(DBHelper::loadComic(_data.value(i)->data(Columns::Id).toULongLong(),db));
|
||||
}
|
||||
|
||||
db.commit();
|
||||
@ -452,23 +472,33 @@ QList<ComicDB> TableModel::getComics(QList<QModelIndex> list)
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
return comics;
|
||||
}
|
||||
|
||||
QVector<bool> TableModel::setComicsRead(QList<QModelIndex> list,bool read)
|
||||
//TODO
|
||||
QVector<YACReaderComicReadStatus> TableModel::setComicsRead(QList<QModelIndex> 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<QModelIndex> 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));
|
||||
}
|
@ -7,6 +7,8 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
#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<bool> getReadList();
|
||||
QVector<bool> setAllComicsRead(bool read);
|
||||
QVector<YACReaderComicReadStatus> getReadList();
|
||||
QVector<YACReaderComicReadStatus> setAllComicsRead(YACReaderComicReadStatus readStatus);
|
||||
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la información común a los comics seleccionados
|
||||
QList<ComicDB> 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<QModelIndex> list); -->inserta la información común para los comics seleccionados
|
||||
QVector<bool> setComicsRead(QList<QModelIndex> list,bool read);
|
||||
QVector<YACReaderComicReadStatus> setComicsRead(QList<QModelIndex> list,YACReaderComicReadStatus read);
|
||||
qint64 asignNumbers(QList<QModelIndex> list,int startingNumber);
|
||||
void remove(ComicDB * comic, int row);
|
||||
void removeInTransaction(int row);
|
||||
|
@ -53,6 +53,7 @@
|
||||
<file>../images/clearSearch.png</file>
|
||||
<file>../images/iconSearch.png</file>
|
||||
<file>../images/readRibbon.png</file>
|
||||
<file>../images/readingRibbon.png</file>
|
||||
<file>../images/shownCovers.png</file>
|
||||
<file>../images/hiddenCovers.png</file>
|
||||
<file>../images/trash.png</file>
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
#include <QMap>
|
||||
#include <QModelIndex>
|
||||
#include <QFileInfo>
|
||||
#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();
|
||||
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
|
@ -192,7 +192,7 @@ public:
|
||||
PictureFlow::ReflectionEffect reflectionEffect;
|
||||
QVector<QImage*> slideImages;
|
||||
|
||||
QVector<bool> marks;
|
||||
QVector<YACReaderComicReadStatus> 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(index<d->state->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(index<d->state->marks.size())
|
||||
d->state->marks[index] = false;
|
||||
d->state->marks[index] = YACReaderComicReadStatus::Unread;
|
||||
}
|
||||
|
||||
void PictureFlow::setMarks(const QVector<bool> & m)
|
||||
void PictureFlow::setMarks(const QVector<YACReaderComicReadStatus> & m)
|
||||
{
|
||||
d->state->marks = m;
|
||||
updateMarks();
|
||||
@ -1376,7 +1376,7 @@ void PictureFlow::setShowMarks(bool enable)
|
||||
updateMarks();
|
||||
}
|
||||
|
||||
QVector<bool> PictureFlow::getMarks()
|
||||
QVector<YACReaderComicReadStatus > PictureFlow::getMarks()
|
||||
{
|
||||
return d->state->marks;
|
||||
}
|
||||
|
@ -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<bool> & marks);
|
||||
void setMarks(const QVector<YACReaderComicReadStatus> & marks);
|
||||
|
||||
void setShowMarks(bool enable);
|
||||
|
||||
QVector<bool> getMarks();
|
||||
QVector<YACReaderComicReadStatus> getMarks();
|
||||
|
||||
|
||||
signals:
|
||||
@ -218,7 +218,6 @@ private slots:
|
||||
private:
|
||||
PictureFlowPrivate* d;
|
||||
QImage mark;
|
||||
QVector<bool> marks;
|
||||
int framesSkip;
|
||||
};
|
||||
|
||||
|
@ -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<bool> marks)
|
||||
void YACReaderFlowGL::setMarks(QVector<YACReaderComicReadStatus> 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)
|
||||
{
|
||||
|
@ -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<bool> loaded;
|
||||
QVector<bool> marks;
|
||||
QVector<YACReaderComicReadStatus> marks;
|
||||
QList<QString> paths;
|
||||
CFImage * cfImages;
|
||||
bool hasBeenInitialized;
|
||||
@ -247,9 +248,9 @@ public:
|
||||
|
||||
//interface with yacreaderlibrary, compatibility
|
||||
void setShowMarks(bool value);
|
||||
void setMarks(QVector<bool> marks);
|
||||
void setMarks(QVector<YACReaderComicReadStatus> 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();
|
||||
|
@ -67,5 +67,12 @@
|
||||
SendComicInfo,
|
||||
};
|
||||
|
||||
enum YACReaderComicReadStatus
|
||||
{
|
||||
Unread = 0,
|
||||
Read = 1,
|
||||
Opened = 2
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 7.8 KiB |
BIN
images/readingRibbon.png
Normal file
BIN
images/readingRibbon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
Loading…
Reference in New Issue
Block a user