summaryrefslogtreecommitdiffstats
path: root/kdict/dict.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:48:06 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:48:06 +0000
commit47c8a359c5276062c4bc17f0e82410f29081b502 (patch)
tree2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /kdict/dict.cpp
parent6f82532777a35e0e60bbd2b290b2e93e646f349b (diff)
downloadtdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz
tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdict/dict.cpp')
-rw-r--r--kdict/dict.cpp100
1 files changed, 50 insertions, 50 deletions
diff --git a/kdict/dict.cpp b/kdict/dict.cpp
index b36f1ac1..74395d4a 100644
--- a/kdict/dict.cpp
+++ b/kdict/dict.cpp
@@ -22,8 +22,8 @@
#include "options.h"
#include "dict.h"
-#include <qregexp.h>
-#include <qtextcodec.h>
+#include <tqregexp.h>
+#include <tqtextcodec.h>
#include <klocale.h>
#include <kdebug.h>
@@ -41,9 +41,9 @@
//********* JobData ******************************************
-JobData::JobData(QueryType Ntype,bool NnewServer,QString const& Nserver,int Nport,
- int NidleHold, int Ntimeout, int NpipeSize, QString const& Nencoding, bool NAuthEnabled,
- QString const& Nuser, QString const& Nsecret, unsigned int NheadLayout)
+JobData::JobData(QueryType Ntype,bool NnewServer,TQString const& Nserver,int Nport,
+ int NidleHold, int Ntimeout, int NpipeSize, TQString const& Nencoding, bool NAuthEnabled,
+ TQString const& Nuser, TQString const& Nsecret, unsigned int NheadLayout)
: type(Ntype), error(ErrNoErr), canceled(false), numFetched(0), newServer(NnewServer),server(Nserver), port(Nport),
timeout(Ntimeout), pipeSize(NpipeSize), idleHold(NidleHold), encoding(Nencoding), authEnabled(NAuthEnabled),
user(Nuser), secret(Nsecret), headLayout(NheadLayout)
@@ -133,7 +133,7 @@ void DictAsyncClient::waitForWork()
if ((tcpSocket!=-1)&&(job->newServer))
doQuit();
- codec = QTextCodec::codecForName(job->encoding.latin1());
+ codec = TQTextCodec::codecForName(job->encoding.latin1());
input[0] = 0; //terminate string
thisLine = input;
nextLine = input;
@@ -181,10 +181,10 @@ void DictAsyncClient::waitForWork()
void DictAsyncClient::define()
{
- QString command;
+ TQString command;
job->defines.clear();
- QStringList::iterator it;
+ TQStringList::iterator it;
for (it = job->databases.begin(); it != job->databases.end(); ++it) {
command = "define ";
command += *it;
@@ -201,7 +201,7 @@ void DictAsyncClient::define()
job->strategy = ".";
if (!match())
return;
- job->result = QString::null;
+ job->result = TQString::null;
if (job->numFetched == 0) {
resultAppend("<body>\n<p class=\"heading\">\n");
resultAppend(i18n("No definitions found for \'%1'.").arg(job->query));
@@ -212,8 +212,8 @@ void DictAsyncClient::define()
resultAppend(i18n("No definitions found for \'%1\'. Perhaps you mean:").arg(job->query));
resultAppend("</p>\n<table width=\"100%\" cols=2>\n");
- QString lastDb;
- QStringList::iterator it;
+ TQString lastDb;
+ TQStringList::iterator it;
for (it = job->matches.begin(); it != job->matches.end(); ++it) {
int pos = (*it).find(' ');
if (pos != -1) {
@@ -241,10 +241,10 @@ void DictAsyncClient::define()
}
-QString htmlString(const QString &raw)
+TQString htmlString(const TQString &raw)
{
unsigned int len=raw.length();
- QString ret;
+ TQString ret;
for (unsigned int i=0; i<len; i++) {
switch (raw[i]) {
@@ -259,13 +259,13 @@ QString htmlString(const QString &raw)
}
-QString generateDefineLink(const QString &raw)
+TQString generateDefineLink(const TQString &raw)
{
- QRegExp http("http://[^\\s<>()\"|\\[\\]{}]+");
- QRegExp ftp("ftp://[^\\s<>()\"|\\[\\]{}]+");
+ TQRegExp http("http://[^\\s<>()\"|\\[\\]{}]+");
+ TQRegExp ftp("ftp://[^\\s<>()\"|\\[\\]{}]+");
int matchPos=0, matchLen=0;
bool httpMatch=false;
- QString ret;
+ TQString ret;
matchPos = http.search(raw);
matchLen = http.matchedLength();
@@ -305,8 +305,8 @@ QString generateDefineLink(const QString &raw)
bool DictAsyncClient::getDefinitions()
{
- QCString lastDb,bracketBuff;
- QStrList hashList;
+ TQCString lastDb,bracketBuff;
+ TQStrList hashList;
char *s;
int defCount,response;
@@ -317,7 +317,7 @@ bool DictAsyncClient::getDefinitions()
defCount = 0;
cmdBuffer = "";
do {
- QStringList::iterator it = job->defines.begin();
+ TQStringList::iterator it = job->defines.begin();
cmdBuffer += codec->fromUnicode(*it);
defCount++;
job->defines.remove(it);
@@ -352,7 +352,7 @@ bool DictAsyncClient::getDefinitions()
}
} else {
job->error = JobData::ErrServerError;
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(thisLine);
doQuit();
return false;
@@ -390,7 +390,7 @@ bool DictAsyncClient::getDefinitions()
bodyDone = true;
}
if (!bodyDone) {
- context.update(QCString(line));
+ context.update(TQCString(line));
if (!bracketBuff.isEmpty()) {
s = strchr(line,'}');
if (!s)
@@ -461,7 +461,7 @@ bool DictAsyncClient::getDefinitions()
bool DictAsyncClient::match()
{
- QStringList::iterator it = job->databases.begin();
+ TQStringList::iterator it = job->databases.begin();
int response;
cmdBuffer = "";
@@ -792,13 +792,13 @@ void DictAsyncClient::openConnection()
if (ks.status() == IO_LookupError)
job->error = JobData::ErrBadHost;
else if (ks.status() == IO_ConnectError) {
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(KExtendedSocket::strError(ks.status(), errno));
job->error = JobData::ErrConnect;
} else if (ks.status() == IO_TimeOutError)
job->error = JobData::ErrTimeout;
else {
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(KExtendedSocket::strError(ks.status(), errno));
job->error = JobData::ErrCommunication;
}
@@ -827,7 +827,7 @@ void DictAsyncClient::openConnection()
}
KMD5 context;
- context.update(QCString(msgId));
+ context.update(TQCString(msgId));
context.update(job->secret.local8Bit());
cmdBuffer += "auth " + job->user.local8Bit() + " ";
@@ -898,7 +898,7 @@ bool DictAsyncClient::waitForRead()
if (ret == -1) { // select failed
if (job) {
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(strerror(errno));
job->error = JobData::ErrCommunication;
}
@@ -918,7 +918,7 @@ bool DictAsyncClient::waitForRead()
}
if (FD_ISSET(tcpSocket,&fdsE)||FD_ISSET(fdPipeIn,&fdsE)) { // broken pipe, etc
if (job) {
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(i18n("The connection is broken."));
job->error = JobData::ErrCommunication;
}
@@ -930,7 +930,7 @@ bool DictAsyncClient::waitForRead()
}
if (job) {
- job->result = QString::null;
+ job->result = TQString::null;
job->error = JobData::ErrCommunication;
}
closeSocket();
@@ -961,7 +961,7 @@ bool DictAsyncClient::waitForWrite()
if (ret == -1) { // select failed
if (job) {
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(strerror(errno));
job->error = JobData::ErrCommunication;
}
@@ -981,7 +981,7 @@ bool DictAsyncClient::waitForWrite()
}
if (FD_ISSET(tcpSocket,&fdsR)||FD_ISSET(tcpSocket,&fdsE)||FD_ISSET(fdPipeIn,&fdsE)) { // broken pipe, etc
if (job) {
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(i18n("The connection is broken."));
job->error = JobData::ErrCommunication;
}
@@ -992,7 +992,7 @@ bool DictAsyncClient::waitForWrite()
return true;
}
if (job) {
- job->result = QString::null;
+ job->result = TQString::null;
job->error = JobData::ErrCommunication;
}
closeSocket();
@@ -1032,7 +1032,7 @@ bool DictAsyncClient::sendBuffer()
ret = KSocks::self()->write(tcpSocket,&cmdBuffer.data()[done],todo);
if (ret <= 0) {
if (job) {
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(strerror(errno));
job->error = JobData::ErrCommunication;
}
@@ -1077,7 +1077,7 @@ bool DictAsyncClient::getNextLine()
} while ((received<0)&&(errno==EINTR)); // don't get tricked by signals
if (received <= 0) {
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(i18n("The connection is broken."));
job->error = JobData::ErrCommunication;
closeSocket();
@@ -1121,7 +1121,7 @@ void DictAsyncClient::handleErrors()
int len = strlen(thisLine);
if (len>80)
len = 80;
- job->result = QString::null;
+ job->result = TQString::null;
resultAppend(codec->toUnicode(thisLine,len));
switch (strtol(thisLine,0L,0)) {
@@ -1167,7 +1167,7 @@ void DictAsyncClient::resultAppend(const char* str)
}
-void DictAsyncClient::resultAppend(QString str)
+void DictAsyncClient::resultAppend(TQString str)
{
if (job)
job->result += str;
@@ -1203,8 +1203,8 @@ DictInterface::DictInterface()
kapp->exit(1);
}
- notifier = new QSocketNotifier(fdPipeIn[0],QSocketNotifier::Read,this);
- connect(notifier,SIGNAL(activated(int)),this,SLOT(clientDone()));
+ notifier = new TQSocketNotifier(fdPipeIn[0],TQSocketNotifier::Read,this);
+ connect(notifier,TQT_SIGNAL(activated(int)),this,TQT_SLOT(clientDone()));
// initialize the KSocks stuff in the main thread, otherwise we get
// strange effects on FreeBSD
@@ -1222,7 +1222,7 @@ DictInterface::DictInterface()
DictInterface::~DictInterface()
{
- disconnect(notifier,SIGNAL(activated(int)),this,SLOT(clientDone()));
+ disconnect(notifier,TQT_SIGNAL(activated(int)),this,TQT_SLOT(clientDone()));
if (0!=pthread_cancel(threadID))
kdWarning() << "pthread_cancel failed!" << endl;
@@ -1271,7 +1271,7 @@ void DictInterface::stop()
}
-void DictInterface::define(const QString &query)
+void DictInterface::define(const TQString &query)
{
JobData *newJob = generateQuery(JobData::TDefine,query);
if (newJob)
@@ -1279,7 +1279,7 @@ void DictInterface::define(const QString &query)
}
-void DictInterface::getDefinitions(QStringList query)
+void DictInterface::getDefinitions(TQStringList query)
{
JobData *newjob = new JobData(JobData::TGetDefinitions,newServer,global->server,global->port,
global->idleHold,global->timeout,global->pipeSize, global->encoding,global->authEnabled,
@@ -1290,7 +1290,7 @@ void DictInterface::getDefinitions(QStringList query)
}
-void DictInterface::match(const QString &query)
+void DictInterface::match(const TQString &query)
{
JobData *newJob = generateQuery(JobData::TMatch,query);
@@ -1306,9 +1306,9 @@ void DictInterface::match(const QString &query)
// fetch detailed db info
-void DictInterface::showDbInfo(const QString &db)
+void DictInterface::showDbInfo(const TQString &db)
{
- QString ndb = db.simplifyWhiteSpace(); // cleanup query string
+ TQString ndb = db.simplifyWhiteSpace(); // cleanup query string
if (ndb.isEmpty())
return;
if (ndb.length()>100) // shorten if necessary
@@ -1362,7 +1362,7 @@ void DictInterface::updateServer()
// client-thread ended
void DictInterface::clientDone()
{
- QString message;
+ TQString message;
cleanPipes(); // read from pipe so that notifier doesn´t fire again
@@ -1372,7 +1372,7 @@ void DictInterface::clientDone()
}
clientDoneInProgress = true;
- QStringList::iterator it;
+ TQStringList::iterator it;
JobData* job = jobList.getFirst();
if (!job->canceled) { // non-interupted job?
if (JobData::ErrNoErr == job->error) {
@@ -1444,7 +1444,7 @@ void DictInterface::clientDone()
emit resultReady(job->result, job->query);
}
} else {
- QString errMsg;
+ TQString errMsg;
switch (job->error) {
case JobData::ErrCommunication:
errMsg = i18n("Communication error:\n\n");
@@ -1514,14 +1514,14 @@ void DictInterface::clientDone()
}
-JobData* DictInterface::generateQuery(JobData::QueryType type, QString query)
+JobData* DictInterface::generateQuery(JobData::QueryType type, TQString query)
{
query = query.simplifyWhiteSpace(); // cleanup query string
if (query.isEmpty())
return 0L;
if (query.length()>300) // shorten if necessary
query.truncate(300);
- query = query.replace(QRegExp("[\"\\]"), ""); // remove remaining illegal chars...
+ query = query.replace(TQRegExp("[\"\\]"), ""); // remove remaining illegal chars...
if (query.isEmpty())
return 0L;
@@ -1579,7 +1579,7 @@ void DictInterface::startClient()
if (::write(fdPipeOut[1],&buf,1) == -1)
::perror( "startClient()" );
- QString message;
+ TQString message;
switch (jobList.getFirst()->type) {
case JobData::TDefine:
case JobData::TGetDefinitions: