Importing Tracks into a collection

Seb Ruiz ruiz at kde.org
Tue Oct 28 22:09:22 CET 2008


2008/10/28 Jeff Mitchell <kde-dev at emailgoeshere.com>:
> Maximilian Kossick wrote:
>> a quick and dirty way would be to check the current thread in the
>> sqlcollectionlocation showdestination dialog method, and use a default
>> way to determine the file location if the thread is not the gui
>> thread.
>>
>> another way would be to add a setParameters(QMap<QString, QVariant>)
>> method to collectionlocation, and check for some magic values in
>> sqlcollectionlocation
>>
>> Cheers, Max
>>
>> On Tue, Oct 28, 2008 at 11:22 AM, Seb Ruiz <ruiz at kde.org> wrote:
>>> Hi Max or anybody else,
>>> With the importer I need to be able to insert Meta::TrackPtrs into the
>>> SqlCollection. I've seen that when copying files to a collection this
>>> is done through the CollectionLocation. There doesn't seem to be any
>>> straight forward method of doing this. The only solution I can think
>>> of is to use a dummy FileCollectionLocation and do a prepareCopy() on
>>> the track that I need to import. However this is inappropriate since
>>> the Collection Location will try to spawn an "organise" dialog should
>>> not be done (as the file location shouldn't actually change) and
>>> cannot be done since it is being executed outside of a GUI thread.
>
> Maybe try using the static QThread::currentThread() compared to
> MainWindow::thread()?  (All QObjects have ::thread(), which returns the
> thread in which the object lives; QThread::currentThread() returns the
> currently executing thread).  I am assuming comparing the pointers
> should be okay...

No, to be honest I really don't want to be using any approach that
requires checking of threads. There is definitely an incorrect meshing
of design and use cases if this is required. Keep in mind that I don't
want to do anything fancy with the TrackPtrs, aside from enter them in
the database (they should *not* be renamed, moved, organised or
modified in anyway).

Perhaps it would be better to augment CollectionLocation with a method
that would allow a direct insertion of tracks into the database,
similar to what insertTracks( const QMap<Meta::TrackPtr, QString>
&trackMap ); does in SqlCollectionLocation.


-- 
Seb Ruiz

http://www.sebruiz.net/
http://amarok.kde.org/


More information about the Amarok-devel mailing list