MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / PresetRule

Class PresetRule

src/data/PresetRule.h:10–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "model/RouteListModel.h"
9
10class PresetRule
11{
12public:
13 PresetRule(){}
14 PresetRule(QJsonObject pkg)
15 {
16 deviceName = pkg.value("deviceName").toString();
17 deviceId = pkg.value("deviceId").toString();
18 preset = pkg.value("preset").toString();
19
20 Route defaultRoute = RouteListModel::makeDefaultRoute();
21 if(!pkg.contains("routeId") || !pkg.contains("routeName")) {
22 routeName = QString::fromStdString(defaultRoute.description);
23 routeId = QString::fromStdString(defaultRoute.name);
24 }
25 else {
26 routeName = pkg.value("routeName").toString();
27 routeId = pkg.value("routeId").toString();
28 }
29 }
30
31 PresetRule(IOutputDevice device, Route route, const QString& _preset)
32 {
33 deviceName = QString::fromStdString(device.description);
34 deviceId = QString::fromStdString(device.name);
35 routeName = QString::fromStdString(route.description);
36 routeId = QString::fromStdString(route.name);
37 preset = _preset;
38 }
39
40
41 PresetRule(const QString& deviceId, const QString& routeId, const QString& preset)
42 : deviceName(deviceId), deviceId(deviceId), preset(preset), routeName(routeId), routeId(routeId) {}
43
44 PresetRule(const QString& deviceName, const QString& deviceId, const QString& routeName, const QString& routeId, const QString& preset)
45 : deviceName(deviceName), deviceId(deviceId), preset(preset), routeName(routeName), routeId(routeId) {}
46
47 QJsonObject toJson() const
48 {
49 QJsonObject pkg;
50 pkg["deviceName"] = deviceName;
51 pkg["deviceId"] = deviceId;
52 pkg["preset"] = preset;
53 pkg["routeName"] = routeName;
54 pkg["routeId"] = routeId;
55 return pkg;
56 }
57
58 bool operator==(const PresetRule &rhs)
59 {
60 return this->deviceName == rhs.deviceName &&
61 this->deviceId == rhs.deviceId &&
62 this->routeName == rhs.routeName &&
63 this->routeId == rhs.routeId &&
64 this->preset == rhs.preset;
65 }
66
67 QString deviceName;

Callers 5

addPresetRuleMethod · 0.85
setPresetRuleMethod · 0.85
ruleMethod · 0.85
loadRulesMethod · 0.85
atMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected