Changeset View
Changeset View
Standalone View
Standalone View
src/core/machineinfo.cpp
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 58 | { | |||
---|---|---|---|---|---|
61 | return instance(); | 61 | return instance(); | ||
62 | } | 62 | } | ||
63 | 63 | | |||
64 | QVariantMap MachineInfo::readProfile(const QString &profileName) const | 64 | QVariantMap MachineInfo::readProfile(const QString &profileName) const | ||
65 | { | 65 | { | ||
66 | m_settings->sync(); | 66 | m_settings->sync(); | ||
67 | m_settings->beginGroup(profileName); | 67 | m_settings->beginGroup(profileName); | ||
68 | QVariantMap data{{decoderMap[KEY::NAME].name, m_settings->group()}}; | 68 | QVariantMap data{{decoderMap[KEY::NAME].name, m_settings->group()}}; | ||
69 | for (int i = 1 ; i <= 10; i++) { | 69 | for (int i = 1; i < decoderMap.size(); i++) { | ||
70 | data.insert(decoderMap[MachineInfo::KEY(i)].name, m_settings->value(decoderMap[MachineInfo::KEY(i)].name, decoderMap[MachineInfo::KEY(i)].defaultValue)); | 70 | data.insert(decoderMap[MachineInfo::KEY(i)].name, m_settings->value(decoderMap[MachineInfo::KEY(i)].name, decoderMap[MachineInfo::KEY(i)].defaultValue)); | ||
71 | } | 71 | } | ||
72 | m_settings->endGroup(); | 72 | m_settings->endGroup(); | ||
73 | return data; | 73 | return data; | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | QVariant MachineInfo::readKey(const QString &profileName, MachineInfo::KEY key) const | 76 | QVariant MachineInfo::readKey(const QString &profileName, MachineInfo::KEY key) const | ||
77 | { | 77 | { | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 115 | { | |||
124 | } | 124 | } | ||
125 | 125 | | |||
126 | if (srcProfile == destProfile) { | 126 | if (srcProfile == destProfile) { | ||
127 | qCWarning(MACHINE_INFO) << "Profile Copy Error: Source is Destination."; | 127 | qCWarning(MACHINE_INFO) << "Profile Copy Error: Source is Destination."; | ||
128 | return false; | 128 | return false; | ||
129 | } | 129 | } | ||
130 | QVariantMap newProfile = readProfile(srcProfile); | 130 | QVariantMap newProfile = readProfile(srcProfile); | ||
131 | m_settings->beginGroup(destProfile); | 131 | m_settings->beginGroup(destProfile); | ||
132 | for (int i = 1 ; i <= 10; i++) { | 132 | for (int i = 1; i < decoderMap.size(); i++) { | ||
patrickelectric: Are you sure that is <= `with .side()` ? | |||||
133 | m_settings->setValue(decoderMap[MachineInfo::KEY(i)].name, newProfile[decoderMap[MachineInfo::KEY(i)].name]); | 133 | m_settings->setValue(decoderMap[MachineInfo::KEY(i)].name, newProfile[decoderMap[MachineInfo::KEY(i)].name]); | ||
134 | } | 134 | } | ||
135 | m_settings->endGroup(); | 135 | m_settings->endGroup(); | ||
136 | m_settings->sync(); | 136 | m_settings->sync(); | ||
137 | if (rmSrc) { | 137 | if (rmSrc) { | ||
138 | removeProfile(srcProfile); | 138 | removeProfile(srcProfile); | ||
139 | //removeProfile emits profilesChanged | 139 | //removeProfile emits profilesChanged | ||
140 | } else { | 140 | } else { | ||
Show All 14 Lines | 147 | { | |||
155 | m_settings->sync(); | 155 | m_settings->sync(); | ||
156 | emit profilesChanged(); | 156 | emit profilesChanged(); | ||
157 | return true; | 157 | return true; | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | void MachineInfo::storeProfile(const QMap<MachineInfo::KEY, QVariant> &profile) const | 160 | void MachineInfo::storeProfile(const QMap<MachineInfo::KEY, QVariant> &profile) const | ||
161 | { | 161 | { | ||
162 | m_settings->beginGroup(profile[KEY::NAME].toString()); | 162 | m_settings->beginGroup(profile[KEY::NAME].toString()); | ||
163 | for (int i = 1 ; i <= 10; i++) { | 163 | for (int i = 1; i < decoderMap.size(); i++) { | ||
164 | m_settings->setValue(decoderMap[MachineInfo::KEY(i)].name, profile[MachineInfo::KEY(i)]); | 164 | m_settings->setValue(decoderMap[MachineInfo::KEY(i)].name, profile[MachineInfo::KEY(i)]); | ||
165 | } | 165 | } | ||
166 | m_settings->endGroup(); | 166 | m_settings->endGroup(); | ||
167 | m_settings->sync(); | 167 | m_settings->sync(); | ||
168 | emit profilesChanged(); | 168 | emit profilesChanged(); | ||
169 | } | 169 | } | ||
170 | 170 | | |||
171 | void MachineInfo::storeProfile(const QVariantMap &profile) const | 171 | void MachineInfo::storeProfile(const QVariantMap &profile) const | ||
Show All 24 Lines |
Are you sure that is <= with .side() ?