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