2 * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "CollectionLocation.h"
20 #include "Collection.h"
22 CollectionLocation::CollectionLocation()
28 CollectionLocation::CollectionLocation( const Collection
* parentCollection
)
31 m_parentCollection
= parentCollection
;
34 CollectionLocation::~CollectionLocation()
40 CollectionLocation::collection() const
42 return m_parentCollection
;
46 CollectionLocation::prettyLocation() const
52 CollectionLocation::isWriteable() const
58 CollectionLocation::prepareCopy( Meta::TrackPtr track
, CollectionLocation
*destination
)
62 prepareCopy( list
, destination
);
67 CollectionLocation::prepareCopy( const Meta::TrackList
&tracks
, CollectionLocation
*destination
)
69 if( !destination
->isWriteable() )
71 m_destination
= destination
;
73 KUrl::List urls
= getKIOCopyableUrls( tracks
);
74 emit
startCopy( urls
, false );
78 CollectionLocation::prepareMove( Meta::TrackPtr track
, CollectionLocation
*destination
)
82 prepareMove( list
, destination
);
86 CollectionLocation::prepareMove( const Meta::TrackList
&tracks
, CollectionLocation
*destination
)
88 if( !destination
->isWriteable() )
90 m_destination
= destination
;
92 KUrl::List urls
= getKIOCopyableUrls( tracks
);
93 emit
startCopy( urls
, true );
97 CollectionLocation::remove( Meta::TrackPtr track
)
104 CollectionLocation::getKIOCopyableUrls( const Meta::TrackList
&tracks
)
107 foreach( Meta::TrackPtr track
, tracks
)
108 if( track
->isPlayable() )
109 urls
.append( track
->playableUrl() );
115 CollectionLocation::copyUrlsToCollection( const KUrl::List
&sources
)
117 //reimplement in implementations which are writeable
119 slotCopyOperationFinished();
123 CollectionLocation::slotCopyOperationFinished()
125 emit
finishCopy( m_removeSources
);
129 CollectionLocation::slotStartCopy( const KUrl::List
&sources
, bool removeSources
)
131 m_removeSources
= removeSources
;
132 copyUrlsToCollection( sources
);
136 CollectionLocation::slotFinishCopy( bool removeSources
)
139 removeSourceTracks( m_sourceTracks
);
140 m_sourceTracks
.clear();
141 m_destination
->deleteLater();
146 CollectionLocation::setupConnections()
148 connect( this, SIGNAL( startCopy( KUrl::List
, bool ) ),
149 m_destination
, SLOT( slotStartCopy( KUrl::List
, bool ) ) );
150 connect( m_destination
, SIGNAL( finishCopy( bool ) ),
151 this, SLOT( slotFinishCopy( bool ) ) );
155 CollectionLocation::removeSourceTracks( const Meta::TrackList
&tracks
)
157 Meta::TrackList notDeletableTracks
;
158 foreach( Meta::TrackPtr track
, tracks
)
160 if( !remove( track
) )
161 notDeletableTracks
.append( track
);
163 //TODO inform user about tracks which were not deleted
166 #include "CollectionLocation.moc"