Changeset View
Changeset View
Standalone View
Standalone View
src/kuitmarkup.cpp
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | |||||
78 | 78 | | |||
79 | static void parseUiMarker(const QString &context_, | 79 | static void parseUiMarker(const QString &context_, | ||
80 | QString &roleName, | 80 | QString &roleName, | ||
81 | QString &cueName, | 81 | QString &cueName, | ||
82 | QString &formatName) | 82 | QString &formatName) | ||
83 | { | 83 | { | ||
84 | // UI marker is in the form @role:cue/format, | 84 | // UI marker is in the form @role:cue/format, | ||
85 | // and must start just after any leading whitespace in the context string. | 85 | // and must start just after any leading whitespace in the context string. | ||
86 | // Names remain untouched if UI marker is not found. | 86 | // Note that names remain untouched if the marker is not found. | ||
87 | 87 | // Normalize the whole string, all lowercase. | |||
88 | // Normalize all names, trimmed, all lower-case | | |||
89 | QString context = context_.trimmed().toLower(); | 88 | QString context = context_.trimmed().toLower(); | ||
89 | if (context.startsWith(QL1C('@'))) { // found UI marker | ||||
90 | static const QRegularExpression wsRx(QStringLiteral("\\s")); | ||||
91 | context = context.mid(1, wsRx.match(context).capturedStart(0) - 1); | ||||
92 | | ||||
93 | // Possible format. | ||||
94 | int pfmt = context.indexOf(QL1C('/')); | ||||
95 | if (pfmt >= 0) { | ||||
96 | formatName = context.mid(pfmt + 1); | ||||
97 | context.truncate(pfmt); | ||||
98 | } | ||||
99 | | ||||
100 | // Possible subcue. | ||||
101 | int pcue = context.indexOf(QL1C(':')); | ||||
102 | if (pcue >= 0) { | ||||
103 | cueName = context.mid(pcue + 1); | ||||
104 | context.truncate(pcue); | ||||
105 | } | ||||
90 | 106 | | |||
91 | static const QRegularExpression rolesRx(QStringLiteral("^@(\\w+):?(\\w*)/?(\\w*)")); | 107 | // Role. | ||
92 | const QRegularExpressionMatch match = rolesRx.match(context); | 108 | roleName = context; | ||
93 | if (match.hasMatch()) { | | |||
94 | roleName = match.captured(1); | | |||
95 | cueName = match.captured(2); | | |||
96 | formatName = match.captured(3); | | |||
97 | } | 109 | } | ||
98 | } | 110 | } | ||
99 | 111 | | |||
100 | // Custom entity resolver for QXmlStreamReader. | 112 | // Custom entity resolver for QXmlStreamReader. | ||
101 | class KuitEntityResolver : public QXmlStreamEntityResolver | 113 | class KuitEntityResolver : public QXmlStreamEntityResolver | ||
102 | { | 114 | { | ||
103 | public: | 115 | public: | ||
104 | 116 | | |||
▲ Show 20 Lines • Show All 1563 Lines • Show Last 20 Lines |