mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-21 05:11:44 +02:00
Add a transfer item to jobsview
Add files work add file
This commit is contained in:
BIN
data/images/downloading.png
Executable file
BIN
data/images/downloading.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
data/images/headphones.png
Executable file
BIN
data/images/headphones.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
data/images/uploading.png
Executable file
BIN
data/images/uploading.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@@ -116,5 +116,8 @@
|
|||||||
<file>data/images/drop-song.png</file>
|
<file>data/images/drop-song.png</file>
|
||||||
<file>data/images/drop-album.png</file>
|
<file>data/images/drop-album.png</file>
|
||||||
<file>data/images/spotify-logo.jpg</file>
|
<file>data/images/spotify-logo.jpg</file>
|
||||||
|
<file>data/images/uploading.png</file>
|
||||||
|
<file>data/images/downloading.png</file>
|
||||||
|
<file>data/images/headphones.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@@ -65,7 +65,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
|||||||
|
|
||||||
# breakpad/BreakPad.cpp
|
# breakpad/BreakPad.cpp
|
||||||
|
|
||||||
transferview.cpp
|
|
||||||
tomahawktrayicon.cpp
|
tomahawktrayicon.cpp
|
||||||
audiocontrols.cpp
|
audiocontrols.cpp
|
||||||
settingsdialog.cpp
|
settingsdialog.cpp
|
||||||
@@ -114,7 +113,6 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
|||||||
sourcetree/items/genericpageitems.h
|
sourcetree/items/genericpageitems.h
|
||||||
sourcetree/items/temporarypageitem.h
|
sourcetree/items/temporarypageitem.h
|
||||||
|
|
||||||
transferview.h
|
|
||||||
tomahawktrayicon.h
|
tomahawktrayicon.h
|
||||||
audiocontrols.h
|
audiocontrols.h
|
||||||
settingsdialog.h
|
settingsdialog.h
|
||||||
|
@@ -219,6 +219,7 @@ set( libSources
|
|||||||
jobview/JobStatusModel.cpp
|
jobview/JobStatusModel.cpp
|
||||||
jobview/JobStatusDelegate.cpp
|
jobview/JobStatusDelegate.cpp
|
||||||
jobview/PipelineStatusItem.cpp
|
jobview/PipelineStatusItem.cpp
|
||||||
|
jobview/TransferStatusItem.cpp
|
||||||
|
|
||||||
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp
|
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp
|
||||||
thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp
|
thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp
|
||||||
@@ -431,6 +432,7 @@ set( libHeaders
|
|||||||
jobview/JobStatusDelegate.h
|
jobview/JobStatusDelegate.h
|
||||||
jobview/JobStatusItem.h
|
jobview/JobStatusItem.h
|
||||||
jobview/PipelineStatusItem.h
|
jobview/PipelineStatusItem.h
|
||||||
|
jobview/TransferStatusItem.h
|
||||||
|
|
||||||
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h
|
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h
|
||||||
thirdparty/Qocoa/qsearchfield.h
|
thirdparty/Qocoa/qsearchfield.h
|
||||||
|
55
src/libtomahawk/database/DatabaseCommand_Latched.cpp
Normal file
55
src/libtomahawk/database/DatabaseCommand_Latched.cpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/* === 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 "DatabaseCommand_Latched.h"
|
||||||
|
|
||||||
|
DatabaseCommand_Latched::DatabaseCommand_Latched(QObject* parent): DatabaseCommandLoggable(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseCommand_Latched::DatabaseCommand_Latched(const Tomahawk::source_ptr& s, QObject* parent): DatabaseCommandLoggable(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DatabaseCommand_Latched::doesMutates() const
|
||||||
|
{
|
||||||
|
return DatabaseCommand::doesMutates();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseCommand_Latched::exec(DatabaseImpl* )
|
||||||
|
{
|
||||||
|
DatabaseCommand::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseCommand_Latched::postCommitHook()
|
||||||
|
{
|
||||||
|
DatabaseCommand::postCommitHook();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DatabaseCommand_Latched::singletonCmd() const
|
||||||
|
{
|
||||||
|
return DatabaseCommand::singletonCmd();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DatabaseCommand_Latched::localOnly() const
|
||||||
|
{
|
||||||
|
return DatabaseCommand::localOnly();
|
||||||
|
}
|
||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,40 +16,30 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TRANSFERVIEW_H
|
#ifndef DATABASECOMMAND_LATCHED_H
|
||||||
#define TRANSFERVIEW_H
|
#define DATABASECOMMAND_LATCHED_H
|
||||||
|
|
||||||
#include <QTreeWidget>
|
#include "database/databasecommandloggable.h"
|
||||||
|
|
||||||
#include "typedefs.h"
|
class DatabaseImpl;
|
||||||
#include "widgets/animatedsplitter.h"
|
|
||||||
|
|
||||||
class StreamConnection;
|
class DatabaseCommand_Latched : public DatabaseCommandLoggable
|
||||||
|
|
||||||
class TransferView : public AnimatedWidget
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TransferView( AnimatedSplitter* parent );
|
enum LatchAction {
|
||||||
virtual ~TransferView()
|
LatchedOn = 0,
|
||||||
{
|
LatchedOff
|
||||||
}
|
};
|
||||||
|
|
||||||
QSize sizeHint() const;
|
explicit DatabaseCommand_Latched( QObject* parent = 0 );
|
||||||
|
explicit DatabaseCommand_Latched( const Tomahawk::source_ptr& s, QObject* parent = 0 );
|
||||||
|
|
||||||
signals:
|
virtual bool doesMutates() const { return true; }
|
||||||
|
virtual void exec( DatabaseImpl* );
|
||||||
private slots:
|
virtual void postCommitHook();
|
||||||
void streamRegistered( StreamConnection* sc );
|
virtual bool singletonCmd() const;
|
||||||
void streamFinished( StreamConnection* sc );
|
virtual bool localOnly() const;
|
||||||
|
|
||||||
void onTransferUpdate();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QHash< StreamConnection*, QPersistentModelIndex > m_index;
|
|
||||||
QTreeWidget* m_tree;
|
|
||||||
AnimatedSplitter* m_parent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSFERVIEW_H
|
#endif // DATABASECOMMAND_LATCHED_H
|
@@ -18,9 +18,11 @@
|
|||||||
|
|
||||||
#include "JobStatusDelegate.h"
|
#include "JobStatusDelegate.h"
|
||||||
|
|
||||||
|
#include "JobStatusModel.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include "JobStatusModel.h"
|
|
||||||
|
|
||||||
#define ROW_HEIGHT 20
|
#define ROW_HEIGHT 20
|
||||||
#define PADDING 2
|
#define PADDING 2
|
||||||
@@ -43,12 +45,12 @@ JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
initStyleOption( &opt, index );
|
initStyleOption( &opt, index );
|
||||||
QFontMetrics fm( opt.font );
|
QFontMetrics fm( opt.font );
|
||||||
|
|
||||||
|
opt.state &= ~QStyle::State_MouseOver;
|
||||||
QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget );
|
QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget );
|
||||||
|
|
||||||
|
// painter->drawLine( opt.rect.topLeft(), opt.rect.topRight() );
|
||||||
|
|
||||||
painter->setRenderHint( QPainter::Antialiasing );
|
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 );
|
const QRect iconRect( PADDING, PADDING + opt.rect.y(), ROW_HEIGHT - 2*PADDING, ROW_HEIGHT - 2*PADDING );
|
||||||
QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
|
QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
|
||||||
p = p.scaled( iconRect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
p = p.scaled( iconRect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||||
@@ -66,7 +68,7 @@ JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
rightEdge = rRect.left();
|
rightEdge = rRect.left();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int mainW = rightEdge - iconRect.right();
|
const int mainW = rightEdge - PADDING - iconRect.right();
|
||||||
QString mainText = index.data( Qt::DisplayRole ).toString();
|
QString mainText = index.data( Qt::DisplayRole ).toString();
|
||||||
mainText = fm.elidedText( mainText, Qt::ElideRight, mainW );
|
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 );
|
painter->drawText( QRect( iconRect.right() + 2*PADDING, PADDING + opt.rect.y(), mainW, opt.rect.height() - 2*PADDING ), Qt::AlignLeft | Qt::AlignVCenter, mainText );
|
||||||
|
@@ -112,30 +112,33 @@ JobStatusModel::itemFinished()
|
|||||||
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
|
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
|
||||||
Q_ASSERT( item );
|
Q_ASSERT( item );
|
||||||
|
|
||||||
// tDebug() << "Got item finished:" << item->type() << item->mainText() << item;
|
tDebug() << "Got item finished:" << item->type() << item->mainText() << item;
|
||||||
// foreach( JobStatusItem* item, m_items )
|
if ( !m_items.contains( item ) && !m_collapseCount.contains( item->type() ) )
|
||||||
// {
|
return;
|
||||||
// qDebug() << "ITEM #:" << item;
|
|
||||||
// }
|
foreach( JobStatusItem* item, m_items )
|
||||||
// foreach( const QString& str, m_collapseCount.keys() )
|
{
|
||||||
// {
|
qDebug() << "ITEM #:" << item;
|
||||||
// tDebug() << "\t" << str;
|
}
|
||||||
// foreach( JobStatusItem* chain, m_collapseCount[ str ] )
|
foreach( const QString& str, m_collapseCount.keys() )
|
||||||
// qDebug() << "\t\t" << chain;
|
{
|
||||||
// }
|
tDebug() << "\t" << str;
|
||||||
|
foreach( JobStatusItem* chain, m_collapseCount[ str ] )
|
||||||
|
qDebug() << "\t\t" << chain;
|
||||||
|
}
|
||||||
if ( m_collapseCount.contains( item->type() ) )
|
if ( m_collapseCount.contains( item->type() ) )
|
||||||
{
|
{
|
||||||
const int indexOf = m_items.indexOf( m_collapseCount[ item->type() ].first() );
|
const int indexOf = m_items.indexOf( m_collapseCount[ item->type() ].first() );
|
||||||
// tDebug() << "index in main list of collapsed irst item:" << indexOf;
|
tDebug() << "index in main list of collapsed irst item:" << indexOf;
|
||||||
if ( m_collapseCount[ item->type() ].first() == item &&
|
if ( m_collapseCount[ item->type() ].first() == item &&
|
||||||
m_items.contains( m_collapseCount[ item->type() ].first() ) && m_collapseCount[ item->type() ].size() > 1 )
|
m_items.contains( m_collapseCount[ item->type() ].first() ) && m_collapseCount[ item->type() ].size() > 1 )
|
||||||
{
|
{
|
||||||
// the placeholder we use that links m_items and m_collapsecount is done, so choose another one
|
// the placeholder we use that links m_items and m_collapsecount is done, so choose another one
|
||||||
m_items.replace( m_items.indexOf( m_collapseCount[ item->type() ].first() ), m_collapseCount[ item->type() ][ 1 ] );
|
m_items.replace( m_items.indexOf( m_collapseCount[ item->type() ].first() ), m_collapseCount[ item->type() ][ 1 ] );
|
||||||
// qDebug() << "Replaced" << m_collapseCount[ item->type() ].first() << "with:" << m_collapseCount[ item->type() ][ 1 ] << m_items;
|
qDebug() << "Replaced" << m_collapseCount[ item->type() ].first() << "with:" << m_collapseCount[ item->type() ][ 1 ] << m_items;
|
||||||
}
|
}
|
||||||
m_collapseCount[ item->type() ].removeAll( item );
|
m_collapseCount[ item->type() ].removeAll( item );
|
||||||
// tDebug() << "New collapse count list:" << m_collapseCount[ item->type() ];
|
tDebug() << "New collapse count list:" << m_collapseCount[ item->type() ];
|
||||||
if ( m_collapseCount[ item->type() ].isEmpty() )
|
if ( m_collapseCount[ item->type() ].isEmpty() )
|
||||||
m_collapseCount.remove( item->type() );
|
m_collapseCount.remove( item->type() );
|
||||||
else
|
else
|
||||||
@@ -149,6 +152,9 @@ JobStatusModel::itemFinished()
|
|||||||
|
|
||||||
// Remove row completely
|
// Remove row completely
|
||||||
const int idx = m_items.indexOf( item );
|
const int idx = m_items.indexOf( item );
|
||||||
|
tDebug() << "Got index of item:" << idx;
|
||||||
|
Q_ASSERT( idx >= 0 );
|
||||||
|
|
||||||
beginRemoveRows( QModelIndex(), idx, idx );
|
beginRemoveRows( QModelIndex(), idx, idx );
|
||||||
m_items.removeAll( item );
|
m_items.removeAll( item );
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include "TransferStatusItem.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -73,6 +74,7 @@ JobStatusView::JobStatusView( AnimatedSplitter* parent )
|
|||||||
hideWidget();
|
hideWidget();
|
||||||
|
|
||||||
new PipelineStatusManager( this );
|
new PipelineStatusManager( this );
|
||||||
|
new TransferStatusManager( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
113
src/libtomahawk/jobview/TransferStatusItem.cpp
Normal file
113
src/libtomahawk/jobview/TransferStatusItem.cpp
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
/* === 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 "TransferStatusItem.h"
|
||||||
|
|
||||||
|
#include "JobStatusView.h"
|
||||||
|
#include "JobStatusModel.h"
|
||||||
|
#include "network/streamconnection.h"
|
||||||
|
#include "network/servent.h"
|
||||||
|
#include "utils/tomahawkutils.h"
|
||||||
|
#include "result.h"
|
||||||
|
#include "source.h"
|
||||||
|
#include "artist.h"
|
||||||
|
|
||||||
|
TransferStatusItem::TransferStatusItem( TransferStatusManager* p, StreamConnection* sc )
|
||||||
|
: m_parent( p )
|
||||||
|
, m_stream( QWeakPointer< StreamConnection >( sc ) )
|
||||||
|
{
|
||||||
|
if ( m_stream.data()->type() == StreamConnection::RECEIVING )
|
||||||
|
m_type = "receive";
|
||||||
|
else
|
||||||
|
m_type = "send";
|
||||||
|
|
||||||
|
connect( m_stream.data(), SIGNAL( updated() ), SLOT( onTransferUpdate() ) );
|
||||||
|
connect( Servent::instance(), SIGNAL( streamFinished( StreamConnection* ) ), SLOT( streamFinished( StreamConnection* ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TransferStatusItem::~TransferStatusItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
TransferStatusItem::mainText() const
|
||||||
|
{
|
||||||
|
if ( m_stream.isNull() )
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
if ( m_stream.data()->source().isNull() && !m_stream.data()->track().isNull() )
|
||||||
|
return QString( "%1" ).arg( QString( "%1 - %2" ).arg( m_stream.data()->track()->artist()->name() ).arg( m_stream.data()->track()->track() ) );
|
||||||
|
else if ( !m_stream.data()->source().isNull() && !m_stream.data()->track().isNull() )
|
||||||
|
return QString( "%1 %2 %3" ).arg( QString( "%1 - %2" ).arg( m_stream.data()->track()->artist()->name() ).arg( m_stream.data()->track()->track() ) )
|
||||||
|
.arg( m_stream.data()->type() == StreamConnection::RECEIVING ? tr( "from" ) : tr( "to" ) )
|
||||||
|
.arg( m_stream.data()->source()->friendlyName() );
|
||||||
|
else
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
TransferStatusItem::rightColumnText() const
|
||||||
|
{
|
||||||
|
if ( m_stream.isNull() )
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
return QString( "%1 kb/s" ).arg( m_stream.data()->transferRate() / 1024 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TransferStatusItem::streamFinished( StreamConnection* sc )
|
||||||
|
{
|
||||||
|
if ( m_stream.data() == sc )
|
||||||
|
emit finished();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap
|
||||||
|
TransferStatusItem::icon() const
|
||||||
|
{
|
||||||
|
if ( m_stream.isNull() )
|
||||||
|
return QPixmap();
|
||||||
|
|
||||||
|
if ( m_stream.data()->type() == StreamConnection::SENDING )
|
||||||
|
return m_parent->rxPixmap();
|
||||||
|
else
|
||||||
|
return m_parent->txPixmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TransferStatusItem::onTransferUpdate()
|
||||||
|
{
|
||||||
|
emit statusChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TransferStatusManager::TransferStatusManager( QObject* parent )
|
||||||
|
: QObject( parent )
|
||||||
|
{
|
||||||
|
m_rxPixmap.load( RESPATH "images/uploading.png" );
|
||||||
|
m_txPixmap.load( RESPATH "images/downloading.png" );
|
||||||
|
|
||||||
|
connect( Servent::instance(), SIGNAL( streamStarted( StreamConnection* ) ), SLOT( streamRegistered( StreamConnection* ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TransferStatusManager::streamRegistered( StreamConnection* sc )
|
||||||
|
{
|
||||||
|
JobStatusView::instance()->model()->addJob( new TransferStatusItem( this, sc ) );
|
||||||
|
}
|
65
src/libtomahawk/jobview/TransferStatusItem.h
Normal file
65
src/libtomahawk/jobview/TransferStatusItem.h
Normal 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 TRANSFERSTATUSITEM_H
|
||||||
|
#define TRANSFERSTATUSITEM_H
|
||||||
|
|
||||||
|
#include "JobStatusItem.h"
|
||||||
|
|
||||||
|
class StreamConnection;
|
||||||
|
|
||||||
|
class TransferStatusManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TransferStatusManager( QObject* parent = 0 );
|
||||||
|
virtual ~TransferStatusManager() {}
|
||||||
|
|
||||||
|
QPixmap rxPixmap() const { return m_rxPixmap; }
|
||||||
|
QPixmap txPixmap() const { return m_txPixmap; }
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void streamRegistered( StreamConnection* sc );
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPixmap m_rxPixmap, m_txPixmap;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TransferStatusItem : public JobStatusItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TransferStatusItem( TransferStatusManager* p, StreamConnection* );
|
||||||
|
virtual ~TransferStatusItem();
|
||||||
|
|
||||||
|
virtual QString rightColumnText() const;
|
||||||
|
virtual QString mainText() const;
|
||||||
|
virtual QPixmap icon() const;
|
||||||
|
virtual QString type() const { return m_type; }
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void streamFinished( StreamConnection* sc );
|
||||||
|
void onTransferUpdate();
|
||||||
|
|
||||||
|
private:
|
||||||
|
TransferStatusManager* m_parent;
|
||||||
|
QString m_type, m_main, m_right;
|
||||||
|
QWeakPointer< StreamConnection > m_stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSFERSTATUSITEM_H
|
@@ -58,7 +58,6 @@
|
|||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
#include "jobview/JobStatusView.h"
|
#include "jobview/JobStatusView.h"
|
||||||
#include "transferview.h"
|
|
||||||
#include "tomahawktrayicon.h"
|
#include "tomahawktrayicon.h"
|
||||||
#include "scanmanager.h"
|
#include "scanmanager.h"
|
||||||
#include "tomahawkapp.h"
|
#include "tomahawkapp.h"
|
||||||
@@ -205,7 +204,6 @@ TomahawkWindow::setupSideBar()
|
|||||||
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
|
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
|
||||||
|
|
||||||
m_sourcetree = new SourceTreeView();
|
m_sourcetree = new SourceTreeView();
|
||||||
TransferView* transferView = new TransferView( m_sidebar );
|
|
||||||
JobStatusView* jobsView = new JobStatusView( m_sidebar );
|
JobStatusView* jobsView = new JobStatusView( m_sidebar );
|
||||||
m_jobsModel = new JobStatusModel( jobsView );
|
m_jobsModel = new JobStatusModel( jobsView );
|
||||||
jobsView->setModel( m_jobsModel );
|
jobsView->setModel( m_jobsModel );
|
||||||
@@ -219,7 +217,6 @@ TomahawkWindow::setupSideBar()
|
|||||||
|
|
||||||
m_sidebar->addWidget( m_searchWidget );
|
m_sidebar->addWidget( m_searchWidget );
|
||||||
m_sidebar->addWidget( m_sourcetree );
|
m_sidebar->addWidget( m_sourcetree );
|
||||||
m_sidebar->addWidget( transferView );
|
|
||||||
m_sidebar->addWidget( jobsView );
|
m_sidebar->addWidget( jobsView );
|
||||||
m_sidebar->addWidget( m_queueView );
|
m_sidebar->addWidget( m_queueView );
|
||||||
|
|
||||||
|
@@ -1,149 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 "transferview.h"
|
|
||||||
|
|
||||||
#include <QHeaderView>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include "artist.h"
|
|
||||||
#include "source.h"
|
|
||||||
#include "network/streamconnection.h"
|
|
||||||
#include "network/servent.h"
|
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
|
|
||||||
TransferView::TransferView( AnimatedSplitter* parent )
|
|
||||||
: AnimatedWidget( parent )
|
|
||||||
, m_parent( parent )
|
|
||||||
{
|
|
||||||
setHiddenSize( QSize( 0, 0 ) );
|
|
||||||
setLayout( new QVBoxLayout() );
|
|
||||||
m_tree = new QTreeWidget( this );
|
|
||||||
|
|
||||||
layout()->setMargin( 0 );
|
|
||||||
layout()->addWidget( m_tree );
|
|
||||||
|
|
||||||
connect( Servent::instance(), SIGNAL( streamStarted( StreamConnection* ) ), SLOT( streamRegistered( StreamConnection* ) ) );
|
|
||||||
connect( Servent::instance(), SIGNAL( streamFinished( StreamConnection* ) ), SLOT( streamFinished( StreamConnection* ) ) );
|
|
||||||
|
|
||||||
QStringList headers;
|
|
||||||
headers << tr( "Peer" ) << tr( "Rate" ) << tr( "Track" );
|
|
||||||
m_tree->setHeaderLabels( headers );
|
|
||||||
|
|
||||||
m_tree->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
|
||||||
m_tree->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored );
|
|
||||||
m_tree->setColumnCount( 3 );
|
|
||||||
m_tree->setColumnWidth( 0, 80 );
|
|
||||||
m_tree->setColumnWidth( 1, 65 );
|
|
||||||
m_tree->setColumnWidth( 2, 10 );
|
|
||||||
|
|
||||||
m_tree->header()->setStretchLastSection( true );
|
|
||||||
m_tree->setRootIsDecorated( false );
|
|
||||||
|
|
||||||
m_tree->setFrameShape( QFrame::NoFrame );
|
|
||||||
m_tree->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
|
||||||
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TransferView::streamRegistered( StreamConnection* sc )
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
connect( sc, SIGNAL( updated() ), SLOT( onTransferUpdate() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TransferView::streamFinished( StreamConnection* sc )
|
|
||||||
{
|
|
||||||
if ( !m_index.contains( sc ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
QPersistentModelIndex i = m_index.take( sc );
|
|
||||||
delete m_tree->invisibleRootItem()->takeChild( i.row() );
|
|
||||||
|
|
||||||
if ( m_tree->invisibleRootItem()->childCount() > 0 )
|
|
||||||
emit showWidget();
|
|
||||||
else
|
|
||||||
emit hideWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TransferView::onTransferUpdate()
|
|
||||||
{
|
|
||||||
StreamConnection* sc = (StreamConnection*)sender();
|
|
||||||
// qDebug() << Q_FUNC_INFO << sc->track().isNull() << sc->source().isNull();
|
|
||||||
|
|
||||||
if ( sc->track().isNull() || sc->source().isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
QTreeWidgetItem* ti = 0;
|
|
||||||
|
|
||||||
if ( m_index.contains( sc ) )
|
|
||||||
{
|
|
||||||
QPersistentModelIndex i = m_index.value( sc );
|
|
||||||
ti = m_tree->invisibleRootItem()->child( i.row() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ti = new QTreeWidgetItem( m_tree );
|
|
||||||
m_index.insert( sc, QPersistentModelIndex( m_tree->model()->index( m_tree->invisibleRootItem()->childCount() - 1, 0 ) ) );
|
|
||||||
emit showWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !ti )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ti->setText( 0, sc->source()->friendlyName() );
|
|
||||||
ti->setText( 1, QString( "%1 kb/s" ).arg( sc->transferRate() / 1024 ) );
|
|
||||||
ti->setText( 2, QString( "%1 - %2" ).arg( sc->track()->artist()->name() ).arg( sc->track()->track() ) );
|
|
||||||
|
|
||||||
if ( isHidden() )
|
|
||||||
emit showWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QSize
|
|
||||||
TransferView::sizeHint() const
|
|
||||||
{
|
|
||||||
unsigned int y = 0;
|
|
||||||
y += m_tree->header()->height();
|
|
||||||
y += m_tree->contentsMargins().top() + m_tree->contentsMargins().bottom();
|
|
||||||
|
|
||||||
if ( m_tree->invisibleRootItem()->childCount() )
|
|
||||||
{
|
|
||||||
unsigned int rowheight = m_tree->sizeHintForRow( 0 );
|
|
||||||
y += rowheight * m_tree->invisibleRootItem()->childCount() + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QSize( 0, y );
|
|
||||||
}
|
|
Reference in New Issue
Block a user