[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-mediacenter] libs/mediacenter: Minor fixes to metadata updater code
From: Shantanu Tushar <shantanu () kde ! org>
Date: 2013-12-31 17:38:24
Message-ID: E1Vy3Gq-0007Gn-E8 () scm ! kde ! org
[Download RAW message or body]
Git commit d74f456c4722c23a52f5d967a62ff2e73dcda0b8 by Shantanu Tushar.
Committed on 31/12/2013 at 17:37.
Pushed by shantanu into branch 'master'.
Minor fixes to metadata updater code
M +8 -4 libs/mediacenter/metadataupdater.cpp
M +1 -1 libs/mediacenter/metadataupdater.h
M +1 -1 libs/mediacenter/pmcmetadatamodel.cpp
http://commits.kde.org/plasma-mediacenter/d74f456c4722c23a52f5d967a62ff2e73dcda0b8
diff --git a/libs/mediacenter/metadataupdater.cpp b/libs/mediacenter/metadataupdater.cpp
index 349eb7b..3d1b661 100644
--- a/libs/mediacenter/metadataupdater.cpp
+++ b/libs/mediacenter/metadataupdater.cpp
@@ -114,7 +114,7 @@ void MetadataUpdater::processPendingIndices()
if (hasTermChanged())
runQuery();
- if (areThereResultsToProcess()) {
+ if (areThereIndicesToProcess()) {
const int i = nextIndexToProcess();
fetchValuesForResult(i, resultForRow(i));
QTimer::singleShot(10, this, SLOT(processPendingIndices()));
@@ -144,8 +144,12 @@ void MetadataUpdater::fetchValuesForResult(int i, const Nepomuk2::Query::Result&
values.insert(role, urlForResource(result.resource()));
break;
case MediaCenter::MediaTypeRole:
- //TODO: Put null checks here
- values.insert(role, mimetypeForResource(result.resource()).split('/').at(0));
+ const QString mimetype = mimetypeForResource(result.resource());
+ if (mimetype.isEmpty() || !mimetype.contains('/')) {
+ values.insert(role, mimetype);
+ } else {
+ values.insert(role, mimetype.split('/').at(0));
+ }
break;
}
}
@@ -181,7 +185,7 @@ Nepomuk2::Query::Result MetadataUpdater::resultForRow(int row)
return m_resultList.at(row);
}
-bool MetadataUpdater::areThereResultsToProcess()
+bool MetadataUpdater::areThereIndicesToProcess()
{
QMutexLocker lock(&m_indicesMutex);
return !m_indices.isEmpty();
diff --git a/libs/mediacenter/metadataupdater.h b/libs/mediacenter/metadataupdater.h
index 6ab301f..e466a80 100644
--- a/libs/mediacenter/metadataupdater.h
+++ b/libs/mediacenter/metadataupdater.h
@@ -80,7 +80,7 @@ private:
QString mimetypeForResource(const Nepomuk2::Resource& resource) const;
QString urlForResource(const Nepomuk2::Resource &resource) const;
void fetchValuesForResult(int i, const Nepomuk2::Query::Result& result);
- bool areThereResultsToProcess();
+ bool areThereIndicesToProcess();
int nextIndexToProcess();
Nepomuk2::Query::Result resultForRow(int row);
bool hasTermChanged();
diff --git a/libs/mediacenter/pmcmetadatamodel.cpp b/libs/mediacenter/pmcmetadatamodel.cpp
index bc436d2..ca2e8be 100644
--- a/libs/mediacenter/pmcmetadatamodel.cpp
+++ b/libs/mediacenter/pmcmetadatamodel.cpp
@@ -175,7 +175,7 @@ QVariant PmcMetadataModel::data(const QModelIndex& index, int role) const
return QVariant();
}
- QVariant metadataValue = metadataValueForRole(index, role);
+ const QVariant metadataValue = metadataValueForRole(index, role);
switch(role) {
case MediaCenter::ResourceIdRole:
case MediaCenter::MediaUrlRole:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic