where do they collections declare that they are queryable?

Maximilian Kossick maximilian.kossick at googlemail.com
Wed Jul 29 10:52:52 CEST 2009


On Sun, Jul 26, 2009 at 7:32 PM, Ian Monroe<ian.monroe at gmail.com> wrote:
> On Sun, Jul 26, 2009 at 10:34 AM, Casey Link<unnamedrambler at gmail.com> wrote:
>>> I see where being enabled or not gets set, I can't figure out where a
>>> collection being queryable gets set.
>>
>> That's because it isn't explicitly set (like it is for service
>> collections like Ampache), but rather determined on the fly in
>> CollectionManager::slotNewCollection( Amarok::Collection* newCollection )
>>
>> Personally, I don't understand the MetaObject blackmagic it is doing..
>> but the key line is:
>> enumValue == -1 ? status = CollectionEnabled : status =
>> (CollectionStatus) enumValue;
>>
>> For the SqlCollection enumValue always == -1, so it's status is set to
>> CollectionEnabled.
>>
>> I don't there there exists a collection that ever makes it to the
>> latter half of that trinary operation, and I wouldn't know how to make
>> one. Ask Maxx!
>
> Ok, just to conclude the thread I figured out what this bitrotted code
> was doign. Basically slotNewCollection is only called for
> SqlCollection, so the code looks like it sets Enabled to all
> collections thats because it does. (Enabled, btw, doesn't mean the
> user decided to enable it, it means the collection is 'visible' and
> queryable).
>
> On top of that, Magnatune isn't even in the Collection Manager. I
> don't know why.
>
> Leo said he did a refactor of this class some months ago, we might try
> to revive this.
>
> Ian

Except that this code is not bitrotted but does what it is supposed to
do. CollectionManager stores the status of all collections (as defiend
by a call to setCollectionStatus) in amarokrc. It does not store the
integer value of the enum, but instead writes and reads the name of
the enum value. That's where all the metaobject magic comes in.

As far as I know setCollectionStatus is currently not used, as we do
not provide a GUI for the user. The idea behind is that e.g. a user
could decide to use ampache or magnatune tracks for dynamic playlists
or that they should be shown in the collection browser (a unified
collection browser; both the service tab and the collection browser
tab use the same view). Therefore all collections use the default
status, which is either automatically set in slotNewCollection (e.g.
for SqlCollection or media devices) or passed in as argument to
addUnmanagedCollection.

Max

ps: sorry for the late reply, but I'm on vacation and did not have
time to check my mails for the last few days


More information about the Amarok-devel mailing list