Changeset View
Changeset View
Standalone View
Standalone View
src/covermanager/CoverFetchQueue.cpp
Show All 10 Lines | |||||
11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * | 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * | ||
12 | * * | 12 | * * | ||
13 | * You should have received a copy of the GNU General Public License along with * | 13 | * You should have received a copy of the GNU General Public License along with * | ||
14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | 14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | ||
15 | ****************************************************************************************/ | 15 | ****************************************************************************************/ | ||
16 | 16 | | |||
17 | #include "CoverFetchQueue.h" | 17 | #include "CoverFetchQueue.h" | ||
18 | 18 | | |||
19 | | ||||
19 | CoverFetchQueue::CoverFetchQueue( QObject *parent ) | 20 | CoverFetchQueue::CoverFetchQueue( QObject *parent ) | ||
20 | : QObject( parent ) | 21 | : QObject( parent ) | ||
21 | { | 22 | { | ||
22 | } | 23 | } | ||
23 | 24 | | |||
24 | CoverFetchQueue::~CoverFetchQueue() | 25 | CoverFetchQueue::~CoverFetchQueue() | ||
25 | { | 26 | { | ||
26 | } | 27 | } | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 93 | CoverFetchQueue::addQuery( const QString &query, | |||
93 | const CoverFetch::Source src, | 94 | const CoverFetch::Source src, | ||
94 | unsigned int page, | 95 | unsigned int page, | ||
95 | Meta::AlbumPtr album ) | 96 | Meta::AlbumPtr album ) | ||
96 | { | 97 | { | ||
97 | CoverFetchSearchPayload *payload = new CoverFetchSearchPayload( query, src, page, album ); | 98 | CoverFetchSearchPayload *payload = new CoverFetchSearchPayload( query, src, page, album ); | ||
98 | add( AmarokSharedPointer< CoverFetchUnit >( new CoverFetchUnit( payload ) ) ); | 99 | add( AmarokSharedPointer< CoverFetchUnit >( new CoverFetchUnit( payload ) ) ); | ||
99 | } | 100 | } | ||
100 | 101 | | |||
101 | int | | |||
102 | CoverFetchQueue::size() const | | |||
103 | { | | |||
104 | return m_queue.size(); | | |||
105 | } | | |||
106 | | ||||
107 | bool | | |||
108 | CoverFetchQueue::isEmpty() const | | |||
109 | { | | |||
110 | return m_queue.isEmpty(); | | |||
111 | } | | |||
112 | | ||||
113 | void | 102 | void | ||
114 | CoverFetchQueue::clear() | 103 | CoverFetchQueue::clear() | ||
115 | { | 104 | { | ||
116 | m_queue.clear(); | 105 | m_queue.clear(); | ||
117 | } | 106 | } | ||
118 | 107 | | |||
119 | void | 108 | void | ||
120 | CoverFetchQueue::remove( const CoverFetchUnit::Ptr unit ) | 109 | CoverFetchQueue::remove( const CoverFetchUnit::Ptr unit ) | ||
Show All 32 Lines | 141 | if( m_queue.at( i )->album() == album ) | |||
153 | return i; | 142 | return i; | ||
154 | } | 143 | } | ||
155 | return -1; | 144 | return -1; | ||
156 | } | 145 | } | ||
157 | 146 | | |||
158 | const CoverFetchUnit::Ptr | 147 | const CoverFetchUnit::Ptr | ||
159 | CoverFetchQueue::take( const Meta::AlbumPtr album ) | 148 | CoverFetchQueue::take( const Meta::AlbumPtr album ) | ||
160 | { | 149 | { | ||
161 | for( int i = 0, end = this->size(); i < end; ++i ) | 150 | for( int i = 0, end = m_queue.size(); i < end; ++i ) | ||
162 | { | 151 | { | ||
163 | const CoverFetchUnit::Ptr unit = m_queue.at( i ); | 152 | const CoverFetchUnit::Ptr unit = m_queue.at( i ); | ||
164 | if( unit->album() == album ) | 153 | if( unit->album() == album ) | ||
165 | { | 154 | { | ||
166 | m_queue.removeAt( i ); | 155 | m_queue.removeAt( i ); | ||
167 | return unit; | 156 | return unit; | ||
168 | } | 157 | } | ||
169 | } | 158 | } | ||
170 | // need to test if album exists with contains() first | 159 | // need to test if album exists with contains() first | ||
171 | return AmarokSharedPointer< CoverFetchUnit >(); | 160 | return AmarokSharedPointer< CoverFetchUnit >(); | ||
172 | } | 161 | } | ||
173 | 162 | |