a?adida la funci?n de borrar c?mics del disco

This commit is contained in:
Luis Ángel San Martín 2013-05-28 16:18:16 +02:00
parent ea9d2bd169
commit ad08f4291a
6 changed files with 51 additions and 0 deletions

View File

@ -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();
}

View File

@ -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);

View File

@ -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>

View File

@ -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());
}
}
}

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB