summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorXizhi Zhu <xizhi.zhu@gmail.com>2012-01-30 17:51:45 +0100
committerQt by Nokia <qt-info@nokia.com>2012-04-05 07:44:07 +0200
commit11b30f6142cc3f58a0221a195b5fe0eeb0fdd11d (patch)
tree7971c094edc2135e417a80be64be7235711cecfc /examples
parent60ca9a8b283a88ea4755d25a699d915a9f301ad8 (diff)
Use enumeration for collection metadata keys.
Change-Id: Iaabd624001e52e644bdaf9891d6c3f3667ab565c Reviewed-by: Päivi Rajala <paivi.rajala@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/calendardemo/src/eventeditpage.cpp18
-rw-r--r--examples/calendardemo/src/journaleditpage.cpp18
-rw-r--r--examples/calendardemo/src/todoeditpage.cpp18
3 files changed, 9 insertions, 45 deletions
diff --git a/examples/calendardemo/src/eventeditpage.cpp b/examples/calendardemo/src/eventeditpage.cpp
index 455566d68..440b6af00 100644
--- a/examples/calendardemo/src/eventeditpage.cpp
+++ b/examples/calendardemo/src/eventeditpage.cpp
@@ -232,27 +232,15 @@ void EventEditPage::eventChanged(QOrganizerManager *manager, const QOrganizerEve
}
// resolve metadata field that contains calendar name (if any)
- QString calendarNameMetadataKey;
m_collections = m_manager->collections();
- if (!m_collections.isEmpty()) {
- QOrganizerCollection firstCollection = m_collections[0];
- QVariantMap metadata = firstCollection.metaData();
- QList<QString> metaDataKeys = metadata.keys();
- foreach(QString key, metaDataKeys) {
- if (key.indexOf("name", 0, Qt::CaseInsensitive) != -1) {
- calendarNameMetadataKey = key;
- break;
- }
- }
- }
int index = 0;
int eventCalendarIndex = -1;
foreach(QOrganizerCollection collection, m_collections) {
// We currently have no way of stringifying ids
//QString visibleName = "Calendar id = " + QString::number(collection.id().localId());
- QString visibleName = "Calendar " + QString::number(index);
- if (!calendarNameMetadataKey.isNull())
- visibleName = collection.metaData(calendarNameMetadataKey).toString();
+ QString visibleName = collection.metaData(QOrganizerCollection::KeyName).toString();
+ if (visibleName.isEmpty())
+ visibleName = "Calendar " + QString::number(index);
m_calendarComboBox->addItem(visibleName);
if (collection.id() == event.collectionId())
diff --git a/examples/calendardemo/src/journaleditpage.cpp b/examples/calendardemo/src/journaleditpage.cpp
index 498e893bd..ed1fd952d 100644
--- a/examples/calendardemo/src/journaleditpage.cpp
+++ b/examples/calendardemo/src/journaleditpage.cpp
@@ -141,27 +141,15 @@ void JournalEditPage::journalChanged(QOrganizerManager *manager, const QOrganize
m_calendarComboBox->clear();
// resolve metadata field that contains calendar name (if any)
- QString calendarNameMetadataKey;
m_collections = m_manager->collections();
- if (!m_collections.isEmpty()) {
- QOrganizerCollection firstCollection = m_collections[0];
- QVariantMap metadata = firstCollection.metaData();
- QList<QString> metaDataKeys = metadata.keys();
- foreach(QString key, metaDataKeys) {
- if (key.indexOf("name", 0, Qt::CaseInsensitive) != -1) {
- calendarNameMetadataKey = key;
- break;
- }
- }
- }
int index = 0;
int journalCalendarIndex = -1;
foreach(QOrganizerCollection collection, m_collections) {
// We currently have no way of stringifying ids
// QString visibleName = "Calendar id = " + QString::number(collection.id().localId());
- QString visibleName = "Calendar " + QString::number(index);
- if (!calendarNameMetadataKey.isNull())
- visibleName = collection.metaData(calendarNameMetadataKey).toString();
+ QString visibleName = collection.metaData(QOrganizerCollection::KeyName).toString();
+ if (visibleName.isEmpty())
+ visibleName = "Calendar " + QString::number(index);
m_calendarComboBox->addItem(visibleName);
if (collection.id() == journal.collectionId())
diff --git a/examples/calendardemo/src/todoeditpage.cpp b/examples/calendardemo/src/todoeditpage.cpp
index 41dcde1fc..81dfaccad 100644
--- a/examples/calendardemo/src/todoeditpage.cpp
+++ b/examples/calendardemo/src/todoeditpage.cpp
@@ -179,27 +179,15 @@ void TodoEditPage::todoChanged(QOrganizerManager *manager, const QOrganizerTodo
m_calendarComboBox->clear();
// resolve metadata field that contains calendar name (if any)
- QString calendarNameMetadataKey;
m_collections = m_manager->collections();
- if (!m_collections.isEmpty()) {
- QOrganizerCollection firstCollection = m_collections[0];
- QVariantMap metadata = firstCollection.metaData();
- QList<QString> metaDataKeys = metadata.keys();
- foreach(QString key, metaDataKeys) {
- if (key.indexOf("name", 0, Qt::CaseInsensitive) != -1) {
- calendarNameMetadataKey = key;
- break;
- }
- }
- }
int counter = 0;
int todoCalendarIndex = -1;
foreach(QOrganizerCollection collection, m_collections) {
// We currently have no way of stringifying ids
// QString visibleName = "Calendar id = " + QString::number(collection.id().localId());
- QString visibleName = "Calendar " + QString::number(counter);
- if (!calendarNameMetadataKey.isNull())
- visibleName = collection.metaData(calendarNameMetadataKey).toString();
+ QString visibleName = collection.metaData(QOrganizerCollection::KeyName).toString();
+ if (visibleName.isEmpty())
+ visibleName = "Calendar " + QString::number(index);
m_calendarComboBox->addItem(visibleName);
if (collection.id() == todo.collectionId())