diff options
author | Arno <arno@disconnect.de> | 2018-03-31 09:30:54 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-03-31 09:30:54 +0200 |
commit | b2b21c5790a3fcf5ecd4fddff40420f5bd2d2009 (patch) | |
tree | 8e00e81c6f02a29245fcb7019b00a5aa44991667 | |
parent | 54b3a12a039610bbf2e6787d99c187ecfd58f655 (diff) | |
download | SheMov-b2b21c5790a3fcf5ecd4fddff40420f5bd2d2009.tar.gz SheMov-b2b21c5790a3fcf5ecd4fddff40420f5bd2d2009.tar.bz2 SheMov-b2b21c5790a3fcf5ecd4fddff40420f5bd2d2009.zip |
Implement forward and back actions in FSWidget
-rw-r--r-- | fswidget.cpp | 14 | ||||
-rw-r--r-- | fswidget.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/fswidget.cpp b/fswidget.cpp index ca7407d..f282a6c 100644 --- a/fswidget.cpp +++ b/fswidget.cpp @@ -32,8 +32,10 @@ void FSWidget::setupWidget(){ rotatematrix.rotate(-180); QIcon buttplugLeft(buttplug.transformed(rotatematrix)); QAction *backA = new QAction(buttplugLeft, tr("Prev. dir"), this); + connect(backA, &QAction::triggered, [=] { advanceDir(-1); }); toolbar->addAction(backA); QAction *forwardA = new QAction(buttplugRight, tr("Next dir"), this); + connect(forwardA, &QAction::triggered, [=] { advanceDir(1); }); toolbar->addAction(forwardA); QIcon plusIcon = Helper::icon(QColor(255,85,255), '+'); @@ -262,6 +264,18 @@ void FSWidget::gatherData(const QString &curDir){ mFileView->setSortingEnabled(true); } +void FSWidget::advanceDir(int by){ + int dirCount = mDirCB->count(); + int nextIdx = mDirCB->currentIndex() + by; + if(nextIdx >= dirCount){ + nextIdx = 0; + } + if(nextIdx < 0){ + nextIdx = dirCount - 1; + } + mDirCB->setCurrentIndex(nextIdx); +} + int FSWidget::queryCount(QSqlQuery &q, const QString &arg) const{ int retval = -1; q.bindValue(":arg", arg); @@ -23,6 +23,7 @@ class FSWidget : public QWidget { void insertItem(QComboBox *cb, const QString &text); void removeItem(QComboBox *cb); void gatherData(const QString &curDir); + void advanceDir(int by); int queryCount(QSqlQuery &q, const QString &arg) const; private: |