Commit eb90e6fb authored by Kurt Hindenburg's avatar Kurt Hindenburg

simplify ProfileReader class as there is no longer multiple versions

parent 0feaa769
......@@ -55,7 +55,7 @@ class ProfileGroup;
*/
class KONSOLEPRIVATE_EXPORT Profile : public QSharedData
{
friend class KDE4ProfileReader;
friend class ProfileReader;
friend class ProfileWriter;
friend class ProfileGroup;
......
......@@ -181,7 +181,7 @@ Profile::Ptr ProfileManager::loadProfile(const QString& shortPath)
}
// load the profile
ProfileReader* reader = new KDE4ProfileReader;
ProfileReader* reader = new ProfileReader();
Profile::Ptr newProfile = Profile::Ptr(new Profile(fallbackProfile()));
newProfile->setProperty(Profile::Path, path);
......@@ -209,13 +209,14 @@ Profile::Ptr ProfileManager::loadProfile(const QString& shortPath)
}
QStringList ProfileManager::availableProfilePaths() const
{
KDE4ProfileReader kde4Reader;
ProfileReader* reader = new ProfileReader();
QStringList paths;
paths += kde4Reader.findProfiles();
paths += reader->findProfiles();
qStableSort(paths.begin(), paths.end(), stringLessThan);
delete reader;
return paths;
}
......
......@@ -41,7 +41,10 @@ static const char FEATURES_GROUP[] = "Terminal Features";
static const char URLHINTS_KEY[] = "EnableUrlHints";
static const char URLHINTSMODIFIERS_KEY[] = "UrlHintsModifiers";
QStringList KDE4ProfileReader::findProfiles()
ProfileReader::ProfileReader() = default;
ProfileReader::~ProfileReader() = default;
QStringList ProfileReader::findProfiles()
{
QStringList profiles;
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole"), QStandardPaths::LocateDirectory);
......@@ -55,7 +58,7 @@ QStringList KDE4ProfileReader::findProfiles()
}
return profiles;
}
void KDE4ProfileReader::readProperties(const KConfig& config, Profile::Ptr profile,
void ProfileReader::readProperties(const KConfig& config, Profile::Ptr profile,
const Profile::PropertyInfo* properties)
{
const char* groupName = nullptr;
......@@ -80,7 +83,7 @@ void KDE4ProfileReader::readProperties(const KConfig& config, Profile::Ptr profi
}
}
bool KDE4ProfileReader::readProfile(const QString& path , Profile::Ptr profile , QString& parentProfile)
bool ProfileReader::readProfile(const QString& path , Profile::Ptr profile , QString& parentProfile)
{
if (!QFile::exists(path)) {
return false;
......
......@@ -28,18 +28,14 @@ class KConfig;
namespace Konsole {
/** Interface for all classes which can load profile settings from a file. */
class ProfileReader
class KONSOLEPRIVATE_EXPORT ProfileReader
{
public:
virtual ~ProfileReader()
{
}
ProfileReader();
~ProfileReader();
/** Returns a list of paths to profiles which this reader can read. */
virtual QStringList findProfiles()
{
return QStringList();
}
QStringList findProfiles();
/**
* Attempts to read a profile from @p path and
......@@ -51,16 +47,8 @@ public:
* @param profile Pointer to the Profile the settings will be read into
* @param parentProfile Receives the name of the parent profile
*/
virtual bool readProfile(const QString &path, Profile::Ptr profile, QString &parentProfile) = 0;
};
bool readProfile(const QString &path, Profile::Ptr profile, QString &parentProfile);
/** Reads a KDE 4 .profile file. */
class KDE4ProfileReader : public ProfileReader
{
public:
QStringList findProfiles() Q_DECL_OVERRIDE;
bool readProfile(const QString &path, Profile::Ptr profile,
QString &parentProfile) Q_DECL_OVERRIDE;
private:
void readProperties(const KConfig &config, Profile::Ptr profile,
const Profile::PropertyInfo *properties);
......
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