1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-01 03:40:16 +02:00

* Moved --demo stuff to Source class.

This commit is contained in:
Christian Muehlhaeuser
2011-04-20 16:21:12 +02:00
parent cbd5196080
commit 2e80475a9d
6 changed files with 25 additions and 24 deletions

View File

@@ -98,9 +98,6 @@ public:
virtual void activate(); virtual void activate();
virtual bool loadUrl( const QString& url ); virtual bool loadUrl( const QString& url );
// because QApplication::arguments() is expensive
bool scrubFriendlyName() const { return m_scrubFriendlyName; }
public slots: public slots:
void instanceStarted( KDSingleApplicationGuard::Instance ); void instanceStarted( KDSingleApplicationGuard::Instance );

View File

@@ -27,6 +27,8 @@
#include "database/databasecommand_logplayback.h" #include "database/databasecommand_logplayback.h"
#include "database/database.h" #include "database/database.h"
#include <QCoreApplication>
using namespace Tomahawk; using namespace Tomahawk;
@@ -40,6 +42,8 @@ Source::Source( int id, const QString& username )
{ {
qDebug() << Q_FUNC_INFO << id << username; qDebug() << Q_FUNC_INFO << id << username;
m_scrubFriendlyName = qApp->arguments().contains( "--demo" );
if ( id == 0 ) if ( id == 0 )
{ {
m_isLocal = true; m_isLocal = true;
@@ -98,8 +102,8 @@ Source::friendlyName() const
return m_username; return m_username;
//TODO: this is a terrible assumption, help me clean this up, mighty muesli! //TODO: this is a terrible assumption, help me clean this up, mighty muesli!
if ( m_friendlyname.contains( "@conference.") ) if ( m_friendlyname.contains( "@conference." ) )
return QString(m_friendlyname).remove( 0, m_friendlyname.lastIndexOf( "/" )+1 ).append(" via MUC"); return QString( m_friendlyname ).remove( 0, m_friendlyname.lastIndexOf( "/" ) + 1 ).append( " via MUC" );
if ( m_friendlyname.contains( "/tomahawk" ) ) if ( m_friendlyname.contains( "/tomahawk" ) )
return m_friendlyname.left( m_friendlyname.indexOf( "/tomahawk" ) ); return m_friendlyname.left( m_friendlyname.indexOf( "/tomahawk" ) );
@@ -108,6 +112,15 @@ Source::friendlyName() const
} }
void
Source::setFriendlyName( const QString& fname )
{
m_friendlyname = fname;
if ( m_scrubFriendlyName )
m_friendlyname = m_friendlyname.split( "@" ).first();
}
void void
Source::addCollection( const collection_ptr& c ) Source::addCollection( const collection_ptr& c )
{ {
@@ -164,7 +177,7 @@ Source::dbLoaded( unsigned int id, const QString& fname )
qDebug() << Q_FUNC_INFO << id << fname; qDebug() << Q_FUNC_INFO << id << fname;
m_id = id; m_id = id;
m_friendlyname = fname; setFriendlyName( fname );
emit syncedWithDatabase(); emit syncedWithDatabase();
} }
@@ -225,10 +238,7 @@ Source::onStateChanged( DBSyncConnection::State newstate, DBSyncConnection::Stat
unsigned int unsigned int
Source::trackCount() const Source::trackCount() const
{ {
if ( m_stats.contains( "numfiles" ) ) return m_stats.value( "numfiles" ).toUInt();
return m_stats.value( "numfiles" ).toUInt();
else
return 0;
} }

View File

@@ -53,7 +53,7 @@ public:
QString userName() const { return m_username; } QString userName() const { return m_username; }
QString friendlyName() const; QString friendlyName() const;
void setFriendlyName( const QString& fname ) { m_friendlyname = fname; } void setFriendlyName( const QString& fname );
collection_ptr collection() const; collection_ptr collection() const;
void addCollection( const Tomahawk::collection_ptr& c ); void addCollection( const Tomahawk::collection_ptr& c );
@@ -111,6 +111,7 @@ private:
QList< QSharedPointer<Collection> > m_collections; QList< QSharedPointer<Collection> > m_collections;
QVariantMap m_stats; QVariantMap m_stats;
QString m_lastOpGuid; QString m_lastOpGuid;
bool m_scrubFriendlyName;
Tomahawk::query_ptr m_currentTrack; Tomahawk::query_ptr m_currentTrack;
QString m_textStatus; QString m_textStatus;

View File

@@ -1,5 +1,5 @@
/* === 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, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -46,14 +46,9 @@ SourceTreeItem::SourceTreeItem( const source_ptr& source, QObject* parent )
QString name; QString name;
if( source.isNull() ) if( source.isNull() )
name = tr( "Super Collection" ); name = tr( "Super Collection" );
else else
{ name = source->friendlyName();
if( TomahawkApp::instance()->scrubFriendlyName() && source->friendlyName().contains( '@' ) )
name = source->friendlyName().left( source->friendlyName().indexOf( '@' ) );
else
name = source->friendlyName();
}
QStandardItem* item = new QStandardItem( name ); QStandardItem* item = new QStandardItem( name );
item->setIcon( QIcon( RESPATH "images/user-avatar.png" ) ); item->setIcon( QIcon( RESPATH "images/user-avatar.png" ) );
item->setEditable( false ); item->setEditable( false );
@@ -114,7 +109,7 @@ SourceTreeItem::onPlaylistsAdded( const QList<playlist_ptr>& playlists )
{ {
// const-ness is important for getting the right pointer! // const-ness is important for getting the right pointer!
foreach( const playlist_ptr& p, playlists ) foreach( const playlist_ptr& p, playlists )
{ {
m_playlists.append( p ); m_playlists.append( p );
qlonglong ptr = reinterpret_cast<qlonglong>( &m_playlists.last() ); qlonglong ptr = reinterpret_cast<qlonglong>( &m_playlists.last() );

View File

@@ -540,7 +540,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
QString tracks; QString tracks;
int figWidth = 0; int figWidth = 0;
if ( status ) if ( status && sti && !sti->source().isNull() )
{ {
tracks = QString::number( sti->source()->trackCount() ); tracks = QString::number( sti->source()->trackCount() );
figWidth = painter->fontMetrics().width( tracks ); figWidth = painter->fontMetrics().width( tracks );

View File

@@ -150,7 +150,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
, m_sipHandler( 0 ) , m_sipHandler( 0 )
, m_servent( 0 ) , m_servent( 0 )
, m_shortcutHandler( 0 ) , m_shortcutHandler( 0 )
, m_scrubFriendlyName( false )
, m_mainwindow( 0 ) , m_mainwindow( 0 )
{ {
qDebug() << "TomahawkApp thread:" << this->thread(); qDebug() << "TomahawkApp thread:" << this->thread();
@@ -193,7 +192,6 @@ TomahawkApp::init()
qDebug() << "Init Echonest Factory."; qDebug() << "Init Echonest Factory.";
GeneratorFactory::registerFactory( "echonest", new EchonestFactory ); GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
m_scrubFriendlyName = arguments().contains( "--demo" );
// Register shortcut handler for this platform // Register shortcut handler for this platform
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
m_shortcutHandler = new MacShortcutHandler( this ); m_shortcutHandler = new MacShortcutHandler( this );