diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:42:31 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:42:31 +0000 |
commit | 576eb4299a00bc053db35414406f46372a0f70f2 (patch) | |
tree | 4c030922d533821db464af566188e7d40cc8848c /kbackgammon/engines/gnubg/kbggnubg.cpp | |
parent | 0718336b6017d1a4fc1d626544180a5a2a29ddec (diff) | |
download | tdegames-576eb4299a00bc053db35414406f46372a0f70f2.tar.gz tdegames-576eb4299a00bc053db35414406f46372a0f70f2.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1157643 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbackgammon/engines/gnubg/kbggnubg.cpp')
-rw-r--r-- | kbackgammon/engines/gnubg/kbggnubg.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/kbackgammon/engines/gnubg/kbggnubg.cpp b/kbackgammon/engines/gnubg/kbggnubg.cpp index eaaa4bdf..d17a6f88 100644 --- a/kbackgammon/engines/gnubg/kbggnubg.cpp +++ b/kbackgammon/engines/gnubg/kbggnubg.cpp @@ -29,17 +29,17 @@ #include <stdlib.h> #include <time.h> #include <unistd.h> -#include <qlayout.h> +#include <tqlayout.h> #include <kiconloader.h> #include <kstdaction.h> -#include <qbuttongroup.h> -#include <qcheckbox.h> +#include <tqbuttongroup.h> +#include <tqcheckbox.h> #include <kconfig.h> #include <iostream> #include <klocale.h> #include <kmainwindow.h> #include <klineeditdlg.h> -#include <qregexp.h> +#include <tqregexp.h> #include <kregexp.h> #include <knotifyclient.h> @@ -75,17 +75,17 @@ void KBgEngineGNU::doubleCube(const int w) -void KBgEngineGNU::handleLine(const QString &l) +void KBgEngineGNU::handleLine(const TQString &l) { if (l.isEmpty()) return; - QString line(l); + TQString line(l); /* * Start of a new game/match */ - if (line.contains(QRegExp("^gnubg rolls [1-6], .* rolls [1-6]\\."))) { + if (line.contains(TQRegExp("^gnubg rolls [1-6], .* rolls [1-6]\\."))) { KRegExp e("^gnubg rolls ([1-6]), .* rolls ([1-6])\\."); e.match(line.latin1()); if (int r = strcmp(e.group(1), e.group(2))) @@ -95,14 +95,14 @@ void KBgEngineGNU::handleLine(const QString &l) /* * Bug fixes for older versions of GNUBG - to be removed */ - if (line.contains(QRegExp("^.* cannot move\\..+$"))) { + if (line.contains(TQRegExp("^.* cannot move\\..+$"))) { KRegExp e("(^.* cannot move.)(.*$)"); e.match(line.latin1()); handleLine(e.group(1)); handleLine(e.group(2)); return; } - if (line.contains(QRegExp("^Are you sure you want to start a new game, and discard the one in progress\\?"))) { + if (line.contains(TQRegExp("^Are you sure you want to start a new game, and discard the one in progress\\?"))) { KRegExp e("(^Are you sure you want to start a new game, and discard the one in progress\\? )(.+$)"); e.match(line.latin1()); handleLine(e.group(1)); @@ -113,7 +113,7 @@ void KBgEngineGNU::handleLine(const QString &l) /* * Cube handling */ - if (line.contains(QRegExp("^gnubg accepts and immediately redoubles to [0-9]+\\.$"))) { + if (line.contains(TQRegExp("^gnubg accepts and immediately redoubles to [0-9]+\\.$"))) { // redoubles mess up the game counter "turn" @@ -122,7 +122,7 @@ void KBgEngineGNU::handleLine(const QString &l) //emit newState(st); } - if (line.contains(QRegExp("^gnubg doubles\\.$"))) { + if (line.contains(TQRegExp("^gnubg doubles\\.$"))) { // TODO: we need some generic class for this. the class // can be shared between all engines @@ -155,14 +155,14 @@ void KBgEngineGNU::handleLine(const QString &l) /* * Ignore the following messages */ - if (line.contains(QRegExp("^TTY boards will be given in raw format"))) { + if (line.contains(TQRegExp("^TTY boards will be given in raw format"))) { line = " "; } /* * Board messages */ - if (line.contains(QRegExp("^board:"))) { + if (line.contains(TQRegExp("^board:"))) { KBgStatus st(line); @@ -248,7 +248,7 @@ void KBgEngineGNU::handleLine(const QString &l) /* * Show the line... */ - line.replace(QRegExp(" "), " "); + line.replace(TQRegExp(" "), " "); if (!line.isEmpty()) emit infoText(line); } @@ -257,7 +257,7 @@ void KBgEngineGNU::handleLine(const QString &l) /* * Handle textual commands. All commands are passed to gnubg. */ -void KBgEngineGNU::handleCommand(const QString& cmd) +void KBgEngineGNU::handleCommand(const TQString& cmd) { cmdList += cmd; nextCommand(); @@ -275,10 +275,10 @@ void KBgEngineGNU::newGame() /* * If there is a game running we warn the user first */ - if (gameRunning && (KMessageBox::warningYesNo((QWidget *)parent(), + if (gameRunning && (KMessageBox::warningYesNo((TQWidget *)parent(), i18n("A game is currently in progress. " "Starting a new one will terminate it."), - QString::null, i18n("Start New Game"), i18n("Continue Old Game")) + TQString::null, i18n("Start New Game"), i18n("Continue Old Game")) == KMessageBox::No)) return; @@ -379,7 +379,7 @@ void KBgEngineGNU::getSetupPages(KDialogBase *nb) /* * Main Widget */ - QVBox *w = nb->addVBoxPage(i18n("GNU Engine"), i18n("Here you can configure the GNU backgammon engine"), + TQVBox *w = nb->addVBoxPage(i18n("GNU Engine"), i18n("Here you can configure the GNU backgammon engine"), kapp->iconLoader()->loadIcon(PROG_NAME "_engine", KIcon::Desktop)); } @@ -422,7 +422,7 @@ void KBgEngineGNU::saveConfig() /* * Constructor */ -KBgEngineGNU::KBgEngineGNU(QWidget *parent, QString *name, QPopupMenu *pmenu) +KBgEngineGNU::KBgEngineGNU(TQWidget *parent, TQString *name, TQPopupMenu *pmenu) : KBgEngine(parent, name, pmenu) { // obsolete @@ -434,12 +434,12 @@ KBgEngineGNU::KBgEngineGNU(QWidget *parent, QString *name, QPopupMenu *pmenu) * internal statue variables */ rollingAllowed = undoPossible = gameRunning = donePossible = false; - connect(this, SIGNAL(allowCommand(int, bool)), this, SLOT(setAllowed(int, bool))); + connect(this, TQT_SIGNAL(allowCommand(int, bool)), this, TQT_SLOT(setAllowed(int, bool))); /* * Setup of menu */ - resAction = new KAction(i18n("&Restart GNU Backgammon"), 0, this, SLOT(startGNU()), this); + resAction = new KAction(i18n("&Restart GNU Backgammon"), 0, this, TQT_SLOT(startGNU()), this); resAction->setEnabled(false); resAction->plug(menu); /* @@ -468,8 +468,8 @@ void KBgEngineGNU::start() /* * Will be started later */ - cmdTimer = new QTimer(this); - connect(cmdTimer, SIGNAL(timeout()), SLOT(nextCommand()) ); + cmdTimer = new TQTimer(this); + connect(cmdTimer, TQT_SIGNAL(timeout()), TQT_SLOT(nextCommand()) ); emit infoText(i18n("This is experimental code which currently requires a specially " "patched version of GNU Backgammon.<br/><br/>")); @@ -484,12 +484,12 @@ void KBgEngineGNU::start() */ gnubg << "gnubg" << "--tty"; - connect(&gnubg, SIGNAL(processExited(KProcess *)), this, SLOT(gnubgExit(KProcess *))); - connect(&gnubg, SIGNAL(receivedStderr(KProcess *, char *, int)), - this, SLOT(receiveData(KProcess *, char *, int))); - connect(&gnubg, SIGNAL(receivedStdout(KProcess *, char *, int)), - this, SLOT(receiveData(KProcess *, char *, int))); - connect(&gnubg, SIGNAL(wroteStdin(KProcess *)), this, SLOT(wroteStdin(KProcess *))); + connect(&gnubg, TQT_SIGNAL(processExited(KProcess *)), this, TQT_SLOT(gnubgExit(KProcess *))); + connect(&gnubg, TQT_SIGNAL(receivedStderr(KProcess *, char *, int)), + this, TQT_SLOT(receiveData(KProcess *, char *, int))); + connect(&gnubg, TQT_SIGNAL(receivedStdout(KProcess *, char *, int)), + this, TQT_SLOT(receiveData(KProcess *, char *, int))); + connect(&gnubg, TQT_SIGNAL(wroteStdin(KProcess *)), this, TQT_SLOT(wroteStdin(KProcess *))); startGNU(); } @@ -503,7 +503,7 @@ void KBgEngineGNU::startGNU() resAction->setEnabled(false); if (!gnubg.start(KProcess::NotifyOnExit, KProcess::All)) - KMessageBox::information((QWidget *)parent(), + KMessageBox::information((TQWidget *)parent(), i18n("Could not start the GNU Backgammon process.\n" "Make sure the program is in your PATH and is " "called \"gnubg\".\n" @@ -532,7 +532,7 @@ void KBgEngineGNU::gnubgExit(KProcess *proc) emit allowMoving(false); - emit infoText(QString("<br/><font color=\"red\">") + i18n("The GNU Backgammon process (%1) has exited. ") + emit infoText(TQString("<br/><font color=\"red\">") + i18n("The GNU Backgammon process (%1) has exited. ") .arg(proc->pid()) + "</font><br/>"); resAction->setEnabled(true); @@ -560,16 +560,16 @@ void KBgEngineGNU::nextCommand() if (!gnubg.isRunning()) return; - for (QStringList::Iterator it = cmdList.begin(); it != cmdList.end(); ++it) { - QString s = (*it) + "\n"; + for (TQStringList::Iterator it = cmdList.begin(); it != cmdList.end(); ++it) { + TQString s = (*it) + "\n"; if (!gnubg.writeStdin(s.latin1(), strlen(s.latin1()))) { cmdTimer->start(250, true); - cmdList.remove(QString::null); + cmdList.remove(TQString::null); return; } - (*it) = QString::null; + (*it) = TQString::null; } - cmdList.remove(QString::null); + cmdList.remove(TQString::null); cmdTimer->stop(); } @@ -587,7 +587,7 @@ void KBgEngineGNU::receiveData(KProcess *proc, char *buffer, int buflen) memcpy(buf, buffer, buflen); buf[buflen] = '\0'; - QStringList l(QStringList::split('\n', buf, true)); + TQStringList l(TQStringList::split('\n', buf, true)); /* * Restore partial lines from the previous time @@ -604,7 +604,7 @@ void KBgEngineGNU::receiveData(KProcess *proc, char *buffer, int buflen) /* * Handle the information from gnubg */ - for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) + for (TQStringList::Iterator it = l.begin(); it != l.end(); ++it) handleLine(*it); } @@ -626,8 +626,8 @@ void KBgEngineGNU::done() // Transform the string to FIBS format lastmove.replace(0, 2, "move "); - lastmove.replace(QRegExp("\\+"), " "); - lastmove.replace(QRegExp("\\-"), " "); + lastmove.replace(TQRegExp("\\+"), " "); + lastmove.replace(TQRegExp("\\-"), " "); // sent it to the server handleCommand(lastmove); @@ -664,12 +664,12 @@ void KBgEngineGNU::redo() * Take the move string and make the changes on the working copy * of the state. */ -void KBgEngineGNU::handleMove(QString *s) +void KBgEngineGNU::handleMove(TQString *s) { lastmove = *s; int index = 0; - QString t = s->mid(index, s->find(' ', index)); + TQString t = s->mid(index, s->find(' ', index)); index += 1 + t.length(); int moves = t.toInt(); |