Commit 31e823b6 authored by Stefan Brüns's avatar Stefan Brüns

Invert logic of shouldShowMountPoint -> ignoredMountPoint

Summary:
Instead of negating the logic values in several places, just invert
the logic. Also move it out of class, as it does not access any
class members.

Reviewers: #baloo, ngraham

Reviewed By: #baloo, ngraham

Subscribers: usta, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27611
parent 8f1043c6
......@@ -53,6 +53,22 @@ namespace {
return QString(url).replace(0, QDir::homePath().length(), QStringLiteral("~"));
return url;
}
bool ignoredMountPoint(const QString& mountPoint) {
if (mountPoint == QLatin1String("/"))
return true;
if (mountPoint.startsWith(QLatin1String("/boot")))
return true;
if (mountPoint.startsWith(QLatin1String("/tmp")))
return true;
// The user's home directory is forcibly added so we can ignore /home
// if /home actually contains the home directory
return mountPoint.startsWith(QLatin1String("/home")) &&
QDir::homePath().startsWith(QLatin1String("/home"));
}
}
FilteredFolderModel::FilteredFolderModel(BalooSettings *settings, QObject *parent)
......@@ -75,7 +91,7 @@ void FilteredFolderModel::updateDirectoryList()
continue;
const QString mountPath = sa->filePath();
if (!shouldShowMountPoint(mountPath))
if (ignoredMountPoint(mountPath))
continue;
m_mountPoints.append(mountPath);
......@@ -209,22 +225,6 @@ QString FilteredFolderModel::folderDisplayName(const QString& url) const
return name;
}
bool FilteredFolderModel::shouldShowMountPoint(const QString& mountPoint)
{
if (mountPoint == QLatin1String("/"))
return false;
if (mountPoint.startsWith(QLatin1String("/boot")))
return false;
if (mountPoint.startsWith(QLatin1String("/tmp")))
return false;
// The user's home directory is forcibly added so we can ignore /home
// if /home actually contains the home directory
return !(mountPoint.startsWith(QLatin1String("/home")) || !QDir::homePath().startsWith(QLatin1String("/home")));
}
QHash<int, QByteArray> FilteredFolderModel::roleNames() const
{
return {
......
......@@ -51,7 +51,6 @@ public slots:
private:
QString folderDisplayName(const QString& url) const;
bool shouldShowMountPoint(const QString& mountPoint);
QString fetchMountPoint(const QString& url) const;
void showMessage(const QString& message);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment