• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

graphia-app / graphia / 42724698251

09 Nov 2026 10:47PM UTC coverage: 71.88% (+0.5%) from 71.427%
42724698251

push

github

timangus
Add Leiden clustering

11927 of 18208 branches covered (65.5%)

Branch coverage included in aggregate %.

486 of 497 new or added lines in 3 files covered. (97.79%)

699 existing lines in 55 files now uncovered.

30522 of 40847 relevant lines covered (74.72%)

740302.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.83
/source/app/transform/graphtransformconfig.cpp
1
/* Copyright © 2013-2025 Tim Angus
2
 * Copyright © 2013-2025 Tom Freeman
3
 *
4
 * This file is part of Graphia.
5
 *
6
 * Graphia is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * Graphia is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with Graphia.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

20
#include "graphtransformconfig.h"
21

22
#include "graphtransform.h"
23
#include "graphtransformconfigparser.h"
24
#include "transformdisplaytext.h"
25

26
#include "app/configgrammar.h"
27
#include "app/attributes/attribute.h"
28

29
#include "shared/utils/container.h"
30

31
#include <QLocale>
32
#include <QObject>
33
#include <QStringList>
34
#include <QtGlobal>
35
#include <QVariantList>
36

37
#include <algorithm>
38
#include <cmath>
39
#include <map>
40

41
using namespace Qt::Literals::StringLiterals;
42

43
// Enforce consistency in rendering doubles to string
44
static QString doubleAsString(double d)
45
{
484 ✔
46
    auto string = QString::number(d, 'g', QLocale::FloatingPointShortest);
484 ✔
47

48
    if(std::isfinite(d) && !string.contains(u'.') && !string.contains(u'e'))
484 !
49
        string += u".0"_s;
42 ✔
50

51
    return string;
484 ✔
52
}
484 ✔
53

54
bool GraphTransformConfig::TerminalCondition::operator==(const GraphTransformConfig::TerminalCondition& other) const
55
{
74 ✔
56
    return _lhs == other._lhs &&
74 ✔
57
            _op == other._op &&
74 !
58
            _rhs == other._rhs;
74 ✔
59
}
74 ✔
60

61

62
bool GraphTransformConfig::UnaryCondition::operator==(const GraphTransformConfig::UnaryCondition& other) const
63
{
4 ✔
64
    return _lhs == other._lhs &&
4 !
65
            _op == other._op;
4 !
66
}
4 ✔
67

68
QString GraphTransformConfig::TerminalCondition::opAsString() const
69
{
1,004 ✔
70
    struct Visitor
1,004 ✔
71
    {
1,004 ✔
72
        QString operator()(ConditionFnOp::Equality v) const  { return GraphTransformConfigParser::opToString(v); }
1,004 ✔
73
        QString operator()(ConditionFnOp::Numerical v) const { return GraphTransformConfigParser::opToString(v); }
1,004 ✔
74
        QString operator()(ConditionFnOp::String v) const    { return GraphTransformConfigParser::opToString(v); }
1,004 ✔
75
    };
1,004 ✔
76

77
    return std::visit(Visitor(), _op);
1,004 ✔
78
}
1,004 ✔
79

80
QString GraphTransformConfig::UnaryCondition::opAsString() const
81
{
12 ✔
82
    return GraphTransformConfigParser::opToString(_op);
12 ✔
83
}
12 ✔
84

85
bool GraphTransformConfig::CompoundCondition::operator==(const GraphTransformConfig::CompoundCondition& other) const
86
{
16 ✔
87
    return _lhs == other._lhs &&
16 !
88
            _op == other._op &&
16 !
89
            _rhs == other._rhs;
16 !
90
}
16 ✔
91

92
QString GraphTransformConfig::CompoundCondition::opAsString() const
93
{
48 ✔
94
    return GraphTransformConfigParser::opToString(_op);
48 ✔
95
}
48 ✔
96

97
bool GraphTransformConfig::Parameter::operator==(const GraphTransformConfig::Parameter& other) const
98
{
128 ✔
99
    return _name == other._name &&
128 ✔
100
            _value == other._value;
128 !
101
}
128 ✔
102

103
const std::vector<QString>& GraphTransformConfig::attributeNames() const
104
{
278 ✔
105
    return _attributes;
278 ✔
106
}
278 ✔
107

108
bool GraphTransformConfig::hasParameter(const QString& name) const
109
{
404 ✔
110
    return std::ranges::find_if(_parameters,
404 ✔
111
    [&name](const auto& parameter) { return name == parameter._name; }) != _parameters.end();
462 ✔
112
}
404 ✔
113

114
const GraphTransformConfig::Parameter* GraphTransformConfig::parameterByName(const QString &name) const
115
{
426 ✔
116
    auto it = std::ranges::find_if(_parameters,
426 ✔
117
        [&name](const auto& parameter) { return name == parameter._name; });
582 ✔
118

119
    if(it != _parameters.end())
426 !
120
        return &(*it);
426 ✔
121

122
    qFatal("Parameter not found");
426 ✔
123
    return nullptr;
×
124
}
426 ✔
125

126
bool GraphTransformConfig::parameterHasValue(const QString& name, const QString& value) const
127
{
30 ✔
128
    if(!hasParameter(name))
30 !
129
        return false;
×
130

131
    return parameterByName(name)->valueAsString() == value;
30 ✔
132
}
30 ✔
133

134
void GraphTransformConfig::setParameterValue(const QString& name,
135
    const GraphTransformConfig::ParameterValue& value)
136
{
130 ✔
137
    auto it = std::ranges::find_if(_parameters,
130 ✔
138
        [&name](const auto& parameter) { return name == parameter._name; });
130 ✔
139

140
    if(it != _parameters.end())
130 !
141
        it->_value = value;
×
142
    else
130 ✔
143
        _parameters.emplace_back(Parameter{._name = name, ._value = value});
130 ✔
144
}
130 ✔
145

146
QString GraphTransformConfig::Parameter::valueAsString(NamedBool<"forExpression"> forExpression) const
147
{
674 ✔
148
    struct Visitor
674 ✔
149
    {
674 ✔
150
        NamedBool<"forExpression"> _forExpression;
674 ✔
151

152
        explicit Visitor(NamedBool<"forExpression"> forExpression_) : _forExpression(forExpression_) {}
674 ✔
153

154
        QString operator()(double d) const          { return doubleAsString(d); }
674 ✔
155
        QString operator()(int i) const             { return QString::number(i); }
674 ✔
156
        QString operator()(const QString& s) const
674 ✔
157
        {
674 ✔
158
            if(_forExpression)
440 ✔
159
                return LexyConfigGrammar::stringForExpression(s);
190 ✔
160

161
            return s;
250 ✔
162
        }
440 ✔
163
    };
674 ✔
164

165
    return std::visit(Visitor(forExpression), _value);
674 ✔
166
}
674 ✔
167

168
double GraphTransformConfig::Parameter::valueAsNumber() const
169
{
100 ✔
170
    struct Visitor
100 ✔
171
    {
100 ✔
172
        double operator()(double d) const       { return d; }
100 ✔
173
        double operator()(int i) const          { return static_cast<double>(i); }
100 ✔
174
        double operator()(const QString&) const { return std::nan(""); }
100 ✔
175
    };
100 ✔
176

177
    return std::visit(Visitor(), _value);
100 ✔
178
}
100 ✔
179

180
bool GraphTransformConfig::hasCondition() const
181
{
1,484 ✔
182
    struct ConditionVisitor
1,484 ✔
183
    {
1,484 ✔
184
        bool operator()(GraphTransformConfig::NoCondition) const { return false; }
1,484 ✔
185
        bool operator()(const TerminalCondition&) const { return true; }
1,484 ✔
186
        bool operator()(const UnaryCondition&) const { return true; }
1,484 ✔
187
        bool operator()(const RecursiveValue<CompoundCondition>&) const { return true; }
1,484 ✔
188
    };
1,484 ✔
189

190
    return std::visit(ConditionVisitor(), _condition);
1,484 ✔
191
}
1,484 ✔
192

193
QVariantMap GraphTransformConfig::conditionAsVariantMap() const
194
{
30 ✔
195
    struct ConditionVisitor
30 ✔
196
    {
30 ✔
197
        static QString terminalValueAsString(const GraphTransformConfig::TerminalValue& terminalValue)
30 ✔
198
        {
66 ✔
199
            struct Visitor
66 ✔
200
            {
66 ✔
201
                QString operator()(const double& d) const       { return doubleAsString(d); }
66 ✔
202
                QString operator()(const int& i) const          { return QString::number(i); }
66 ✔
203
                QString operator()(const QString& s) const      { return s; }
66 ✔
204
                QString operator()(const AttributeRef& a) const { return a._name; }
66 ✔
205
            };
66 ✔
206

207
            return std::visit(Visitor(), terminalValue);
66 ✔
208
        }
66 ✔
209

210
        QVariantMap operator()(GraphTransformConfig::NoCondition) const { return {}; }
30 ✔
211
        QVariantMap operator()(const TerminalCondition& terminalCondition) const
30 ✔
212
        {
32 ✔
213
            QVariantMap map;
32 ✔
214

215
            map.insert(u"lhs"_s, terminalValueAsString(terminalCondition._lhs));
32 ✔
216
            map.insert(u"lhsIsName"_s, std::holds_alternative<AttributeRef>(terminalCondition._lhs));
32 ✔
217
            map.insert(u"op"_s, terminalCondition.opAsString());
32 ✔
218
            map.insert(u"rhs"_s, terminalValueAsString(terminalCondition._rhs));
32 ✔
219
            map.insert(u"rhsIsName"_s, std::holds_alternative<AttributeRef>(terminalCondition._rhs));
32 ✔
220

221
            return map;
32 ✔
222
        }
32 ✔
223

224
        QVariantMap operator()(const UnaryCondition& unaryCondition) const
30 ✔
225
        {
30 ✔
226
            QVariantMap map;
2 ✔
227

228
            map.insert(u"lhs"_s, terminalValueAsString(unaryCondition._lhs));
2 ✔
229
            map.insert(u"lhsIsName"_s, std::holds_alternative<AttributeRef>(unaryCondition._lhs));
2 ✔
230
            map.insert(u"op"_s, unaryCondition.opAsString());
2 ✔
231

232
            return map;
2 ✔
233
        }
2 ✔
234

235
        QVariantMap operator()(const RecursiveValue<CompoundCondition>& wrapper) const
30 ✔
236
        {
30 ✔
237
            const auto& compoundCondition = *wrapper;
4 ✔
238
            QVariantMap map;
4 ✔
239
            auto lhs = std::visit(ConditionVisitor(), compoundCondition._lhs);
4 ✔
240
            auto rhs = std::visit(ConditionVisitor(), compoundCondition._rhs);
4 ✔
241

242
            map.insert(u"lhs"_s, lhs);
4 ✔
243
            map.insert(u"op"_s, compoundCondition.opAsString());
4 ✔
244
            map.insert(u"rhs"_s, rhs);
4 ✔
245

246
            return map;
4 ✔
247
        }
4 ✔
248
    };
30 ✔
249

250
    return std::visit(ConditionVisitor(), _condition);
30 ✔
251
}
30 ✔
252

253
QString GraphTransformConfig::conditionAsString(NamedBool<"forDisplay"> forDisplay,
254
    const AttributeDisplayNameFn& attributeDisplayName, const AttributeDisplayValueFn& attributeDisplayValue) const
255
{
938 ✔
256
    struct ConditionVisitor
938 ✔
257
    {
938 ✔
258
        ConditionVisitor(NamedBool<"forDisplay"> forDisplay, const AttributeDisplayNameFn& attributeDisplayName,
938 ✔
259
            const AttributeDisplayValueFn& attributeDisplayValue) :
938 ✔
260
            _forDisplay(forDisplay), _attributeDisplayName(attributeDisplayName),
1,026 ✔
261
            _attributeDisplayValue(attributeDisplayValue) {}
1,026 ✔
262

263
        NamedBool<"forDisplay"> _forDisplay;
938 ✔
264
        AttributeDisplayNameFn _attributeDisplayName;
938 ✔
265
        AttributeDisplayValueFn _attributeDisplayValue;
938 ✔
266

267
        QString terminalValueAsString(const GraphTransformConfig::TerminalValue& terminalValue) const
938 ✔
268
        {
1,954 ✔
269
            struct Visitor
1,954 ✔
270
            {
1,954 ✔
271
                Visitor(NamedBool<"forDisplay"> forDisplay, const AttributeDisplayNameFn& attributeDisplayName) :
1,954 ✔
272
                    _forDisplay(forDisplay), _attributeDisplayName(attributeDisplayName) {}
1,954 ✔
273

274
                NamedBool<"forDisplay"> _forDisplay;
1,954 ✔
275
                AttributeDisplayNameFn _attributeDisplayName;
1,954 ✔
276

277
                QString operator()(const double& d) const   { return doubleAsString(d); }
1,954 ✔
278
                QString operator()(const int& i) const      { return QString::number(i); }
1,954 ✔
279
                QString operator()(const QString& s) const
1,954 ✔
280
                {
1,954 ✔
281
                    return _forDisplay ? s : LexyConfigGrammar::stringForExpression(s);
136 ✔
282
                }
136 ✔
283

284
                QString operator()(const AttributeRef& a) const
1,954 ✔
285
                {
1,954 ✔
286
                    if(_forDisplay)
982 ✔
287
                    {
22 ✔
288
                        return _attributeDisplayName ? _attributeDisplayName(a._name) :
22 !
289
                            Attribute::fullyQualifiedDisplayName(a._name, [](const QString& name) { return name; });
22 ✔
290
                    }
22 ✔
291

292
                    return u"$%1"_s.arg(Attribute::attributeNameForExpression(a._name));
960 ✔
293
                }
982 ✔
294
            };
1,954 ✔
295

296
            return std::visit(Visitor(_forDisplay, _attributeDisplayName), terminalValue);
1,954 ✔
297
        }
1,954 ✔
298

299
        QString applyOp(const QString& op, const QString& lhs, const QString& rhs) const
938 ✔
300
        {
1,016 ✔
301
            if(_forDisplay)
1,016 ✔
302
                return GraphTransformConfigParser::opDisplayText(op)._phrase.arg(lhs, rhs);
32 ✔
303

304
            return u"%1 %2 %3"_s.arg(lhs, op, rhs);
984 ✔
305
        }
1,016 ✔
306

307
        QString applyOp(const QString& op, const QString& lhs) const
938 ✔
308
        {
938 ✔
309
            if(_forDisplay)
10 !
UNCOV
310
                return GraphTransformConfigParser::opDisplayText(op)._phrase.arg(lhs);
×
311

312
            return u"%1 %2"_s.arg(lhs, op);
10 ✔
313
        }
10 ✔
314

315
        QString operator()(GraphTransformConfig::NoCondition) const { return {}; }
938 ✔
316
        QString operator()(const TerminalCondition& terminalCondition) const
938 ✔
317
        {
972 ✔
318
            auto rhs = terminalValueAsString(terminalCondition._rhs);
972 ✔
319

320
            if(_forDisplay && _attributeDisplayValue)
972 !
321
            {
22 ✔
322
                const auto* attribute = std::get_if<AttributeRef>(&terminalCondition._lhs);
22 ✔
323
                const auto* value = std::get_if<QString>(&terminalCondition._rhs);
22 ✔
324

325
                if(attribute != nullptr && value != nullptr)
22 !
326
                    rhs = _attributeDisplayValue(attribute->_name, *value);
14 ✔
327
            }
22 ✔
328

329
            return applyOp(terminalCondition.opAsString(),
972 ✔
330
                terminalValueAsString(terminalCondition._lhs), rhs);
972 ✔
331
        }
972 ✔
332

333
        QString operator()(const UnaryCondition& unaryCondition) const
938 ✔
334
        {
938 ✔
335
            return applyOp(unaryCondition.opAsString(),
10 ✔
336
                terminalValueAsString(unaryCondition._lhs));
10 ✔
337
        }
10 ✔
338

339
        QString operator()(const RecursiveValue<CompoundCondition>& wrapper) const
938 ✔
340
        {
938 ✔
341
            const auto& compoundCondition = *wrapper;
44 ✔
342

343
            auto operandAsString = [this](const Condition& operand)
44 ✔
344
            {
88 ✔
345
                auto s = std::visit(ConditionVisitor(_forDisplay, _attributeDisplayName, _attributeDisplayValue), operand);
88 ✔
346

347
                if(std::holds_alternative<RecursiveValue<CompoundCondition>>(operand))
88 ✔
348
                    return u"(%1)"_s.arg(s);
12 ✔
349

350
                return s;
76 ✔
351
            };
88 ✔
352

353
            auto lhs = operandAsString(compoundCondition._lhs);
44 ✔
354
            auto rhs = operandAsString(compoundCondition._rhs);
44 ✔
355

356
            return applyOp(compoundCondition.opAsString(), lhs, rhs);
44 ✔
357
        }
44 ✔
358
    };
938 ✔
359

360
    return std::visit(ConditionVisitor(forDisplay, attributeDisplayName, attributeDisplayValue), _condition);
938 ✔
361
}
938 ✔
362

363
QVariantMap GraphTransformConfig::asVariantMap(const GraphTransformFactory* factory) const
364
{
54 ✔
365
    QVariantMap map;
54 ✔
366

367
    QVariantList flags;
54 ✔
368
    flags.reserve(static_cast<int>(_flags.size()));
54 ✔
369
    for(const auto& flag : _flags)
54 ✔
370
        flags.append(flag);
8 ✔
371
    map.insert(u"flags"_s, flags);
54 ✔
372

373
    map.insert(u"action"_s, _action);
54 ✔
374
    map.insert(u"displayName"_s, factory != nullptr ? factory->displayName() : _action);
54 ✔
375

376
    QStringList attributes;
54 ✔
377
    attributes.reserve(static_cast<int>(_attributes.size()));
54 ✔
378
    for(const auto& attribute : _attributes)
54 ✔
379
        attributes.append(Attribute::attributeNameForExpression(attribute));
12 ✔
380
    map.insert(u"attributes"_s, attributes);
54 ✔
381

382
    QVariantList parameters;
54 ✔
383
    for(const auto& parameter : _parameters)
54 ✔
384
    {
26 ✔
385
        QVariantMap parameterMap;
26 ✔
386
        parameterMap.insert(u"name"_s, parameter._name);
26 ✔
387
        parameterMap.insert(u"value"_s, parameter.valueAsString());
26 ✔
388
        parameters.append(parameterMap);
26 ✔
389
    }
26 ✔
390
    map.insert(u"parameters"_s, parameters);
54 ✔
391

392
    if(hasCondition())
54 ✔
393
        map.insert(u"condition"_s, conditionAsVariantMap());
30 ✔
394

395
    return map;
54 ✔
396
}
54 ✔
397

398
QString GraphTransformConfig::asString(NamedBool<"forDisplay"> forDisplay, const GraphTransformFactory* factory,
399
    const AttributeDisplayNameFn& attributeDisplayName, const AttributeDisplayValueFn& attributeDisplayValue) const
400
{
1,302 ✔
401
    if(forDisplay)
1,302 ✔
402
        return asDisplayString(factory, attributeDisplayName, attributeDisplayValue);
28 ✔
403

404
    QString s;
1,274 ✔
405

406
    if(!_flags.empty())
1,274 ✔
407
    {
362 ✔
408
        s += u"["_s;
362 ✔
409
        for(const auto& flag : _flags)
362 ✔
410
        {
362 ✔
411
            if(s[s.length() - 1] != '[')
362 !
UNCOV
412
                s += u", "_s;
×
413

414
            s += flag;
362 ✔
415
        }
362 ✔
416
        s += u"] "_s;
362 ✔
417
    }
362 ✔
418

419
    s += LexyConfigGrammar::stringForExpression(_action);
1,274 ✔
420

421
    if(!_attributes.empty())
1,274 ✔
422
    {
132 ✔
423
        s += u" using"_s;
132 ✔
424

425
        for(const auto& attribute : _attributes)
132 ✔
426
            s += u" $%1"_s.arg(Attribute::attributeNameForExpression(attribute));
158 ✔
427
    }
132 ✔
428

429
    if(!_parameters.empty())
1,274 ✔
430
    {
268 ✔
431
        s += u" with"_s;
268 ✔
432

433
        for(const auto& parameter : _parameters)
268 ✔
434
            s += u" %1 = %2"_s.arg(LexyConfigGrammar::stringForExpression(parameter._name),
394 ✔
435
                parameter.valueAsString("forExpression"_yes));
394 ✔
436
    }
268 ✔
437

438
    if(hasCondition())
1,274 ✔
439
    {
926 ✔
440
        s += u" where "_s;
926 ✔
441
        s += conditionAsString();
926 ✔
442
    }
926 ✔
443

444
    return s;
1,274 ✔
445
}
1,302 ✔
446

447
QString GraphTransformConfig::asDisplayString(const GraphTransformFactory* factory,
448
    const AttributeDisplayNameFn& attributeDisplayName, const AttributeDisplayValueFn& attributeDisplayValue) const
449
{
28 ✔
450
    // Each part wraps those before it, so a translation can put it wherever its language needs
451
    auto s = factory != nullptr ? factory->displayName() : _action;
28 ✔
452

453
    if(!_attributes.empty())
28 ✔
454
    {
10 ✔
455
        QStringList attributes;
10 ✔
456
        attributes.reserve(static_cast<qsizetype>(_attributes.size()));
10 ✔
457

458
        for(const auto& attribute : _attributes)
10 ✔
459
            attributes.append(attributeDisplayName ? attributeDisplayName(attribute) : attribute);
14 !
460

461
        s = TransformDisplayText::usingAttributes().arg(s, attributes.join(u' '));
10 ✔
462
    }
10 ✔
463

464
    if(!_parameters.empty())
28 ✔
465
    {
14 ✔
466
        QStringList parameters;
14 ✔
467
        parameters.reserve(static_cast<qsizetype>(_parameters.size()));
14 ✔
468

469
        for(const auto& parameter : _parameters)
14 ✔
470
        {
18 ✔
471
            auto factoryParameter = factory != nullptr ?
18 ✔
472
                factory->parameter(parameter._name) :
16 ✔
473
                GraphTransformParameter();
18 ✔
474

475
            auto name = !factoryParameter.name().isEmpty() ?
18 ✔
476
                factoryParameter.displayName() :
16 ✔
477
                parameter._name;
18 ✔
478

479
            auto value = parameter.valueAsString();
18 ✔
480
            if(factoryParameter.type() == ValueType::StringList)
18 ✔
481
                value = factoryParameter.displayValue(value);
4 ✔
482

483
            parameters.append(TransformDisplayText::parameter().arg(name, value));
18 ✔
484
        }
18 ✔
485

486
        s = TransformDisplayText::withParameters().arg(s, parameters.join(u' '));
14 ✔
487
    }
14 ✔
488

489
    if(hasCondition())
28 ✔
490
    {
12 ✔
491
        s = TransformDisplayText::whereCondition().arg(s,
12 ✔
492
            conditionAsString("forDisplay"_yes, attributeDisplayName, attributeDisplayValue));
12 ✔
493
    }
12 ✔
494

495
    if(isFlagSet(u"pinned"_s))
28 ✔
496
        s = TransformDisplayText::pinned().arg(s);
4 ✔
497

498
    return s;
28 ✔
499
}
28 ✔
500

501
std::vector<QString> GraphTransformConfig::referencedAttributeNames() const
502
{
1,686 ✔
503
    auto names = _attributes;
1,686 ✔
504

505
    struct ConditionVisitor
1,686 ✔
506
    {
1,686 ✔
507
        explicit ConditionVisitor(std::vector<QString>* innerNames) :
1,686 ✔
508
            _names(innerNames) {}
1,706 ✔
509

510
        std::vector<QString>* _names;
1,686 ✔
511

512
        void operator()(GraphTransformConfig::NoCondition) const {};
1,686 ✔
513

514
        static QString attributeFromTerminalValue(const TerminalValue& terminalValue)
1,686 ✔
515
        {
2,644 ✔
516
            const auto* attribute = std::get_if<AttributeRef>(&terminalValue);
2,644 ✔
517
            return attribute != nullptr ? attribute->_name : QString();
2,644 ✔
518
        }
2,644 ✔
519

520
        void operator()(const TerminalCondition& terminalCondition) const
1,686 ✔
521
        {
1,686 ✔
522
            auto lhs = attributeFromTerminalValue(terminalCondition._lhs);
1,318 ✔
523
            auto rhs = attributeFromTerminalValue(terminalCondition._rhs);
1,318 ✔
524

525
            if(!lhs.isEmpty())
1,318 !
526
            {
1,318 ✔
527
                auto attributeName = Attribute::parseAttributeName(lhs);
1,318 ✔
528
                _names->emplace_back(attributeName._name);
1,318 ✔
529
            }
1,318 ✔
530

531
            if(!rhs.isEmpty())
1,318 !
UNCOV
532
            {
×
UNCOV
533
                auto attributeName = Attribute::parseAttributeName(rhs);
×
UNCOV
534
                _names->emplace_back(attributeName._name);
×
UNCOV
535
            }
×
536
        }
1,318 ✔
537

538
        void operator()(const UnaryCondition& unaryCondition) const
1,686 ✔
539
        {
1,686 ✔
540
            auto lhs = attributeFromTerminalValue(unaryCondition._lhs);
8 ✔
541

542
            if(!lhs.isEmpty())
8 !
543
                _names->emplace_back(lhs);
8 ✔
544
        }
8 ✔
545

546
        void operator()(const RecursiveValue<CompoundCondition>& wrapper) const
1,686 ✔
547
        {
1,686 ✔
548
            const auto& compoundCondition = *wrapper;
10 ✔
549
            std::visit(ConditionVisitor(_names), compoundCondition._lhs);
10 ✔
550
            std::visit(ConditionVisitor(_names), compoundCondition._rhs);
10 ✔
551
        }
10 ✔
552
    };
1,686 ✔
553

554
    std::visit(ConditionVisitor(&names), _condition);
1,686 ✔
555

556
    return names;
1,686 ✔
557
}
1,686 ✔
558

559
bool GraphTransformConfig::equals(const GraphTransformConfig& other,
560
    NamedBool<"ignoreInertFlags"> ignoreInertFlags) const
561
{
114 ✔
562
    std::vector<QString> flagsToIgnore;
114 ✔
563

564
    if(ignoreInertFlags)
114 ✔
565
    {
50 ✔
566
        // These flags do not cause a change in a transform's effect,
567
        // so ignore them for comparison purposes
568
        flagsToIgnore = {"locked", "pinned"};
50 ✔
569
    }
50 ✔
570

571
    auto flags = u::setDifference(_flags, flagsToIgnore);
114 ✔
572
    auto otherFlags = u::setDifference(other._flags, flagsToIgnore);
114 ✔
573

574
    return _action == other._action &&
114 ✔
575
            !u::setsDiffer(_parameters, other._parameters) &&
114 !
576
            !u::setsDiffer(flags, otherFlags) &&
114 ✔
577
            _attributes == other._attributes &&
114 !
578
            _condition == other._condition;
114 ✔
579
}
114 ✔
580

581
bool GraphTransformConfig::isFlagSet(const QString& flag) const
582
{
3,264 ✔
583
    return u::contains(_flags, flag);
3,264 ✔
584
}
3,264 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc