[Kde-pim] note format

Kevin Krammer krammer at kde.org
Tue Mar 18 15:10:47 GMT 2014


Hi Patrick,

On Tuesday, 2014-03-18, 15:53:00, Patrick Ohly wrote:
> 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.

Ah, a misunderstanding :-/
The fromUrl() method is just a convenience method to parse URLs create by 
Collection::url(), i.e. a way to initialize a Collection instance with the 
data contained in the URL.
The URL either contains just the identifier or the identifier+name of the 
collection.

So all information available after fromUrl() is basically the identifier.

All of a collection's other properties have to be retrieved from the server 
(using a CollectionFetchJob).

> 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?

You'll need to handle the job's result, the arguments are not passed by 
reference or pointer and cannot be modified by the job.

I.e. the CollectionFetchJob works almost exactly like the ItemFetchJob: you 
provide identifyable collection(s), what kind of information details you are 
interested in (fetch scope) and it notifies you on hits and when it is done.

Cheers,
Kevin

-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20140318/89641136/attachment.sig>
-------------- next part --------------
_______________________________________________
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