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. --- archivecontroller.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'archivecontroller.cpp') diff --git a/archivecontroller.cpp b/archivecontroller.cpp index 30d94f3..bda54c2 100644 --- a/archivecontroller.cpp +++ b/archivecontroller.cpp @@ -61,6 +61,7 @@ void ArchiveController::setMetadata(QTextEdit *metadata){ void ArchiveController::init(){ connect(mArchiveSelection, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(treeSelectionChanged(QItemSelection,QItemSelection))); connect(mArchiveFiles, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(fileDoubleClicked(QModelIndex))); + connect(mFileSelection, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(fileSelectionChanged(QItemSelection,QItemSelection))); } void ArchiveController::playSelectedFiles(){ @@ -211,6 +212,31 @@ void ArchiveController::treeSelectionChanged(const QItemSelection &selected, con } } +void ArchiveController::fileSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected){ + Q_UNUSED(selected); + Q_UNUSED(deselected); + QModelIndexList sel = mapToSource(mArchiveFilesProxy, mFileSelection->selectedRows()); + if(sel.isEmpty()){ + return; + } + qint64 size = 0; + qint64 duration = 0; + bool maybeMore = false; + foreach(QModelIndex i, sel){ + size += i.data(ArchiveFilesModel::SizeRole).toInt(); + int type = i.data(ArchiveFilesModel::FileTypeRole).toInt(); + if(type == ArchiveFilesModel::Movie){ + int dur = i.data(ArchiveFilesModel::SizeDurRole).toInt(); + duration += dur; + if(dur == 0){ + maybeMore = true; + } + } + } + emit sizeChanged(size); + emit durationChanged(duration, maybeMore); +} + void ArchiveController::fileDoubleClicked(const QModelIndex &idx){ if(!idx.isValid()){ return; -- cgit v1.2.3-70-g09d2