diff --git a/data/images/downloading.png b/data/images/downloading.png
new file mode 100755
index 000000000..eed3b85b3
Binary files /dev/null and b/data/images/downloading.png differ
diff --git a/data/images/headphones.png b/data/images/headphones.png
new file mode 100755
index 000000000..d7c2a2e47
Binary files /dev/null and b/data/images/headphones.png differ
diff --git a/data/images/uploading.png b/data/images/uploading.png
new file mode 100755
index 000000000..4e4340e17
Binary files /dev/null and b/data/images/uploading.png differ
diff --git a/resources.qrc b/resources.qrc
index d9ec823de..4fe78982f 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -116,5 +116,8 @@
data/images/drop-song.png
data/images/drop-album.png
data/images/spotify-logo.jpg
+ data/images/uploading.png
+ data/images/downloading.png
+ data/images/headphones.png
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a95e6b622..302f33ab0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -65,7 +65,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
# breakpad/BreakPad.cpp
- transferview.cpp
tomahawktrayicon.cpp
audiocontrols.cpp
settingsdialog.cpp
@@ -114,7 +113,6 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
sourcetree/items/genericpageitems.h
sourcetree/items/temporarypageitem.h
- transferview.h
tomahawktrayicon.h
audiocontrols.h
settingsdialog.h
diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt
index 4cf92d3de..6c5427e69 100644
--- a/src/libtomahawk/CMakeLists.txt
+++ b/src/libtomahawk/CMakeLists.txt
@@ -219,6 +219,7 @@ set( libSources
jobview/JobStatusModel.cpp
jobview/JobStatusDelegate.cpp
jobview/PipelineStatusItem.cpp
+ jobview/TransferStatusItem.cpp
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp
thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp
@@ -431,6 +432,7 @@ set( libHeaders
jobview/JobStatusDelegate.h
jobview/JobStatusItem.h
jobview/PipelineStatusItem.h
+ jobview/TransferStatusItem.h
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h
thirdparty/Qocoa/qsearchfield.h
diff --git a/src/libtomahawk/database/DatabaseCommand_Latched.cpp b/src/libtomahawk/database/DatabaseCommand_Latched.cpp
new file mode 100644
index 000000000..bb9966c83
--- /dev/null
+++ b/src/libtomahawk/database/DatabaseCommand_Latched.cpp
@@ -0,0 +1,55 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2010-2011, Leo Franchi
+ *
+ * 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 .
+ */
+
+#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();
+}
+
diff --git a/src/transferview.h b/src/libtomahawk/database/DatabaseCommand_Latched.h
similarity index 50%
rename from src/transferview.h
rename to src/libtomahawk/database/DatabaseCommand_Latched.h
index 4cd02d5be..86a4e4392 100644
--- a/src/transferview.h
+++ b/src/libtomahawk/database/DatabaseCommand_Latched.h
@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - ===
*
- * Copyright 2010-2011, Christian Muehlhaeuser
+ * Copyright 2010-2011, Leo Franchi
*
* 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,40 +16,30 @@
* along with Tomahawk. If not, see .
*/
-#ifndef TRANSFERVIEW_H
-#define TRANSFERVIEW_H
+#ifndef DATABASECOMMAND_LATCHED_H
+#define DATABASECOMMAND_LATCHED_H
-#include
+#include "database/databasecommandloggable.h"
-#include "typedefs.h"
-#include "widgets/animatedsplitter.h"
+class DatabaseImpl;
-class StreamConnection;
-
-class TransferView : public AnimatedWidget
+class DatabaseCommand_Latched : public DatabaseCommandLoggable
{
-Q_OBJECT
-
+ Q_OBJECT
public:
- explicit TransferView( AnimatedSplitter* parent );
- virtual ~TransferView()
- {
- }
+ enum LatchAction {
+ LatchedOn = 0,
+ LatchedOff
+ };
- QSize sizeHint() const;
+ explicit DatabaseCommand_Latched( QObject* parent = 0 );
+ explicit DatabaseCommand_Latched( const Tomahawk::source_ptr& s, QObject* parent = 0 );
-signals:
-
-private slots:
- void streamRegistered( StreamConnection* sc );
- void streamFinished( StreamConnection* sc );
-
- void onTransferUpdate();
-
-private:
- QHash< StreamConnection*, QPersistentModelIndex > m_index;
- QTreeWidget* m_tree;
- AnimatedSplitter* m_parent;
+ virtual bool doesMutates() const { return true; }
+ virtual void exec( DatabaseImpl* );
+ virtual void postCommitHook();
+ virtual bool singletonCmd() const;
+ virtual bool localOnly() const;
};
-#endif // TRANSFERVIEW_H
+#endif // DATABASECOMMAND_LATCHED_H
diff --git a/src/libtomahawk/jobview/JobStatusDelegate.cpp b/src/libtomahawk/jobview/JobStatusDelegate.cpp
index 0e9deb5fe..b5e3fea67 100644
--- a/src/libtomahawk/jobview/JobStatusDelegate.cpp
+++ b/src/libtomahawk/jobview/JobStatusDelegate.cpp
@@ -18,9 +18,11 @@
#include "JobStatusDelegate.h"
+#include "JobStatusModel.h"
+#include "utils/logger.h"
+
#include
#include
-#include "JobStatusModel.h"
#define ROW_HEIGHT 20
#define PADDING 2
@@ -43,12 +45,12 @@ JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
initStyleOption( &opt, index );
QFontMetrics fm( opt.font );
+ opt.state &= ~QStyle::State_MouseOver;
QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget );
+// painter->drawLine( opt.rect.topLeft(), opt.rect.topRight() );
+
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 );
@@ -66,7 +68,7 @@ JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
rightEdge = rRect.left();
}
- const int mainW = rightEdge - iconRect.right();
+ const int mainW = rightEdge - PADDING - 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 );
diff --git a/src/libtomahawk/jobview/JobStatusModel.cpp b/src/libtomahawk/jobview/JobStatusModel.cpp
index fdaf8bc2e..fe787eae4 100644
--- a/src/libtomahawk/jobview/JobStatusModel.cpp
+++ b/src/libtomahawk/jobview/JobStatusModel.cpp
@@ -112,30 +112,33 @@ JobStatusModel::itemFinished()
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
Q_ASSERT( item );
-// tDebug() << "Got item finished:" << item->type() << item->mainText() << item;
-// foreach( JobStatusItem* item, m_items )
-// {
-// qDebug() << "ITEM #:" << item;
-// }
-// foreach( const QString& str, m_collapseCount.keys() )
-// {
-// tDebug() << "\t" << str;
-// foreach( JobStatusItem* chain, m_collapseCount[ str ] )
-// qDebug() << "\t\t" << chain;
-// }
+ tDebug() << "Got item finished:" << item->type() << item->mainText() << item;
+ if ( !m_items.contains( item ) && !m_collapseCount.contains( item->type() ) )
+ return;
+
+ foreach( JobStatusItem* item, m_items )
+ {
+ qDebug() << "ITEM #:" << item;
+ }
+ foreach( const QString& str, m_collapseCount.keys() )
+ {
+ tDebug() << "\t" << str;
+ foreach( JobStatusItem* chain, m_collapseCount[ str ] )
+ qDebug() << "\t\t" << chain;
+ }
if ( m_collapseCount.contains( item->type() ) )
{
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 &&
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
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 );
-// tDebug() << "New collapse count list:" << m_collapseCount[ item->type() ];
+ tDebug() << "New collapse count list:" << m_collapseCount[ item->type() ];
if ( m_collapseCount[ item->type() ].isEmpty() )
m_collapseCount.remove( item->type() );
else
@@ -149,6 +152,9 @@ JobStatusModel::itemFinished()
// Remove row completely
const int idx = m_items.indexOf( item );
+ tDebug() << "Got index of item:" << idx;
+ Q_ASSERT( idx >= 0 );
+
beginRemoveRows( QModelIndex(), idx, idx );
m_items.removeAll( item );
endRemoveRows();
diff --git a/src/libtomahawk/jobview/JobStatusView.cpp b/src/libtomahawk/jobview/JobStatusView.cpp
index 732875377..867e8638f 100644
--- a/src/libtomahawk/jobview/JobStatusView.cpp
+++ b/src/libtomahawk/jobview/JobStatusView.cpp
@@ -31,6 +31,7 @@
#include
#include
#include
+#include "TransferStatusItem.h"
using namespace Tomahawk;
@@ -73,6 +74,7 @@ JobStatusView::JobStatusView( AnimatedSplitter* parent )
hideWidget();
new PipelineStatusManager( this );
+ new TransferStatusManager( this );
}
void
diff --git a/src/libtomahawk/jobview/TransferStatusItem.cpp b/src/libtomahawk/jobview/TransferStatusItem.cpp
new file mode 100644
index 000000000..87dd827d3
--- /dev/null
+++ b/src/libtomahawk/jobview/TransferStatusItem.cpp
@@ -0,0 +1,113 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2010-2011, Leo Franchi
+ *
+ * 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 .
+ */
+
+#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 ) );
+}
diff --git a/src/libtomahawk/jobview/TransferStatusItem.h b/src/libtomahawk/jobview/TransferStatusItem.h
new file mode 100644
index 000000000..2387580ec
--- /dev/null
+++ b/src/libtomahawk/jobview/TransferStatusItem.h
@@ -0,0 +1,65 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2010-2011, Leo Franchi
+ *
+ * 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 .
+ */
+
+#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
diff --git a/src/tomahawkwindow.cpp b/src/tomahawkwindow.cpp
index 33a6d7562..cd1596483 100644
--- a/src/tomahawkwindow.cpp
+++ b/src/tomahawkwindow.cpp
@@ -58,7 +58,6 @@
#include "tomahawksettings.h"
#include "sourcelist.h"
#include "jobview/JobStatusView.h"
-#include "transferview.h"
#include "tomahawktrayicon.h"
#include "scanmanager.h"
#include "tomahawkapp.h"
@@ -205,7 +204,6 @@ TomahawkWindow::setupSideBar()
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
m_sourcetree = new SourceTreeView();
- TransferView* transferView = new TransferView( m_sidebar );
JobStatusView* jobsView = new JobStatusView( m_sidebar );
m_jobsModel = new JobStatusModel( jobsView );
jobsView->setModel( m_jobsModel );
@@ -219,7 +217,6 @@ TomahawkWindow::setupSideBar()
m_sidebar->addWidget( m_searchWidget );
m_sidebar->addWidget( m_sourcetree );
- m_sidebar->addWidget( transferView );
m_sidebar->addWidget( jobsView );
m_sidebar->addWidget( m_queueView );
diff --git a/src/transferview.cpp b/src/transferview.cpp
deleted file mode 100644
index 77a886d63..000000000
--- a/src/transferview.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/* === This file is part of Tomahawk Player - ===
- *
- * Copyright 2010-2011, Christian Muehlhaeuser
- *
- * 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 .
- */
-
-#include "transferview.h"
-
-#include
-#include
-
-#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 );
-}