[Kde-pim] note format

Patrick Ohly patrick.ohly at gmx.de
Tue Mar 18 14:53:00 GMT 2014


On Tue, 2014-03-18 at 12:13 +0100, Kevin Krammer wrote:
> On Tuesday, 2014-03-18, 11:20:38, Patrick Ohly wrote:
> 
> > However, Collection::getContentMimeTypes() returns an empty list in this
> > code:
> > 
> >     m_collection = Collection::fromUrl(KUrl(id.c_str()));
> >     m_contentMimeType = "";
> >     QStringList collectionMimeTypes = m_collection.contentMimeTypes();
> >     foreach (const QString &mimeType, m_mimeTypes) {
> >         if (collectionMimeTypes.contains(mimeType)) {
> >             m_contentMimeType = mimeType;
> >             break;
> >         }
> >     }
> >     if (m_contentMimeType.isEmpty()) {
> >         SE_THROW(StringPrintf("Resource %s cannot store items of type(s) %s.
> > It can only store %s.", id.c_str(),
> >                               m_mimeTypes.join(",").toUtf8().constData(),
> >                              
> > collectionMimeTypes.join(",").toUtf8().constData())); }
> > 
> > Why is that? The collection is found by a CollectionFetchJob with a
> > scope including the m_mimeTypes list, so the URL is right.
> 
> Whatever was in m_collection is overwritten by Collection::fromUrl()
> From then on it only contains the collection id.
> 
> Unless your code snippet is missing the colleciton fetch job between line two 
> an three?

The code is as I have it at the moment. The documentation [1] does not
mention that Collection::fromUrl() only returns a partially usable
Collection instance. It might be worthwhile to add that.

If I add a CollectionFetchJob, does that automatically enhance the
Collection instance for which I already have a handle (in m_collection),
or do I need to get the final instance from the fetch response?

Bye, Patrick

[1] http://api.kde.org/4.x-api/kdepimlibs-apidocs/akonadi/html/classAkonadi_1_1Collection.html

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list