diff --git a/YACReaderLibrary/db/tablemodel.cpp b/YACReaderLibrary/db/tablemodel.cpp index eacdf17f..7898f3d4 100644 --- a/YACReaderLibrary/db/tablemodel.cpp +++ b/YACReaderLibrary/db/tablemodel.cpp @@ -577,7 +577,23 @@ void TableModel::reload(const ComicDB & comic) row++; } if(found) - emit dataChanged(index(row,TableModel::CurrentPage),index(row,TableModel::CurrentPage)); + emit dataChanged(index(row,TableModel::CurrentPage),index(row,TableModel::CurrentPage)); +} + +void TableModel::resetComicRating(const QModelIndex &mi) +{ + ComicDB comic = getComic(mi); + + QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + + comic.info.rating = 0; + _data[mi.row()]->setData(TableModel::Rating,0); + DBHelper::update(&(comic.info),db); + + emit dataChanged(mi,mi); + + db.close(); + QSqlDatabase::removeDatabase(_databasePath); } void TableModel::updateRating(int rating, QModelIndex mi) diff --git a/YACReaderLibrary/db/tablemodel.h b/YACReaderLibrary/db/tablemodel.h index 8b268fb4..e17aab83 100644 --- a/YACReaderLibrary/db/tablemodel.h +++ b/YACReaderLibrary/db/tablemodel.h @@ -54,6 +54,7 @@ public: void remove(ComicDB * comic, int row); void removeInTransaction(int row); void reload(const ComicDB & comic); + void resetComicRating(const QModelIndex & mi); enum Columns { Number = 0, diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 38c13fcd..8f7cf2e0 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -445,6 +445,9 @@ void LibraryWindow::createActions() openContainingFolderComicAction->setText(tr("Open containing folder...")); openContainingFolderComicAction->setIcon(QIcon(":/images/open.png")); + resetComicRatingAction = new QAction(this); + resetComicRatingAction->setText(tr("Reset comic rating")); + //Edit comics actions------------------------------------------------------ selectAllComicsAction = new QAction(this); selectAllComicsAction->setText(tr("Select all comics")); @@ -496,6 +499,8 @@ void LibraryWindow::disableComicsActions(bool disabled) deleteComicsAction->setDisabled(disabled); //context menu openContainingFolderComicAction->setDisabled(disabled); + resetComicRatingAction->setDisabled(disabled); + getInfoAction->setDisabled(disabled); @@ -607,6 +612,14 @@ void LibraryWindow::createToolBars() void LibraryWindow::createMenus() { comicView->addAction(openContainingFolderComicAction); + + { + QAction *act = new QAction(this); + act->setSeparator(true); + comicView->addAction(act); + } + comicView->addAction(resetComicRatingAction); + foldersView->addAction(openContainingFolderAction); selectedLibrary->addAction(updateLibraryAction); @@ -739,6 +752,7 @@ void LibraryWindow::createConnections() //ContextMenus connect(openContainingFolderComicAction,SIGNAL(triggered()),this,SLOT(openContainingFolderComic())); connect(openContainingFolderAction,SIGNAL(triggered()),this,SLOT(openContainingFolder())); + connect(resetComicRatingAction,SIGNAL(triggered()),this,SLOT(resetComicRating())); //connect(dm,SIGNAL(directoryLoaded(QString)),foldersView,SLOT(expandAll())); //connect(dm,SIGNAL(directoryLoaded(QString)),this,SLOT(updateFoldersView(QString))); @@ -1443,7 +1457,19 @@ void LibraryWindow::checkRemoveError() { QMessageBox::critical(this,tr("Unable to delete"),tr("There was an issue trying to delete the selected comics. Please, check for write permissions in the selected files or containing folder.")); } - removeError = false; + removeError = false; +} + +void LibraryWindow::resetComicRating() +{ + QModelIndexList indexList = getSelectedComics(); + + dmCV->startTransaction(); + for(auto & index:indexList) + { + dmCV->resetComicRating(index); + } + dmCV->finishTransaction(); } void LibraryWindow::asignNumbers() diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 536cb0db..d299b07f 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -144,6 +144,7 @@ private: //QAction * setAllAsNonReadAction; QAction * showHideMarksAction; QAction * getInfoAction; //comic vine + QAction * resetComicRatingAction; //edit info actions QAction * selectAllComicsAction; @@ -274,6 +275,7 @@ public: void showComicVineScraper(); void setRemoveError(); void checkRemoveError(); + void resetComicRating(); }; #endif