mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 10:52:49 +00:00
kdecore: use foreach() for iterations in KStandardDirs
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c332784ea6
commit
6052ab3b7f
1 changed files with 36 additions and 64 deletions
|
@ -930,64 +930,54 @@ QStringList KStandardDirs::KStandardDirsPrivate::resourceDirs(const char* type)
|
||||||
const QString typeInstallPath = installPath(type); // could be empty
|
const QString typeInstallPath = installPath(type); // could be empty
|
||||||
const QString installdir = typeInstallPath.isEmpty() ? QString() : realPath(typeInstallPath);
|
const QString installdir = typeInstallPath.isEmpty() ? QString() : realPath(typeInstallPath);
|
||||||
const QString installprefix = installPath("kdedir");
|
const QString installprefix = installPath("kdedir");
|
||||||
if (!dirs.isEmpty())
|
if (!dirs.isEmpty()) {
|
||||||
{
|
|
||||||
bool local = true;
|
bool local = true;
|
||||||
|
|
||||||
for (QStringList::ConstIterator it = dirs.constBegin();
|
foreach (const QString &it, dirs) {
|
||||||
it != dirs.constEnd(); ++it)
|
if (it.startsWith(QLatin1Char('%'))) {
|
||||||
{
|
|
||||||
if ((*it).startsWith(QLatin1Char('%'))) {
|
|
||||||
// grab the "data" from "%data/apps"
|
// grab the "data" from "%data/apps"
|
||||||
const int pos = (*it).indexOf(QLatin1Char('/'));
|
const int pos = it.indexOf(QLatin1Char('/'));
|
||||||
QByteArray rel = (*it).mid(1, pos - 1).toUtf8();
|
QByteArray rel = it.mid(1, pos - 1).toUtf8();
|
||||||
QString rest = (*it).mid(pos + 1);
|
QString rest = it.mid(pos + 1);
|
||||||
foreach (const QString &it2, resourceDirs(rel.constData()))
|
foreach (const QString &it2, resourceDirs(rel.constData())) {
|
||||||
{
|
|
||||||
const QString path = realPath( it2 + rest );
|
const QString path = realPath( it2 + rest );
|
||||||
testdir.setPath(path);
|
testdir.setPath(path);
|
||||||
if ((local || testdir.exists()) && !candidates.contains(path, case_sensitivity))
|
if ((local || testdir.exists()) && !candidates.contains(path, case_sensitivity)) {
|
||||||
candidates.append(path);
|
candidates.append(path);
|
||||||
|
}
|
||||||
local = false;
|
local = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList *prefixList = 0;
|
const QStringList *prefixList = 0;
|
||||||
if (strncmp(type, "xdgdata-", 8) == 0)
|
if (strncmp(type, "xdgdata-", 8) == 0) {
|
||||||
prefixList = &(xdgdata_prefixes);
|
prefixList = &(xdgdata_prefixes);
|
||||||
else if (strncmp(type, "xdgconf-", 8) == 0)
|
} else if (strncmp(type, "xdgconf-", 8) == 0) {
|
||||||
prefixList = &(xdgconf_prefixes);
|
prefixList = &(xdgconf_prefixes);
|
||||||
else
|
} else {
|
||||||
prefixList = &m_prefixes;
|
prefixList = &m_prefixes;
|
||||||
|
}
|
||||||
|
|
||||||
for (QStringList::ConstIterator pit = prefixList->begin();
|
for (QStringList::ConstIterator pit = prefixList->begin(); pit != prefixList->end(); ++pit) {
|
||||||
pit != prefixList->end();
|
if((*pit).compare(installprefix, case_sensitivity) != 0 || installdir.isEmpty()) {
|
||||||
++pit)
|
foreach (const QString &it, dirs) {
|
||||||
{
|
if (it.startsWith(QLatin1Char('%')))
|
||||||
if((*pit).compare(installprefix, case_sensitivity) != 0 || installdir.isEmpty())
|
|
||||||
{
|
|
||||||
for (QStringList::ConstIterator it = dirs.constBegin();
|
|
||||||
it != dirs.constEnd(); ++it)
|
|
||||||
{
|
|
||||||
if ((*it).startsWith(QLatin1Char('%')))
|
|
||||||
continue;
|
continue;
|
||||||
const QString path = realPath( *pit + *it );
|
const QString path = realPath(*pit + it);
|
||||||
testdir.setPath(path);
|
testdir.setPath(path);
|
||||||
if ((local || testdir.exists()) && !candidates.contains(path, case_sensitivity))
|
if ((local || testdir.exists()) && !candidates.contains(path, case_sensitivity))
|
||||||
candidates.append(path);
|
candidates.append(path);
|
||||||
}
|
}
|
||||||
local = false;
|
local = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// we have a custom install path, so use this instead of <installprefix>/<relative dir>
|
// we have a custom install path, so use this instead of <installprefix>/<relative dir>
|
||||||
testdir.setPath(installdir);
|
testdir.setPath(installdir);
|
||||||
if(testdir.exists() && ! candidates.contains(installdir, case_sensitivity))
|
if (testdir.exists() && ! candidates.contains(installdir, case_sensitivity))
|
||||||
candidates.append(installdir);
|
candidates.append(installdir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// make sure we find the path where it's installed
|
// make sure we find the path where it's installed
|
||||||
if (!installdir.isEmpty()) {
|
if (!installdir.isEmpty()) {
|
||||||
|
@ -1002,13 +992,10 @@ QStringList KStandardDirs::KStandardDirsPrivate::resourceDirs(const char* type)
|
||||||
candidates.append(installdir);
|
candidates.append(installdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList absDirs = m_absolutes.value(type);
|
foreach (const QString &it, m_absolutes.value(type)) {
|
||||||
for (QStringList::ConstIterator it = absDirs.constBegin();
|
testdir.setPath(it);
|
||||||
it != absDirs.constEnd(); ++it)
|
|
||||||
{
|
|
||||||
testdir.setPath(*it);
|
|
||||||
if (testdir.exists()) {
|
if (testdir.exists()) {
|
||||||
const QString filename = realPath( *it );
|
const QString filename = realPath(it);
|
||||||
if (!candidates.contains(filename, case_sensitivity)) {
|
if (!candidates.contains(filename, case_sensitivity)) {
|
||||||
candidates.append(filename);
|
candidates.append(filename);
|
||||||
}
|
}
|
||||||
|
@ -1121,25 +1108,16 @@ QString KStandardDirs::findRootExe( const QString& appname,
|
||||||
return findExe(appname, exePaths.join(s_pathseparator), options);
|
return findExe(appname, exePaths.join(s_pathseparator), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
int KStandardDirs::findAllExe( QStringList& list, const QString& appname,
|
int KStandardDirs::findAllExe(QStringList& list, const QString& appname,
|
||||||
const QString& pstr, SearchOptions options )
|
const QString& pstr, SearchOptions options)
|
||||||
{
|
{
|
||||||
QFileInfo info;
|
|
||||||
QString p;
|
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|
||||||
const QStringList exePaths = systemPaths( pstr );
|
foreach (const QString &it, systemPaths(pstr)) {
|
||||||
for (QStringList::ConstIterator it = exePaths.begin(); it != exePaths.end(); ++it)
|
QString p = it + QLatin1Char('/') + appname;
|
||||||
{
|
QFileInfo info(p);
|
||||||
p = (*it) + QLatin1Char('/');
|
if (info.exists() && ((options & IgnoreExecBit) || info.isExecutable()) && info.isFile()) {
|
||||||
p += appname;
|
list.append(p );
|
||||||
|
|
||||||
|
|
||||||
info.setFile( p );
|
|
||||||
|
|
||||||
if( info.exists() && ( ( options & IgnoreExecBit ) || info.isExecutable())
|
|
||||||
&& info.isFile() ) {
|
|
||||||
list.append( p );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1343,11 +1321,8 @@ void KStandardDirs::addKDEDefaults()
|
||||||
localXdgDir = KShell::tildeExpand(localXdgDir);
|
localXdgDir = KShell::tildeExpand(localXdgDir);
|
||||||
addXdgConfigPrefix(localXdgDir);
|
addXdgConfigPrefix(localXdgDir);
|
||||||
|
|
||||||
for (QStringList::ConstIterator it = xdgdirList.constBegin();
|
foreach (const QString &it, xdgdirList) {
|
||||||
it != xdgdirList.constEnd(); ++it)
|
addXdgConfigPrefix(KShell::tildeExpand(it));
|
||||||
{
|
|
||||||
QString dir = KShell::tildeExpand(*it);
|
|
||||||
addXdgConfigPrefix(dir);
|
|
||||||
}
|
}
|
||||||
// end XDG_CONFIG_XXX
|
// end XDG_CONFIG_XXX
|
||||||
|
|
||||||
|
@ -1392,11 +1367,8 @@ void KStandardDirs::addKDEDefaults()
|
||||||
localXdgDir = KShell::tildeExpand(localXdgDir);
|
localXdgDir = KShell::tildeExpand(localXdgDir);
|
||||||
addXdgDataPrefix(localXdgDir);
|
addXdgDataPrefix(localXdgDir);
|
||||||
|
|
||||||
for (QStringList::ConstIterator it = xdgdirList.constBegin();
|
foreach (const QString &it, xdgdirList) {
|
||||||
it != xdgdirList.constEnd(); ++it)
|
addXdgDataPrefix(KShell::tildeExpand(it));
|
||||||
{
|
|
||||||
QString dir = KShell::tildeExpand(*it);
|
|
||||||
addXdgDataPrefix(dir);
|
|
||||||
}
|
}
|
||||||
// end XDG_DATA_XXX
|
// end XDG_DATA_XXX
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue