diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-20 06:53:52 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-20 06:53:52 +0000 |
commit | 3a09386ad170dafdce88c5dcd70275cc7d4081e9 (patch) | |
tree | 0f9544da38cdb9c5cc20ad9d695588413b4cd5f9 /amarok/src/moodbar.cpp | |
parent | 36a9c1916513474b11c59a9060cbaf8770d1bbc0 (diff) | |
download | amarok-3a09386ad170dafdce88c5dcd70275cc7d4081e9.tar.gz amarok-3a09386ad170dafdce88c5dcd70275cc7d4081e9.zip |
Initial TQt conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/amarok@1165727 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'amarok/src/moodbar.cpp')
-rw-r--r-- | amarok/src/moodbar.cpp | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/amarok/src/moodbar.cpp b/amarok/src/moodbar.cpp index 16cd0872..c80c3ab1 100644 --- a/amarok/src/moodbar.cpp +++ b/amarok/src/moodbar.cpp @@ -31,7 +31,7 @@ // // The Moodbar is part of the track's metadata, so it's held by a // MetaBundle. The actual Moodbar object is only used to draw a -// QPixmap, which it does efficiently -- it caches a pixmap of the +// TQPixmap, which it does efficiently -- it caches a pixmap of the // last thing it drew, and just copies that pixmap if the dimensions // have not changed. To use the moodbar, one just needs a few lines of // code, such as the following, based on PrettySlider: @@ -39,8 +39,8 @@ // void MyClass::MyClass( void ) // { // // This only needs to be done once! -// connect( &m_bundle.moodbar(), SIGNAL( jobEvent( int ) ), -// SLOT( newMoodData( int ) ) ); +// connect( &m_bundle.moodbar(), TQT_SIGNAL( jobEvent( int ) ), +// TQT_SLOT( newMoodData( int ) ) ); // } // // void MyClass::newMetaBundle( const MetaBundle &b ) @@ -55,7 +55,7 @@ // // void MyClass::draw( void ) // { -// QPixmap toDraw; +// TQPixmap toDraw; // if( m_bundle.moodbar().dataExists() ) // toDraw = m_bundle.moodbar().draw( width(), height() ); // // else draw something else... @@ -121,7 +121,7 @@ // when MoodServer::queueJob() is called, and is disconnected in // slotJobEvent(). The reason for this care is because MetaBundle's, // and hence Moodbar's, are copied around and passed-by-value all the -// time, so I wanted to reduce overhead; also QObject::disconnect() is +// time, so I wanted to reduce overhead; also TQObject::disconnect() is // not reentrant (from what I understand), so we don't want that being // called every time a Moodbar is destroyed! For the same reason, the // PlaylistItem does not listen for the jobEvent() signal; instead it @@ -185,7 +185,7 @@ // ask MoodServer to run a job for us. Always changes the state // from Unloaded so subsequent calls to load() do nothing. // -// draw(): Draw the moodbar onto a QPixmap. Cache what we drew +// draw(): Draw the moodbar onto a TQPixmap. Cache what we drew // so that if draw() is called again with the same dimensions // we don't have to redraw. // @@ -287,10 +287,10 @@ #include "mountpointmanager.h" #include "statusbar.h" -#include <qfile.h> -#include <qdir.h> // For QDir::rename() -#include <qpainter.h> -#include <qtimer.h> +#include <tqfile.h> +#include <tqdir.h> // For TQDir::rename() +#include <tqpainter.h> +#include <tqtimer.h> #include <kstandarddirs.h> @@ -319,20 +319,20 @@ MoodServer::MoodServer( void ) : m_moodbarBroken( false ) , m_currentProcess( 0 ) { - connect( App::instance(), SIGNAL( moodbarPrefs( bool, bool, int, bool ) ), - SLOT( slotMoodbarPrefs( bool, bool, int, bool ) ) ); + connect( App::instance(), TQT_SIGNAL( moodbarPrefs( bool, bool, int, bool ) ), + TQT_SLOT( slotMoodbarPrefs( bool, bool, int, bool ) ) ); connect( CollectionDB::instance(), - SIGNAL( fileMoved( const QString &, const QString & ) ), - SLOT( slotFileMoved( const QString &, const QString & ) ) ); + TQT_SIGNAL( fileMoved( const TQString &, const TQString & ) ), + TQT_SLOT( slotFileMoved( const TQString &, const TQString & ) ) ); connect( CollectionDB::instance(), - SIGNAL( fileMoved( const QString &, const QString &, const QString & ) ), - SLOT( slotFileMoved( const QString &, const QString & ) ) ); + TQT_SIGNAL( fileMoved( const TQString &, const TQString &, const TQString & ) ), + TQT_SLOT( slotFileMoved( const TQString &, const TQString & ) ) ); connect( CollectionDB::instance(), - SIGNAL( fileDeleted( const QString & ) ), - SLOT( slotFileDeleted( const QString & ) ) ); + TQT_SIGNAL( fileDeleted( const TQString & ) ), + TQT_SLOT( slotFileDeleted( const TQString & ) ) ); connect( CollectionDB::instance(), - SIGNAL( fileDeleted( const QString &, const QString & ) ), - SLOT( slotFileDeleted( const QString & ) ) ); + TQT_SIGNAL( fileDeleted( const TQString &, const TQString & ) ), + TQT_SLOT( slotFileDeleted( const TQString & ) ) ); } @@ -359,7 +359,7 @@ MoodServer::queueJob( MetaBundle *bundle ) } // Check if there's already a job in the queue for that URL - QValueList<ProcData>::iterator it; + TQValueList<ProcData>::iterator it; for( it = m_jobQueue.begin(); it != m_jobQueue.end(); ++it ) { if( (*it).m_url == bundle->url() ) @@ -383,7 +383,7 @@ MoodServer::queueJob( MetaBundle *bundle ) m_mutex.unlock(); // New jobs *must* be started from the GUI thread! - QTimer::singleShot( 1000, this, SLOT( slotNewJob( void ) ) ); + TQTimer::singleShot( 1000, this, TQT_SLOT( slotNewJob( void ) ) ); return false; } @@ -407,7 +407,7 @@ MoodServer::deQueueJob( KURL url ) } // Check if there's already a job in the queue for that URL - QValueList<ProcData>::iterator it; + TQValueList<ProcData>::iterator it; for( it = m_jobQueue.begin(); it != m_jobQueue.end(); ++it ) { if( (*it).m_url == url ) @@ -476,8 +476,8 @@ MoodServer::slotNewJob( void ) << (m_currentData.m_outfile + ".tmp") << m_currentData.m_infile; - connect( m_currentProcess, SIGNAL( processExited( KProcess* ) ), - SLOT( slotJobCompleted( KProcess* ) ) ); + connect( m_currentProcess, TQT_SIGNAL( processExited( KProcess* ) ), + TQT_SLOT( slotJobCompleted( KProcess* ) ) ); // We have to enable KProcess::Stdout (even though we don't monitor // it) since otherwise the child process crashes every time in @@ -525,13 +525,13 @@ MoodServer::slotJobCompleted( KProcess *proc ) if( success ) { - QString file = m_currentData.m_outfile; - QString dir = file.left( file.findRev( '/' ) ); + TQString file = m_currentData.m_outfile; + TQString dir = file.left( file.findRev( '/' ) ); file = file.right( file.length() - file.findRev( '/' ) - 1 ); - QDir( dir ).rename( file + ".tmp", file ); + TQDir( dir ).rename( file + ".tmp", file ); } else - QFile::remove( m_currentData.m_outfile + ".tmp" ); + TQFile::remove( m_currentData.m_outfile + ".tmp" ); delete m_currentProcess; m_currentProcess = 0; @@ -611,34 +611,34 @@ MoodServer::slotMoodbarPrefs( bool show, bool moodier, int alter, bool withMusic // When a file is deleted, either manually using Organize Collection or // automatically detected using AFT, delete the corresponding mood file. void -MoodServer::slotFileDeleted( const QString &path ) +MoodServer::slotFileDeleted( const TQString &path ) { - QString mood = Moodbar::moodFilename( KURL::fromPathOrURL( path ) ); - if( mood.isEmpty() || !QFile::exists( mood ) ) + TQString mood = Moodbar::moodFilename( KURL::fromPathOrURL( path ) ); + if( mood.isEmpty() || !TQFile::exists( mood ) ) return; debug() << "MoodServer::slotFileDeleted: deleting " << mood << endl; - QFile::remove( mood ); + TQFile::remove( mood ); } // When a file is moved, either manually using Organize Collection or // automatically using AFT, move the corresponding mood file. void -MoodServer::slotFileMoved( const QString &srcPath, const QString &dstPath ) +MoodServer::slotFileMoved( const TQString &srcPath, const TQString &dstPath ) { - QString srcMood = Moodbar::moodFilename( KURL::fromPathOrURL( srcPath ) ); - QString dstMood = Moodbar::moodFilename( KURL::fromPathOrURL( dstPath ) ); + TQString srcMood = Moodbar::moodFilename( KURL::fromPathOrURL( srcPath ) ); + TQString dstMood = Moodbar::moodFilename( KURL::fromPathOrURL( dstPath ) ); if( srcMood.isEmpty() || dstMood.isEmpty() || - srcMood == dstMood || !QFile::exists( srcMood ) ) + srcMood == dstMood || !TQFile::exists( srcMood ) ) return; debug() << "MoodServer::slotFileMoved: moving " << srcMood << " to " << dstMood << endl; Moodbar::copyFile( srcMood, dstMood ); - QFile::remove( srcMood ); + TQFile::remove( srcMood ); } @@ -673,12 +673,12 @@ MoodServer::clearJobs( void ) // We don't want to emit jobEvent (or really do anything // external) while the mutex is locked. m_mutex.lock(); - QValueList<ProcData> queueCopy - = QDeepCopy< QValueList<ProcData> > ( m_jobQueue ); + TQValueList<ProcData> queueCopy + = TQDeepCopy< TQValueList<ProcData> > ( m_jobQueue ); m_jobQueue.clear(); m_mutex.unlock(); - QValueList<ProcData>::iterator it; + TQValueList<ProcData>::iterator it; for( it = queueCopy.begin(); it != queueCopy.end(); ++it ) emit jobEvent( (*it).m_url, Moodbar::JobStateFailed ); } @@ -702,7 +702,7 @@ MoodServer::clearJobs( void ) // member of a MetaBundle, in other words. Moodbar::Moodbar( MetaBundle *mb ) - : QObject ( ) + : TQObject ( ) , m_bundle ( mb ) , m_hueSort ( 0 ) , m_state ( Unloaded ) @@ -746,8 +746,8 @@ Moodbar::operator=( const Moodbar &mood ) if( JOB_PENDING( m_state ) && !JOB_PENDING( oldState ) ) { connect( MoodServer::instance(), - SIGNAL( jobEvent( KURL, int ) ), - SLOT( slotJobEvent( KURL, int ) ) ); + TQT_SIGNAL( jobEvent( KURL, int ) ), + TQT_SLOT( slotJobEvent( KURL, int ) ) ); // Increase the refcount for this job. Use mood.m_bundle // since that one's already initialized. MoodServer::instance()->queueJob( mood.m_bundle ); @@ -756,7 +756,7 @@ Moodbar::operator=( const Moodbar &mood ) // If we had a job pending, de-queue it if( !JOB_PENDING( m_state ) && JOB_PENDING( oldState ) ) { - MoodServer::instance()->disconnect( this, SLOT( slotJobEvent( KURL, int ) ) ); + MoodServer::instance()->disconnect( this, TQT_SLOT( slotJobEvent( KURL, int ) ) ); MoodServer::instance()->deQueueJob( oldURL ); } @@ -779,12 +779,12 @@ Moodbar::reset( void ) if( JOB_PENDING( m_state ) ) { - MoodServer::instance()->disconnect( this, SLOT( slotJobEvent( KURL, int ) ) ); + MoodServer::instance()->disconnect( this, TQT_SLOT( slotJobEvent( KURL, int ) ) ); MoodServer::instance()->deQueueJob( m_url ); } m_data.clear(); - m_pixmap = QPixmap(); + m_pixmap = TQPixmap(); m_url = KURL(); m_hueSort = 0; m_state = Unloaded; @@ -799,11 +799,11 @@ Moodbar::detach( void ) { m_mutex.lock(); - m_data = QDeepCopy<ColorList>(m_data); + m_data = TQDeepCopy<ColorList>(m_data); m_pixmap.detach(); // Apparently this is the wrong hack -- don't detach urls - //QString url( QDeepCopy<QString>( m_url.url() ) ); + //TQString url( TQDeepCopy<TQString>( m_url.url() ) ); //m_url = KURL::fromPathOrURL( url ); m_mutex.unlock(); @@ -898,8 +898,8 @@ Moodbar::load( void ) // Ok no more excuses, we have to queue a job connect( MoodServer::instance(), - SIGNAL( jobEvent( KURL, int ) ), - SLOT( slotJobEvent( KURL, int ) ) ); + TQT_SIGNAL( jobEvent( KURL, int ) ), + TQT_SLOT( slotJobEvent( KURL, int ) ) ); bool isRunning = MoodServer::instance()->queueJob( m_bundle ); m_state = isRunning ? JobRunning : JobQueued; m_url = m_bundle->url(); // Use this URL for MoodServer::deQueueJob @@ -930,7 +930,7 @@ Moodbar::slotJobEvent( KURL url, int newState ) m_mutex.lock(); // Disconnect the signal for efficiency's sake - MoodServer::instance()->disconnect( this, SLOT( slotJobEvent( KURL, int ) ) ); + MoodServer::instance()->disconnect( this, TQT_SLOT( slotJobEvent( KURL, int ) ) ); if( !success ) { @@ -968,7 +968,7 @@ QPixmap Moodbar::draw( int width, int height ) { if( m_state != Loaded || !AmarokConfig::showMoodbar() ) // Naughty caller! - return QPixmap(); + return TQPixmap(); m_mutex.lock(); @@ -979,17 +979,17 @@ Moodbar::draw( int width, int height ) return m_pixmap; } - m_pixmap = QPixmap( width, height ); - QPainter paint( &m_pixmap ); + m_pixmap = TQPixmap( width, height ); + TQPainter paint( &m_pixmap ); // First average the moodbar samples that will go into each // vertical bar on the screen. if( m_data.size() == 0 ) // Play it safe -- see below - return QPixmap(); + return TQPixmap(); ColorList screenColors; - QColor bar; + TQColor bar; float r, g, b; int h, s, v; @@ -1011,9 +1011,9 @@ Moodbar::draw( int width, int height ) } uint n = end - start; - bar = QColor( int( r / float( n ) ), + bar = TQColor( int( r / float( n ) ), int( g / float( n ) ), - int( b / float( n ) ), QColor::Rgb ); + int( b / float( n ) ), TQColor::Rgb ); /* Snap to the HSV values for later */ bar.getHsv(&h, &s, &v); @@ -1036,10 +1036,10 @@ Moodbar::draw( int width, int height ) float coeff2 = 1.f - ((1.f - coeff) * (1.f - coeff)); coeff = 1.f - (1.f - coeff) / 2.f; coeff2 = 1.f - (1.f - coeff2) / 2.f; - paint.setPen( QColor( h, + paint.setPen( TQColor( h, CLAMP( 0, int( float( s ) * coeff ), 255 ), CLAMP( 0, int( 255.f - (255.f - float( v )) * coeff2), 255 ), - QColor::Hsv ) ); + TQColor::Hsv ) ); paint.drawPoint(x, y); paint.drawPoint(x, height - 1 - y); } @@ -1072,15 +1072,15 @@ Moodbar::readFile( void ) if( m_state == Loaded ) return true; - QString path = moodFilename( m_bundle->url() ); + TQString path = moodFilename( m_bundle->url() ); if( path.isEmpty() ) return false; debug() << "Moodbar::readFile: Trying to read " << path << endl; - QFile moodFile( path ); + TQFile moodFile( path ); - if( !QFile::exists( path ) || + if( !TQFile::exists( path ) || !moodFile.open( IO_ReadOnly ) ) { // If the user has changed his/her preference about where to @@ -1088,11 +1088,11 @@ Moodbar::readFile( void ) // in the other place, so we should check there before giving // up. - QString path2 = moodFilename( m_bundle->url(), + TQString path2 = moodFilename( m_bundle->url(), !AmarokConfig::moodsWithMusic() ); moodFile.setName( path2 ); - if( !QFile::exists( path2 ) || + if( !TQFile::exists( path2 ) || !moodFile.open( IO_ReadOnly ) ) return false; @@ -1134,9 +1134,9 @@ Moodbar::readFile( void ) g = moodFile.getch(); b = moodFile.getch(); - m_data.push_back( QColor( CLAMP( 0, r, 255 ), + m_data.push_back( TQColor( CLAMP( 0, r, 255 ), CLAMP( 0, g, 255 ), - CLAMP( 0, b, 255 ), QColor::Rgb ) ); + CLAMP( 0, b, 255 ), TQColor::Rgb ) ); // Make a histogram of hues m_data.last().getHsv( &h, &s, &v ); @@ -1300,7 +1300,7 @@ Moodbar::readFile( void ) // Returns where the mood file for this bundle should be located, // based on the user preferences. If no location can be determined, -// return QString::null. +// return TQString::null. QString Moodbar::moodFilename( const KURL &url ) @@ -1313,7 +1313,7 @@ Moodbar::moodFilename( const KURL &url, bool withMusic ) { // No need to lock the object - QString path; + TQString path; if( withMusic ) { @@ -1321,12 +1321,12 @@ Moodbar::moodFilename( const KURL &url, bool withMusic ) path.truncate(path.findRev('.')); if (path.isEmpty()) // Weird... - return QString(); + return TQString(); path += ".mood"; int slash = path.findRev('/') + 1; - QString dir = path.left(slash); - QString file = path.right(path.length() - slash); + TQString dir = path.left(slash); + TQString file = path.right(path.length() - slash); path = dir + '.' + file; } @@ -1341,9 +1341,9 @@ Moodbar::moodFilename( const KURL &url, bool withMusic ) path.truncate(path.findRev('.')); if (path.isEmpty()) // Weird... - return QString(); + return TQString(); - path = QString::number( deviceid ) + ',' + path = TQString::number( deviceid ) + ',' + path.replace('/', ',') + ".mood"; // Creates the path if necessary @@ -1357,12 +1357,12 @@ Moodbar::moodFilename( const KURL &url, bool withMusic ) // Quick-n-dirty -->synchronous<-- file copy (the GUI needs its // moodbars immediately!) bool -Moodbar::copyFile( const QString &srcPath, const QString &dstPath ) +Moodbar::copyFile( const TQString &srcPath, const TQString &dstPath ) { - QFile file( srcPath ); + TQFile file( srcPath ); if( !file.open( IO_ReadOnly ) ) return false; - QByteArray contents = file.readAll(); + TQByteArray contents = file.readAll(); file.close(); file.setName( dstPath ); if( !file.open( IO_WriteOnly | IO_Truncate ) ) |