From bf7f88413be3831a9372d323d02fc0335b9f9188 Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 26 May 2011 21:04:57 +0000 Subject: TQt4 port Gwenview This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/gwenview@1233720 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/gvcore/externaltoolmanager.cpp | 96 +++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'src/gvcore/externaltoolmanager.cpp') diff --git a/src/gvcore/externaltoolmanager.cpp b/src/gvcore/externaltoolmanager.cpp index 9e6fc9e..3471bc0 100644 --- a/src/gvcore/externaltoolmanager.cpp +++ b/src/gvcore/externaltoolmanager.cpp @@ -21,8 +21,8 @@ Copyright 2000-2004 Aur // STL #include -// Qt -#include +// TQt +#include // KDE #include @@ -47,7 +47,7 @@ namespace Gwenview { #endif // Helper functions for createContextInternal -inline bool mimeTypeMatches(const QString& candidate, const QString& reference) { +inline bool mimeTypeMatches(const TQString& candidate, const TQString& reference) { if (reference=="*") return true; if (reference.right(1)=="*") { @@ -57,15 +57,15 @@ inline bool mimeTypeMatches(const QString& candidate, const QString& reference) } } -inline bool isSubSetOf(const QStringList& subSet, const QStringList& set) { +inline bool isSubSetOf(const TQStringList& subSet, const TQStringList& set) { // Simple implementation, might need some optimization - QStringList::ConstIterator itSubSet=subSet.begin(); - QStringList::ConstIterator itSetBegin=set.begin(); - QStringList::ConstIterator itSetEnd=set.end(); + TQStringList::ConstIterator itSubSet=subSet.begin(); + TQStringList::ConstIterator itSetBegin=set.begin(); + TQStringList::ConstIterator itSetEnd=set.end(); for (; itSubSet!=subSet.end(); ++itSubSet) { bool matchFound=false; - QStringList::ConstIterator itSet=itSetBegin; + TQStringList::ConstIterator itSet=itSetBegin; for (; itSet!=itSetEnd; ++itSet) { if (mimeTypeMatches(*itSubSet, *itSet)) { matchFound=true; @@ -81,9 +81,9 @@ inline bool isSubSetOf(const QStringList& subSet, const QStringList& set) { struct ExternalToolManagerPrivate { - QDict mDesktopFiles; - QPtrList mServices; - QString mUserToolDir; + TQDict mDesktopFiles; + TQPtrList mServices; + TQString mUserToolDir; /** * Helper function for createContextInternal @@ -95,49 +95,49 @@ struct ExternalToolManagerPrivate { } ExternalToolContext* createContextInternal( - QObject* parent, const KURL::List& urls, const QStringList& mimeTypes) + TQObject* tqparent, const KURL::List& urls, const TQStringList& mimeTypes) { bool onlyOneURL=urls.size()==1; // Only add to selectionServices the services which can handle all the // different mime types present in the selection // - // We use std::list instead of QValueList because it's not possible to + // We use std::list instead of TQValueList because it's not possible to // pass a sort functor to qHeapSort std::list selectionServices; - QPtrListIterator it(mServices); + TQPtrListIterator it(mServices); for (; it.current(); ++it) { KService* service=it.current(); if (!onlyOneURL && !service->allowMultipleFiles()) { continue; } - QStringList serviceTypes=service->serviceTypes(); + TQStringList serviceTypes=service->serviceTypes(); if (isSubSetOf(mimeTypes, serviceTypes)) { selectionServices.push_back(service); } } selectionServices.sort(compareKServicePtrByName); - return new ExternalToolContext(parent, selectionServices, urls); + return new ExternalToolContext(tqparent, selectionServices, urls); } }; // Helper function for ctor -void loadDesktopFiles(QDict& dict, const QString& dirString) { - QDir dir(dirString); - QStringList list=dir.entryList("*.desktop"); - QStringList::ConstIterator it=list.begin(); +void loadDesktopFiles(TQDict& dict, const TQString& dirString) { + TQDir dir(dirString); + TQStringList list=dir.entryList("*.desktop"); + TQStringList::ConstIterator it=list.begin(); for (; it!=list.end(); ++it) { KDesktopFile* df=new KDesktopFile( dir.filePath(*it) ); dict.insert(*it, df); } } -inline QString addSlash(const QString& _str) { - QString str(_str); +inline TQString addSlash(const TQString& _str) { + TQString str(_str); if (str.right(1)!="/") str.append('/'); return str; } @@ -151,12 +151,12 @@ ExternalToolManager::ExternalToolManager() { Q_ASSERT(!d->mUserToolDir.isEmpty()); LOG("d->mUserToolDir:" << d->mUserToolDir); - QStringList dirs=KGlobal::dirs()->findDirs("appdata", "tools"); + TQStringList dirs=KGlobal::dirs()->findDirs("appdata", "tools"); LOG("dirs:" << dirs.join(",")); // Loading desktop files - QDict systemDesktopFiles; - QStringList::ConstIterator it; + TQDict systemDesktopFiles; + TQStringList::ConstIterator it; for (it=dirs.begin(); it!=dirs.end(); ++it) { if (addSlash(*it)==d->mUserToolDir) { LOG("skipping " << *it); @@ -165,18 +165,18 @@ ExternalToolManager::ExternalToolManager() { LOG("loading system desktop files from " << *it); loadDesktopFiles(systemDesktopFiles, *it); } - QDict userDesktopFiles; + TQDict userDesktopFiles; loadDesktopFiles(userDesktopFiles, d->mUserToolDir); // Merge system and user desktop files into our KDesktopFile dictionary d->mDesktopFiles=systemDesktopFiles; d->mDesktopFiles.setAutoDelete(true); - QDictIterator itDict(userDesktopFiles); + TQDictIterator itDict(userDesktopFiles); for (; itDict.current(); ++itDict) { - QString name=itDict.currentKey(); + TQString name=itDict.currentKey(); KDesktopFile* df=itDict.current(); - if (d->mDesktopFiles.find(name)) { + if (d->mDesktopFiles.tqfind(name)) { d->mDesktopFiles.remove(name); } if (df->readBoolEntry("Hidden")) { @@ -204,7 +204,7 @@ ExternalToolManager* ExternalToolManager::instance() { void ExternalToolManager::updateServices() { d->mServices.clear(); - QDictIterator it(d->mDesktopFiles); + TQDictIterator it(d->mDesktopFiles); for (; it.current(); ++it) { KDesktopFile* desktopFile=it.current(); // If sync() is not called, KService does not read up to date content @@ -215,14 +215,14 @@ void ExternalToolManager::updateServices() { } -QDict& ExternalToolManager::desktopFiles() const { +TQDict& ExternalToolManager::desktopFiles() const { return d->mDesktopFiles; } void ExternalToolManager::hideDesktopFile(KDesktopFile* desktopFile) { - QFileInfo fi(desktopFile->fileName()); - QString name=QString("%1.desktop").arg( fi.baseName(true) ); + TQFileInfo fi(desktopFile->fileName()); + TQString name=TQString("%1.desktop").tqarg( fi.baseName(true) ); d->mDesktopFiles.take(name); if (desktopFile->isReadOnly()) { @@ -237,57 +237,57 @@ void ExternalToolManager::hideDesktopFile(KDesktopFile* desktopFile) { KDesktopFile* ExternalToolManager::editSystemDesktopFile(const KDesktopFile* desktopFile) { Q_ASSERT(desktopFile); - QFileInfo fi(desktopFile->fileName()); + TQFileInfo fi(desktopFile->fileName()); - QString name=fi.baseName(true); - d->mDesktopFiles.remove(QString("%1.desktop").arg(name)); + TQString name=fi.baseName(true); + d->mDesktopFiles.remove(TQString("%1.desktop").tqarg(name)); return createUserDesktopFile(name); } -KDesktopFile* ExternalToolManager::createUserDesktopFile(const QString& name) { +KDesktopFile* ExternalToolManager::createUserDesktopFile(const TQString& name) { Q_ASSERT(!name.isEmpty()); KDesktopFile* desktopFile=new KDesktopFile( d->mUserToolDir + "/" + name + ".desktop", false); - d->mDesktopFiles.insert(QString("%1.desktop").arg(name), desktopFile); + d->mDesktopFiles.insert(TQString("%1.desktop").tqarg(name), desktopFile); return desktopFile; } ExternalToolContext* ExternalToolManager::createContext( - QObject* parent, const KFileItemList* items) + TQObject* tqparent, const KFileItemList* items) { KURL::List urls; - QStringList mimeTypes; + TQStringList mimeTypes; // Create our URL list and a list of the different mime types present in // the selection - QPtrListIterator it(*items); + TQPtrListIterator it(*items); for (; it.current(); ++it) { urls.append(it.current()->url()); - QString mimeType=it.current()->mimetype(); - if (!mimeTypes.contains(mimeType)) { + TQString mimeType=it.current()->mimetype(); + if (!mimeTypes.tqcontains(mimeType)) { mimeTypes.append(mimeType); } } - return d->createContextInternal(parent, urls, mimeTypes); + return d->createContextInternal(tqparent, urls, mimeTypes); } ExternalToolContext* ExternalToolManager::createContext( - QObject* parent, const KURL& url) + TQObject* tqparent, const KURL& url) { KURL::List urls; - QStringList mimeTypes; + TQStringList mimeTypes; urls.append(url); - QString mimeType=KMimeType::findByURL(url, 0, url.isLocalFile(), true)->name(); + TQString mimeType=KMimeType::findByURL(url, 0, url.isLocalFile(), true)->name(); mimeTypes.append(mimeType); - return d->createContextInternal(parent, urls, mimeTypes); + return d->createContextInternal(tqparent, urls, mimeTypes); } -- cgit v1.2.1