diff --git a/YACReaderLibrary/db/comic.cpp b/YACReaderLibrary/db/comic.cpp index 82a36f0a..c21f1f4d 100644 --- a/YACReaderLibrary/db/comic.cpp +++ b/YACReaderLibrary/db/comic.cpp @@ -166,17 +166,51 @@ bool ComicInfo::load(QString hash, QSqlDatabase & db) { QSqlRecord record = findComicInfo.record(); - this->hash = hash; - this->id = record.value("id").toLongLong(); - this->title = record.value("title").toString(); - this->read = record.value("read").toBool(); - this->edited = record.value("edited").toBool(); - existOnDb = true; - return true; + hash = hash; + id = record.value("id").toLongLong(); + read = record.value("read").toBool(); + edited = record.value("edited").toBool(); + + title = record.value("title").toString(); + pages = record.value("pages").toInt(); + + coverPage = record.value("coverPage").toInt(); + + if(!record.value("number").isNull()) + number = record.value("number").toInt(); + else + number = -1; + isBis = record.value("isBis").toBool(); + count = record.value("count").toInt(); + + volume = record.value("volume").toString(); + storyArc = record.value("storyArc").toString(); + arcNumber = record.value("arcNumber").toInt(); + arcCount = record.value("arcCount").toInt(); + + genere = record.value("genere").toString(); + + writer = record.value("writer").toString(); + penciller = record.value("penciller").toString(); + inker = record.value("inker").toString(); + colorist = record.value("colorist").toString(); + letterer = record.value("letterer").toString(); + coverArtist = record.value("coverArtist").toString(); + + date = record.value("date").toString(); + publisher = record.value("publisher").toString(); + format = record.value("format").toString(); + color = record.value("color").toBool(); + ageRating = record.value("ageRating").toString(); + + synopsis = record.value("synopsis").toString(); + characters = record.value("characters").toString(); + notes = record.value("notes").toString(); + + return existOnDb = true; } - existOnDb = false; - return false; + return existOnDb = false; } qulonglong ComicInfo::insert(QSqlDatabase & db) @@ -191,10 +225,11 @@ void ComicInfo::update(QSqlDatabase & db) { //db.open(); QSqlQuery findComicInfo(db); - findComicInfo.prepare("UPDATE comic_info SET title = :title, read = :read WHERE id = :id "); + findComicInfo.prepare("UPDATE comic_info SET title = :title, read = :read, edited = :edited WHERE id = :id "); findComicInfo.bindValue(":title", title); findComicInfo.bindValue(":read", read?1:0); findComicInfo.bindValue(":id", id); + findComicInfo.bindValue(":edited", edited?1:0); findComicInfo.exec(); //db.close(); } diff --git a/YACReaderLibrary/db/comic.h b/YACReaderLibrary/db/comic.h index b6276922..6191eb3f 100644 --- a/YACReaderLibrary/db/comic.h +++ b/YACReaderLibrary/db/comic.h @@ -19,7 +19,40 @@ public: bool read; bool edited; QString hash; + QString title; + int pages; + + int coverPage; + + int number; + bool isBis; + int count; + + QString volume; + QString storyArc; + int arcNumber; + int arcCount; + + QString genere; + + QString writer; + QString penciller; + QString inker; + QString colorist; + QString letterer; + QString coverArtist; + + QString date; + QString publisher; + QString format; + bool color; + QString ageRating; + + QString synopsis; + QString characters; + QString notes; + bool existOnDb; }; diff --git a/YACReaderLibrary/db/data_base_management.cpp b/YACReaderLibrary/db/data_base_management.cpp index 6e31ac51..a5d9d875 100644 --- a/YACReaderLibrary/db/data_base_management.cpp +++ b/YACReaderLibrary/db/data_base_management.cpp @@ -68,7 +68,44 @@ bool DataBaseManagement::createTables(QSqlDatabase & database) //COMIC INFO (representa la información de un cómic, cada cómic tendrá un idéntificador único formado por un hash sha1'de los primeros 512kb' + su tamaño en bytes) QSqlQuery queryComicInfo(database); - queryComicInfo.prepare("CREATE TABLE comic_info (id INTEGER PRIMARY KEY, hash TEXT NOT NULL, edited BOOLEAN DEFAULT 0, title TEXT, read BOOLEAN)"); + queryComicInfo.prepare("CREATE TABLE comic_info (" + "id INTEGER PRIMARY KEY," + "title TEXT," + + "coverPage INTEGER," + "numPages INTEGER," + + "number INTEGER," + "isBis BOOLEAN," + "count INTEGER," + + "volume TEXT," + "storyArc TEXT," + "arcNumber INTEGER," + "arcCount INTEGER," + + "genere TEXT," + + "writer TEXT," + "penciller TEXT," + "inker TEXT," + "colorist TEXT," + "letterer TEXT," + "coverArtist TEXT," + + "date TEXT," //dd/mm/yyyy --> se mostrará en 3 campos diferentes + "publisher TEXT," + "format TEXT," + "color BOOLEAN," + "ageRating BOOLEAN," + + "synopsis TEXT," + "characters TEXT," + "notes TEXT," + + "hash TEXT NOT NULL," + "edited BOOLEAN DEFAULT 0," + "read BOOLEAN)"); success = success && queryComicInfo.exec(); //COMIC (representa un cómic en disco, contiene el nombre de fichero) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 3658e223..03318c96 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1039,6 +1039,7 @@ void LibraryWindow::showProperties() //ThumbnailCreator tc(path,""); //tc.create(); propertiesDialog->setComics(comics); + propertiesDialog->database = dm->getDatabase(); /*propertiesDialog->setCover(tc.getCover()); propertiesDialog->setFilename(path.split("/").last()); propertiesDialog->setNumpages(tc.getNumPages()); diff --git a/YACReaderLibrary/properties_dialog.cpp b/YACReaderLibrary/properties_dialog.cpp index 8856a347..38135762 100644 --- a/YACReaderLibrary/properties_dialog.cpp +++ b/YACReaderLibrary/properties_dialog.cpp @@ -7,7 +7,7 @@ #include #include #include -#include + PropertiesDialog::PropertiesDialog(QWidget * parent) :QDialog(parent) @@ -74,7 +74,7 @@ void PropertiesDialog::createCoverBox() QVBoxLayout * coverLayout = new QVBoxLayout(); coverLayout->addWidget(cover); - coverLayout->addWidget(new QLineEdit()); + coverLayout->addWidget(coverPageEdit = new QLineEdit()); coverBox->setLayout(coverLayout); } @@ -105,28 +105,28 @@ void PropertiesDialog::createGeneralInfoBox() QHBoxLayout * number = new QHBoxLayout; - number->addWidget(new QLineEdit()); + number->addWidget(numberEdit = new QLineEdit()); number->addWidget(new QLabel("Bis:")); - number->addWidget(new QCheckBox()); + number->addWidget(isBisCheck = new QCheckBox()); number->addWidget(new QLabel("of:")); - number->addWidget(new QLineEdit()); + number->addWidget(countEdit = new QLineEdit()); number->addStretch(1); /*generalInfoLayout->addRow(tr("&Issue number:"), ); generalInfoLayout->addRow(tr("&Bis:"), );*/ generalInfoLayout->addRow(tr("Issue number:"), number); - generalInfoLayout->addRow(tr("&Volume:"), pages = new QLineEdit()); + generalInfoLayout->addRow(tr("&Volume:"), volumeEdit = new QLineEdit()); QHBoxLayout * arc = new QHBoxLayout; - arc->addWidget(new QLineEdit()); + arc->addWidget(storyArcEdit = new QLineEdit()); arc->addWidget(new QLabel("Arc number:")); - arc->addWidget(new QLineEdit()); + arc->addWidget(arcNumberEdit = new QLineEdit()); arc->addWidget(new QLabel("of:")); - arc->addWidget(new QLineEdit()); + arc->addWidget(arcCountEdit = new QLineEdit()); arc->addStretch(1); generalInfoLayout->addRow(tr("&Story arc:"), arc); - generalInfoLayout->addRow(tr("&Genere:"), new QLineEdit()); + generalInfoLayout->addRow(tr("&Genere:"), genereEdit = new QLineEdit()); generalInfoLayout->addRow(tr("&Size:"), size = new QLabel("size")); @@ -144,10 +144,10 @@ void PropertiesDialog::createAuthorsBox() QVBoxLayout * vl1 = new QVBoxLayout; QVBoxLayout * vr1 = new QVBoxLayout; vl1->addWidget(new QLabel(tr("Writer(s):"))); - vl1->addWidget(new QPlainTextEdit()); + vl1->addWidget(writer = new QPlainTextEdit()); h1->addLayout(vl1); vr1->addWidget(new QLabel(tr("Penciller(s):"))); - vr1->addWidget(new QPlainTextEdit()); + vr1->addWidget(penciller = new QPlainTextEdit()); h1->addLayout(vr1); //authorsLayout->addRow(tr("Writer(s):"), new QPlainTextEdit()); //authorsLayout->addRow(tr("Penciller(s):"), new QPlainTextEdit()); @@ -155,10 +155,10 @@ void PropertiesDialog::createAuthorsBox() QVBoxLayout * vl2 = new QVBoxLayout; QVBoxLayout * vr2 = new QVBoxLayout; vl2->addWidget(new QLabel(tr("Inker(s):"))); - vl2->addWidget(new QPlainTextEdit()); + vl2->addWidget(inker = new QPlainTextEdit()); h2->addLayout(vl2); vr2->addWidget(new QLabel(tr("Colorist(s):"))); - vr2->addWidget(new QPlainTextEdit()); + vr2->addWidget(colorist = new QPlainTextEdit()); h2->addLayout(vr2); //authorsLayout->addRow(tr("Inker(s):"), new QPlainTextEdit()); @@ -168,10 +168,10 @@ void PropertiesDialog::createAuthorsBox() QVBoxLayout * vl3 = new QVBoxLayout; QVBoxLayout * vr3 = new QVBoxLayout; vl3->addWidget(new QLabel(tr("Letterer(es):"))); - vl3->addWidget(new QPlainTextEdit()); + vl3->addWidget(letterer = new QPlainTextEdit()); h3->addLayout(vl3); vr3->addWidget(new QLabel(tr("Cover Artist(s):"))); - vr3->addWidget(new QPlainTextEdit()); + vr3->addWidget(coverArtist = new QPlainTextEdit()); h3->addLayout(vr3); //authorsLayout->addRow(tr("Letterer(es):"), new QPlainTextEdit()); //authorsLayout->addRow(tr("Cover Artist(s):"), new QPlainTextEdit()); @@ -190,13 +190,21 @@ void PropertiesDialog::createPublishingBox() QFormLayout *publishingLayout = new QFormLayout; + QHBoxLayout * date = new QHBoxLayout; + date->addWidget(new QLabel(tr("Day:"))); + date->addWidget(dayEdit = new QLineEdit()); + date->addWidget(new QLabel(tr("Month:"))); + date->addWidget(monthEdit = new QLineEdit()); + date->addWidget(new QLabel(tr("Year:"))); + date->addWidget(yearEdit = new QLineEdit()); + date->addStretch(1); + publishingLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); - publishingLayout->addRow(tr("Year:"), new QLineEdit()); - publishingLayout->addRow(tr("Month:"), new QLineEdit()); - publishingLayout->addRow(tr("Publisher:"), new QLineEdit()); - publishingLayout->addRow(tr("Format:"), new QLineEdit()); - publishingLayout->addRow(tr("Color/BW:"), new QLineEdit()); - publishingLayout->addRow(tr("Age rating:"), new QLineEdit()); + publishingLayout->addRow(date); + publishingLayout->addRow(tr("Publisher:"), publisherEdit = new QLineEdit()); + publishingLayout->addRow(tr("Format:"), formatEdit = new QLineEdit()); + publishingLayout->addRow(tr("Color/BW:"), colorCheck = new QCheckBox()); + publishingLayout->addRow(tr("Age rating:"), ageRatingEdit = new QLineEdit()); publishingBox->setLayout(publishingLayout); } @@ -208,9 +216,9 @@ void PropertiesDialog::createPlotBox() QFormLayout *plotLayout = new QFormLayout; plotLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); - plotLayout->addRow(tr("Synopsis:"), new QPlainTextEdit()); - plotLayout->addRow(tr("Characters:"), new QPlainTextEdit()); - plotLayout->addRow(tr("Notes:"), new QPlainTextEdit()); + plotLayout->addRow(tr("Synopsis:"), synopsis = new QPlainTextEdit()); + plotLayout->addRow(tr("Characters:"), characters = new QPlainTextEdit()); + plotLayout->addRow(tr("Notes:"), notes = new QPlainTextEdit()); plotBox->setLayout(plotLayout); @@ -231,21 +239,29 @@ void PropertiesDialog::createButtonBox() void PropertiesDialog::setComics(QList comics) { + this->comics = comics; if(comics.length() > 1) { + setDisableUniqueValues(true); } else { Comic comic = comics.at(0); title->setText(comic.info.title); + + numberEdit->setText(QString::number(comic.info.number)); + + setDisableUniqueValues(false); } } -void PropertiesDialog::updateComics(QList comics) +void PropertiesDialog::updateComics() { - + database.open(); + comics[0].info.update(database); + database.close(); } //Deprecated void PropertiesDialog::setCover(const QPixmap & coverImage) @@ -291,4 +307,20 @@ void PropertiesDialog::setSize(float sizeFloat) { size->setText(QString::number(sizeFloat,'f',2) + " MB"); +} + +void PropertiesDialog::save() +{ + + comics[0].info.title = title->text(); + comics[0].info.edited = true; + updateComics(); +} + +void PropertiesDialog::setDisableUniqueValues(bool disabled) +{ + coverPageEdit->setDisabled(disabled); + numberEdit->setDisabled(disabled); + isBisCheck->setDisabled(disabled); + arcNumberEdit->setDisabled(disabled); } \ No newline at end of file diff --git a/YACReaderLibrary/properties_dialog.h b/YACReaderLibrary/properties_dialog.h index 4d92dac6..f5b58e08 100644 --- a/YACReaderLibrary/properties_dialog.h +++ b/YACReaderLibrary/properties_dialog.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include "comic.h" @@ -30,6 +32,37 @@ QLineEdit * pages; QLabel * size; + QLineEdit * coverPageEdit; + + QLineEdit * numberEdit; + QCheckBox * isBisCheck; + QLineEdit * countEdit; + + QLineEdit * volumeEdit; + QLineEdit * storyArcEdit; + QLineEdit * arcNumberEdit; + QLineEdit * arcCountEdit; + + QLineEdit * genereEdit; + + QPlainTextEdit * writer; + QPlainTextEdit * penciller; + QPlainTextEdit * inker; + QPlainTextEdit * colorist; + QPlainTextEdit * letterer; + QPlainTextEdit * coverArtist; + + QLineEdit * dayEdit; + QLineEdit * monthEdit; + QLineEdit * yearEdit; + QLineEdit * publisherEdit; + QLineEdit * formatEdit; + QCheckBox * colorCheck; + QLineEdit * ageRatingEdit; + + QPlainTextEdit * synopsis; + QPlainTextEdit * characters; + QPlainTextEdit * notes; QWidget * authorsBox; @@ -51,17 +84,23 @@ void createButtonBox(); + void setDisableUniqueValues(bool disabled); + + QList comics; + public: PropertiesDialog(QWidget * parent = 0); + QSqlDatabase database; public slots: void setComics(QList comics); - void updateComics(QList comics); + void updateComics(); //Deprecated void setCover(const QPixmap & cover); void setFilename(const QString & name); void setNumpages(int pages); void setSize(float size); + void save(); }; #endif