diff options
author | Arno <am@disconnect.de> | 2013-07-27 03:59:47 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-07-27 04:02:21 +0200 |
commit | 0afebd0e3cb3da831cd5ffba1eefbe9e61e408a1 (patch) | |
tree | e92bd13b2ddda3af1af51d25c22d5042fb635139 /archivecontroller.cpp | |
parent | 46a552d89c70895abc75d94f3c647be29873afd9 (diff) | |
download | SheMov-0afebd0e3cb3da831cd5ffba1eefbe9e61e408a1.tar.gz SheMov-0afebd0e3cb3da831cd5ffba1eefbe9e61e408a1.tar.bz2 SheMov-0afebd0e3cb3da831cd5ffba1eefbe9e61e408a1.zip |
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.
Diffstat (limited to 'archivecontroller.cpp')
-rw-r--r-- | archivecontroller.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
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; |