Commit dfc8e6ed authored by Ahmad Samir's avatar Ahmad Samir Committed by Tomaz Canabrava
Browse files

Make Profile::DefaultPropertyNames a vector instead of built-in array

A vector doesn't decay to pointer, so we can iterate over it with range-for
in Profile and ProfileReader/Writer without using pointers to array
elements, and a while loop that checks for the special element at the end
of the array to stop the loop. Also remove that dud element at the end of

std::array is a viable option, but the downside is we'd have to specify the
number of elements in it (as that's part of its type), and keeping that
number in sync when adding new properties could be problematic.
parent 392bb51e
......@@ -40,7 +40,7 @@ static const char CURSOR_GROUP[] = "Cursor Options";
static const char INTERACTION_GROUP[] = "Interaction Options";
static const char ENCODING_GROUP[] = "Encoding Options";
const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
const std::vector<Profile::PropertyInfo> Profile::DefaultPropertyNames = {
// General
{Path, "Path", nullptr, QVariant::String},
{Name, "Name", GENERAL_GROUP, QVariant::String},
......@@ -135,10 +135,8 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
// Encoding
{DefaultEncoding, "DefaultEncoding", ENCODING_GROUP, QVariant::String}
{static_cast<Profile::Property>(0), nullptr, nullptr, QVariant::Invalid}};
{DefaultEncoding, "DefaultEncoding", ENCODING_GROUP, QVariant::String},
QHash<QString, Profile::PropertyInfo> Profile::PropertyInfoByName;
......@@ -17,6 +17,8 @@
#include <QStringList>
#include <QVariant>
#include <vector>
// Konsole
#include "konsoleprofile_export.h"
......@@ -781,7 +783,7 @@ private:
const char *group;
QVariant::Type type;
static const PropertyInfo DefaultPropertyNames[];
static const std::vector<PropertyInfo> DefaultPropertyNames;
inline bool Profile::canInheritProperty(Property p)
Supports Markdown
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