From 8eba6e7f033617f3e7ea3bd9913105df0de74ae2 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 31 Jul 2010 16:26:10 +0200 Subject: Implement FilePropertiesDialog Implemented a dialog for file properties. When the mime type says it's a video, fork ffprobe to read the properties of all streams and show them in a QTreeView powered by a SmTreeModel. If the mime type is image, use QImage to read some properties and show them in the same dialog. This commit introduces the new class FilePropertiesDialog. I also had to implement a copy constructor for SmTreeItem. It obsoletes classes ActorWidget, ActorModel and MoviePropertiesDialog. --- filestreemodel.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'filestreemodel.cpp') diff --git a/filestreemodel.cpp b/filestreemodel.cpp index 1f224fd..9c17084 100644 --- a/filestreemodel.cpp +++ b/filestreemodel.cpp @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include #include "filestreemodel.h" #include "smtreeitem.h" @@ -235,6 +238,79 @@ QHash FilesTreeModel::filesBySeriesPartId(int seriesPartId){ return retval; } +QList > FilesTreeModel::streamInfo(const QModelIndex &idx){ + QList > retval; + if(!idx.isValid()){ + return retval; + } + QSettings s; + QString ffProbe = s.value("paths/ffprobe").toString(); + QString fullPath = idx.data(FullPathRole).toString(); + QStringList args; + args << "-show_streams" << fullPath; + QProcess ffproc; + ffproc.start(ffProbe, args); + if(!ffproc.waitForStarted()){ + return retval; + } + ffproc.waitForFinished(); + QByteArray ffData = ffproc.readAllStandardOutput(); + QList lines = ffData.split('\n'); + QMap current; + foreach(QString l, lines){ + if(l.startsWith("[STREAM]")){ + continue; + } + if(l.startsWith("[/STREAM]")){ + retval << current; + current.clear(); + continue; + } + QStringList parts = l.split('='); + if(parts.size() == 2){ + current.insert(parts.at(0), parts.at(1)); + } + } + return retval; +} + +QMap FilesTreeModel::pictureInfo(const QModelIndex &idx){ + QMap retval; + if(!idx.isValid()){ + return retval; + } + QString fullPath = idx.data(FullPathRole).toString(); + QImage img(fullPath); + if(img.isNull()){ + return retval; + } + retval.insert("Width", QString::number(img.width())); + retval.insert("Height", QString::number(img.height())); + retval.insert("Colors", QString::number(img.colorCount())); + retval.insert("Color depth", QString::number(img.depth())); + retval.insert("Byte count", QString::number(img.byteCount())); + retval.insert("Bytes per line", QString::number(img.bytesPerLine())); + retval.insert("Alpha channel", img.hasAlphaChannel() ? tr("yes") : tr("no")); + retval.insert("Gray scale", img.isGrayscale() ? tr("yes") : tr("no")); + return retval; +} + +QMap FilesTreeModel::pictureMetaInfo(const QModelIndex &idx){ + QMap retval; + if(!idx.isValid()){ + return retval; + } + QString fullPath = idx.data(FullPathRole).toString(); + QImage img(fullPath); + if(img.isNull()){ + return retval; + } + foreach(QString v, img.textKeys()){ + retval.insert(v, img.text(v)); + } + return retval; +} + bool FilesTreeModel::addFile(const QString &fullPath, int type, int quality, int filePart, int seriesPartId, int dvd){ QFileInfo fi(fullPath); qint64 size = fi.size(); -- cgit v1.2.3-70-g09d2