diff options
Diffstat (limited to 'src/appimpl.cpp')
-rw-r--r-- | src/appimpl.cpp | 119 |
1 files changed, 37 insertions, 82 deletions
diff --git a/src/appimpl.cpp b/src/appimpl.cpp index 8676bcf..0f5639e 100644 --- a/src/appimpl.cpp +++ b/src/appimpl.cpp @@ -42,10 +42,13 @@ bool AppImpl::listRoot(TQValueList<TDEIO::UDSEntry> &list) { kdDebug() << "AppImpl::listRoot" << endl; - TQStringList dirList = TQStringList::split(":", getenv("PATH")); + //TQStringList dirList = TQStringList::split(":", getenv("PATH")); + TQStringList dirList; + dirList << "/opt/trinity/bin/"; + dirList << "/usr/bin/"; + dirList << "/usr/local/bin/"; kdDebug() << dirList << endl; - TQStringList names_found; for (const TQString &dirName : dirList) { TQDir dir(dirName); @@ -56,18 +59,10 @@ bool AppImpl::listRoot(TQValueList<TDEIO::UDSEntry> &list) TQStringList filenames = dir.entryList(TQDir::Files | TQDir::Readable); TDEIO::UDSEntry entry; - for(const TQString &filename : filenames) + for (const TQString &filename : filenames) { - if (!names_found.contains(filename)) - { - entry.clear(); - createEntry(entry, filename); - if (!entry.isEmpty()) - { - list.append(entry); - names_found.append(filename); - } - } + createEntry(entry, filename); + list.append(entry); } } @@ -76,9 +71,7 @@ bool AppImpl::listRoot(TQValueList<TDEIO::UDSEntry> &list) bool AppImpl::parseURL(const KURL &url, TQString &name, TQString &path) const { - kdDebug() << "AppImpl::parseURL" << endl; TQString url_path = url.path(); - int i = url_path.find('/', 1); if (i > 0) { @@ -106,7 +99,7 @@ bool AppImpl::realURL(const TQString &name, const TQString &path, KURL &url) con return true; } -bool AppImpl::statByName(const TQString &filename, TDEIO::UDSEntry& entry) +bool AppImpl::statByName(const TQString &filename, TDEIO::UDSEntry &entry) { kdDebug() << "AppImpl::statByName" << endl; @@ -125,7 +118,6 @@ bool AppImpl::statByName(const TQString &filename, TDEIO::UDSEntry& entry) } TQStringList filenames = dir.entryList(TQDir::Files | TQDir::Readable); - TDEIO::UDSEntry entry; for (const TQString &fname : filenames) { if (fname == filename) @@ -199,14 +191,12 @@ void AppImpl::createEntry(TDEIO::UDSEntry &entry, const TQString &file) entry.clear(); addAtom(entry, TDEIO::UDS_NAME, 0, file); - - TQString new_filename = file; - new_filename.truncate(file.length() - 8); - addAtom(entry, TDEIO::UDS_URL, 0, "app:/" + new_filename); + addAtom(entry, TDEIO::UDS_URL, 0, "appinfo:/" + file); addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_ACCESS, 0555); addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - KService::Ptr service = KService::serviceByDesktopName(new_filename); + KService::Ptr service = KService::serviceByDesktopName(file); if (service && service->isValid()) { addAtom(entry, TDEIO::UDS_ICON_NAME, 0, service->icon()); @@ -250,7 +240,8 @@ void AppImpl::createExeEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry } } -void AppImpl::createManPageEntry(TDEIO::UDSEntry &entry, const TQString &shortname) +void AppImpl::createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, + const TQString &shortname) { entry.clear(); addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Manual for %1").arg(shortname)); @@ -258,9 +249,10 @@ void AppImpl::createManPageEntry(TDEIO::UDSEntry &entry, const TQString &shortna addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "application/x-desktop"); addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "man"); + list.append(entry); } -void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, +void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, const TQString &shortname) { TQStringList homedir; @@ -281,7 +273,7 @@ void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEn addAtom(entry, TDEIO::UDS_URL, 0, fname); addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "cachefolder"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "folder"); list.append(entry); } } @@ -309,7 +301,7 @@ void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UD addAtom(entry, TDEIO::UDS_URL, 0, dirname); addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "binaryfolder"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "folder"); list.append(entry); } } @@ -340,13 +332,14 @@ void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, addAtom(entry, TDEIO::UDS_URL, 0, dirname); addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "binaryfolder"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "folder"); list.append(entry); } } -void AppImpl::createTDEConfigEntry(TDEIO::UDSEntry &entry, const TQString &shortname) +void AppImpl::createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, + TDEIO::UDSEntry &entry, const TQString &shortname) { TQString TDEDataDir = locate("config", shortname + "rc"); kdDebug() << "TDEDataDir: " << TDEDataDir << endl; @@ -361,6 +354,7 @@ void AppImpl::createTDEConfigEntry(TDEIO::UDSEntry &entry, const TQString &short addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "text/plain"); addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "configure"); + list.append(entry); } void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, @@ -420,7 +414,7 @@ void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn { TQStringList dirList; dirList << "/tmp/"; - TQStringList TmpDir = getFullLocation(dirList,shortname, + TQStringList TmpDir = getFullLocation(dirList, shortname, TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), true, true); if (TmpDir.isEmpty()) { @@ -450,7 +444,7 @@ void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Tmp Data (%1)").arg(fname)); addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "tmpfolder"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "folder"); } else { @@ -480,72 +474,33 @@ void AppImpl::slotResult(TDEIO::Job *) bool AppImpl::listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry> &list) { - kdDebug() << "AppImpl::listAppEntries" << endl; +tqWarning("MIKE AppImpl::listAppContents name="+name); + kdDebug() << "AppImpl::listAppContents" << endl; + TDEIO::UDSEntry entry; // Create entry for binary file - entry.clear(); createExeEntry(list, entry, name, getAppAddress(name)); - if (!entry.isEmpty()) - { - list.append(entry); - } // Create entry for man page entry.clear(); - createManPageEntry(entry, name); - if (!entry.isEmpty()) - { - list.append(entry); - } - // Create entry for apps folder in home dir - entry.clear(); + // Create entry for apps data folder in home dir createHomeDirEntry(list, entry, name); - if (!entry.isEmpty()) - { - list.append(entry); - } - // Create entry for apps folder in home dir - entry.clear(); - createTDEDataDirEntry(list, entry, name); - if (!entry.isEmpty()) - { - list.append(entry); - } - - // Create entry for apps folder in home dir - entry.clear(); + // Create entry for standard config and data folders + createStandardConfigEntry(list, entry, name); createStandardDataDirEntry(list, entry, name); - if (!entry.isEmpty()) - { - list.append(entry); - } - // Create entry for apps folder in home dir - entry.clear(); - createTDEConfigEntry(entry, name); - if (!entry.isEmpty()) - { - list.append(entry); - } + // Create entry for TDE config and data folders + createTDEConfigEntry(list, entry, name); + createTDEDataDirEntry(list, entry, name); - // Create entry for apps folder in home dir - entry.clear(); - createStandardConfigEntry(list, entry, name); - if (!entry.isEmpty()) - { - list.append(entry); - } + // Create entry for manual + createManPageEntry(list, entry, name); //Create entry for apps folder in home dir - entry.clear(); createTmpDirEntry(list, entry, name); - if (!entry.isEmpty()) - { - list.append(entry); - } return true; } @@ -553,9 +508,9 @@ bool AppImpl::listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry> TQStringList AppImpl::getAppAddress(const TQString &name) { TQStringList dirList; + dirList << "/opt/trinity/bin/"; dirList << "/usr/bin/"; dirList << "/usr/local/bin/"; - dirList << "/opt/trinity/bin/"; return getFullLocation(dirList, name, TQDir::FilterSpec(TQDir::Files | TQDir::Readable), false, false); @@ -573,7 +528,7 @@ TQStringList AppImpl::getFullLocation(const TQStringList &dirList, const TQStrin } TQStringList filenames = dir.entryList(filter); - for (const TQString &filename : dirList) + for (const TQString &filename : filenames) { if (recursive && filename != ".." && filename != ".") { |