summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-10-12 17:14:05 +0200
committerArno <am@disconnect.de>2013-10-12 17:14:05 +0200
commit31a6c7e9afc50c6c3426937d411e21a79fec77e7 (patch)
treeb8976b0d0e6a486d947e25447a0bb14c61637b49
parent89662ce745c1eee152e7bc2200be5f08caee78a8 (diff)
downloadSheMov-31a6c7e9afc50c6c3426937d411e21a79fec77e7.tar.gz
SheMov-31a6c7e9afc50c6c3426937d411e21a79fec77e7.tar.bz2
SheMov-31a6c7e9afc50c6c3426937d411e21a79fec77e7.zip
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
-rw-r--r--pictureviewer2.cpp34
-rw-r--r--pictureviewer2.h4
-rw-r--r--shemov.cpp4
-rw-r--r--shemov.h1
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;
diff --git a/shemov.cpp b/shemov.cpp
index ac32419..437a38b 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -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
diff --git a/shemov.h b/shemov.h
index 5c8ee08..fdbc5a9 100644
--- a/shemov.h
+++ b/shemov.h
@@ -123,6 +123,7 @@ class SheMov : public QMainWindow {
QAction *mPVToggleA;
QAction *mPVAddA;
QAction *mPVMarkA;
+ QAction *mPVDeleteA;
QAction *mPVClearMarksA;
QAction *mPVReplaceA;
QAction *mPVSelectAllA;