summaryrefslogtreecommitdiffstats
path: root/kicker-applets/mediacontrol/mpdInterface.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:22:56 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:22:56 +0000
commit7346aee26bf190a7e70333c40fab4caca847cd27 (patch)
tree4b019b434f88dcc3eeaafe1d3f26240b4c4718e8 /kicker-applets/mediacontrol/mpdInterface.cpp
parent23a3d3aa5b44cbdf305495919866d9dbf4f6da54 (diff)
downloadtdeaddons-7346aee26bf190a7e70333c40fab4caca847cd27.tar.gz
tdeaddons-7346aee26bf190a7e70333c40fab4caca847cd27.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1157634 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kicker-applets/mediacontrol/mpdInterface.cpp')
-rw-r--r--kicker-applets/mediacontrol/mpdInterface.cpp130
1 files changed, 65 insertions, 65 deletions
diff --git a/kicker-applets/mediacontrol/mpdInterface.cpp b/kicker-applets/mediacontrol/mpdInterface.cpp
index 8027f82..98ba0cb 100644
--- a/kicker-applets/mediacontrol/mpdInterface.cpp
+++ b/kicker-applets/mediacontrol/mpdInterface.cpp
@@ -23,7 +23,7 @@
#include <cstring>
-#include <qregexp.h>
+#include <tqregexp.h>
#include <kmessagebox.h>
#include <kdebug.h>
@@ -39,16 +39,16 @@ MpdInterface::MpdInterface()
, slider_timer(0)
, reconnect_timer(0)
{
- connect(&sock, SIGNAL(error(int)), this, SLOT(connectionError(int)));
- connect(&sock, SIGNAL(error(int)), this, SLOT(stopSliderClock()));
+ connect(&sock, TQT_SIGNAL(error(int)), this, TQT_SLOT(connectionError(int)));
+ connect(&sock, TQT_SIGNAL(error(int)), this, TQT_SLOT(stopSliderClock()));
- connect(&sock, SIGNAL(connected()), this, SLOT(startSliderClock()));
- connect(&sock, SIGNAL(connected()), this, SLOT(stopReconnectClock()));
- connect(&sock, SIGNAL(connected()), this, SLOT(connected()));
+ connect(&sock, TQT_SIGNAL(connected()), this, TQT_SLOT(startSliderClock()));
+ connect(&sock, TQT_SIGNAL(connected()), this, TQT_SLOT(stopReconnectClock()));
+ connect(&sock, TQT_SIGNAL(connected()), this, TQT_SLOT(connected()));
- connect(&sock, SIGNAL(connectionClosed()), this, SLOT(stopSliderClock()));
- connect(&sock, SIGNAL(connectionClosed()), this, SLOT(startReconnectClock()));
- connect(&sock, SIGNAL(connectionClosed()), this, SIGNAL(playerStopped()));
+ connect(&sock, TQT_SIGNAL(connectionClosed()), this, TQT_SLOT(stopSliderClock()));
+ connect(&sock, TQT_SIGNAL(connectionClosed()), this, TQT_SLOT(startReconnectClock()));
+ connect(&sock, TQT_SIGNAL(connectionClosed()), this, TQT_SIGNAL(playerStopped()));
reconnect();
}
@@ -95,7 +95,7 @@ void MpdInterface::stopReconnectClock()
}
-void MpdInterface::timerEvent(QTimerEvent* te)
+void MpdInterface::timerEvent(TQTimerEvent* te)
{
if (te->timerId() == slider_timer) updateSlider();
else if (te->timerId() == reconnect_timer) reconnect();
@@ -104,7 +104,7 @@ void MpdInterface::timerEvent(QTimerEvent* te)
void MpdInterface::reconnect() const
{
- if (sock.state()==QSocket::Idle)
+ if (sock.state()==TQSocket::Idle)
{
sock_mutex.tryLock();
//kdDebug(90200) << "Connecting to " << hostname.latin1() << ":" << port << "...\n";
@@ -131,18 +131,18 @@ void MpdInterface::connectionError(int e)
{
sock_mutex.unlock();
emit playerStopped();
- QString message;
+ TQString message;
if (messagebox_mutex.tryLock())
{
switch (e)
{
- case QSocket::ErrConnectionRefused:
+ case TQSocket::ErrConnectionRefused:
message=i18n("Connection refused to %1:%2.\nIs mpd running?").arg(hostname).arg(port);
break;
- case QSocket::ErrHostNotFound:
+ case TQSocket::ErrHostNotFound:
message=i18n("Host '%1' not found.").arg(hostname);
break;
- case QSocket::ErrSocketRead:
+ case TQSocket::ErrSocketRead:
message=i18n("Error reading socket.");
break;
default:
@@ -166,7 +166,7 @@ void MpdInterface::connectionError(int e)
bool MpdInterface::dispatch(const char* cmd) const
{
- if (sock.state()==QSocket::Connected && sock_mutex.tryLock())
+ if (sock.state()==TQSocket::Connected && sock_mutex.tryLock())
{
long cmd_len=strlen(cmd);
//kdDebug(90200) << "sending: " << cmd;
@@ -186,10 +186,10 @@ bool MpdInterface::dispatch(const char* cmd) const
return false;
}
-bool MpdInterface::fetchLine(QString& res) const
+bool MpdInterface::fetchLine(TQString& res) const
{
- QString errormessage;
- while (sock.state()==QSocket::Connected)
+ TQString errormessage;
+ while (sock.state()==TQSocket::Connected)
{
if (!sock.canReadLine())
{
@@ -231,7 +231,7 @@ bool MpdInterface::fetchLine(QString& res) const
bool MpdInterface::fetchOk() const
{
- QString res;
+ TQString res;
while (fetchLine(res)) { }
if (res.startsWith("OK"))
return true;
@@ -244,8 +244,8 @@ void MpdInterface::updateSlider()
//kdDebug(90200) << "update slider\n";
if (!dispatch("status\n")) return;
- QString res;
- QRegExp time_re("time: (\\d+):(\\d+)");
+ TQString res;
+ TQRegExp time_re("time: (\\d+):(\\d+)");
while(fetchLine(res))
{
if (res.startsWith("state: "))
@@ -265,7 +265,7 @@ void MpdInterface::updateSlider()
}
else if (time_re.search(res)>=0)
{
- QStringList timeinfo=time_re.capturedTexts();
+ TQStringList timeinfo=time_re.capturedTexts();
timeinfo.pop_front();
int elapsed_seconds=timeinfo.first().toInt();
timeinfo.pop_front();
@@ -292,13 +292,13 @@ void MpdInterface::jumpToTime(int sec)
long songid=-1;
- QString res;
- QRegExp songid_re("songid: (\\d+)");
+ TQString res;
+ TQRegExp songid_re("songid: (\\d+)");
while(fetchLine(res))
{
if (songid_re.search(res)>=0)
{
- QStringList songidinfo=songid_re.capturedTexts();
+ TQStringList songidinfo=songid_re.capturedTexts();
songidinfo.pop_front();
songid=songidinfo.first().toInt();
}
@@ -306,7 +306,7 @@ void MpdInterface::jumpToTime(int sec)
if (songid>-1)
{
- if (dispatch(QString("seekid %1 %2\n").arg(songid).arg(sec).latin1()))
+ if (dispatch(TQString("seekid %1 %2\n").arg(songid).arg(sec).latin1()))
{
fetchOk(); // unlocks
}
@@ -349,13 +349,13 @@ void MpdInterface::changeVolume(int delta)
int volume=-1;
- QString res;
- QRegExp volume_re("volume: (\\d+)");
+ TQString res;
+ TQRegExp volume_re("volume: (\\d+)");
while(fetchLine(res))
{
if (volume_re.search(res)>=0)
{
- QStringList info=volume_re.capturedTexts();
+ TQStringList info=volume_re.capturedTexts();
info.pop_front();
volume=info.first().toInt();
}
@@ -366,7 +366,7 @@ void MpdInterface::changeVolume(int delta)
volume+=delta;
if (volume<0) volume=0;
if (volume>100) volume=100;
- if (dispatch(QString("setvol %1\n").arg(volume).latin1()))
+ if (dispatch(TQString("setvol %1\n").arg(volume).latin1()))
{
fetchOk();
}
@@ -385,12 +385,12 @@ void MpdInterface::volumeDown()
changeVolume(-5);
}
-void MpdInterface::dragEnterEvent(QDragEnterEvent* event)
+void MpdInterface::dragEnterEvent(TQDragEnterEvent* event)
{
event->accept( KURLDrag::canDecode(event) );
}
-void MpdInterface::dropEvent(QDropEvent* event)
+void MpdInterface::dropEvent(TQDropEvent* event)
{
reconnect();
@@ -403,15 +403,15 @@ void MpdInterface::dropEvent(QDropEvent* event)
if (dispatch("playlistid\n"))
{
long songid=-1;
- QString file;
- QString res;
+ TQString file;
+ TQString res;
while(fetchLine(res))
{
- QRegExp file_re("file: (.+)");
- QRegExp id_re("Id: (.+)");
+ TQRegExp file_re("file: (.+)");
+ TQRegExp id_re("Id: (.+)");
if (file.isEmpty() && file_re.search(res)>=0)
{
- QStringList info=file_re.capturedTexts();
+ TQStringList info=file_re.capturedTexts();
info.pop_front();
// if the dropped file ends with the same name, record it
if (list.front().path().endsWith(info.first()))
@@ -422,7 +422,7 @@ void MpdInterface::dropEvent(QDropEvent* event)
else if (!file.isEmpty() && id_re.search(res)>=0)
{
// when we have the file, pick up the id (file scomes first)
- QStringList info=id_re.capturedTexts();
+ TQStringList info=id_re.capturedTexts();
info.pop_front();
songid=info.first().toInt();
fetchOk(); // skip to the end
@@ -433,7 +433,7 @@ void MpdInterface::dropEvent(QDropEvent* event)
// found song, so lets play it
if (songid>-1)
{
- if (dispatch((QString("playid %1\n").arg(songid)).latin1()))
+ if (dispatch((TQString("playid %1\n").arg(songid)).latin1()))
{
if (fetchOk()) list.pop_front();
return;
@@ -447,13 +447,13 @@ void MpdInterface::dropEvent(QDropEvent* event)
{
if ((*i).isLocalFile())
{
- QStringList path=QStringList::split("/",(*i).path());
+ TQStringList path=TQStringList::split("/",(*i).path());
while (!path.empty())
{
- if (dispatch((QString("add \"")
+ if (dispatch((TQString("add \"")
+path.join("/").replace("\"","\\\"")
- +QString("\"\n")).latin1()))
+ +TQString("\"\n")).latin1()))
{
if (fetchOk()) break;
}
@@ -468,22 +468,22 @@ void MpdInterface::dropEvent(QDropEvent* event)
}
}
-const QString MpdInterface::getTrackTitle() const
+const TQString MpdInterface::getTrackTitle() const
{
- QString result;
+ TQString result;
reconnect();
if (!dispatch("status\n")) return result;
long songid=-1;
- QString res;
+ TQString res;
while(fetchLine(res))
{
- QRegExp songid_re("songid: (\\d+)");
+ TQRegExp songid_re("songid: (\\d+)");
if (songid_re.search(res)>=0)
{
- QStringList songidinfo=songid_re.capturedTexts();
+ TQStringList songidinfo=songid_re.capturedTexts();
songidinfo.pop_front();
songid=songidinfo.first().toInt();
}
@@ -491,48 +491,48 @@ const QString MpdInterface::getTrackTitle() const
if (!(songid>-1)) return result;
- if (!dispatch(QString("playlistid %1\n").arg(songid).latin1()))
+ if (!dispatch(TQString("playlistid %1\n").arg(songid).latin1()))
return result;
- QString artist;
- QString album;
- QString title;
- QString track;
- QString file;
+ TQString artist;
+ TQString album;
+ TQString title;
+ TQString track;
+ TQString file;
while(fetchLine(res))
{
- QRegExp artist_re("Artist: (.+)");
- QRegExp album_re("Album: (.+)");
- QRegExp track_re("Album: (.+)");
- QRegExp title_re("Title: (.+)");
- QRegExp file_re("file: (.+)");
+ TQRegExp artist_re("Artist: (.+)");
+ TQRegExp album_re("Album: (.+)");
+ TQRegExp track_re("Album: (.+)");
+ TQRegExp title_re("Title: (.+)");
+ TQRegExp file_re("file: (.+)");
if (artist_re.search(res)>=0)
{
- QStringList info=artist_re.capturedTexts();
+ TQStringList info=artist_re.capturedTexts();
info.pop_front();
artist=info.first();
}
else if (album_re.search(res)>=0)
{
- QStringList info=album_re.capturedTexts();
+ TQStringList info=album_re.capturedTexts();
info.pop_front();
album=info.first();
}
else if (title_re.search(res)>=0)
{
- QStringList info=title_re.capturedTexts();
+ TQStringList info=title_re.capturedTexts();
info.pop_front();
title=info.first();
}
else if (track_re.search(res)>=0)
{
- QStringList info=track_re.capturedTexts();
+ TQStringList info=track_re.capturedTexts();
info.pop_front();
track=info.first();
}
else if (file_re.search(res)>=0)
{
- QStringList info=file_re.capturedTexts();
+ TQStringList info=file_re.capturedTexts();
info.pop_front();
file=info.first();
}
@@ -568,7 +568,7 @@ int MpdInterface::playingStatus()
if (!dispatch("status\n")) return Stopped;
PlayingStatus status=Stopped;
- QString res;
+ TQString res;
while(fetchLine(res))
{
if (res.startsWith("state: "))