uic: Port enumeration lookups to QLatin1StringView
This makes string operations on them easier. Pick-to: 6.5 Task-number: PYSIDE-2492 Task-number: PYSIDE-1735 Task-number: QTBUG-118473 Change-Id: I92922b701fd72f5521eee7f6d3ef63492e03be9b Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit d7ebe91781b80c8f748ea56d7915f03e69916516) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
962291ab17
commit
69487198ef
@ -33,7 +33,7 @@ namespace {
|
|||||||
return result;
|
return result;
|
||||||
switch (pstyle->kind()) {
|
switch (pstyle->kind()) {
|
||||||
case DomProperty::Number:
|
case DomProperty::Number:
|
||||||
result = QLatin1StringView(language::toolbarArea(pstyle->elementNumber()));
|
result = language::toolbarArea(pstyle->elementNumber());
|
||||||
break;
|
break;
|
||||||
case DomProperty::Enum:
|
case DomProperty::Enum:
|
||||||
result = pstyle->elementEnum();
|
result = pstyle->elementEnum();
|
||||||
|
@ -83,19 +83,19 @@ QTextStream &operator<<(QTextStream &str, const closeQtConfig &c)
|
|||||||
struct EnumLookup
|
struct EnumLookup
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
const char *valueString;
|
QLatin1StringView valueString;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <int N>
|
template <int N>
|
||||||
const char *lookupEnum(const EnumLookup(&array)[N], int value, int defaultIndex = 0)
|
QLatin1StringView lookupEnum(const EnumLookup(&array)[N], int value, int defaultIndex = 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < N; ++i) {
|
for (int i = 0; i < N; ++i) {
|
||||||
if (value == array[i].value)
|
if (value == array[i].value)
|
||||||
return array[i].valueString;
|
return array[i].valueString;
|
||||||
}
|
}
|
||||||
const char *defaultValue = array[defaultIndex].valueString;
|
auto defaultValue = array[defaultIndex].valueString;
|
||||||
qWarning("uic: Warning: Invalid enumeration value %d, defaulting to %s",
|
qWarning("uic: Warning: Invalid enumeration value %d, defaulting to %s",
|
||||||
value, defaultValue);
|
value, defaultValue.data());
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,74 +106,74 @@ QString fixClassName(QString className)
|
|||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *toolbarArea(int v)
|
QLatin1StringView toolbarArea(int v)
|
||||||
{
|
{
|
||||||
static const EnumLookup toolBarAreas[] =
|
static const EnumLookup toolBarAreas[] =
|
||||||
{
|
{
|
||||||
{0, "NoToolBarArea"},
|
{0, "NoToolBarArea"_L1},
|
||||||
{0x1, "LeftToolBarArea"},
|
{0x1, "LeftToolBarArea"_L1},
|
||||||
{0x2, "RightToolBarArea"},
|
{0x2, "RightToolBarArea"_L1},
|
||||||
{0x4, "TopToolBarArea"},
|
{0x4, "TopToolBarArea"_L1},
|
||||||
{0x8, "BottomToolBarArea"},
|
{0x8, "BottomToolBarArea"_L1},
|
||||||
{0xf, "AllToolBarAreas"}
|
{0xf, "AllToolBarAreas"_L1}
|
||||||
};
|
};
|
||||||
return lookupEnum(toolBarAreas, v);
|
return lookupEnum(toolBarAreas, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *sizePolicy(int v)
|
QLatin1StringView sizePolicy(int v)
|
||||||
{
|
{
|
||||||
static const EnumLookup sizePolicies[] =
|
static const EnumLookup sizePolicies[] =
|
||||||
{
|
{
|
||||||
{0, "Fixed"},
|
{0, "Fixed"_L1},
|
||||||
{0x1, "Minimum"},
|
{0x1, "Minimum"_L1},
|
||||||
{0x4, "Maximum"},
|
{0x4, "Maximum"_L1},
|
||||||
{0x5, "Preferred"},
|
{0x5, "Preferred"_L1},
|
||||||
{0x3, "MinimumExpanding"},
|
{0x3, "MinimumExpanding"_L1},
|
||||||
{0x7, "Expanding"},
|
{0x7, "Expanding"_L1},
|
||||||
{0xD, "Ignored"}
|
{0xD, "Ignored"_L1}
|
||||||
};
|
};
|
||||||
return lookupEnum(sizePolicies, v, 3);
|
return lookupEnum(sizePolicies, v, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *dockWidgetArea(int v)
|
QLatin1StringView dockWidgetArea(int v)
|
||||||
{
|
{
|
||||||
static const EnumLookup dockWidgetAreas[] =
|
static const EnumLookup dockWidgetAreas[] =
|
||||||
{
|
{
|
||||||
{0, "NoDockWidgetArea"},
|
{0, "NoDockWidgetArea"_L1},
|
||||||
{0x1, "LeftDockWidgetArea"},
|
{0x1, "LeftDockWidgetArea"_L1},
|
||||||
{0x2, "RightDockWidgetArea"},
|
{0x2, "RightDockWidgetArea"_L1},
|
||||||
{0x4, "TopDockWidgetArea"},
|
{0x4, "TopDockWidgetArea"_L1},
|
||||||
{0x8, "BottomDockWidgetArea"},
|
{0x8, "BottomDockWidgetArea"_L1},
|
||||||
{0xf, "AllDockWidgetAreas"}
|
{0xf, "AllDockWidgetAreas"_L1}
|
||||||
};
|
};
|
||||||
return lookupEnum(dockWidgetAreas, v);
|
return lookupEnum(dockWidgetAreas, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *paletteColorRole(int v)
|
QLatin1StringView paletteColorRole(int v)
|
||||||
{
|
{
|
||||||
static const EnumLookup colorRoles[] =
|
static const EnumLookup colorRoles[] =
|
||||||
{
|
{
|
||||||
{0, "WindowText"},
|
{0, "WindowText"_L1},
|
||||||
{1, "Button"},
|
{1, "Button"_L1},
|
||||||
{2, "Light"},
|
{2, "Light"_L1},
|
||||||
{3, "Midlight"},
|
{3, "Midlight"_L1},
|
||||||
{4, "Dark"},
|
{4, "Dark"_L1},
|
||||||
{5, "Mid"},
|
{5, "Mid"_L1},
|
||||||
{6, "Text"},
|
{6, "Text"_L1},
|
||||||
{7, "BrightText"},
|
{7, "BrightText"_L1},
|
||||||
{8, "ButtonText"},
|
{8, "ButtonText"_L1},
|
||||||
{9, "Base"},
|
{9, "Base"_L1},
|
||||||
{10, "Window"},
|
{10, "Window"_L1},
|
||||||
{11, "Shadow"},
|
{11, "Shadow"_L1},
|
||||||
{12, "Highlight"},
|
{12, "Highlight"_L1},
|
||||||
{13, "HighlightedText"},
|
{13, "HighlightedText"_L1},
|
||||||
{14, "Link"},
|
{14, "Link"_L1},
|
||||||
{15, "LinkVisited"},
|
{15, "LinkVisited"_L1},
|
||||||
{16, "AlternateBase"},
|
{16, "AlternateBase"_L1},
|
||||||
{17, "NoRole"},
|
{17, "NoRole"_L1},
|
||||||
{18, "ToolTipBase"},
|
{18, "ToolTipBase"_L1},
|
||||||
{19, "ToolTipText"},
|
{19, "ToolTipText"_L1},
|
||||||
{20, "PlaceholderText"},
|
{20, "PlaceholderText"_L1},
|
||||||
};
|
};
|
||||||
return lookupEnum(colorRoles, v);
|
return lookupEnum(colorRoles, v);
|
||||||
}
|
}
|
||||||
|
@ -75,10 +75,10 @@ QTextStream &operator<<(QTextStream &, const closeQtConfig &c);
|
|||||||
|
|
||||||
QString fixClassName(QString className);
|
QString fixClassName(QString className);
|
||||||
|
|
||||||
const char *toolbarArea(int v);
|
QLatin1StringView toolbarArea(int v);
|
||||||
const char *sizePolicy(int v);
|
QLatin1StringView sizePolicy(int v);
|
||||||
const char *dockWidgetArea(int v);
|
QLatin1StringView dockWidgetArea(int v);
|
||||||
const char *paletteColorRole(int v);
|
QLatin1StringView paletteColorRole(int v);
|
||||||
|
|
||||||
enum class Encoding { Utf8, Unicode };
|
enum class Encoding { Utf8, Unicode };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user