From c663b6440964f6ac48027143ac9e63298991f9d0 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:33:34 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1157639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kioslave/man/kio_man.cpp | 386 +++++++++++++++++++++--------------------- kioslave/man/kio_man.h | 60 +++---- kioslave/man/kio_man_test.cpp | 4 +- kioslave/man/kmanpart.cpp | 16 +- kioslave/man/kmanpart.h | 14 +- kioslave/man/man2html.cpp | 206 +++++++++++----------- kioslave/man/man2html.h | 4 +- 7 files changed, 345 insertions(+), 345 deletions(-) (limited to 'kioslave/man') diff --git a/kioslave/man/kio_man.cpp b/kioslave/man/kio_man.cpp index 068287b7e..013a15248 100644 --- a/kioslave/man/kio_man.cpp +++ b/kioslave/man/kio_man.cpp @@ -22,14 +22,14 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -56,7 +56,7 @@ MANProtocol *MANProtocol::_self = 0; * Drop trailing ".section[.gz]" from name */ static -void stripExtension( QString *name ) +void stripExtension( TQString *name ) { int pos = name->length(); @@ -77,11 +77,11 @@ void stripExtension( QString *name ) } static -bool parseUrl(const QString& _url, QString &title, QString §ion) +bool parseUrl(const TQString& _url, TQString &title, TQString §ion) { - section = QString::null; + section = TQString::null; - QString url = _url; + TQString url = _url; if (url.at(0) == '/') { if (KStandardDirs::exists(url)) { title = url; @@ -111,13 +111,13 @@ bool parseUrl(const QString& _url, QString &title, QString §ion) } -MANProtocol::MANProtocol(const QCString &pool_socket, const QCString &app_socket) - : QObject(), SlaveBase("man", pool_socket, app_socket) +MANProtocol::MANProtocol(const TQCString &pool_socket, const TQCString &app_socket) + : TQObject(), SlaveBase("man", pool_socket, app_socket) { assert(!_self); _self = this; - const QString common_dir = KGlobal::dirs()->findResourceDir( "html", "en/common/kde-common.css" ); - const QString strPath=QString( "file:%1/en/common" ).arg( common_dir ); + const TQString common_dir = KGlobal::dirs()->findResourceDir( "html", "en/common/kde-common.css" ); + const TQString strPath=TQString( "file:%1/en/common" ).arg( common_dir ); m_htmlPath=strPath.local8Bit(); // ### TODO encode for HTML m_cssPath=strPath.local8Bit(); // ### TODO encode for CSS section_names << "1" << "2" << "3" << "3n" << "3p" << "4" << "5" << "6" << "7" @@ -132,18 +132,18 @@ MANProtocol::~MANProtocol() _self = 0; } -void MANProtocol::parseWhatIs( QMap &i, QTextStream &t, const QString &mark ) +void MANProtocol::parseWhatIs( TQMap &i, TQTextStream &t, const TQString &mark ) { - QRegExp re( mark ); - QString l; + TQRegExp re( mark ); + TQString l; while ( !t.atEnd() ) { l = t.readLine(); int pos = re.search( l ); if (pos != -1) { - QString names = l.left(pos); - QString descr = l.mid(pos + re.matchedLength()); + TQString names = l.left(pos); + TQString descr = l.mid(pos + re.matchedLength()); while ((pos = names.find(",")) != -1) { i[names.left(pos++)] = descr; @@ -156,20 +156,20 @@ void MANProtocol::parseWhatIs( QMap &i, QTextStream &t, const } } -bool MANProtocol::addWhatIs(QMap &i, const QString &name, const QString &mark) +bool MANProtocol::addWhatIs(TQMap &i, const TQString &name, const TQString &mark) { - QFile f(name); + TQFile f(name); if (!f.open(IO_ReadOnly)) return false; - QTextStream t(&f); + TQTextStream t(&f); parseWhatIs( i, t, mark ); return true; } -QMap MANProtocol::buildIndexMap(const QString §ion) +TQMap MANProtocol::buildIndexMap(const TQString §ion) { - QMap i; - QStringList man_dirs = manDirectories(); + TQMap i; + TQStringList man_dirs = manDirectories(); // Supplementary places for whatis databases man_dirs += m_mandbpath; if (man_dirs.find("/var/cache/man")==man_dirs.end()) @@ -177,16 +177,16 @@ QMap MANProtocol::buildIndexMap(const QString §ion) if (man_dirs.find("/var/catman")==man_dirs.end()) man_dirs << "/var/catman"; - QStringList names; + TQStringList names; names << "whatis.db" << "whatis"; - QString mark = "\\s+\\(" + section + "[a-z]*\\)\\s+-\\s+"; + TQString mark = "\\s+\\(" + section + "[a-z]*\\)\\s+-\\s+"; - for ( QStringList::ConstIterator it_dir = man_dirs.begin(); + for ( TQStringList::ConstIterator it_dir = man_dirs.begin(); it_dir != man_dirs.end(); ++it_dir ) { - if ( QFile::exists( *it_dir ) ) { - QStringList::ConstIterator it_name; + if ( TQFile::exists( *it_dir ) ) { + TQStringList::ConstIterator it_name; for ( it_name = names.begin(); it_name != names.end(); it_name++ ) @@ -197,11 +197,11 @@ QMap MANProtocol::buildIndexMap(const QString §ion) if ( it_name == names.end() ) { KProcess proc; proc << "whatis" << "-M" << (*it_dir) << "-w" << "*"; - myStdStream = QString::null; - connect( &proc, SIGNAL( receivedStdout(KProcess *, char *, int ) ), - SLOT( slotGetStdOutput( KProcess *, char *, int ) ) ); + myStdStream = TQString::null; + connect( &proc, TQT_SIGNAL( receivedStdout(KProcess *, char *, int ) ), + TQT_SLOT( slotGetStdOutput( KProcess *, char *, int ) ) ); proc.start( KProcess::Block, KProcess::Stdout ); - QTextStream t( &myStdStream, IO_ReadOnly ); + TQTextStream t( &myStdStream, IO_ReadOnly ); parseWhatIs( i, t, mark ); } } @@ -209,54 +209,54 @@ QMap MANProtocol::buildIndexMap(const QString §ion) return i; } -QStringList MANProtocol::manDirectories() +TQStringList MANProtocol::manDirectories() { checkManPaths(); // // Build a list of man directories including translations // - QStringList man_dirs; + TQStringList man_dirs; - for ( QStringList::ConstIterator it_dir = m_manpath.begin(); + for ( TQStringList::ConstIterator it_dir = m_manpath.begin(); it_dir != m_manpath.end(); it_dir++ ) { // Translated pages in "/" if the directory // exists - QStringList languages = KGlobal::locale()->languageList(); + TQStringList languages = KGlobal::locale()->languageList(); - for (QStringList::ConstIterator it_lang = languages.begin(); + for (TQStringList::ConstIterator it_lang = languages.begin(); it_lang != languages.end(); it_lang++ ) { - if ( !(*it_lang).isEmpty() && (*it_lang) != QString("C") ) { - QString dir = (*it_dir) + '/' + (*it_lang); + if ( !(*it_lang).isEmpty() && (*it_lang) != TQString("C") ) { + TQString dir = (*it_dir) + '/' + (*it_lang); struct stat sbuf; - if ( ::stat( QFile::encodeName( dir ), &sbuf ) == 0 + if ( ::stat( TQFile::encodeName( dir ), &sbuf ) == 0 && S_ISDIR( sbuf.st_mode ) ) { - const QString p = QDir(dir).canonicalPath(); + const TQString p = TQDir(dir).canonicalPath(); if (!man_dirs.contains(p)) man_dirs += p; } } } // Untranslated pages in "" - const QString p = QDir(*it_dir).canonicalPath(); + const TQString p = TQDir(*it_dir).canonicalPath(); if (!man_dirs.contains(p)) man_dirs += p; } return man_dirs; } -QStringList MANProtocol::findPages(const QString &_section, - const QString &title, +TQStringList MANProtocol::findPages(const TQString &_section, + const TQString &title, bool full_path) { - QString section = _section; + TQString section = _section; - QStringList list; + TQStringList list; // kdDebug() << "findPages '" << section << "' '" << title << "'\n"; if (title.at(0) == '/') { @@ -264,12 +264,12 @@ QStringList MANProtocol::findPages(const QString &_section, return list; } - const QString star( "*" ); + const TQString star( "*" ); // // Find man sections in this directory // - QStringList sect_list; + TQStringList sect_list; if ( section.isEmpty() ) section = star; @@ -287,41 +287,41 @@ QStringList MANProtocol::findPages(const QString &_section, sect_list += section; } - QStringList man_dirs = manDirectories(); + TQStringList man_dirs = manDirectories(); // // Find man pages in the sections listed above // - for ( QStringList::ConstIterator it_sect = sect_list.begin(); + for ( TQStringList::ConstIterator it_sect = sect_list.begin(); it_sect != sect_list.end(); it_sect++ ) { - QString it_real = (*it_sect).lower(); + TQString it_real = (*it_sect).lower(); // // Find pages // - for ( QStringList::ConstIterator it_dir = man_dirs.begin(); + for ( TQStringList::ConstIterator it_dir = man_dirs.begin(); it_dir != man_dirs.end(); it_dir++ ) { - QString man_dir = (*it_dir); + TQString man_dir = (*it_dir); // // Sections = all sub directories "man*" and "sman*" // - DIR *dp = ::opendir( QFile::encodeName( man_dir ) ); + DIR *dp = ::opendir( TQFile::encodeName( man_dir ) ); if ( !dp ) continue; struct dirent *ep; - const QString man = QString("man"); - const QString sman = QString("sman"); + const TQString man = TQString("man"); + const TQString sman = TQString("sman"); while ( (ep = ::readdir( dp )) != 0L ) { - const QString file = QFile::decodeName( ep->d_name ); - QString sect = QString::null; + const TQString file = TQFile::decodeName( ep->d_name ); + TQString sect = TQString::null; if ( file.startsWith( man ) ) sect = file.mid(3); @@ -340,8 +340,8 @@ QStringList MANProtocol::findPages(const QString &_section, ::closedir( dp ); if ( *it_sect != star ) { // in that case we only look around for sections - const QString dir = man_dir + QString("/man") + (it_real) + '/'; - const QString sdir = man_dir + QString("/sman") + (it_real) + '/'; + const TQString dir = man_dir + TQString("/man") + (it_real) + '/'; + const TQString sdir = man_dir + TQString("/sman") + (it_real) + '/'; findManPagesInSection(dir, title, full_path, list); findManPagesInSection(sdir, title, full_path, list); @@ -354,12 +354,12 @@ QStringList MANProtocol::findPages(const QString &_section, return list; } -void MANProtocol::findManPagesInSection(const QString &dir, const QString &title, bool full_path, QStringList &list) +void MANProtocol::findManPagesInSection(const TQString &dir, const TQString &title, bool full_path, TQStringList &list) { kdDebug() << "findManPagesInSection " << dir << " " << title << endl; bool title_given = !title.isEmpty(); - DIR *dp = ::opendir( QFile::encodeName( dir ) ); + DIR *dp = ::opendir( TQFile::encodeName( dir ) ); if ( !dp ) return; @@ -369,7 +369,7 @@ void MANProtocol::findManPagesInSection(const QString &dir, const QString &title while ( (ep = ::readdir( dp )) != 0L ) { if ( ep->d_name[0] != '.' ) { - QString name = QFile::decodeName( ep->d_name ); + TQString name = TQFile::decodeName( ep->d_name ); // check title if we're looking for a specific page if ( title_given ) { @@ -378,7 +378,7 @@ void MANProtocol::findManPagesInSection(const QString &dir, const QString &title } else { // beginning matches, do a more thorough check... - QString tmp_name = name; + TQString tmp_name = name; stripExtension( &tmp_name ); if ( tmp_name != title ) continue; @@ -404,7 +404,7 @@ void MANProtocol::output(const char *insert) { m_outputBuffer.close(); data(m_outputBuffer.buffer()); - m_outputBuffer.setBuffer(QByteArray()); + m_outputBuffer.setBuffer(TQByteArray()); m_outputBuffer.open(IO_WriteOnly); } } @@ -421,9 +421,9 @@ void output_real(const char *insert) MANProtocol::self()->output(insert); } -static QString text2html(const QString& txt) +static TQString text2html(const TQString& txt) { - QString reply = txt; + TQString reply = txt; reply = reply.replace('&', "&"); reply = reply.replace('<', "<"); @@ -437,7 +437,7 @@ void MANProtocol::get(const KURL& url ) { kdDebug(7107) << "GET " << url.url() << endl; - QString title, section; + TQString title, section; if (!parseUrl(url.path(), title, section)) { @@ -458,7 +458,7 @@ void MANProtocol::get(const KURL& url ) // tell the mimetype mimeType("text/html"); - const QStringList foundPages=findPages(section, title); + const TQStringList foundPages=findPages(section, title); bool pageFound=true; if (foundPages.isEmpty()) { @@ -488,7 +488,7 @@ void MANProtocol::get(const KURL& url ) { setResourcePath(m_htmlPath,m_cssPath); m_outputBuffer.open(IO_WriteOnly); - const QCString filename=QFile::encodeName(foundPages[0]); + const TQCString filename=TQFile::encodeName(foundPages[0]); char *buf = readManPage(filename); if (!buf) @@ -505,26 +505,26 @@ void MANProtocol::get(const KURL& url ) m_outputBuffer.close(); data(m_outputBuffer.buffer()); - m_outputBuffer.setBuffer(QByteArray()); + m_outputBuffer.setBuffer(TQByteArray()); // tell we are done - data(QByteArray()); + data(TQByteArray()); } finished(); } void MANProtocol::slotGetStdOutput(KProcess* /* p */, char *s, int len) { - myStdStream += QString::fromLocal8Bit(s, len); + myStdStream += TQString::fromLocal8Bit(s, len); } void MANProtocol::slotGetStdOutputUtf8(KProcess* /* p */, char *s, int len) { - myStdStream += QString::fromUtf8(s, len); + myStdStream += TQString::fromUtf8(s, len); } char *MANProtocol::readManPage(const char *_filename) { - QCString filename = _filename; + TQCString filename = _filename; char *buf = NULL; @@ -533,21 +533,21 @@ char *MANProtocol::readManPage(const char *_filename) * /usr/man/sman7fs/pcfs.7fs -> text/x-csrc : WRONG * If the path name constains the string sman, assume that it's SGML and * convert it to roff format (used on Solaris). */ - //QString file_mimetype = KMimeType::findByPath(QString(filename), 0, false)->name(); + //TQString file_mimetype = KMimeType::findByPath(TQString(filename), 0, false)->name(); if (filename.contains("sman", false)) //file_mimetype == "text/html" || ) { - myStdStream =QString::null; + myStdStream =TQString::null; KProcess proc; /* Determine path to sgml2roff, if not already done. */ getProgramPath(); proc << mySgml2RoffPath << filename; - QApplication::connect(&proc, SIGNAL(receivedStdout (KProcess *, char *, int)), - this, SLOT(slotGetStdOutput(KProcess *, char *, int))); + TQApplication::connect(&proc, TQT_SIGNAL(receivedStdout (KProcess *, char *, int)), + this, TQT_SLOT(slotGetStdOutput(KProcess *, char *, int))); proc.start(KProcess::Block, KProcess::All); - const QCString cstr=myStdStream.latin1(); + const TQCString cstr=myStdStream.latin1(); const int len = cstr.size()-1; buf = new char[len + 4]; qmemmove(buf + 1, cstr.data(), len); @@ -556,30 +556,30 @@ char *MANProtocol::readManPage(const char *_filename) } else { - if (QDir::isRelativePath(filename)) { + if (TQDir::isRelativePath(filename)) { kdDebug(7107) << "relative " << filename << endl; - filename = QDir::cleanDirPath(lastdir + "/" + filename).utf8(); + filename = TQDir::cleanDirPath(lastdir + "/" + filename).utf8(); if (!KStandardDirs::exists(filename)) { // exists perhaps with suffix lastdir = filename.left(filename.findRev('/')); - QDir mandir(lastdir); + TQDir mandir(lastdir); mandir.setNameFilter(filename.mid(filename.findRev('/') + 1) + ".*"); - filename = lastdir + "/" + QFile::encodeName(mandir.entryList().first()); + filename = lastdir + "/" + TQFile::encodeName(mandir.entryList().first()); } kdDebug(7107) << "resolved to " << filename << endl; } lastdir = filename.left(filename.findRev('/')); - myStdStream = QString::null; + myStdStream = TQString::null; KProcess proc; /* TODO: detect availability of 'man --recode' so that this can go * upstream */ proc << "man" << "--recode" << "UTF-8" << filename; - QApplication::connect(&proc, SIGNAL(receivedStdout (KProcess *, char *, int)), - this, SLOT(slotGetStdOutputUtf8(KProcess *, char *, int))); + TQApplication::connect(&proc, TQT_SIGNAL(receivedStdout (KProcess *, char *, int)), + this, TQT_SLOT(slotGetStdOutputUtf8(KProcess *, char *, int))); proc.start(KProcess::Block, KProcess::All); - const QCString cstr=myStdStream.utf8(); + const TQCString cstr=myStdStream.utf8(); const int len = cstr.size()-1; buf = new char[len + 4]; qmemmove(buf + 1, cstr.data(), len); @@ -590,11 +590,11 @@ char *MANProtocol::readManPage(const char *_filename) } -void MANProtocol::outputError(const QString& errmsg) +void MANProtocol::outputError(const TQString& errmsg) { - QByteArray array; - QTextStream os(array, IO_WriteOnly); - os.setEncoding(QTextStream::UnicodeUTF8); + TQByteArray array; + TQTextStream os(array, IO_WriteOnly); + os.setEncoding(TQTextStream::UnicodeUTF8); os << "" << endl; os << "" << endl; @@ -608,11 +608,11 @@ void MANProtocol::outputError(const QString& errmsg) data(array); } -void MANProtocol::outputMatchingPages(const QStringList &matchingPages) +void MANProtocol::outputMatchingPages(const TQStringList &matchingPages) { - QByteArray array; - QTextStream os(array, IO_WriteOnly); - os.setEncoding(QTextStream::UnicodeUTF8); + TQByteArray array; + TQTextStream os(array, IO_WriteOnly); + os.setEncoding(TQTextStream::UnicodeUTF8); os << "" << endl; os << "\n"<\n