1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
4
* Christian Muehlhaeuser <muesli@tomahawk-player.org>
5
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
7
* Tomahawk is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* Tomahawk is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
21
#include "PipelineStatusItem.h"
23
#include "utils/TomahawkUtilsGui.h"
25
#include "JobStatusModel.h"
26
#include "JobStatusView.h"
30
PipelineStatusItem::PipelineStatusItem( const Tomahawk::query_ptr& q )
33
connect( Tomahawk::Pipeline::instance(), SIGNAL( resolving( Tomahawk::query_ptr ) ), this, SLOT( resolving( Tomahawk::query_ptr ) ) );
34
connect( Tomahawk::Pipeline::instance(), SIGNAL( idle() ), this, SLOT( idle() ) );
41
PipelineStatusItem::~PipelineStatusItem()
47
PipelineStatusItem::rightColumnText() const
49
return QString( "%1" ).arg( Tomahawk::Pipeline::instance()->activeQueryCount() + Tomahawk::Pipeline::instance()->pendingQueryCount() );
54
PipelineStatusItem::mainText() const
61
PipelineStatusItem::idle()
63
if ( !Tomahawk::Pipeline::instance()->activeQueryCount() )
69
PipelineStatusItem::icon() const
71
return TomahawkUtils::defaultPixmap( TomahawkUtils::Search );
76
PipelineStatusItem::resolving( const Tomahawk::query_ptr& query )
78
if ( query->isFullTextQuery() )
79
m_latestQuery = query->fullTextQuery();
81
m_latestQuery = QString( "%1 - %2" ).arg( query->artist() ).arg( query->track() );
83
if ( m_latestQuery.isEmpty() )
84
qDebug() << "EMPTY STRING IN STATUS ITEM:" << query->fullTextQuery() << query->track() << query->artist() << query->album();
85
Q_ASSERT( !m_latestQuery.isEmpty() );
91
PipelineStatusManager::PipelineStatusManager( QObject* parent )
94
connect( Tomahawk::Pipeline::instance(), SIGNAL( resolving( Tomahawk::query_ptr ) ), this, SLOT( resolving( Tomahawk::query_ptr ) ) );
99
PipelineStatusManager::resolving( const Tomahawk::query_ptr& p )
101
if ( m_curItem.isNull() )
103
// No current query item and we're resolving something, so show it
104
m_curItem = QWeakPointer< PipelineStatusItem >( new PipelineStatusItem( p ) );
105
JobStatusView::instance()->model()->addJob( m_curItem.data() );