summaryrefslogtreecommitdiffstats
path: root/archiveview.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-07-27 03:59:47 +0200
committerArno <am@disconnect.de>2013-07-27 04:02:21 +0200
commit0afebd0e3cb3da831cd5ffba1eefbe9e61e408a1 (patch)
treee92bd13b2ddda3af1af51d25c22d5042fb635139 /archiveview.cpp
parent46a552d89c70895abc75d94f3c647be29873afd9 (diff)
downloadSheMov-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 'archiveview.cpp')
-rw-r--r--archiveview.cpp65
1 files changed, 1 insertions, 64 deletions
diff --git a/archiveview.cpp b/archiveview.cpp
index 3031815..18effbd 100644
--- a/archiveview.cpp
+++ b/archiveview.cpp
@@ -27,6 +27,7 @@
#include "archiveview.h"
#include "archivecontroller.h"
#include "mappingtablewidget.h"
+#include "delegates.h"
#include "smglobals.h"
#include "helper.h"
@@ -674,67 +675,3 @@ QString PartEditor::subtitle() const {
return mSubtitle->text();
}
-/* Delegate for File no. */
-
-QString FileNoDelegate::displayText(const QVariant &value, const QLocale &locale) const{
- Q_UNUSED(locale);
- int no = value.toInt();
- if(no){
- return QString::number(no);
- }
- return QString();
-}
-
-QWidget *FileNoDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const{
- Q_UNUSED(option);
- QSpinBox *retval = new QSpinBox(parent);
- int no = index.data().toInt();
- retval->setValue(no);
- return retval;
-}
-
-/* Delegate for Dvd no. */
-
-QString DvdNoDelegate::displayText(const QVariant &value, const QLocale &locale) const{
- Q_UNUSED(locale);
- int no = value.toInt();
- if(no < 0){
- return tr("(local)");
- }
- QString retval = QString(tr("#%1")).arg(QString::number(no));
- return retval;
-}
-
-/* Delegate for size */
-
-QString SizeDelegate::displayText(const QVariant &value, const QLocale &locale) const{
- // locale.toString() doesn't work, maybe b/c it's const
- Q_UNUSED(locale);
- QLocale l;
- return l.toString(value.toLongLong());
-}
-
-/* Delegate for duration */
-
-QString DurationDelegate::displayText(const QVariant &value, const QLocale &locale) const{
- Q_UNUSED(locale);
- if(value.toString().contains("x")){
- return value.toString();
- }
- qint64 secs = value.toInt();
- if(secs == 0){
- return tr("n/a");
- }
- Helper::Duration dur(secs);
- return dur.toString();
-}
-
-/* Empty delegate */
-
-QString EmptyDelegate::displayText(const QVariant &value, const QLocale &locale) const{
- int i = value.toInt();
- if(i < 1){
- return QString();
- }
- return QStyledItemDelegate::displayText(value, locale);
-}