From aea54efd00c1cbd0f66bcda83e9c7a196d3c317b Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 6 Nov 2016 06:07:07 +0100 Subject: Kinda fix display of metadata If a seriespart is selected in the tree, display a summary. When a file is selected, display the actual metadata. It's much more consistent. Before, the metadata of the first *item in the selected list was displayed. --- archivecontroller.cpp | 71 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 13 deletions(-) (limited to 'archivecontroller.cpp') diff --git a/archivecontroller.cpp b/archivecontroller.cpp index d13eb14..087fd67 100644 --- a/archivecontroller.cpp +++ b/archivecontroller.cpp @@ -289,21 +289,63 @@ void ArchiveController::setMetadata(QTextEdit *metaEdit){ void ArchiveController::getMetadata(QSet ids){ mMetaEdit->clear(); - QList metadata = mArchiveModel->metadataList(*ids.begin()); + if(ids.isEmpty()){ + return; + } + QString meta; - meta.append(""); - meta.append(QString("").arg(metadata.at(ArchiveModel::ReleaseYear).toString())); - meta.append(QString("").arg(metadata.at(ArchiveModel::Source).toString())); - meta.append(QString("").arg(metadata.at(ArchiveModel::Subject).toString())); - meta.append(QString("").arg(metadata.at(ArchiveModel::Added).toDateTime().toString())); - - meta.append("
Release year%1
Source%1
Subj./Name%1
Added%1
"); - QString comment = metadata.at(ArchiveModel::Comment).toString(); - if(comment.isEmpty()){ - comment = tr("(none)"); + + if(ids.size() == 1){ + QList metadata = mArchiveModel->metadataList(*ids.begin()); + if(metadata.at(0).isValid()){ + meta.append(""); + meta.append(QString("").arg(metadata.at(ArchiveModel::ReleaseYear).toString())); + meta.append(QString("").arg(metadata.at(ArchiveModel::Source).toString())); + meta.append(QString("").arg(metadata.at(ArchiveModel::Subject).toString())); + meta.append(QString("").arg(metadata.at(ArchiveModel::Added).toDateTime().toString())); + + meta.append("
Release year%1
Source%1
Subj./Name%1
Added%1
"); + QString comment = metadata.at(ArchiveModel::Comment).toString(); + if(comment.isEmpty()){ + comment = tr("(none)"); + } + meta.append(QString("

Comments:

%1

").arg(comment)); + meta.append(""); + }else{ + meta = tr("No metadata available"); + } + }else{ + QStringList tmpH; + for(int i = 0; i < ArchiveFilesModel::NumFields; ++i){ + tmpH << ""; + } + tmpH.reserve(ArchiveFilesModel::NumFields); + ArchiveFilesModel tmpFModel(tmpH, this); + tmpFModel.populate(ids); + quint64 totalSize = tmpFModel.totalSize(); + QString sizeStr; + QLocale l; + if(totalSize / 1024 / 1024 / 1024 > 0){ //display GB + double ts = (double)totalSize / 1024.0 / 1024.0 / 1024.0; + sizeStr = QString("%1 GB").arg(l.toString(ts)); + }else if(totalSize / 1024 / 1024 > 0){ //display MB + double ts = (double)totalSize / 1024.0 / 1024.0; + sizeStr = QString("%1 MB").arg(l.toString(ts)); + }else if(totalSize == 0){ + sizeStr = tr("n/a"); + } + meta.append(""); + meta.append(QString("").arg(sizeStr)); + quint64 totalDur = tmpFModel.totalDuration(); + Helper::Duration dur(totalDur); + meta.append(QString("").arg(dur.toString())); + int moviefiles = tmpFModel.movieFilesCount(); + meta.append(QString("").arg(QString::number(moviefiles))); + int otherfiles = tmpFModel.otherFilesCount(); + meta.append(QString("").arg(QString::number(otherfiles))); + meta.append("
Total Size%1
Total Duration%1
Movie files%1
Other files%1
"); + meta.append(""); } - meta.append(QString("

Comments:

%1

").arg(comment)); - meta.append(""); mMetaEdit->setHtml(meta); } @@ -317,7 +359,9 @@ void ArchiveController::fileSelectionChanged(const QItemSelection &selected, con qint64 size = 0; qint64 duration = 0; bool maybeMore = false; + QSet seriesParts; foreach(QModelIndex i, sel){ + seriesParts << i.data(ArchiveFilesModel::SeriesPartIdRole).toInt(); size += i.data(ArchiveFilesModel::SizeRole).toInt(); int type = i.data(ArchiveFilesModel::FileTypeRole).toInt(); if(type == FT_MOVIE){ @@ -328,6 +372,7 @@ void ArchiveController::fileSelectionChanged(const QItemSelection &selected, con } } } + getMetadata(seriesParts); emit sizeChanged(size); emit durationChanged(duration, maybeMore); } -- cgit v1.2.3-70-g09d2