From 0afebd0e3cb3da831cd5ffba1eefbe9e61e408a1 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 27 Jul 2013 03:59:47 +0200 Subject: Read JSON from ffprobe Use JSON output from ffprobe instead of string parsing to get some kind of type safety. For doing that, some changes were needed in FileView: Use delegates for displaying Duration and Bitrate instead of mangling output in Qt::Displayrole. To reuse code, move all delegates from the new Archive to a separate file. And, of course, the initial objective: Show the accumulated size and duration of selected files in the status bar from the experimental archive. --- shemov.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'shemov.cpp') diff --git a/shemov.cpp b/shemov.cpp index 7acf59f..8865d0c 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -102,6 +102,10 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla connect(mNewMovieWizard, SIGNAL(accepted()), c->archiveTreeModel(), SLOT(refresh())); mNewPicsDialog = new NewPicsDialog(this); + //experimental archive + connect(c, SIGNAL(sizeChanged(qint64)), this, SLOT(setSize(qint64))); + connect(c, SIGNAL(durationChanged(qint64,bool)), this, SLOT(setDuration(qint64,bool))); + QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(mTab); @@ -116,7 +120,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla splash.showMessage(tr("Finishing..."), Qt::AlignHCenter, Qt::yellow); qApp->processEvents(); connect(mFSWidget->fileView(), SIGNAL(selectedSize(qint64)), this, SLOT(setSize(qint64))); - connect(mFSWidget->fileView(), SIGNAL(selectedDuration(QVariant)), this, SLOT(setDuration(QVariant))); + connect(mFSWidget->fileView(), SIGNAL(selectedDuration(qint64,bool)), this, SLOT(setDuration(qint64,bool))); connect(mFSWidget->fileView(), SIGNAL(numSelected(int)), this, SLOT(updateSelectedCount(int))); connect(mFSWidget, SIGNAL(windowTitle(QString)), this, SLOT(setWindowTitle(QString))); connect(mFSWidget->fileView(), SIGNAL(statusbarMessage(const QString &)), this, SLOT(statusbarMessage(const QString &))); @@ -197,15 +201,19 @@ void SheMov::tabChanged(int newTab){ mPVShowNPDialogA->setEnabled(newTab == FileManager); mPVAddToNPA->setEnabled(newTab == FileManager); statusbarMessage(QString()); + ArchiveController *c = SmGlobals::instance()->archiveController(); switch(newTab){ case FileManager: connect(mPVSelectAllA, SIGNAL(triggered()), mFSWidget, SLOT(selectAllPV())); - setDuration(mFSWidget->fileView()->duration()); + mFSWidget->fileView()->selectedFilesChanged(); + break; + case Experimental: + c->fileSelectionChanged(QItemSelection(), QItemSelection()); break; case Pictures: connect(mPVSelectAllA, SIGNAL(triggered()), mPicWidget->picView(), SLOT(setPVAll())); default: - setDuration(QVariant()); + setDuration(0x0, false); ;; } } @@ -322,9 +330,13 @@ void SheMov::setSize(qint64 size){ mSelectedSize->setText(val); } -void SheMov::setDuration(const QVariant dur){ - Helper::Duration d = dur.value(); - mSelectedDuration->setText(d.toString()); +void SheMov::setDuration(qint64 dur, bool maybeMore){ + Helper::Duration d(dur); + QString t = d.toString(); + if(maybeMore){ + t.append("+"); + } + mSelectedDuration->setText(t); } QAction *SheMov::createSeparator(){ -- cgit v1.2.3-70-g09d2