1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-20 16:02:07 +02:00

Add new jobs status view

This commit is contained in:
Leo Franchi 2011-09-16 18:37:36 -04:00
parent 2ce5bb1fea
commit 6970ea39e4
17 changed files with 779 additions and 16 deletions

View File

@ -115,5 +115,6 @@
<file>data/images/drop-top-songs.png</file>
<file>data/images/drop-song.png</file>
<file>data/images/drop-album.png</file>
<file>data/images/spotify-logo.jpg</file>
</qresource>
</RCC>

View File

@ -63,10 +63,13 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
sourcetree/items/genericpageitems.cpp
sourcetree/items/temporarypageitem.cpp
jobview/JobStatusView.cpp
jobview/JobStatusModel.cpp
jobview/JobStatusDelegate.cpp
jobview/PipelineStatusItem.cpp
# breakpad/BreakPad.cpp
transferview.cpp
PipelineStatusView.cpp
tomahawktrayicon.cpp
audiocontrols.cpp
settingsdialog.cpp
@ -115,8 +118,13 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
sourcetree/items/genericpageitems.h
sourcetree/items/temporarypageitem.h
jobview/JobStatusView.h
jobview/JobStatusModel.h
jobview/JobStatusDelegate.h
jobview/JobStatusItem.h
jobview/PipelineStatusItem.h
transferview.h
PipelineStatusView.h
tomahawktrayicon.h
audiocontrols.h
settingsdialog.h

View File

@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,7 +17,7 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PipelineStatusView.h"
#include "JobStatusView.h"
#include <QHeaderView>
#include <QVBoxLayout>
@ -28,7 +29,7 @@
using namespace Tomahawk;
PipelineStatusView::PipelineStatusView( AnimatedSplitter* parent )
JobStatusView::JobStatusView( AnimatedSplitter* parent )
: AnimatedWidget( parent )
, m_parent( parent )
{
@ -76,7 +77,7 @@ PipelineStatusView::PipelineStatusView( AnimatedSplitter* parent )
void
PipelineStatusView::onPipelineUpdate( const query_ptr& query )
JobStatusView::onPipelineUpdate( const query_ptr& query )
{
QTreeWidgetItem* ti = m_tree->invisibleRootItem()->child( 0 );
@ -100,7 +101,7 @@ PipelineStatusView::onPipelineUpdate( const query_ptr& query )
QSize
PipelineStatusView::sizeHint() const
JobStatusView::sizeHint() const
{
unsigned int y = 0;
y += m_tree->header()->height();

View File

@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,8 +17,8 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINESTATUSVIEW_H
#define PIPELINESTATUSVIEW_H
#ifndef JOBSTATUSVIEW_H
#define JOBSTATUSVIEW_H
#include <QTreeWidget>
@ -27,13 +28,13 @@
class StreamConnection;
class PipelineStatusView : public AnimatedWidget
class JobStatusView : public AnimatedWidget
{
Q_OBJECT
public:
explicit PipelineStatusView( AnimatedSplitter* parent );
virtual ~PipelineStatusView()
explicit JobStatusView( AnimatedSplitter* parent );
virtual ~JobStatusView()
{
}
@ -43,8 +44,8 @@ private slots:
void onPipelineUpdate( const Tomahawk::query_ptr& query = Tomahawk::query_ptr() );
private:
QTreeWidget* m_tree;
QTreeView* m_tree;
AnimatedSplitter* m_parent;
};
#endif // TRANSFERVIEW_H
#endif // JOBSTATUSVIEW_H

View File

@ -0,0 +1,82 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "JobStatusDelegate.h"
#include <QPainter>
#include <QApplication>
#include "JobStatusModel.h"
#define ROW_HEIGHT 20
#define PADDING 2
JobStatusDelegate::JobStatusDelegate( QObject* parent )
: QStyledItemDelegate ( parent )
{
}
JobStatusDelegate::~JobStatusDelegate()
{
}
void
JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
QStyleOptionViewItemV4 opt = option;
initStyleOption( &opt, index );
QFontMetrics fm( opt.font );
QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget );
painter->setRenderHint( QPainter::Antialiasing );
painter->drawLine( opt.rect.topLeft(), opt.rect.topRight() );
const QRect iconRect( PADDING, PADDING + opt.rect.y(), ROW_HEIGHT - 2*PADDING, ROW_HEIGHT - 2*PADDING );
QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
p = p.scaled( iconRect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation );
painter->drawPixmap( iconRect, p );
// draw right column if there is one
const QString rCol = index.data( JobStatusModel::RightColumnRole ).toString();
int rightEdge = opt.rect.right();
if ( !rCol.isEmpty() )
{
const int w = fm.width( rCol );
const QRect rRect( opt.rect.right() - PADDING - w, PADDING + opt.rect.y(), w, opt.rect.height() - 2*PADDING );
painter->drawText( rRect, Qt::AlignCenter, rCol );
rightEdge = rRect.left();
}
const int mainW = rightEdge - iconRect.right();
QString mainText = index.data( Qt::DisplayRole ).toString();
mainText = fm.elidedText( mainText, Qt::ElideRight, mainW );
painter->drawText( QRect( iconRect.right() + 2*PADDING, PADDING + opt.rect.y(), mainW, opt.rect.height() - 2*PADDING ), Qt::AlignLeft | Qt::AlignVCenter, mainText );
}
QSize
JobStatusDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
// return QStyledItemDelegate::sizeHint( option, index );
const int w = QStyledItemDelegate::sizeHint ( option, index ).width();
return QSize( w, ROW_HEIGHT );
}

View File

@ -0,0 +1,38 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOBSTATUSDELEGATE_H
#define JOBSTATUSDELEGATE_H
#include <QStyledItemDelegate>
class QPainter;
class JobStatusDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit JobStatusDelegate ( QObject* parent = 0 );
virtual ~JobStatusDelegate();
virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
};
#endif // JOBSTATUSDELEGATE_H

View File

@ -0,0 +1,65 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOB_STATUS_ITEM
#define JOB_STATUS_ITEM
#include <QObject>
#include <QPixmap>
/**
* Implement your own JobStatusItem if you want to add some sort of job status entry in the JobStatusView.
*
* Status items have 3 columns:
* ________________________________
* | icon | main col | right col|
* _________________________________
*
* The right column may be empty.
*
*/
class JobStatusItem : public QObject
{
Q_OBJECT
public:
explicit JobStatusItem() : QObject() {}
virtual ~JobStatusItem() {}
virtual QString type() const = 0;
/// Please cache this.
virtual QPixmap icon() const = 0;
virtual QString mainText() const = 0;
virtual QString rightColumnText() const = 0;
/**
* If collapse item is true, sending multiple items of the same type will "collapse" them into one
* instead of showing each individually. In this case, the right column from the item will be ignored
* and a count will be shown instead.
*/
virtual bool collapseItem() const { return false; }
signals:
/// Ask for an update
void statusChanged();
/// Job is finished, will be deleted by the model
void finished();
};
#endif

View File

@ -0,0 +1,146 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "JobStatusModel.h"
#include "JobStatusItem.h"
JobStatusModel::JobStatusModel( QObject* parent )
: QAbstractListModel ( parent )
{
}
JobStatusModel::~JobStatusModel()
{
qDeleteAll( m_items );
m_collapseCount.clear();
}
void
JobStatusModel::addJob( JobStatusItem* item )
{
if ( item->collapseItem() )
{
if ( m_collapseCount.contains( item->type() ) )
{
m_collapseCount[ item->type() ].append( item );
return; // we're done, no new rows
}
else
{
m_collapseCount.insert( item->type(), QList< JobStatusItem* >() << item );
}
}
connect( item, SIGNAL( statusChanged() ), this, SLOT( itemUpdated() ) );
connect( item, SIGNAL( finished() ), this, SLOT( itemFinished() ) );
beginInsertRows( QModelIndex(), 0, 0 );
m_items.prepend( item );
endInsertRows();
}
Qt::ItemFlags
JobStatusModel::flags( const QModelIndex& index ) const
{
// Don't let the items be selectable
return Qt::ItemIsEnabled;
}
QVariant
JobStatusModel::data( const QModelIndex& index, int role ) const
{
if ( !hasIndex( index.row(), index.column(), index.parent() ) )
return QVariant();
JobStatusItem* item = m_items[ index.row() ];
switch ( role )
{
case Qt::DecorationRole:
return item->icon();
case Qt::DisplayRole:
{
if ( m_collapseCount.contains( item->type() ) )
return m_collapseCount[ item->type() ].last()->mainText();
else
return item->mainText();
}
case RightColumnRole:
{
if ( m_collapseCount.contains( item->type() ) )
return m_collapseCount[ item->type() ].count();
else
return item->rightColumnText();
}
}
return QVariant();
}
int
JobStatusModel::rowCount( const QModelIndex& parent ) const
{
return m_items.count();
}
void
JobStatusModel::itemFinished()
{
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
Q_ASSERT( item );
if ( m_collapseCount.contains( item->type() ) )
{
m_collapseCount[ item->type() ].removeAll( item );
if ( m_collapseCount[ item->type() ].isEmpty() )
m_collapseCount.remove( item->type() );
else
{
// One less to count, but item is still there
const QModelIndex idx = index( m_items.indexOf( m_collapseCount[ item->type() ].first() ), 0, QModelIndex() );
emit dataChanged( idx, idx );
return;
}
}
// Remove row completely
const int idx = m_items.indexOf( item );
beginRemoveRows( QModelIndex(), idx, idx );
m_items.removeAll( item );
endRemoveRows();
item->deleteLater();
}
void
JobStatusModel::itemUpdated()
{
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
Q_ASSERT( item );
if ( m_collapseCount.contains( item->type() ) )
item = m_collapseCount[ item->type() ].first();
const QModelIndex idx = index( m_items.indexOf( item ), 0, QModelIndex() );
emit dataChanged( idx, idx );
return;
}

View File

@ -0,0 +1,54 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOBSTATUSMODEL_H
#define JOBSTATUSMODEL_H
#include <QModelIndex>
class JobStatusItem;
class JobStatusModel : public QAbstractListModel
{
Q_OBJECT
public:
enum JobRoles {
// DecorationRole is icon
// DisplayRole is main col
RightColumnRole = Qt::UserRole + 1
};
explicit JobStatusModel( QObject* parent = 0 );
virtual ~JobStatusModel();
virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
/// Takes ownership of job
void addJob( JobStatusItem* item );
private slots:
void itemUpdated();
void itemFinished();
private:
QList< JobStatusItem* > m_items;
QHash< QString, QList< JobStatusItem* > > m_collapseCount;
};
#endif // JOBSTATUSMODEL_H

View File

@ -0,0 +1,110 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "JobStatusView.h"
#include "libtomahawk/pipeline.h"
#include "JobStatusModel.h"
#include "JobStatusDelegate.h"
#include "PipelineStatusItem.h"
#include "utils/logger.h"
#include <QHeaderView>
#include <QVBoxLayout>
#include <QListView>
#include <QAbstractItemModel>
using namespace Tomahawk;
JobStatusView::JobStatusView( AnimatedSplitter* parent )
: AnimatedWidget( parent )
, m_parent( parent )
{
setHiddenSize( QSize( 0, 0 ) );
setLayout( new QVBoxLayout() );
m_view = new QListView( this );
layout()->setMargin( 0 );
layout()->addWidget( m_view );
m_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_view->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored );
m_view->setFrameShape( QFrame::NoFrame );
m_view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
// new QTreeWidgetItem( m_tree );
m_view->setUniformItemSizes( true );
#ifndef Q_WS_WIN
QFont f = font();
f.setPointSize( f.pointSize() - 1 );
setFont( f );
#endif
#ifdef Q_WS_MAC
f.setPointSize( f.pointSize() - 2 );
setFont( f );
#endif
hideWidget();
new PipelineStatusManager( this );
}
void
JobStatusView::setModel( QAbstractItemModel* m )
{
m_view->setModel( m );
m_view->setItemDelegate( new JobStatusDelegate( m_view ) );
connect( m_view->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
connect( m_view->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
}
void
JobStatusView::checkCount()
{
if ( m_view->model()->rowCount() == 0 && !isHidden() )
emit hideWidget();
else if ( isHidden() && m_view->model()->rowCount() > 0 )
emit showWidget();
}
QSize
JobStatusView::sizeHint() const
{
unsigned int y = 0;
// y += m_tree->header()->height();
y += m_view->contentsMargins().top() + m_view->contentsMargins().bottom();
if ( m_view->model()->rowCount() )
{
unsigned int rowheight = m_view->sizeHintForRow( 0 );
y += rowheight * m_view->model()->rowCount() + 2;
}
return QSize( 0, y );
}

View File

@ -0,0 +1,53 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOBSTATUSVIEW_H
#define JOBSTATUSVIEW_H
#include "typedefs.h"
#include "widgets/animatedsplitter.h"
class QAbstractItemModel;
class QListView;
class JobStatusModel;
class StreamConnection;
class JobStatusView : public AnimatedWidget
{
Q_OBJECT
public:
explicit JobStatusView( AnimatedSplitter* parent );
virtual ~JobStatusView()
{
}
QSize sizeHint() const;
void setModel( QAbstractItemModel* model );
private slots:
void checkCount();
private:
QListView* m_view;
AnimatedSplitter* m_parent;
};
#endif // JOBSTATUSVIEW_H

View File

@ -0,0 +1,81 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PipelineStatusItem.h"
#include "utils/tomahawkutils.h"
#include "pipeline.h"
#include "tomahawkapp.h"
#include "JobStatusModel.h"
PipelineStatusItem::PipelineStatusItem()
: JobStatusItem()
{
m_icon.load( RESPATH"images/search-icon.png" );
connect( Tomahawk::Pipeline::instance(), SIGNAL( resolving( Tomahawk::query_ptr ) ), this, SLOT( resolving( Tomahawk::query_ptr ) ) );
connect( Tomahawk::Pipeline::instance(), SIGNAL( idle() ), this, SLOT( idle() ) );
}
PipelineStatusItem::~PipelineStatusItem()
{
}
QString
PipelineStatusItem::rightColumnText() const
{
return QString( "%1" ).arg( Tomahawk::Pipeline::instance()->activeQueryCount() + Tomahawk::Pipeline::instance()->pendingQueryCount() );
}
QString
PipelineStatusItem::mainText() const
{
return m_latestQuery;
}
void
PipelineStatusItem::idle()
{
if ( !Tomahawk::Pipeline::instance()->activeQueryCount() )
emit finished();
}
void
PipelineStatusItem::resolving( const Tomahawk::query_ptr& query )
{
m_latestQuery = QString( "%1 - %2" ).arg( query->artist() ).arg( query->track() );
emit statusChanged();
}
PipelineStatusManager::PipelineStatusManager( QObject* parent )
: QObject(parent)
{
connect( Tomahawk::Pipeline::instance(), SIGNAL( resolving( Tomahawk::query_ptr ) ), this, SLOT( resolving( Tomahawk::query_ptr ) ) );
}
void
PipelineStatusManager::resolving( const Tomahawk::query_ptr& p )
{
if ( m_curItem.isNull() )
{
// No current query item and we're resolving something, so show it
m_curItem = QWeakPointer< PipelineStatusItem >( new PipelineStatusItem );
APP->mainWindow()->jobsModel()->addJob( m_curItem.data() );
}
}

View File

@ -0,0 +1,64 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINESTATUSITEM_H
#define PIPELINESTATUSITEM_H
#include "jobview/JobStatusItem.h"
#include "query.h"
class PipelineStatusItem : public JobStatusItem
{
Q_OBJECT
public:
explicit PipelineStatusItem();
virtual ~PipelineStatusItem();
virtual QString rightColumnText() const;
virtual QString mainText() const;
virtual QPixmap icon() const { return m_icon; }
virtual QString type() const { return "pipeline"; }
virtual bool collapseItem() const { return false; } // We can't collapse, since we use this meta-item instead of one per resolve
private slots:
void resolving( const Tomahawk::query_ptr& query );
void idle();
private:
QPixmap m_icon;
QString m_latestQuery;
};
class PipelineStatusManager : public QObject
{
Q_OBJECT
public:
explicit PipelineStatusManager( QObject* parent = 0 );
virtual ~PipelineStatusManager() {}
private slots:
void resolving( const Tomahawk::query_ptr& p );
private:
QWeakPointer<PipelineStatusItem> m_curItem;
};
#endif // PIPELINESTATUSITEM_H

View File

@ -29,6 +29,32 @@
using namespace Tomahawk;
QPixmap SpotifyParser::s_pixmap = QPixmap();
SpotifyJobNotifier::SpotifyJobNotifier( const QString &type, const QPixmap& pixmap )
: JobStatusItem()
, m_type( type )
, m_icon( pixmap )
{
}
SpotifyJobNotifier::~SpotifyJobNotifier()
{}
QString
SpotifyJobNotifier::rightColumnText() const
{
}
QString
SpotifyJobNotifier::mainText() const
{
}
SpotifyParser::SpotifyParser( const QStringList& Urls, bool createNewPlaylist, QObject* parent )
: QObject ( parent )
, m_single( false )
@ -46,6 +72,9 @@ SpotifyParser::SpotifyParser( const QString& Url, bool createNewPlaylist, QObjec
, m_trackMode( true )
, m_createNewPlaylist( createNewPlaylist )
{
if ( s_pixmap.isNull() )
s_pixmap.load( RESPATH "images/spotify-logo.jpg" );
lookupUrl( Url );
}

View File

@ -22,6 +22,7 @@
#include "dllmacro.h"
#include "typedefs.h"
#include "query.h"
#include "jobview/JobStatusItem.h"
#include <QObject>
#include <QSet>
@ -69,6 +70,29 @@ private:
QSet< QNetworkReply* > m_queries;
QString m_title, m_info, m_creator;
Tomahawk::playlist_ptr m_playlist;
static QPixmap s_pixmap;
};
class DLLEXPORT SpotifyJobNotifier : public JobStatusItem
{
Q_OBJECT
friend class SpotifyParser;
public:
SpotifyJobNotifier( const QString& type, const QPixmap& pixmap );
virtual ~SpotifyJobNotifier();
virtual QString rightColumnText() const;
virtual QString mainText() const;
virtual QPixmap icon() const { return m_icon; }
virtual QString type() const { return m_type; }
virtual bool collapseItem() const { return true; }
private:
void set
QPixmap m_icon;
QString m_type;
};
}

View File

@ -57,7 +57,7 @@
#include "diagnosticsdialog.h"
#include "tomahawksettings.h"
#include "sourcelist.h"
#include "PipelineStatusView.h"
#include "jobview/JobStatusView.h"
#include "transferview.h"
#include "tomahawktrayicon.h"
#include "scanmanager.h"
@ -68,6 +68,7 @@
#endif
#include "utils/logger.h"
#include "jobview/JobStatusModel.h"
using namespace Tomahawk;
@ -205,7 +206,9 @@ TomahawkWindow::setupSideBar()
m_sourcetree = new SourceTreeView();
TransferView* transferView = new TransferView( m_sidebar );
PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar );
JobStatusView* jobsView = new JobStatusView( m_sidebar );
m_jobsModel = new JobStatusModel( jobsView );
jobsView->setModel( m_jobsModel );
m_queueView = new QueueView( m_sidebar );
m_queueModel = new PlaylistModel( m_queueView );
@ -217,7 +220,7 @@ TomahawkWindow::setupSideBar()
m_sidebar->addWidget( m_searchWidget );
m_sidebar->addWidget( m_sourcetree );
m_sidebar->addWidget( transferView );
m_sidebar->addWidget( pipelineView );
m_sidebar->addWidget( jobsView );
m_sidebar->addWidget( m_queueView );
m_sidebar->setGreedyWidget( 1 );

View File

@ -28,6 +28,7 @@
#include "result.h"
#include "utils/xspfloader.h"
class JobStatusModel;
class QSearchField;
class SipPlugin;
class SourceTreeView;
@ -56,6 +57,7 @@ public:
AudioControls* audioControls() { return m_audioControls; }
SourceTreeView* sourceTreeView() const { return m_sourcetree; }
JobStatusModel* jobsModel() const { return m_jobsModel; }
void setWindowTitle( const QString& title );
@ -130,6 +132,7 @@ private:
PlaylistModel* m_queueModel;
QueueView* m_queueView;
AnimatedSplitter* m_sidebar;
JobStatusModel* m_jobsModel;
Tomahawk::result_ptr m_currentTrack;
QString m_windowTitle;