13 qCDebug(LogViewerControllerLog) <<
this;
18 qCDebug(LogViewerControllerLog) <<
this;
23 _plottableFields.clear();
25 _selectedFields.clear();
26 _expandedGroups.clear();
49 _plottableFields = fieldNames;
50 std::sort(_plottableFields.begin(), _plottableFields.end());
51 _selectedFields.clear();
58 if (_selectedFields.isEmpty()) {
62 _selectedFields.clear();
68 if (_expandedGroups.contains(groupName)) {
69 _expandedGroups.remove(groupName);
71 _expandedGroups.insert(groupName);
79 return _expandedGroups.contains(groupName);
84 const bool currentlySelected = _selectedFields.contains(fieldName);
85 if (currentlySelected == selected) {
90 _selectedFields.append(fieldName);
92 _selectedFields.removeAll(fieldName);
100 return _selectedFields.contains(fieldName);
105 return _assignColorForKey(fieldName);
110 if (eventType == QStringLiteral(
"mode")) {
111 return _assignColorForKey(QStringLiteral(
"event-mode"));
113 if (eventType == QStringLiteral(
"error")) {
114 return _assignColorForKey(QStringLiteral(
"event-error"));
116 if (eventType == QStringLiteral(
"event")) {
117 return _assignColorForKey(QStringLiteral(
"event-generic"));
119 if (eventType == QStringLiteral(
"warning")) {
120 return _assignColorForKey(QStringLiteral(
"event-warning"));
123 return _assignColorForKey(QStringLiteral(
"event-other"));
126void LogViewerController::_setLog(SourceType sourceType,
const QString &path)
133 if (_currentLogPath != path) {
134 _currentLogPath = path;
138 qCDebug(LogViewerControllerLog) <<
"sourceType" <<
static_cast<int>(_sourceType) <<
"path" << _currentLogPath;
141void LogViewerController::_rebuildFieldRows()
143 QHash<QString, QStringList> groupedMap;
146 for (
const QString &field : _plottableFields) {
147 const int splitIndex = field.indexOf(
'.');
148 const QString groupName = (splitIndex > 0) ? field.left(splitIndex) : tr(
"Other");
149 const QString shortName = (splitIndex > 0) ? field.mid(splitIndex + 1) : field;
150 if (!groupedMap.contains(groupName)) {
151 groups.append(groupName);
153 groupedMap[groupName].append(shortName);
156 std::sort(groups.begin(), groups.end());
159 for (
const QString &groupName : groups) {
160 QVariantMap groupRow;
161 groupRow[QStringLiteral(
"rowType")] = QStringLiteral(
"group");
162 groupRow[QStringLiteral(
"group")] = groupName;
163 rows.append(groupRow);
165 if (!_expandedGroups.contains(groupName)) {
169 QStringList fieldNames = groupedMap.value(groupName);
170 std::sort(fieldNames.begin(), fieldNames.end());
171 for (
const QString &shortName : fieldNames) {
172 QVariantMap fieldRow;
173 fieldRow[QStringLiteral(
"rowType")] = QStringLiteral(
"field");
174 fieldRow[QStringLiteral(
"group")] = groupName;
175 fieldRow[QStringLiteral(
"shortName")] = shortName;
176 fieldRow[QStringLiteral(
"fullName")] = QStringLiteral(
"%1.%2").arg(groupName, shortName);
177 rows.append(fieldRow);
185QString LogViewerController::_assignColorForKey(
const QString &key)
const
187 static const QStringList palette = {
188 QStringLiteral(
"#3776D6"),
189 QStringLiteral(
"#D9534F"),
190 QStringLiteral(
"#3FA96B"),
191 QStringLiteral(
"#D98E04"),
192 QStringLiteral(
"#7B5CC9"),
193 QStringLiteral(
"#D64E8B"),
194 QStringLiteral(
"#2FA9A2"),
195 QStringLiteral(
"#D96A2D"),
196 QStringLiteral(
"#4A6CD4"),
197 QStringLiteral(
"#6EA827"),
201 for (
const QChar ch : key) {
202 hash = (hash * 31U) + ch.unicode();
205 const qsizetype idx =
static_cast<qsizetype
>(hash %
static_cast<quint32
>(palette.count()));
#define QGC_LOGGING_CATEGORY(name, categoryStr)
Q_INVOKABLE bool isGroupExpanded(const QString &groupName) const
Q_INVOKABLE void openTLog(const QString &path)
void currentLogPathChanged()
Q_INVOKABLE void openBinLog(const QString &path)
SourceType sourceType() const
Q_INVOKABLE void setPlottableFields(const QStringList &fieldNames)
Q_INVOKABLE bool isFieldSelected(const QString &fieldName) const
Q_INVOKABLE QString fieldColor(const QString &fieldName) const
Q_INVOKABLE void setFieldSelected(const QString &fieldName, bool selected)
Q_INVOKABLE void clearSelection()
Q_INVOKABLE void openULogFile(const QString &path)
Q_INVOKABLE void toggleGroupExpanded(const QString &groupName)
Q_INVOKABLE QString eventColor(const QString &eventType) const
void selectedFieldsChanged()