diff options
Diffstat (limited to 'src/kio_locate.cpp')
-rw-r--r-- | src/kio_locate.cpp | 204 |
1 files changed, 102 insertions, 102 deletions
diff --git a/src/kio_locate.cpp b/src/kio_locate.cpp index 9beee51..0e930ea 100644 --- a/src/kio_locate.cpp +++ b/src/kio_locate.cpp @@ -36,7 +36,7 @@ #include <klocale.h> #include <kurl.h> #include <kuser.h> -#include <qfile.h> +#include <tqfile.h> #include "kio_locate.h" #include "klocateconfig.h" @@ -47,12 +47,12 @@ using namespace KIO; -static const QString queryQuery = "q"; -static const QString queryDirectory = "directory"; -static const QString queryCase = "case"; -static const QString queryRegExp = "regexp"; +static const TQString queryQuery = "q"; +static const TQString queryDirectory = "directory"; +static const TQString queryCase = "case"; +static const TQString queryRegExp = "regexp"; -static const QString iconToStringTable[] = { +static const TQString iconToStringTable[] = { "folder", "folder_green", "folder_grey", "folder_orange", "folder_red", "folder_violet", "folder_yellow" }; @@ -67,7 +67,7 @@ static const QString iconToStringTable[] = { * For older versions of Konqueror: + behaves identical to * * @param s the string to inspect */ -static bool hasWildcards(const QString& s) +static bool hasWildcards(const TQString& s) { for (unsigned int i = 0; i < s.length(); ++i) { if ((s[i] == '*' || s[i] == '+' || s[i] == '?' || s[i] == '[' || s[i] == ']') && (i < 1 || s[i-1] != '\\')) @@ -84,7 +84,7 @@ static bool hasWildcards(const QString& s) * @param s the string to convert * @return the converted string */ -static QString convertWildcardsToRegExp(QString s) +static TQString convertWildcardsToRegExp(TQString s) { bool in_set = false; @@ -92,7 +92,7 @@ static QString convertWildcardsToRegExp(QString s) // (Konqueror makes passing chars like "/" almost impossible anyway.) // Note that this converts actual wildcards to escaped wildcards (\wildcard), // and escaped wildcards to 'triple'-escaped wildcards (\\\wildcard). - s = QRegExp::escape(s); + s = TQRegExp::escape(s); // Walk through the string, converting \wildcard to regexp and // \\\wildcard back to \wildcard. @@ -144,7 +144,7 @@ static QString convertWildcardsToRegExp(QString s) * Determines if path includes a trailing slash. * @param path the path to inspect */ -static bool hasTrailingSlash(const QString& path) +static bool hasTrailingSlash(const TQString& path) { int n = path.length(); return ((n > 0) && (path[n-1] == '/')); @@ -155,7 +155,7 @@ static bool hasTrailingSlash(const QString& path) * Strips a trailing slash / from a path. * @param path the path to strip the slash off */ -static QString stripTrailingSlash(const QString& path) +static TQString stripTrailingSlash(const TQString& path) { int n = path.length(); if ((n > 0) && (path[n-1] == '/')) { @@ -169,7 +169,7 @@ static QString stripTrailingSlash(const QString& path) * Add a trailing slash / to a path if there is none yet. * @param path the path to append the slash to */ -static QString addTrailingSlash(const QString& path) +static TQString addTrailingSlash(const TQString& path) { int n = path.length(); if ((n > 0) && (path[n-1] == '/')) { @@ -179,7 +179,7 @@ static QString addTrailingSlash(const QString& path) } -static void addAtom(UDSEntry& entry, unsigned int uds, const QString& s) +static void addAtom(UDSEntry& entry, unsigned int uds, const TQString& s) { UDSAtom a; a.m_uds = uds; @@ -197,8 +197,8 @@ static void addAtom(UDSEntry& entry, unsigned int uds, long l) } -static const UDSEntry pathToUDSEntry(const QString& path, const QString& display, - const QString& url = QString::null, const QString& icon = QString::null) +static const UDSEntry pathToUDSEntry(const TQString& path, const TQString& display, + const TQString& url = TQString(), const TQString& icon = TQString()) { UDSEntry entry; addAtom(entry, KIO::UDS_NAME, display); @@ -224,7 +224,7 @@ static const UDSEntry pathToUDSEntry(const QString& path, const QString& display mode_t type = info.st_mode; if (S_ISLNK(type)) { - QString slink = QString::null; + TQString slink = TQString(); char buff[1000]; int n = readlink(path, buff, 1000); if (n != -1) { @@ -238,7 +238,7 @@ static const UDSEntry pathToUDSEntry(const QString& path, const QString& display addAtom(entry, KIO::UDS_FILE_TYPE, type); #ifdef HAVE_UDS_HIDDEN - if (path.contains("/.")) { + if (path.tqcontains("/.")) { addAtom(entry, KIO::UDS_HIDDEN, 1); } #endif @@ -262,15 +262,15 @@ static const UDSEntry pathToUDSEntry(const QString& path, const QString& display ///////////////////////////////////////////////////////////////////// // INITIALIZATION -LocateProtocol::LocateProtocol(const QCString &pool_socket, const QCString &app_socket) +LocateProtocol::LocateProtocol(const TQCString &pool_socket, const TQCString &app_socket) : SlaveBase("kio_locate", pool_socket, app_socket) { DEBUGSTR << "LocateProtocol::LocateProtocol()" << endl; - connect(&m_locater, SIGNAL(found(const QStringList&)), - this, SLOT(processLocateOutput(const QStringList&))); - connect(&m_locater, SIGNAL(finished()), - this, SLOT(locateFinished())); + connect(&m_locater, TQT_SIGNAL(found(const TQStringList&)), + this, TQT_SLOT(processLocateOutput(const TQStringList&))); + connect(&m_locater, TQT_SIGNAL(finished()), + this, TQT_SLOT(locateFinished())); m_baseDir = NULL; m_curDir = NULL; @@ -303,7 +303,7 @@ int LocateProtocol::getCollapseDirectoryThreshold() const void LocateProtocol::setUrl(const KURL& url) { if (url.protocol() != "locater") { - QString pattern = KURL::decode_string(url.url()); + TQString pattern = KURL::decode_string(url.url()); pattern = pattern.mid(url.protocol().length() + 1); KURL newUrl; @@ -345,9 +345,9 @@ void LocateProtocol::get(const KURL& url) if (isSearchRequest()) { if (m_locater.binaryExists()) { - error(KIO::ERR_IS_DIRECTORY, QString::null); + error(KIO::ERR_IS_DIRECTORY, TQString()); } else { - QString html = i18n("<h1>\"%1\" could not be started.</h1><p>Please note that kio-locate can't be used on its own. You need an additional program for doing searches. Typically this is the command line tool <i>locate</i> that can be found in many distributions by default. You can check if the correct tool is used by looking at the <a href=\"locater:config\">setting</a> \"Locate Binary\".<p>Besides the mentioned tool <i>locate</i>, kio-locate can use any tool that uses the same syntax. In particular, it was reported to work with <i>slocate</i> and <i>rlocate</i>.").arg(m_locater.binary()); + TQString html = i18n("<h1>\"%1\" could not be started.</h1><p>Please note that kio-locate can't be used on its own. You need an additional program for doing searches. Typically this is the command line tool <i>locate</i> that can be found in many distributions by default. You can check if the correct tool is used by looking at the <a href=\"locater:config\">setting</a> \"Locate Binary\".<p>Besides the mentioned tool <i>locate</i>, kio-locate can use any tool that uses the same syntax. In particular, it was reported to work with <i>slocate</i> and <i>rlocate</i>.").tqarg(m_locater.binary()); outputHtml(html); } } else if (isConfigRequest()) { @@ -356,7 +356,7 @@ void LocateProtocol::get(const KURL& url) helpRequest(); } else { // What's this? - error(KIO::ERR_DOES_NOT_EXIST, QString::null); + error(KIO::ERR_DOES_NOT_EXIST, TQString()); } } @@ -380,7 +380,7 @@ void LocateProtocol::stat(const KURL& url) /// by konqueror anyway. How to change this? } else { // What's this? - error(KIO::ERR_DOES_NOT_EXIST, QString::null); + error(KIO::ERR_DOES_NOT_EXIST, TQString()); } } @@ -394,10 +394,10 @@ void LocateProtocol::listDir(const KURL& url) if (isSearchRequest()) { searchRequest(); } else if (isConfigRequest() || isHelpRequest()) { - error(KIO::ERR_IS_FILE, QString::null); + error(KIO::ERR_IS_FILE, TQString()); } else { // What's this? - error(KIO::ERR_DOES_NOT_EXIST, QString::null); + error(KIO::ERR_DOES_NOT_EXIST, TQString()); } } @@ -421,11 +421,11 @@ void LocateProtocol::mimetype(const KURL& url) } -void LocateProtocol::outputHtml(const QString& body) +void LocateProtocol::outputHtml(const TQString& body) { mimeType("text/html"); - QString theData = "<html><body>" + body + "</body></html>"; + TQString theData = "<html><body>" + body + "</body></html>"; data(theData.local8Bit()); finished(); } @@ -445,10 +445,10 @@ void LocateProtocol::searchRequest() // Reset old values. m_caseSensitivity = caseAuto; m_useRegExp = false; - m_locatePattern = QString::null; - m_locateDirectory = QString::null; + m_locatePattern = TQString(); + m_locateDirectory = TQString(); m_regExps.clear(); - m_pendingPath = QString::null; + m_pendingPath = TQString(); delete m_baseDir; m_baseDir = NULL; @@ -456,17 +456,17 @@ void LocateProtocol::searchRequest() updateConfig(); - QString query = m_url.queryItem(queryQuery); + TQString query = m_url.queryItem(queryQuery); m_locateDirectory = addTrailingSlash(m_url.queryItem(queryDirectory)); - QString caseSensitivity = m_url.queryItem(queryCase); + TQString caseSensitivity = m_url.queryItem(queryCase); if (caseSensitivity == "sensitive") { m_caseSensitivity = caseSensitive; } else if (caseSensitivity == "insensitive") { m_caseSensitivity = caseInsensitive; } - QString useRegExp = m_url.queryItem(queryRegExp); + TQString useRegExp = m_url.queryItem(queryRegExp); if (!useRegExp.isEmpty() && useRegExp != "0") { m_useRegExp = true; } @@ -480,12 +480,12 @@ void LocateProtocol::searchRequest() int s = 0; int n = query.length(); bool regexp; - QString display; + TQString display; for (int i = 0; i <= n; i++) { if ((i == n) || ((query[i] == ' ') && (i > 0) && (query[i-1] != '\\') && (i-s > 0))) { - QString temp = query.mid(s, i-s); - QString part = partToPattern(temp, s==0); + TQString temp = query.mid(s, i-s); + TQString part = partToPattern(temp, s==0); if (s == 0) { // We don't want to show the escaped regexpified string to // the user, so we store the string we get in for later display. @@ -512,7 +512,7 @@ void LocateProtocol::searchRequest() m_locateRegExp = LocateRegExp(convertWildcardsToRegExp(m_locatePattern), !isCaseSensitive(m_locatePattern)); // Now perform the search... - infoMessage(i18n("Locating %1 ...").arg(display)); + infoMessage(i18n("Locating %1 ...").tqarg(display)); bool started = m_locater.locate(m_locatePattern, !isCaseSensitive(m_locatePattern), regexp); @@ -523,7 +523,7 @@ void LocateProtocol::searchRequest() } -bool LocateProtocol::isCaseSensitive(const QString& text) +bool LocateProtocol::isCaseSensitive(const TQString& text) { if (m_caseSensitivity == caseSensitive) { return true; @@ -539,10 +539,10 @@ bool LocateProtocol::isCaseSensitive(const QString& text) } -void LocateProtocol::addHit(const QString& path, int subItems) +void LocateProtocol::addHit(const TQString& path, int subItems) { // DEBUGSTR << "LocateProtocol::addHit( " << path << ", " << subItems << " )" << endl; - if (QFile::exists(path)) { + if (TQFile::exists(path)) { if (subItems > 0) { m_entries += pathToUDSEntry(path, pathToDisplay(path, subItems), makeLocaterUrl(path), iconToStringTable[m_config.m_collapsedIcon]); } else { @@ -574,7 +574,7 @@ void LocateProtocol::addPreviousLocateOutput() } -void LocateProtocol::processPath(const QString &path, const QString &nextPath) +void LocateProtocol::processPath(const TQString &path, const TQString &nextPath) { if (!nextPath) { // We need to know the next path, so we remember this path for later processing. @@ -586,8 +586,8 @@ void LocateProtocol::processPath(const QString &path, const QString &nextPath) } // Add path to current directory. if (m_baseDir == NULL) { - int p = path.find('/', 1); - QString base = path; + int p = path.tqfind('/', 1); + TQString base = path; if (p >= 0) { base = path.left(p+1); } @@ -600,7 +600,7 @@ void LocateProtocol::processPath(const QString &path, const QString &nextPath) } -void LocateProtocol::processLocateOutput(const QStringList& items) +void LocateProtocol::processLocateOutput(const TQStringList& items) { // I don't know if this really necessary, but if we were signaled, we'll // better stop. @@ -609,15 +609,15 @@ void LocateProtocol::processLocateOutput(const QStringList& items) return; } // Go through what we have found. - QStringList::ConstIterator it = items.begin(); + TQStringList::ConstIterator it = items.begin(); if (m_pendingPath) { processPath(m_pendingPath, *it); - m_pendingPath = QString::null; + m_pendingPath = TQString(); } for (; it != items.end();) { - QString path = *it; + TQString path = *it; ++it; - processPath(path, it != items.end() ? *it : QString::null); + processPath(path, it != items.end() ? *it : TQString()); } } @@ -627,7 +627,7 @@ void LocateProtocol::locateFinished() // Add any pending items. if (m_pendingPath) { processPath(m_pendingPath, ""); - m_pendingPath = QString::null; + m_pendingPath = TQString(); } addPreviousLocateOutput(); @@ -637,12 +637,12 @@ void LocateProtocol::locateFinished() } -QString LocateProtocol::partToPattern(const QString& part, bool forLocate) +TQString LocateProtocol::partToPattern(const TQString& part, bool forLocate) { DEBUGSTR << "BEG part: " << part << endl; - QString pattern = part; + TQString pattern = part; // Unescape whitespace. - pattern.replace("\\ ", " "); + pattern.tqreplace("\\ ", " "); // Unquote quoted pattern. int n = pattern.length(), index; if ((n > 1) && (pattern[0] == '"') && (pattern[n-1] == '"')) { @@ -651,7 +651,7 @@ QString LocateProtocol::partToPattern(const QString& part, bool forLocate) // We can't do regular expression matching on the locate pattern, // the regular expression format used by locate is incompatible - // with the format used by QRegExp. + // with the format used by TQRegExp. if (!m_useRegExp || forLocate) { // Escape regexp characters for filtering pattern, and for locate, // but the latter only if it is actually necessary to pass a regexp to locate. @@ -661,11 +661,11 @@ QString LocateProtocol::partToPattern(const QString& part, bool forLocate) } else { // Special case for locate pattern without wildcards: // Unescape all escaped wildcards. - pattern.replace("\\*", "*"); - pattern.replace("\\+", "+"); - pattern.replace("\\?", "?"); - pattern.replace("\\[", "["); - pattern.replace("\\]", "]"); + pattern.tqreplace("\\*", "*"); + pattern.tqreplace("\\+", "+"); + pattern.tqreplace("\\?", "?"); + pattern.tqreplace("\\[", "["); + pattern.tqreplace("\\]", "]"); } } @@ -673,28 +673,28 @@ QString LocateProtocol::partToPattern(const QString& part, bool forLocate) if (forLocate) { // Replace ~/ and ~user/ at the beginning (as the shell does) if ((pattern.length() > 0) && (pattern[0] == '~')) { - index = pattern.find('/'); + index = pattern.tqfind('/'); if (index >= 0) { - QString name = pattern.mid(1, index-1); - QString homeDir; + TQString name = pattern.mid(1, index-1); + TQString homeDir; if (name.isEmpty()) { homeDir = KUser(KUser::UseRealUserID).homeDir(); } else { homeDir = KUser(name).homeDir(); } if (!homeDir.isEmpty()) { - pattern.replace(0, index, homeDir); + pattern.tqreplace(0, index, homeDir); } } } - pattern.replace("\\~", "~"); + pattern.tqreplace("\\~", "~"); } DEBUGSTR << "END part: " << pattern << endl; return pattern; } -bool LocateProtocol::isMatching(const QString& path) +bool LocateProtocol::isMatching(const TQString& path) { // The file has to belong to our directory. if (!path.startsWith(m_locateDirectory)) { @@ -717,28 +717,28 @@ bool LocateProtocol::isMatching(const QString& path) } -QString LocateProtocol::pathToDisplay(const QString& path, int subItems) +TQString LocateProtocol::pathToDisplay(const TQString& path, int subItems) { // Split off the directory part. If it is not just the minimal '/'. - QString display = path; + TQString display = path; if ((m_locateDirectory != "/") && display.startsWith(m_locateDirectory)) { display = display.mid(m_locateDirectory.length()); } if (subItems > 0) { - // Can't use m_collapsedDisplay.arg(subItems).arg(display); here + // Can't use m_collapsedDisplay.tqarg(subItems).tqarg(display); here // because user might forget to type %1 or %2, or type it twice. // In both cases the result of arg() is undefined. - QString output = m_config.m_collapsedDisplay, temp; + TQString output = m_config.m_collapsedDisplay, temp; temp.setNum(subItems); - output.replace("%1", temp); - output.replace("%2", display); + output.tqreplace("%1", temp); + output.tqreplace("%2", display); display = output; } return display; } -QString LocateProtocol::makeLocaterUrl(const QString& directory) +TQString LocateProtocol::makeLocaterUrl(const TQString& directory) { KURL url(m_url); url.removeQueryItem(queryDirectory); @@ -771,18 +771,18 @@ void LocateProtocol::configRequest() KDialogBase::Default|KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Help, KDialogBase::Ok, true); dialog->setCaption(i18n("Configure - kio-locate")); - dialog->setIcon(SmallIcon("find")); + dialog->setIcon(SmallIcon("tqfind")); dialog->addPage(new KLocateConfigWidget(), i18n("General"), "package_settings"); dialog->addPage(new KLocateConfigFilterWidget(), i18n("Filters"), "filter"); - dialog->addPage(new KLocateConfigLocateWidget(), i18n("Locate"), "find"); + dialog->addPage(new KLocateConfigLocateWidget(), i18n("Locate"), "tqfind"); // React on user's actions. - connect(dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfig())); - connect(dialog, SIGNAL(finished()), this, SLOT(configFinished())); + connect(dialog, TQT_SIGNAL(settingsChanged()), this, TQT_SLOT(updateConfig())); + connect(dialog, TQT_SIGNAL(finished()), this, TQT_SLOT(configFinished())); dialog->show(); - qApp->enter_loop(); + tqApp->enter_loop(); delete dialog; } @@ -791,9 +791,9 @@ void LocateProtocol::configFinished() { DEBUGSTR << "LocateProtocol::configFinished" << endl; - qApp->exit_loop(); + tqApp->exit_loop(); - QString html; + TQString html; if (m_configUpdated) { html = i18n("Configuration succesfully updated."); } else { @@ -843,20 +843,20 @@ void LocateProtocol::helpRequest() ///////////////////////////////////////////////////////////////////// // SEARCH STRUCTURES -LocateDirectory::LocateDirectory(LocateDirectory *parent, const QString& path) +LocateDirectory::LocateDirectory(LocateDirectory *tqparent, const TQString& path) { - m_parent = parent; + m_parent = tqparent; m_path = path; m_childs.setAutoDelete(true); m_itemsCount = 0; } -LocateDirectory *LocateDirectory::addPath(const QString& path) +LocateDirectory *LocateDirectory::addPath(const TQString& path) { if (path.startsWith(m_path)) { - QString relPath = path.mid(m_path.length()); - int p = relPath.findRev('/'); + TQString relPath = path.mid(m_path.length()); + int p = relPath.tqfindRev('/'); if (p >= 0) { LocateDirectory *child = getSubDirectory(relPath.left(p)); child->addItem(relPath.mid(p+1)); @@ -873,14 +873,14 @@ LocateDirectory *LocateDirectory::addPath(const QString& path) } -LocateDirectory *LocateDirectory::getSubDirectory(const QString& relPath) +LocateDirectory *LocateDirectory::getSubDirectory(const TQString& relPath) { - QString base = relPath; - int p = relPath.find('/'); + TQString base = relPath; + int p = relPath.tqfind('/'); if (p >= 0) { base = relPath.left(p); } - LocateDirectory *child = m_childs.find(base); + LocateDirectory *child = m_childs.tqfind(base); if (child == NULL) { child = new LocateDirectory(this, addTrailingSlash(m_path + base)); m_childs.insert(base, child); @@ -892,7 +892,7 @@ LocateDirectory *LocateDirectory::getSubDirectory(const QString& relPath) } -void LocateDirectory::addItem(const QString& path) +void LocateDirectory::addItem(const TQString& path) { m_items += LocateItem(m_path + path, 0); m_itemsCount++; @@ -929,20 +929,20 @@ void LocateDirectory::prepareListing(const LocateProtocol* protocol, int skip) m_fullCount = countMatchingItems(protocol, newSkip); // Collapse if directory part matches. - LocateDirectory* parent = m_parent; - if (parent == NULL) { - parent = this; + LocateDirectory* tqparent = m_parent; + if (tqparent == NULL) { + tqparent = this; } if (n > skip && protocol->getRegExp().isMatching(m_path.mid(skip))) { // Directory part matches. m_childs.clear(); m_items.clear(); m_itemsCount = 0; - parent->m_items += LocateItem(m_path, m_fullCount); - ++parent->m_itemsCount; + tqparent->m_items += LocateItem(m_path, m_fullCount); + ++tqparent->m_itemsCount; if (m_fullCount != 0) { - parent->m_items += LocateItem(m_path, 0); - ++parent->m_itemsCount; + tqparent->m_items += LocateItem(m_path, 0); + ++tqparent->m_itemsCount; } } @@ -958,7 +958,7 @@ void LocateDirectory::prepareListing(const LocateProtocol* protocol, int skip) ++m_itemsCount; } } else { - // Propagate items to parent. + // Propagate items to tqparent. // (only root LocateDirectory runs listItems) if (m_parent != NULL) { m_parent->m_items += m_items; @@ -979,7 +979,7 @@ void LocateDirectory::listItems(LocateProtocol *protocol) void LocateDirectory::debugTrace(int level) { - QString ws; + TQString ws; ws.fill(' ', level); DEBUGSTR << ws << m_path << endl; LocateItems::ConstIterator item = m_items.begin(); @@ -998,7 +998,7 @@ LocateItem::LocateItem() } -LocateItem::LocateItem(const QString& path, int subItems) +LocateItem::LocateItem(const TQString& path, int subItems) { m_path = path; m_subItems = subItems; |