mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
a?adida la funci?n de borrar c?mics del disco
This commit is contained in:
parent
ea9d2bd169
commit
ad08f4291a
@ -433,4 +433,20 @@ QModelIndex TableModel::getIndexFromId(quint64 id)
|
||||
}
|
||||
|
||||
return index(i,0);
|
||||
}
|
||||
|
||||
void TableModel::remove(ComicDB * comic, int row)
|
||||
{
|
||||
beginRemoveRows(QModelIndex(),row,row);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
|
||||
DBHelper::removeFromDB(comic,db);
|
||||
|
||||
removeRow(row);
|
||||
delete _data.at(row);
|
||||
_data.removeAt(row);
|
||||
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
endRemoveRows();
|
||||
}
|
@ -45,6 +45,7 @@ public:
|
||||
//setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la información común para los comics seleccionados
|
||||
QVector<bool> setComicsRead(QList<QModelIndex> list,bool read);
|
||||
qint64 asignNumbers(QList<QModelIndex> list,int startingNumber);
|
||||
void remove(ComicDB * comic, int row);
|
||||
private:
|
||||
void setupModelData( QSqlQuery &sqlquery);
|
||||
ComicDB _getComic(const QModelIndex & mi);
|
||||
|
@ -70,5 +70,6 @@
|
||||
<file>../images/readRibbon.png</file>
|
||||
<file>../images/shownCovers.png</file>
|
||||
<file>../images/hiddenCovers.png</file>
|
||||
<file>../images/trash.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -477,6 +477,10 @@ void LibraryWindow::createActions()
|
||||
forceConverExtractedAction->setText(tr("Update cover"));
|
||||
forceConverExtractedAction->setIcon(QIcon(":/images/importCover.png"));
|
||||
|
||||
deleteComicsAction = new QAction(this);
|
||||
deleteComicsAction->setText(tr("Delete selected comics"));
|
||||
deleteComicsAction->setIcon(QIcon(":/images/trash.png"));
|
||||
|
||||
hideComicViewAction = new QAction(this);
|
||||
hideComicViewAction->setText(tr("Hide comic flow"));
|
||||
hideComicViewAction->setIcon(QIcon(":/images/hideComicFlow.png"));
|
||||
@ -620,6 +624,10 @@ void LibraryWindow::createToolBars()
|
||||
|
||||
editInfoToolBar->addAction(showHideMarksAction);
|
||||
|
||||
editInfoToolBar->addSeparator();
|
||||
|
||||
editInfoToolBar->addAction(deleteComicsAction);
|
||||
|
||||
editInfoToolBar->addWidget(new QToolBarStretch());
|
||||
editInfoToolBar->addAction(hideComicViewAction);
|
||||
|
||||
@ -734,6 +742,8 @@ void LibraryWindow::createConnections()
|
||||
connect(editSelectedComicsAction,SIGNAL(triggered()),this,SLOT(showProperties()));
|
||||
connect(asignOrderActions,SIGNAL(triggered()),this,SLOT(asignNumbers()));
|
||||
|
||||
connect(deleteComicsAction,SIGNAL(triggered()),this,SLOT(deleteComics()));
|
||||
|
||||
connect(hideComicViewAction, SIGNAL(toggled(bool)),this, SLOT(hideComicFlow(bool)));
|
||||
|
||||
}
|
||||
@ -1475,4 +1485,25 @@ QModelIndexList LibraryWindow::getSelectedComics()
|
||||
selection = comicView->selectionModel()->selectedRows();
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
void LibraryWindow::deleteComics()
|
||||
{
|
||||
//TODO move this to another thread
|
||||
QModelIndexList indexList = getSelectedComics();
|
||||
|
||||
QString currentComicPath;
|
||||
QListIterator<QModelIndex> i(indexList);
|
||||
i.toBack();
|
||||
while (i.hasPrevious())
|
||||
{
|
||||
QModelIndex mi = i.previous();
|
||||
ComicDB comic = dmCV->getComic(mi);
|
||||
currentComicPath = currentPath() + comic.path;
|
||||
if(QFile::remove(currentComicPath))
|
||||
{
|
||||
dmCV->remove(&comic,mi.row());
|
||||
comicFlow->remove(mi.row());
|
||||
}
|
||||
}
|
||||
}
|
@ -139,6 +139,7 @@ private:
|
||||
QAction * editSelectedComicsAction;
|
||||
QAction * asignOrderActions;
|
||||
QAction * forceConverExtractedAction;
|
||||
QAction * deleteComicsAction;
|
||||
QAction * hideComicViewAction;
|
||||
|
||||
|
||||
@ -233,6 +234,7 @@ public:
|
||||
void manageUpdatingError(const QString & error);
|
||||
void manageOpeningLibraryError(const QString & error);
|
||||
QModelIndexList getSelectedComics();
|
||||
void deleteComics();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
BIN
images/trash.png
Normal file
BIN
images/trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
Loading…
x
Reference in New Issue
Block a user