From eb9ed351b179802e3cfc21ccb3311077965d6541 Mon Sep 17 00:00:00 2001 From: Arno Date: Tue, 3 Apr 2018 05:59:38 +0200 Subject: FSWidget: Update status bar Show count, size and duration. --- fswidget.cpp | 18 ++++++++++++++++++ fswidget.h | 2 ++ shemov.cpp | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/fswidget.cpp b/fswidget.cpp index 75ecd28..c3753b1 100644 --- a/fswidget.cpp +++ b/fswidget.cpp @@ -160,6 +160,7 @@ void FSWidget::setupWidget(){ mProxy->setSourceModel(mModel); mFileView->setModel(mProxy); mFileView->sortByColumn(0, Qt::AscendingOrder); + connect(mFileView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &FSWidget::calculateSelectionChanged); mFileView->addActions(QList() << playSelectedA << playRepeatMA << mPlayWithA << Helper::createSeparator(this) << backA << forwardA << Helper::createSeparator(this) << refreshA << deleteFilesA << Helper::createSeparator(this) << archiveMovieA << archivePicsA << unpackA << previewA << selectFilterA << unselectAllA); @@ -564,3 +565,20 @@ void FSWidget::selectFilter(){ } } + +void FSWidget::calculateSelectionChanged(){ + QModelIndexList selected = mFileView->selectionModel()->selectedRows(); + if(selected.isEmpty()){ + emit selectionChanged(0, 0, 0); + return; + } + int count = 0; + qint64 duration = 0; + qint64 size = 0; + for(const QModelIndex &idx : selected){ + ++count; + duration += idx.data(DurationRole).toLongLong(); + size += idx.data(SizeRole).toLongLong(); + } + emit selectionChanged(count, size, duration); +} diff --git a/fswidget.h b/fswidget.h index 9a9cc2e..a7ef536 100644 --- a/fswidget.h +++ b/fswidget.h @@ -43,9 +43,11 @@ class FSWidget : public QWidget { void preview(); void playSelected(int count, QString player); void selectFilter(); + void calculateSelectionChanged(); signals: void message(QString msg); + void selectionChanged(int count, qint64 size, qint64 duration); private: void setupWidget(); diff --git a/shemov.cpp b/shemov.cpp index 2a7aa7e..47018b7 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -65,6 +65,11 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla mFileWidget = new FSWidget; mTab->addTab(mFileWidget, tr("FS")); connect(mFileWidget, &FSWidget::message, this, &SheMov::statusbarMessage); + connect(mFileWidget, &FSWidget::selectionChanged, [=](int count, qint64 size, qint64 duration) { + updateSelectedCount(count); + setSize(size); + setDuration(duration, false); + }); //experimental splash.showMessage(tr("Creating Movie archive..."), Qt::AlignHCenter, Qt::yellow); -- cgit v1.2.3-70-g09d2