diff options
-rw-r--r-- | pictureviewer2.cpp | 34 | ||||
-rw-r--r-- | pictureviewer2.h | 4 | ||||
-rw-r--r-- | shemov.cpp | 4 | ||||
-rw-r--r-- | shemov.h | 1 |
4 files changed, 40 insertions, 3 deletions
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(); } diff --git a/pictureviewer2.h b/pictureviewer2.h index 2e879d1..eabc3a0 100644 --- a/pictureviewer2.h +++ b/pictureviewer2.h @@ -34,7 +34,7 @@ typedef QList<QList<QVariant> > PicDataList; class PictureViewer2 : public QGraphicsView { Q_OBJECT public: - enum AssocActions { SlideAction, HideAction, MarkAction }; + enum AssocActions { SlideAction, HideAction, MarkAction, DeleteAction }; explicit PictureViewer2(QWidget *parent = 0); void addFiles(const PicDataList &files, bool clear = true); void addFiles(const QString &dir, bool clear = true); @@ -59,6 +59,7 @@ class PictureViewer2 : public QGraphicsView { void shuffle(); void initActions(); void copyCurrent(); + void deleteCurrent(); void showNewPicsDialog(); void addToNewPics(); void markCurrent(); @@ -102,6 +103,7 @@ class PictureViewer2 : public QGraphicsView { QAction *mSlideA; QAction *mHideA; QAction *mMarkA; + QAction *mDeleteA; MappingTreeModel *mMappingTreeModel; PicFilesModel *mPicFilesModel; PicData mCurPicData; @@ -528,6 +528,10 @@ void SheMov::createActions(){ mPVClearMarksA = new QAction(tr("Clear marks"), this); connect(mPVClearMarksA, SIGNAL(triggered()), picViewer, SLOT(clearMarks())); picViewer->addAction(mPVClearMarksA); + mPVDeleteA = new QAction(QIcon(":/delete.png"), tr("Delete..."), this); + mPVDeleteA->setData(PictureViewer2::DeleteAction); + connect(mPVDeleteA, SIGNAL(triggered()), picViewer, SLOT(deleteCurrent())); + picViewer->addAction(mPVDeleteA); picViewer->addAction(createSeparator()); // Slide @@ -123,6 +123,7 @@ class SheMov : public QMainWindow { QAction *mPVToggleA; QAction *mPVAddA; QAction *mPVMarkA; + QAction *mPVDeleteA; QAction *mPVClearMarksA; QAction *mPVReplaceA; QAction *mPVSelectAllA; |