From 31a6c7e9afc50c6c3426937d411e21a79fec77e7 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 12 Oct 2013 17:14:05 +0200 Subject: Use marked files from PictureViewer2 * Call NewPicsDialog with marked files list * some more keyboard navigation: -> Cursor UP and RIGHT - previous -> Cursor DOWN and LEFT - next -> DELETE - delete file --- pictureviewer2.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'pictureviewer2.cpp') diff --git a/pictureviewer2.cpp b/pictureviewer2.cpp index cc7357f..dfb4993 100644 --- a/pictureviewer2.cpp +++ b/pictureviewer2.cpp @@ -253,6 +253,9 @@ void PictureViewer2::initActions(){ if(a->data().toInt() == MarkAction){ mMarkA = a; } + if(a->data().toInt() == DeleteAction){ + mDeleteA = a; + } } } @@ -274,7 +277,30 @@ void PictureViewer2::copyCurrent(){ } } +void PictureViewer2::deleteCurrent(){ + int retval = QMessageBox::question(this, tr("Delete file"), tr("Are you sure?"), QMessageBox::No | QMessageBox::Yes); + if(retval == QMessageBox::Yes){ + if(mMarkedFiles.contains(mFiles.at(mCurPos))){ + mMarkedFiles.removeAll(mFiles.at(mCurPos)); + } + QString fullPath = mFiles.at(mCurPos).at(PicFilesModel::FullPath).toString(); + QFile f(fullPath); + if(f.remove()){ + mFiles.removeAt(mCurPos); + } + } +} + void PictureViewer2::showNewPicsDialog(){ + if(mMarkedFiles.isEmpty()){ + return; + } + mNewPicsDlg->clearFiles(); + QStringList fileList; + foreach(QVariantList v, mMarkedFiles){ + fileList << v.at(PicFilesModel::FullPath).toString();; + } + mNewPicsDlg->addFiles(fileList); mNewPicsDlg->exec(); } @@ -326,12 +352,16 @@ void PictureViewer2::keyPressEvent(QKeyEvent *e){ if(e->key() == Qt::Key_M){ markCurrent(); } - if(e->key() == Qt::Key_N){ + if((e->key() == Qt::Key_N) || (e->key() == Qt::Key_Down) || (e->key() == Qt::Key_Right)){ next(); } - if(e->key() == Qt::Key_P){ + if((e->key() == Qt::Key_P) || (e->key() == Qt::Key_Up) || (e->key() == Qt::Key_Left)){ previous(); } + if(e->key() == Qt::Key_Delete){ + deleteCurrent(); + next(); + } e->accept(); } -- cgit v1.2.3-70-g09d2