Index: sources/storage/RxProfilesController.cpp =================================================================== diff -u -r1f927e37764a81fb6538b5cf7a74d8beacf56aac -r4dfe31f9c42a18b2ea10c1fe6fe315e39c0e23b3 --- sources/storage/RxProfilesController.cpp (.../RxProfilesController.cpp) (revision 1f927e37764a81fb6538b5cf7a74d8beacf56aac) +++ sources/storage/RxProfilesController.cpp (.../RxProfilesController.cpp) (revision 4dfe31f9c42a18b2ea10c1fe6fe315e39c0e23b3) @@ -32,14 +32,12 @@ #define FLOAT3 0,'f',3 #define ADDTITLE(vTITLE) logContent += QString("[%1]\n").arg(vTITLE) #define ADDALINE(vTEXT ) logContent += QString("%1\n" ).arg(vTEXT ) -/* -#define ADDTOLOG( vINDEX ) index = vINDEX; logContent += title(index) + _sep + value(index) + _sep + unit(index) + "\n"; -#define ADDTOLOG_MT(vINDEX, vVALUE ) \ - index = vINDEX; \ - logContent += title(index) + _sep + \ - ( value(index).trimmed().isEmpty() ? vVALUE : value(index) ) + _sep + \ - unit(index) + "\n"; -*/ + +//#define ADDTOLOG( vINDEX ) index = vINDEX; logContent += title(index) + _sep + value(index) + _sep + unit(index) + "\n"; +#define ADDTOLOG_MT(vINDEX, vVALUE, vTITLES ) \ + logContent += vTITLES[vINDEX] + _sep + \ + ( vVALUE[vINDEX] ) + "\n"; + /*! * \brief RxProfiles::RxProfiles * The constructor to initial the Treatment Log @@ -66,8 +64,6 @@ connect(&_DeviceController , SIGNAL(didReadFilesList(const QFileInfoList &)), this , SLOT(onReceieveRxProfileList(const QFileInfoList &))); -// connect(&_DeviceController , SIGNAL(didReadFilesList(const QFileInfoList &)), -// this , SIGNAL(didRxProfileList(const QFileInfoList &))); } void RxProfiles::doInitRxProfiles() @@ -96,63 +92,41 @@ QSettings rxSettings(rxProfile.absoluteFilePath(), QSettings::IniFormat); for (int i = 0; i < Model::RxProfilesIndex::eRxContentIndexCount; i++){ QString rxTitle = Model::MRxProfilesData::titles()[i]; - if ( rxSettings.contains(rxTitle) ){ + if ( rxSettings.contains(rxTitle) ) + { rxData.rxProfileContent.append(rxSettings.value(rxTitle).toString()); - } - else{ - qDebug() << "No Choochoob" << rxSettings.allKeys(); - } + } else goto lError; } //Order of the below does matter to match the enum index - rxData.rxProfileContent.append(rxProfile.baseName().replace("_", " ")); //eProfileName + rxData.rxProfileContent.append(rxProfile.baseName().replace(_underscore, " ")); //eProfileName rxData.rxProfileContent.append("false"); rxData.rxProfileContent.append(rxProfile.lastModified().date().toString("MM-dd-yyyy")); +lError: return rxData; } -//void RxProfiles::readFavorite(const QString &vFile) -//{ -// QString content; -// QFileInfo rxProfile(vFile); -// Storage::FileHandler::read(vFile, content); -// QStringList lines = content.split('\n'); -// for ( const QString &line : lines ) { -// QStringList fields = line.split(','); -// if ( fields.count() >= Role::eCount ) { -// QString key = QString(fields[0].trimmed()); -// QString value = fields.mid(1).join(", ").trimmed(); // TODO: Remove comma adjustment when Acid and Bicarb structure change -// //TODO: Add to model structure and add error checking -// _values[_rxKeyMap[key]] = QString(value); -// } -// } -// _values[eProfileName] = rxProfile.baseName(); -// _values[eFavorite] = false; // TODO: add conf file read here -// _values[eLastModifiedDate] = rxProfile.lastModified().date().toString("MM-dd-yyyy"); - -//} - // ----- Save /*! * \brief RxProfiles::doSave * The save slot to be exposed to the UI to be able to request for save */ -void RxProfiles::doSave(const QString &fileName) +void RxProfiles::doSave(const QStringList &RxModel) { if (_saveWatcher.isRunning()) return; isIdle(false); - saveLogConcurrent(fileName); + saveLogConcurrent(RxModel); } /*! * \brief RxProfiles::saveLogConcurrent * The treatment log save which is using a thread pool to run the save process. */ -void RxProfiles::saveLogConcurrent(const QString &fileName) +void RxProfiles::saveLogConcurrent(const QStringList &RxModel) { LOG_DEBUG("Save Treatment Log Started"); - QFuture mFuture = QtConcurrent::run(this, &RxProfiles::saveLog, fileName); + QFuture mFuture = QtConcurrent::run(this, &RxProfiles::saveLog, RxModel); _saveWatcher.setFuture(mFuture); } @@ -161,36 +135,37 @@ * The actual treatment log save function which does the save into the Prescription log * \return true on successful save and false otherwise. */ -bool RxProfiles::saveLog(const QString &fileName) +bool RxProfiles::saveLog(const QStringList &RxModel) { -// _lastTxInfo.clear(); - bool ok = (unsigned)_values.count() >= Model::RxProfilesIndex::eRxProfilesIndexCount; + bool ok = RxModel.size() >= Model::RxProfilesIndex::eRxProfilesIndexCount - 1; if (!ok) return false; -// QString logContent ; -// QString csv = "%1" + _sep ; -// QString end = "%1" ; -// uint index = 0 ; + QString logContent ; + QString fileName = QString("%1%2.%3").arg(_rxProfilesPath, + RxModel[Model::RxProfilesIndex::eRxContentIndexCount], + _rxProfiles); + fileName.replace(" ", _underscore); -// ADDTITLE("Treatment Parameters" ); -// ADDTOLOG( eTreatmentDuration ); -// ADDTOLOG( eBloodFlowRate ); -// ADDTOLOG( eDialysateFlowRate ); -// ADDTOLOG( eAcidConcentrateType ); -// ADDTOLOG( eBicarbonateConcentrateType ); -// ADDTOLOG( eDialysateTemperature ); -// ADDTOLOG( eDialyzerType ); -// ADDTOLOG( eHeparinConcentration ); -// ADDTOLOG( eHeparinBolusVolume ); -// ADDTOLOG( eHeparinDispenseRate ); -// ADDTOLOG( eHeparinStop ); + ADDTOLOG_MT( Model::RxProfilesIndex::eBloodFlowRate , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eDialysateFlowRate , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eTreatmentDuration , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eAcidConcentrateType , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eBicarbonateConcentrateType , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eDialysateTemperature , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eDialyzerType , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eHeparinConcentration , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eHeparinBolusVolume , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eHeparinDispenseRate , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eHeparinStop , RxModel , Model::MRxProfilesData::titles() ); + ADDTOLOG_MT( Model::RxProfilesIndex::eVitalSigns , RxModel , Model::MRxProfilesData::titles() ); -// //DEBUG qDebug() << _lastTxInfo.mFileName; -// ok = Storage::FileHandler::makeFolder(_rxProfilesPath); -// if ( ! ok ) { LOG_DEBUG(QString("Cannot create folder %1").arg(_rxProfilesPath )); return ok; } -// ok = Storage::FileHandler::write(fileName, logContent, false); - if ( ! ok ) { LOG_DEBUG(QString("Cannot write to file %1").arg(fileName)); return ok; } +// qDebug() << "WRITING FILE: " < vRxProfileDataList; for (const QFileInfo fileInfo:vRxProfileList){ - vRxProfileDataList.append(initModel(fileInfo)); + RxProfilesData rxData = initModel(fileInfo) ; + if (rxData.rxProfileContent.size() == Model::RxProfilesIndex::eRxProfilesIndexCount - 1) + { + vRxProfileDataList.append(rxData); + } + else LOG_DEBUG(QString("Bad Prescription Log Given: %1, %2").arg(fileInfo.baseName(), + QString::number( rxData.rxProfileContent.size() ))); } - emit didRxProfileList(vRxProfileDataList); //TODO: change to vRxProfileDataList + //below is Test to write a file +// QStringList rxDataTest = vRxProfileDataList[0].rxProfileContent; +// rxDataTest.replace(Model::RxProfilesIndex::eProfileName, QString("Written New Rx")) ; +// // rxProfileContent +// doSave(rxDataTest); + emit didRxProfileList(vRxProfileDataList); } /*! Index: sources/storage/RxProfilesController.h =================================================================== diff -u -r1f927e37764a81fb6538b5cf7a74d8beacf56aac -r4dfe31f9c42a18b2ea10c1fe6fe315e39c0e23b3 --- sources/storage/RxProfilesController.h (.../RxProfilesController.h) (revision 1f927e37764a81fb6538b5cf7a74d8beacf56aac) +++ sources/storage/RxProfilesController.h (.../RxProfilesController.h) (revision 4dfe31f9c42a18b2ea10c1fe6fe315e39c0e23b3) @@ -43,7 +43,8 @@ int _pendingCounter = 0 ; // const int _RxLimit = 10 ; // SRS- - const QString _sep = ","; + const QString _sep = "="; + const QString _underscore = "_"; QString _rxProfilesPath; const char* _rxProfiles = "rxp"; @@ -71,15 +72,10 @@ return str; } - QString value(quint8 vIndex) const { return string(vIndex, _values );} - - // Lists - QStringList _values; - void initConnections(); - bool saveLog (const QString &fileName); - void saveLogConcurrent (const QString &fileName); + bool saveLog (const QStringList &RxModel); + void saveLogConcurrent (const QStringList &RxModel); bool exportLog (); void exportLogConcurrent(); bool importLog (); @@ -108,7 +104,7 @@ public slots: // void doFavorite (); - void doSave (const QString &fileName); + void doSave (const QStringList &RxModel); void doExport (); void doImport (); void doInitRxProfiles(); Index: sources/view/VRxProfiles.cpp =================================================================== diff -u -r9f2f52d19e8cf2a2e93b521439ae4b9c0dc1ba56 -r4dfe31f9c42a18b2ea10c1fe6fe315e39c0e23b3 --- sources/view/VRxProfiles.cpp (.../VRxProfiles.cpp) (revision 9f2f52d19e8cf2a2e93b521439ae4b9c0dc1ba56) +++ sources/view/VRxProfiles.cpp (.../VRxProfiles.cpp) (revision 4dfe31f9c42a18b2ea10c1fe6fe315e39c0e23b3) @@ -36,7 +36,10 @@ _rxProfilesModels(this) { connect (this, SIGNAL(didRxProfileList()), &_RxProfilesController, SLOT(doInitRxProfiles())); + ACTION_METHOD_BRIDGE_CONNECTION(RxProfileList, _RxProfilesController, QList) + + QQmlEngine::setObjectOwnership(&_rxProfilesModels, QQmlEngine::CppOwnership); _rxProfilesModels.setRoleNames({ { eDataRole_BloodFlow , "bloodFlow" }, @@ -76,22 +79,6 @@ for (int i = 0; i < rxData.rxProfileContent.size(); ++i) { hash.insert(i+Qt::UserRole, QVariant(rxData.rxProfileContent.at(i))); } -// hash[eDataRole_BloodFlow ] = QVariant(rxData.rxProfileContent.at(eDataRole_BloodFlow )); -// hash[eDataRole_DialysateFlow ] = QVariant(rxData.rxProfileContent.at(eDataRole_DialysateFlow )); -// hash[eDataRole_TreatmentDuration ] = QVariant(rxData.rxProfileContent.at(eDataRole_TreatmentDuration )); -// hash[eDataRole_AcidConcentrateType ] = QVariant(rxData.rxProfileContent.at(eDataRole_AcidConcentrateType )); -// hash[eDataRole_BicarbonateConcentrateType ] = QVariant(rxData.rxProfileContent.at(eDataRole_BicarbonateConcentrateType )); -// hash[eDataRole_DialysateTemperature ] = QVariant(rxData.rxProfileContent.at(eDataRole_DialysateTemperature )); -// hash[eDataRole_DialyzerType ] = QVariant(rxData.rxProfileContent.at(eDataRole_DialyzerType )); -// hash[eDataRole_HeparinConcentration ] = QVariant(rxData.rxProfileContent.at(eDataRole_HeparinConcentration )); -// hash[eDataRole_HeparinBolusVolume ] = QVariant(rxData.rxProfileContent.at(eDataRole_HeparinBolusVolume )); -// hash[eDataRole_HeparinDispenseRate ] = QVariant(rxData.rxProfileContent.at(eDataRole_HeparinDispenseRate )); -// hash[eDataRole_HeparinStop ] = QVariant(rxData.rxProfileContent.at(eDataRole_HeparinStop )); -// hash[eDataRole_VitalSigns ] = QVariant(rxData.rxProfileContent.at(eDataRole_VitalSigns )); -// hash[eDataRole_ProfileName ] = QVariant(rxData.rxProfileContent.at(eDataRole_ProfileName )); -// hash[eDataRole_Favorite ] = QVariant(rxData.rxProfileContent.at(eDataRole_Favorite )); -// hash[eDataRole_LastModifiedDate ] = QVariant(rxData.rxProfileContent.at(eDataRole_LastModifiedDate )); -// hash[eDataRole_RecentlyUsedDate ] = QVariant(rxData.rxProfileContent.at(eDataRole_RecentlyUsedDate )); RxProfilesList.append(hash); } Index: sources/view/VRxProfiles.h =================================================================== diff -u -r1f927e37764a81fb6538b5cf7a74d8beacf56aac -r4dfe31f9c42a18b2ea10c1fe6fe315e39c0e23b3 --- sources/view/VRxProfiles.h (.../VRxProfiles.h) (revision 1f927e37764a81fb6538b5cf7a74d8beacf56aac) +++ sources/view/VRxProfiles.h (.../VRxProfiles.h) (revision 4dfe31f9c42a18b2ea10c1fe6fe315e39c0e23b3) @@ -45,7 +45,7 @@ // friends friend class::tst_views; - PROPERTY(QStringList , rxProfilesList , {}) +// PROPERTY(QStringList , rxProfilesList , {}) Q_PROPERTY(MListModel* rxProfiles READ rxProfiles CONSTANT)