Index: sources/view/settings/VSettings.cpp =================================================================== diff -u -redb8ee3edc41b1d324cd8a53e8e27a2a58289563 -red3945bdd13d73f5cb1aec03fafa1697be5f1b66 --- sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision edb8ee3edc41b1d324cd8a53e8e27a2a58289563) +++ sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision ed3945bdd13d73f5cb1aec03fafa1697be5f1b66) @@ -37,11 +37,13 @@ { static bool init = false; if ( init ) return; - PROPERTY_POST_CONNECTION(VSettings, servicePass ); - PROPERTY_POST_CONNECTION(VSettings, alarmVolume ); - PROPERTY_POST_CONNECTION(VSettings, roWaterMode ); - PROPERTY_POST_CONNECTION(VSettings, userMode ); - + PROPERTY_POST_CONNECTION(VSettings, servicePass ); + PROPERTY_POST_CONNECTION(VSettings, alarmVolume ); + PROPERTY_POST_CONNECTION(VSettings, roWaterMode ); + PROPERTY_POST_CONNECTION(VSettings, integratedBPCuff ); + PROPERTY_POST_CONNECTION(VSettings, heparinSyringePump ); + PROPERTY_POST_CONNECTION(VSettings, chemicalDisinfection); + PROPERTY_POST_CONNECTION(VSettings, advancedMode); init = true; } @@ -61,14 +63,36 @@ } } -void VSettings::userMode_post(const bool &vuserMode_post) { +void VSettings::advancedMode_post(const bool &vadvancedMode_post) { //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. - if ( Storage::Settings::save(userModeGroup(), userModeKey(), QString::number(vuserMode_post)) != 0 ) { - userMode(false); + if ( Storage::Settings::save(advancedModeGroup(), advancedModeKey(), QString::number(vadvancedMode_post)) != 0 ) { + advancedMode(false); + } +} +void VSettings::integratedBPCuff_post(const bool &vintegratedBPCuff_post) { + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. + if ( Storage::Settings::save(integratedBPCuffGroup(), integratedBPCuffKey(), QString::number(vintegratedBPCuff_post)) != 0 ) { + integratedBPCuff(false); // FIXME: Notify UI with a message } } +void VSettings::heparinSyringePump_post(const bool &vheparinSyringePump_post) { + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. + if ( Storage::Settings::save(heparinSyringePumpGroup(), heparinSyringePumpKey(), QString::number(vheparinSyringePump_post)) != 0 ) { + heparinSyringePump(false); + // FIXME: Notify UI with a message + } +} + +void VSettings::chemicalDisinfection_post(const bool &vchemicalDisinfection_post) { + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. + if ( Storage::Settings::save(chemicalDisinfectionGroup(), chemicalDisinfectionKey(), QString::number(vchemicalDisinfection_post)) != 0 ) { + chemicalDisinfection(false); + // FIXME: Notify UI with a message + } +} + void VSettings::alarmVolume_post(const quint8 &valarmVolume) { //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. Storage::Settings::save(alarmVolumeGroup(), alarmVolumeKey(), QString::number(valarmVolume)); @@ -82,12 +106,25 @@ for (const auto &category : mCategorys) { QStringList groups = _Settings.groups(category); for (const auto &group : groups) { - QStringList keys = _Settings.keys (category, group); - QVariantList values = _Settings.values (category, group); + QStringList keys ; + QVariantList values ; + QString title = ""; + for (const QString &key : _Settings.keys(category, group)) { + if (Storage::Settings::isKeyTitle ( key ) ) { + title = _Settings.value(category, group, key).toString(); + } else { + const QString imagePath = QStringLiteral("%1%2").arg(_location) + .arg(_Settings.value(category, group, key).toString()); + QFileInfo fileInfo(imagePath); + values.append(fileInfo.exists() && fileInfo.isFile() ? "file:" + imagePath : ""); + keys.append(key); + } + } + if ( Storage::Settings::isCategoryInstructions( category ) ) { - TKeysList keysList = updateReplacements(group, keys ); - updateInstructions(group, keysList, values ); - updateInstructions(group ); + TKeysList keysList = updateReplacements(group, keys ); + updateInstructions(group, keysList, values, title ); + updateInstructions(group ); } else { //TODO: Since it is global system settings, move this to the settings controller so the C++ backend can also use it. like Date/Time formats. for (const auto &key : qAsConst(keys)) { @@ -105,12 +142,30 @@ keyValue[key] = mRoWaterMode ; roWaterMode ( mRoWaterMode); } - else if ( isuserMode (category, group, key) ) { - bool mUserMode; - mUserMode = _Settings.value(category, group, key).toBool (); - keyValue[key] = mUserMode ; - userMode ( mUserMode); + else if ( isadvancedMode(category, group, key) ) { + bool mAdvancedMode; + mAdvancedMode = _Settings.value(category, group, key).toBool (); + keyValue[key] = mAdvancedMode ; + advancedMode ( mAdvancedMode ); } + else if ( isintegratedBPCuff (category, group, key) ) { + bool mIntegratedBPCuff; + mIntegratedBPCuff = _Settings.value(category, group, key).toBool (); + keyValue[key] = mIntegratedBPCuff ; + integratedBPCuff ( mIntegratedBPCuff ); + } + else if ( isheparinSyringePump (category, group, key) ) { + bool mHeparinSyringePump; + mHeparinSyringePump = _Settings.value(category, group, key).toBool (); + keyValue[key] = mHeparinSyringePump ; + heparinSyringePump ( mHeparinSyringePump ); + } + else if ( ischemicalDisinfection (category, group, key) ) { + bool mChemicalDisinfection; + mChemicalDisinfection = _Settings.value(category, group, key).toBool (); + keyValue[key] = mChemicalDisinfection ; + chemicalDisinfection ( mChemicalDisinfection ); + } else if ( isalarmVolume (category, group, key) ) { quint8 mAlarmVolume; mAlarmVolume = _Settings.value(category, group, key).toInt (); // returns 0 if fails, so no error checking needed. @@ -133,7 +188,7 @@ servicePass ( _servicePass ); alarmVolume ( _alarmVolume ); roWaterMode ( _roWaterMode ); - userMode ( _userMode ); + advancedMode( _advancedMode ); //DEBUG qDebug() << servicePass() << roWaterMode() << alarmVolume(); adjustment(true); @@ -177,10 +232,10 @@ return keysList; } -void VSettings::updateInstructions(const QString &vGroup, const TKeysList &vKeysList, const QVariantList &vValues) +void VSettings::updateInstructions(const QString &vGroup, const TKeysList &vKeysList, const QVariantList &vValues, const QString &vTitle) { TInstruction mInstruction; - mInstruction.location = _location; + mInstruction.title = vTitle; mInstruction.keys = vKeysList; mInstruction.values = vValues ; _instructionMap[vGroup] = mInstruction; @@ -191,12 +246,13 @@ //TODO: this function or even the structure may need to update to send less data to qml and only the updated part. TKeysList keysList = _instructionMap[vGroup].keys ; QVariantList values = _instructionMap[vGroup].values; + QString title = _instructionMap[vGroup].title; QStringList keyList; for ( const auto &keys : keysList) { keyList += keys.join(""); } QVariantMap details; - details["location"] = _location ; + details["title"] = title ; details["keys" ] = keyList ; details["values" ] = values ; _instructions[vGroup] = details ;