mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added comicVineID field to the data base, if the comic information has been scraped the properties dialog shows a link to the Comic Vine page with the comic information
This commit is contained in:
parent
498f71afb2
commit
d6ace428ad
@ -418,7 +418,9 @@ void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingIn
|
|||||||
QByteArray result = comicVineClient->getComicDetail(p.second,error,timeout); //TODO check timeOut or Connection error
|
QByteArray result = comicVineClient->getComicDetail(p.second,error,timeout); //TODO check timeOut or Connection error
|
||||||
if(error || timeout)
|
if(error || timeout)
|
||||||
continue; //TODO
|
continue; //TODO
|
||||||
comics.push_back(parseComicInfo(p.first,result,count,publisher)); //TODO check result error
|
ComicDB comic = parseComicInfo(p.first,result,count,publisher);//TODO check result error
|
||||||
|
comic.info.comicVineID = p.second;
|
||||||
|
comics.push_back(comic);
|
||||||
|
|
||||||
setLoadingMessage(tr("Retrieving tags for : %1").arg(p.first.getFileName()));
|
setLoadingMessage(tr("Retrieving tags for : %1").arg(p.first.getFileName()));
|
||||||
}
|
}
|
||||||
@ -459,7 +461,7 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr
|
|||||||
}
|
}
|
||||||
|
|
||||||
ComicDB comic = parseComicInfo(comics[currentIndex],result,count,publisher); //TODO check result error
|
ComicDB comic = parseComicInfo(comics[currentIndex],result,count,publisher); //TODO check result error
|
||||||
|
comic.info.comicVineID = comicId;
|
||||||
setLoadingMessage(tr("Retrieving tags for : %1").arg(comics[currentIndex].getFileName()));
|
setLoadingMessage(tr("Retrieving tags for : %1").arg(comics[currentIndex].getFileName()));
|
||||||
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
||||||
|
@ -37,6 +37,8 @@ static QString fields = "title ,"
|
|||||||
"characters,"
|
"characters,"
|
||||||
"notes,"
|
"notes,"
|
||||||
|
|
||||||
|
"comicVineID,"
|
||||||
|
|
||||||
"hash"
|
"hash"
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -179,8 +181,11 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
|||||||
"bookmark3 INTEGER DEFAULT -1, "
|
"bookmark3 INTEGER DEFAULT -1, "
|
||||||
"brightness INTEGER DEFAULT -1, "
|
"brightness INTEGER DEFAULT -1, "
|
||||||
"contrast INTEGER DEFAULT -1, "
|
"contrast INTEGER DEFAULT -1, "
|
||||||
"gamma INTEGER DEFAULT -1 "
|
"gamma INTEGER DEFAULT -1, "
|
||||||
")");
|
//new 7.1 fields
|
||||||
|
"comicVineID TEXT"
|
||||||
|
|
||||||
|
")");
|
||||||
success = success && queryComicInfo.exec();
|
success = success && queryComicInfo.exec();
|
||||||
//queryComicInfo.finish();
|
//queryComicInfo.finish();
|
||||||
|
|
||||||
@ -304,7 +309,9 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
|||||||
"characters = :characters,"
|
"characters = :characters,"
|
||||||
"notes = :notes,"
|
"notes = :notes,"
|
||||||
|
|
||||||
"edited = :edited"
|
"edited = :edited,"
|
||||||
|
|
||||||
|
"comicVineID = :comicVineID"
|
||||||
|
|
||||||
" WHERE hash = :hash ");
|
" WHERE hash = :hash ");
|
||||||
|
|
||||||
@ -337,6 +344,7 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
|||||||
"notes,"
|
"notes,"
|
||||||
"read,"
|
"read,"
|
||||||
"edited,"
|
"edited,"
|
||||||
|
"comicVineID,"
|
||||||
"hash)"
|
"hash)"
|
||||||
|
|
||||||
"VALUES (:title,"
|
"VALUES (:title,"
|
||||||
@ -372,6 +380,7 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
|||||||
|
|
||||||
":read,"
|
":read,"
|
||||||
":edited,"
|
":edited,"
|
||||||
|
":comicVineID,"
|
||||||
|
|
||||||
":hash )");
|
":hash )");
|
||||||
|
|
||||||
@ -445,7 +454,7 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
|||||||
return b;
|
return b;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//TODO fix these bindings
|
||||||
void DataBaseManagement::bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query)
|
void DataBaseManagement::bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query)
|
||||||
{
|
{
|
||||||
bindString("title",record,query);
|
bindString("title",record,query);
|
||||||
@ -481,7 +490,22 @@ void DataBaseManagement::bindValuesFromRecord(const QSqlRecord & record, QSqlQue
|
|||||||
bindString("characters",record,query);
|
bindString("characters",record,query);
|
||||||
bindString("notes",record,query);
|
bindString("notes",record,query);
|
||||||
|
|
||||||
bindString("hash",record,query);
|
bindString("comicVineID",record,query);
|
||||||
|
|
||||||
|
bindString("hash",record,query);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBaseManagement::addColumns(const QString &tableName, const QStringList &columnDefs, const QSqlDatabase &db)
|
||||||
|
{
|
||||||
|
QString sql = "ALTER TABLE %1 ADD COLUMN %2";
|
||||||
|
foreach(QString columnDef, columnDefs)
|
||||||
|
{
|
||||||
|
QSqlQuery alterTableComicInfo(db);
|
||||||
|
alterTableComicInfo.prepare(sql.arg(tableName).arg(columnDef));
|
||||||
|
//alterTableComicInfo.bindValue(":column_def",columnDef);
|
||||||
|
alterTableComicInfo.exec();
|
||||||
|
return (alterTableComicInfo.numRowsAffected() > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataBaseManagement::bindString(const QString & name, const QSqlRecord & record, QSqlQuery & query)
|
void DataBaseManagement::bindString(const QString & name, const QSqlRecord & record, QSqlQuery & query)
|
||||||
@ -552,8 +576,11 @@ int DataBaseManagement::compareVersions(const QString & v1, const QString v2)
|
|||||||
bool DataBaseManagement::updateToCurrentVersion(const QString & fullPath)
|
bool DataBaseManagement::updateToCurrentVersion(const QString & fullPath)
|
||||||
{
|
{
|
||||||
bool pre7 = false;
|
bool pre7 = false;
|
||||||
|
bool pre7_1 = false;
|
||||||
if(compareVersions(DataBaseManagement::checkValidDB(fullPath),"7.0.0")<0)
|
if(compareVersions(DataBaseManagement::checkValidDB(fullPath),"7.0.0")<0)
|
||||||
pre7 = true;
|
pre7 = true;
|
||||||
|
if(compareVersions(DataBaseManagement::checkValidDB(fullPath),"7.0.3")<0)
|
||||||
|
pre7_1 = true;
|
||||||
|
|
||||||
QSqlDatabase db = loadDatabaseFromFile(fullPath);
|
QSqlDatabase db = loadDatabaseFromFile(fullPath);
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
@ -581,17 +608,17 @@ bool DataBaseManagement::updateToCurrentVersion(const QString & fullPath)
|
|||||||
<< "brightness INTEGER DEFAULT -1"
|
<< "brightness INTEGER DEFAULT -1"
|
||||||
<< "contrast INTEGER DEFAULT -1"
|
<< "contrast INTEGER DEFAULT -1"
|
||||||
<< "gamma INTEGER DEFAULT -1";
|
<< "gamma INTEGER DEFAULT -1";
|
||||||
QString sql = "ALTER TABLE comic_info ADD COLUMN %1";
|
|
||||||
foreach(QString columnDef, columnDefs)
|
returnValue = returnValue && addColumns("comic_info", columnDefs, db);
|
||||||
{
|
|
||||||
QSqlQuery alterTableComicInfo(db);
|
|
||||||
alterTableComicInfo.prepare(sql.arg(columnDef));
|
|
||||||
//alterTableComicInfo.bindValue(":column_def",columnDef);
|
|
||||||
alterTableComicInfo.exec();
|
|
||||||
returnValue = returnValue && (alterTableComicInfo.numRowsAffected() > 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//TODO update hasBeenOpened value
|
//TODO update hasBeenOpened value
|
||||||
|
|
||||||
|
if(pre7_1)
|
||||||
|
{
|
||||||
|
QStringList columnDefs;
|
||||||
|
columnDefs << "comicVineID TEXT DEFAULT NULL";
|
||||||
|
returnValue = returnValue && addColumns("comic_info", columnDefs, db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
@ -37,6 +37,8 @@ private:
|
|||||||
static void bindInt(const QString & name, const QSqlRecord & record, QSqlQuery & query);
|
static void bindInt(const QString & name, const QSqlRecord & record, QSqlQuery & query);
|
||||||
static void bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query);
|
static void bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query);
|
||||||
|
|
||||||
|
static bool addColumns(const QString & tableName, const QStringList & columnDefs, const QSqlDatabase & db);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataBaseManagement();
|
DataBaseManagement();
|
||||||
//TreeModel * newTreeModel(QString path);
|
//TreeModel * newTreeModel(QString path);
|
||||||
@ -56,4 +58,4 @@ public:
|
|||||||
static bool updateToCurrentVersion(const QString & path);
|
static bool updateToCurrentVersion(const QString & path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -212,7 +212,10 @@ void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
|||||||
"brightness = :brightness,"
|
"brightness = :brightness,"
|
||||||
"contrast = :contrast, "
|
"contrast = :contrast, "
|
||||||
"gamma = :gamma,"
|
"gamma = :gamma,"
|
||||||
"rating = :rating"
|
"rating = :rating,"
|
||||||
|
|
||||||
|
//new 7.1 fields
|
||||||
|
"comicVineID = :comicVineID"
|
||||||
//--
|
//--
|
||||||
" WHERE id = :id ");
|
" WHERE id = :id ");
|
||||||
|
|
||||||
@ -263,6 +266,8 @@ void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
|||||||
updateComicInfo.bindValue(":gamma", comicInfo->gamma);
|
updateComicInfo.bindValue(":gamma", comicInfo->gamma);
|
||||||
updateComicInfo.bindValue(":rating", comicInfo->rating);
|
updateComicInfo.bindValue(":rating", comicInfo->rating);
|
||||||
|
|
||||||
|
updateComicInfo.bindValue(":comicVineID", comicInfo->comicVineID);
|
||||||
|
|
||||||
updateComicInfo.exec();
|
updateComicInfo.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,6 +646,8 @@ ComicInfo DBHelper::loadComicInfo(QString hash, QSqlDatabase & db)
|
|||||||
comicInfo.characters = record.value("characters");
|
comicInfo.characters = record.value("characters");
|
||||||
comicInfo.notes = record.value("notes");
|
comicInfo.notes = record.value("notes");
|
||||||
|
|
||||||
|
comicInfo.comicVineID = record.value("comicVineID");
|
||||||
|
|
||||||
comicInfo.existOnDb = true;
|
comicInfo.existOnDb = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -181,7 +181,16 @@ void PropertiesDialog::createGeneralInfoBox()
|
|||||||
|
|
||||||
generalInfoLayout->addRow(tr("Size:"), size = new QLabel("size"));
|
generalInfoLayout->addRow(tr("Size:"), size = new QLabel("size"));
|
||||||
|
|
||||||
generalInfoBox->setLayout(generalInfoLayout);
|
//generalInfoLayout->addRow(tr("Comic Vine link:"), comicVineLink = new QLabel("..."));
|
||||||
|
//generalInfoLayout->addRow(bottom);
|
||||||
|
|
||||||
|
QVBoxLayout * main = new QVBoxLayout;
|
||||||
|
main->addLayout(generalInfoLayout);
|
||||||
|
main->addStretch();
|
||||||
|
main->addWidget(comicVineLink = new QLabel("Comic Vine link : ..."));
|
||||||
|
comicVineLink->setOpenExternalLinks(true);
|
||||||
|
|
||||||
|
generalInfoBox->setLayout(main);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::createAuthorsBox()
|
void PropertiesDialog::createAuthorsBox()
|
||||||
@ -373,6 +382,13 @@ void PropertiesDialog::setComics(QList<ComicDB> comics)
|
|||||||
|
|
||||||
if(!comic.info.title.isNull())
|
if(!comic.info.title.isNull())
|
||||||
title->setText(comic.info.title.toString());
|
title->setText(comic.info.title.toString());
|
||||||
|
if(!comic.info.comicVineID.isNull())
|
||||||
|
{
|
||||||
|
comicVineLink->setHidden(false);
|
||||||
|
comicVineLink->setText(QString(tr("Comic Vine link: <a style='color: #FFCB00; text-decoration:none; font-weight:bold;' href=\"http://www.comicvine.com/comic/4000-%1/\"> view </a>").arg(comic.info.comicVineID.toString())));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
comicVineLink->setHidden(true);
|
||||||
|
|
||||||
if(comics.length()==1 && !comic.info.coverPage.isNull())
|
if(comics.length()==1 && !comic.info.coverPage.isNull())
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,7 @@ class QToolButton;
|
|||||||
YACReaderFieldEdit * title;
|
YACReaderFieldEdit * title;
|
||||||
YACReaderFieldEdit * numPagesEdit;
|
YACReaderFieldEdit * numPagesEdit;
|
||||||
QLabel * size;
|
QLabel * size;
|
||||||
|
QLabel * comicVineLink;
|
||||||
|
|
||||||
YACReaderFieldEdit * coverPageEdit;
|
YACReaderFieldEdit * coverPageEdit;
|
||||||
QIntValidator coverPageValidator;
|
QIntValidator coverPageValidator;
|
||||||
|
@ -201,7 +201,7 @@ ComicInfo & ComicInfo::operator=(const ComicInfo & comicInfo)
|
|||||||
synopsis = comicInfo.synopsis;
|
synopsis = comicInfo.synopsis;
|
||||||
characters = comicInfo.characters;
|
characters = comicInfo.characters;
|
||||||
notes = comicInfo.notes;
|
notes = comicInfo.notes;
|
||||||
comicVineURL = comicInfo.comicVineURL;
|
comicVineID = comicInfo.comicVineID;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -414,6 +414,9 @@ QDataStream &operator<<(QDataStream & stream, const ComicInfo & comicInfo)
|
|||||||
stream << comicInfo.synopsis;
|
stream << comicInfo.synopsis;
|
||||||
stream << comicInfo.characters;
|
stream << comicInfo.characters;
|
||||||
stream << comicInfo.notes;
|
stream << comicInfo.notes;
|
||||||
|
|
||||||
|
stream << comicInfo.comicVineID;
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,6 +470,8 @@ QDataStream &operator>>(QDataStream & stream, ComicInfo & comicInfo)
|
|||||||
stream >> comicInfo.synopsis;
|
stream >> comicInfo.synopsis;
|
||||||
stream >> comicInfo.characters;
|
stream >> comicInfo.characters;
|
||||||
stream >> comicInfo.notes;
|
stream >> comicInfo.notes;
|
||||||
|
|
||||||
|
stream >> comicInfo.comicVineID;
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
QVariant characters;//string
|
QVariant characters;//string
|
||||||
QVariant notes;//string
|
QVariant notes;//string
|
||||||
|
|
||||||
QVariant comicVineURL;//string
|
QVariant comicVineID;//string
|
||||||
|
|
||||||
QImage cover;
|
QImage cover;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define VERSION "7.0.2"
|
#define VERSION "7.1.0"
|
||||||
|
|
||||||
#define PATH "PATH"
|
#define PATH "PATH"
|
||||||
#define MAG_GLASS_SIZE "MAG_GLASS_SIZE"
|
#define MAG_GLASS_SIZE "MAG_GLASS_SIZE"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user