diff options
Diffstat (limited to 'qt3')
-rw-r--r-- | qt3/kqt3.cpp | 316 |
1 files changed, 158 insertions, 158 deletions
diff --git a/qt3/kqt3.cpp b/qt3/kqt3.cpp index 833b01d..d738b29 100644 --- a/qt3/kqt3.cpp +++ b/qt3/kqt3.cpp @@ -23,7 +23,7 @@ * ************************************************************************/ -#define KQT_OVERLOAD_NON_STATIC_FILEDIALOGS +#define KTQT_OVERLOAD_NON_STATIC_FILEDIALOGS #define _GNU_SOURCE #include <dlfcn.h> @@ -39,20 +39,20 @@ #include <errno.h> #include <string.h> #include <sys/types.h> -#include <qstring.h> -#include <qstringlist.h> -#include <qwidget.h> -#include <qapplication.h> -#ifdef KQT_OVERLOAD_NON_STATIC_FILEDIALOGS -#include <qcombobox.h> -#include <qlineedit.h> -#include <qobjectlist.h> +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqwidget.h> +#include <tqapplication.h> +#ifdef KTQT_OVERLOAD_NON_STATIC_FILEDIALOGS +#include <tqcombobox.h> +#include <tqlineedit.h> +#include <tqobjectlist.h> #define private public // HACK HACK HACK!!! #endif -#include <qfiledialog.h> -#include <qthread.h> -#include <qnamespace.h> -#include <qeventloop.h> +#include <tqfiledialog.h> +#include <tqthread.h> +#include <tqnamespace.h> +#include <tqeventloop.h> #include "connect.h" #include "config.h" #include "mangled.h" @@ -93,16 +93,16 @@ static char * getAppNameFromPid(int pid) return appName; } -static const char * getAppName(bool useQt=true) +static const char * getAppName(bool useTQt=true) { static const char *appName=NULL; if(!appName) { - const char *a=useQt && qApp ? qApp->argv()[0] : getAppNameFromPid(getpid()); + const char *a=useTQt && tqApp ? tqApp->argv()[0] : getAppNameFromPid(getpid()); const char *slash; - // Was the cmdline app java? if so, try to use its parent name - just in case + // Was the cmdline app java? if so, try to use its tqparent name - just in case // its run from a shell script, etc. - e.g. as eclipse does if(a && 0==strcmp(a, "java")) a=getAppNameFromPid(getppid()); @@ -112,13 +112,13 @@ static const char * getAppName(bool useQt=true) appName=a && (slash=strrchr(a, '/')) && '\0'!=slash[1] ? &(slash[1]) - : a ? a : "QtApp"; + : a ? a : "TQtApp"; } return appName; } -int QApplication::exec() +int TQApplication::exec() { static bool init=false; @@ -135,19 +135,19 @@ int QApplication::exec() return (int)realFunction(this); }; -static QString qt2KdeFilter(const QString &f) +static TQString qt2KdeFilter(const TQString &f) { - QString filter; - QTextOStream str(&filter); - QStringList list(QStringList::split(";;", f)); - QStringList::Iterator it(list.begin()), + TQString filter; + TQTextOStream str(&filter); + TQStringList list(TQStringList::split(";;", f)); + TQStringList::Iterator it(list.begin()), end(list.end()); bool first=true; for(; it!=end; ++it) { - int ob=(*it).findRev('('), - cb=(*it).findRev(')'); + int ob=(*it).tqfindRev('('), + cb=(*it).tqfindRev(')'); if(-1!=cb && ob<cb) { @@ -162,17 +162,17 @@ static QString qt2KdeFilter(const QString &f) return filter; } -static void kde2QtFilter(const QString &orig, QString *sel) +static void kde2TQtFilter(const TQString &orig, TQString *sel) { if(sel) { - QStringList list(QStringList::split(";;", orig)); - QStringList::Iterator it(list.begin()), + TQStringList list(TQStringList::split(";;", orig)); + TQStringList::Iterator it(list.begin()), end(list.end()); int pos; for(; it!=end; ++it) - if(-1!=(pos=(*it).find(*sel)) && pos>0 && + if(-1!=(pos=(*it).tqfind(*sel)) && pos>0 && ('('==(*it)[pos-1] || ' '==(*it)[pos-1]) && (*it).length()>=sel->length()+pos && (')'==(*it)[pos+sel->length()] || ' '==(*it)[pos+sel->length()])) @@ -183,39 +183,39 @@ static void kde2QtFilter(const QString &orig, QString *sel) } } -#ifdef KQT_OVERLOAD_NON_STATIC_FILEDIALOGS -#ifdef KQT_USE_QFILEDIALOG_PRIVATE +#ifdef KTQT_OVERLOAD_NON_STATIC_FILEDIALOGS +#ifdef KTQT_USE_TQFILEDIALOG_PRIVATE // HACK HACK HACK!!! -// KGtk versions <=0.9.1 used this copied QFileDialogPrivate to access the file filters -// newer versions walk the file dialogs children... -class QFileDialogPrivate { +// KGtk versions <=0.9.1 used this copied TQFileDialogPrivate to access the file filters +// newer versions walk the file dialogs tqchildren... +class TQFileDialogPrivate { public: - ~QFileDialogPrivate(); + ~TQFileDialogPrivate(); - QStringList history; + TQStringList history; - bool geometryDirty; - QComboBox * paths; - QComboBox * types; + bool tqgeometryDirty; + TQComboBox * paths; + TQComboBox * types; }; #endif -static const QString getFilters(QFileDialog *dlg, bool scribusSave=false) +static const TQString getFilters(TQFileDialog *dlg, bool scribusSave=false) { - QString filter; + TQString filter; -#if KQT_USE_QFILEDIALOG_PRIVATE +#if KTQT_USE_TQFILEDIALOG_PRIVATE if(dlg && dlg->d && dlg->d->types) { - QTextOStream str(&filter); + TQTextOStream str(&filter); for(int i=0; i<dlg->d->types->count(); ++i) { if(i) str << ";;"; - if(scribusSave && -1!=dlg->d->types->text(i).find("(*.sla *.sla.gz *.scd *scd.gz)")) + if(scribusSave && -1!=dlg->d->types->text(i).tqfind("(*.sla *.sla.gz *.scd *scd.gz)")) str << "Compressed Documents (*.sla.gz *scd.gz);;Documents (*.sla *.scd)"; else str << dlg->d->types->text(i); @@ -224,25 +224,25 @@ static const QString getFilters(QFileDialog *dlg, bool scribusSave=false) #else if(dlg) { - const QObjectList *children=((QObject *)dlg)->children(); + const TQObjectList tqchildren=((TQObject *)dlg)->childrenListObject(); - if(children) + if(!tqchildren.isEmpty()) { - QObjectList::ConstIterator it(children->begin()), - end(children->end()); + TQObjectList::ConstIterator it(tqchildren.begin()), + end(tqchildren.end()); for(; it!=end; ++it) - if(::qt_cast<QComboBox *>(*it) && 0==qstrcmp((*it)->name(), "file types")) + if(::tqqt_cast<TQComboBox *>(*it) && 0==qstrcmp((*it)->name(), "file types")) { - QComboBox *types=(QComboBox *)(*it); - QTextOStream str(&filter); + TQComboBox *types=(TQComboBox *)(*it); + TQTextOStream str(&filter); for(int i=0; i<types->count(); ++i) { if(i) str << ";;"; - if(scribusSave && -1!=types->text(i).find("(*.sla *.sla.gz *.scd *scd.gz)")) + if(scribusSave && -1!=types->text(i).tqfind("(*.sla *.sla.gz *.scd *scd.gz)")) str << "Compressed Documents (*.sla.gz *scd.gz);;Documents (*.sla *.scd)"; else str << types->text(i); @@ -257,31 +257,31 @@ static const QString getFilters(QFileDialog *dlg, bool scribusSave=false) return filter; } -static QString getCurrentFileName(QFileDialog *dlg) +static TQString getCurrentFileName(TQFileDialog *dlg) { if(dlg) { - const QObjectList *children=((QObject *)dlg)->children(); + const TQObjectList tqchildren=((TQObject *)dlg)->childrenListObject(); - if(children) + if(!tqchildren.isEmpty()) { - QObjectList::ConstIterator it(children->begin()), - end(children->end()); + TQObjectList::ConstIterator it(tqchildren.begin()), + end(tqchildren.end()); for(; it!=end; ++it) - if(::qt_cast<QLineEdit *>(*it)) // && 0==qstrcmp((*it)->name(), "name/filter editor")) - return ((QLineEdit *)(*it))->text(); + if(::tqqt_cast<TQLineEdit *>(*it)) // && 0==qstrcmp((*it)->name(), "name/filter editor")) + return ((TQLineEdit *)(*it))->text(); } } - return QString(); + return TQString(); } -static QString getDir(const QString &f) +static TQString getDir(const TQString &f) { - QString d(f); + TQString d(f); - int slashPos=d.findRev('/'); + int slashPos=d.tqfindRev('/'); if(slashPos!=-1) d.remove(slashPos+1, d.length()); @@ -290,9 +290,9 @@ static QString getDir(const QString &f) } #endif -static bool writeString(int fd, const QString &str) +static bool writeString(int fd, const TQString &str) { - QCString utf8(str.utf8()); + TQCString utf8(str.utf8()); int size=utf8.length()+1; return writeBlock(fd, (char *)&size, 4) && writeBlock(fd, utf8.data(), size); @@ -305,11 +305,11 @@ static bool writeBool(int fd, bool b) return writeBlock(fd, (char *)&bv, 1); } -class KQtDialog : public QDialog +class KTQtDialog : public TQDialog { public: - KQtDialog(QWidget *parent) : QDialog(parent, "kqt", true, WStyle_NoBorder|WX11BypassWM) + KTQtDialog(TQWidget *tqparent) : TQDialog(tqparent, "kqt", true, WStyle_NoBorder|WX11BypassWM) { resize(1, 1); setWindowOpacity(0.0); @@ -317,37 +317,37 @@ class KQtDialog : public QDialog move(32768, 32768); } -/* void r() { QDialog::reject(); }*/ +/* void r() { TQDialog::reject(); }*/ }; -class KQtThread : public QThread +class KTQtThread : public TQThread { public: - KQtThread(QStringList &l, QString &s, int f, KQtDialog *dlg) : dialog(dlg), kdialogdError(false), res(l), selFilter(s), fd(f) + KTQtThread(TQStringList &l, TQString &s, int f, KTQtDialog *dlg) : dialog(dlg), kdialogdError(false), res(l), selFilter(s), fd(f) { } - bool readData(QCString &buffer, int size) + bool readData(TQCString &buffer, int size) { buffer.resize(size); return ::readBlock(fd, buffer.data(), size); } - bool readString(QString &str, int size) + bool readString(TQString &str, int size) { - QCString buffer; + TQCString buffer; buffer.resize(size); if(!readBlock(fd, buffer.data(), size)) return false; - str=QString::fromUtf8(buffer.data()); + str=TQString::fromUtf8(buffer.data()); return true; } void run() { - QString buffer; + TQString buffer; int num=0; if(readBlock(fd, (char *)&num, 4)) @@ -381,23 +381,23 @@ class KQtThread : public QThread else kdialogdError=true; - QApplication::postEvent(dialog, new QCloseEvent); + TQApplication::postEvent(dialog, new TQCloseEvent); } - KQtDialog *dialog; + KTQtDialog *dialog; bool kdialogdError; - QStringList &res; - QString &selFilter; + TQStringList &res; + TQString &selFilter; int fd; }; -static bool sendMessage(QWidget *parent, Operation op, QStringList &res, QString &selFilter, - const QString &title, const QString &p1, const QString *p2, bool ow) +static bool sendMessage(TQWidget *tqparent, Operation op, TQStringList &res, TQString &selFilter, + const TQString &title, const TQString &p1, const TQString *p2, bool ow) { if(connectToKDialogD(getAppName())) { char o=(char)op; - int xid=parent ? parent->topLevelWidget()->winId() : qApp->activeWindow()->winId(); + int xid=tqparent ? tqparent->tqtopLevelWidget()->winId() : tqApp->activeWindow()->winId(); if(writeBlock(kdialogdSocket, &o, 1) && writeBlock(kdialogdSocket, (char *)&xid, 4) && @@ -406,8 +406,8 @@ static bool sendMessage(QWidget *parent, Operation op, QStringList &res, QString (p2? writeString(kdialogdSocket, *p2) : true) && (OP_FILE_SAVE==op ? writeBool(kdialogdSocket, ow) : true)) { - KQtDialog dlg(parent); - KQtThread thread(res, selFilter, kdialogdSocket, &dlg); + KTQtDialog dlg(tqparent); + KTQtThread thread(res, selFilter, kdialogdSocket, &dlg); thread.start(); dlg.exec(); @@ -424,7 +424,7 @@ static bool sendMessage(QWidget *parent, Operation op, QStringList &res, QString return false; } -static QString getTitle(const QString &title, Operation op) +static TQString getTitle(const TQString &title, Operation op) { if(!title.isEmpty()) return title; @@ -432,13 +432,13 @@ static QString getTitle(const QString &title, Operation op) return "."; } -static bool openKdeDialog(QWidget *widget, const QString &title, const QString &p1, const QString *p2, - Operation op, QStringList &res, QString *selFilter, bool ow=false) +static bool openKdeDialog(TQWidget *widget, const TQString &title, const TQString &p1, const TQString *p2, + Operation op, TQStringList &res, TQString *selFilter, bool ow=false) { - QString filter; + TQString filter; bool rv=sendMessage(widget, op, res, filter, getTitle(title, op), p1, p2, ow); - // If we failed to talk to, or start kdialogd, then dont keep trying - just fall back to Qt + // If we failed to talk to, or start kdialogd, then dont keep trying - just fall back to TQt if(!rv) /*useKde=false*/; else if(selFilter) @@ -468,98 +468,98 @@ static bool kqtInit() return useKde; } -static QString lastDir; +static TQString lastDir; -static void storeLastDir(const QString &f) +static void storeLastDir(const TQString &f) { lastDir=f; - int slashPos(lastDir.findRev('/')); + int slashPos(lastDir.tqfindRev('/')); if(slashPos!=-1) lastDir.remove(slashPos+1, lastDir.length()); } -static const QString & startDir(const QString &d) +static const TQString & startDir(const TQString &d) { return d.isEmpty() ? lastDir : d; } -QString QFileDialog::getOpenFileName(const QString &initially, const QString &filter, - QWidget *parent, const char *name, const QString &caption, - QString *selectedFilter, bool resolveSymlinks) +TQString TQFileDialog::getOpenFileName(const TQString &initially, const TQString &filter, + TQWidget *tqparent, const char *name, const TQString &caption, + TQString *selectedFilter, bool resolveSymlinks) { - QStringList res; - QString f(qt2KdeFilter(filter)); + TQStringList res; + TQString f(qt2KdeFilter(filter)); kqtInit(); - if(openKdeDialog(parent, caption, startDir(initially), &f, OP_FILE_OPEN, res, selectedFilter)) + if(openKdeDialog(tqparent, caption, startDir(initially), &f, OP_FILE_OPEN, res, selectedFilter)) { - kde2QtFilter(filter, selectedFilter); - QString fn(res.first()); + kde2TQtFilter(filter, selectedFilter); + TQString fn(res.first()); storeLastDir(fn); return fn; } - return QString::null; + return TQString(); } -QString QFileDialog::getSaveFileName(const QString &initially, const QString &filter, QWidget *parent, - const char *name, const QString &caption, - QString *selectedFilter, bool resolveSymlinks) +TQString TQFileDialog::getSaveFileName(const TQString &initially, const TQString &filter, TQWidget *tqparent, + const char *name, const TQString &caption, + TQString *selectedFilter, bool resolveSymlinks) { - QStringList res; - QString f(qt2KdeFilter(filter)); + TQStringList res; + TQString f(qt2KdeFilter(filter)); kqtInit(); - if (openKdeDialog(parent, caption, startDir(initially), &f, OP_FILE_SAVE, res, selectedFilter)) + if (openKdeDialog(tqparent, caption, startDir(initially), &f, OP_FILE_SAVE, res, selectedFilter)) { - kde2QtFilter(filter, selectedFilter); - QString fn(res.first()); + kde2TQtFilter(filter, selectedFilter); + TQString fn(res.first()); storeLastDir(fn); return fn; } - return QString::null; + return TQString(); } -QString QFileDialog::getExistingDirectory(const QString &dir, QWidget *parent, const char *name, - const QString &caption, bool dirOnly, bool resolveSymlinks) +TQString TQFileDialog::getExistingDirectory(const TQString &dir, TQWidget *tqparent, const char *name, + const TQString &caption, bool dirOnly, bool resolveSymlinks) { - QStringList res; - QString dummy; + TQStringList res; + TQString dummy; kqtInit(); - return openKdeDialog(parent, caption, dir, NULL, OP_FOLDER, res, &dummy) + return openKdeDialog(tqparent, caption, dir, NULL, OP_FOLDER, res, &dummy) ? res.first() - : QString::null; + : TQString(); } -QStringList QFileDialog::getOpenFileNames(const QString &filter, const QString &dir, QWidget *parent, - const char *name, const QString &caption, - QString *selectedFilter, bool resolveSymlinks) +TQStringList TQFileDialog::getOpenFileNames(const TQString &filter, const TQString &dir, TQWidget *tqparent, + const char *name, const TQString &caption, + TQString *selectedFilter, bool resolveSymlinks) { - QStringList res; - QString f(qt2KdeFilter(filter)); + TQStringList res; + TQString f(qt2KdeFilter(filter)); kqtInit(); - openKdeDialog(parent, caption, startDir(dir), &f, OP_FILE_OPEN_MULTIPLE, res, selectedFilter); + openKdeDialog(tqparent, caption, startDir(dir), &f, OP_FILE_OPEN_MULTIPLE, res, selectedFilter); if(res.count()) { - kde2QtFilter(filter, selectedFilter); + kde2TQtFilter(filter, selectedFilter); storeLastDir(res.first()); } return res; } -#ifdef KQT_OVERLOAD_NON_STATIC_FILEDIALOGS -static QString getFile(const QString &f) +#ifdef KTQT_OVERLOAD_NON_STATIC_FILEDIALOGS +static TQString getFile(const TQString &f) { - QString d(f); + TQString d(f); - int slashPos=d.findRev('/'); + int slashPos=d.tqfindRev('/'); if(slashPos!=-1) d.remove(0, slashPos+1); @@ -567,70 +567,70 @@ static QString getFile(const QString &f) return d; } -int QDialog::exec() +int TQDialog::exec() { - int res=QDialog::Rejected; + int res=TQDialog::Rejected; - if(inherits("QFileDialog")) + if(inherits("TQFileDialog")) { - QFileDialog *that=(QFileDialog *)this; + TQFileDialog *that=(TQFileDialog *)this; - const QDir *dirp=that->dir(); - QString dir, + const TQDir *dirp=that->dir(); + TQString dir, selectedFilter, file, - initialDir(dirp ? dirp->absPath() : QDir::homeDirPath()); - QStringList files; + initialDir(dirp ? dirp->absPath() : TQDir::homeDirPath()); + TQStringList files; if(dirp) delete dirp; - QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput, 1); + TQApplication::eventLoop()->processEvents(TQEventLoop::ExcludeUserInput, 1); switch(that->mode()) { - case QFileDialog::Directory: - case QFileDialog::DirectoryOnly: - dir=QFileDialog::getExistingDirectory(initialDir, parentWidget(), NULL, + case TQFileDialog::Directory: + case TQFileDialog::DirectoryOnly: + dir=TQFileDialog::getExistingDirectory(initialDir, tqparentWidget(), NULL, caption(), true, true); if(!dir.isEmpty()) - res=QDialog::Accepted; + res=TQDialog::Accepted; break; - case QFileDialog::AnyFile: + case TQFileDialog::AnyFile: { - QString app(getFile(qApp->argv()[0])), + TQString app(getFile(tqApp->argv()[0])), initialFile(getCurrentFileName(that)); if(!initialFile.isEmpty()) - initialDir=initialDir+QChar('/')+initialFile; + initialDir=initialDir+TQChar('/')+initialFile; - file=QFileDialog::getSaveFileName(initialDir, + file=TQFileDialog::getSaveFileName(initialDir, getFilters(that, "scribus"==app || "scribus-ng"==app), - parentWidget(), NULL, caption(), &selectedFilter, + tqparentWidget(), NULL, caption(), &selectedFilter, true); if(!file.isEmpty()) - res=QDialog::Accepted; + res=TQDialog::Accepted; break; } - case QFileDialog::ExistingFile: - file=QFileDialog::getOpenFileName(initialDir, getFilters(that), parentWidget(), + case TQFileDialog::ExistingFile: + file=TQFileDialog::getOpenFileName(initialDir, getFilters(that), tqparentWidget(), NULL, caption(), &selectedFilter, true); if(!file.isEmpty()) - res=QDialog::Accepted; + res=TQDialog::Accepted; break; - case QFileDialog::ExistingFiles: - files=QFileDialog::getOpenFileNames(getFilters(that), initialDir, parentWidget(), + case TQFileDialog::ExistingFiles: + files=TQFileDialog::getOpenFileNames(getFilters(that), initialDir, tqparentWidget(), NULL, caption(), &selectedFilter, true); if(files.count()) - res=QDialog::Accepted; + res=TQDialog::Accepted; break; } - if(QDialog::Accepted==res) + if(TQDialog::Accepted==res) { if(file.isEmpty() && files.count()) file=files.first(); @@ -645,16 +645,16 @@ int QDialog::exec() if(files.count() && that->nameEdit) { - QStringList::Iterator it(files.begin()), + TQStringList::Iterator it(files.begin()), end(files.end()); - QString filesStr; - QTextOStream str(&filesStr); + TQString filesStr; + TQTextOStream str(&filesStr); for(; it!=end; ++it) str << "\"" << (*it) << "\" "; that->nameEdit->setText(filesStr); } - QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput, 1); + TQApplication::eventLoop()->processEvents(TQEventLoop::ExcludeUserInput, 1); } } else |