Index: sources/storage/Settings.cpp =================================================================== diff -u -r4fd6a7d7801d91ffbce9e8d4b54900224f6a0fac -r0eb3d05f90d7ed90eadfab6c0c1db76fa2a70fb6 --- sources/storage/Settings.cpp (.../Settings.cpp) (revision 4fd6a7d7801d91ffbce9e8d4b54900224f6a0fac) +++ sources/storage/Settings.cpp (.../Settings.cpp) (revision 0eb3d05f90d7ed90eadfab6c0c1db76fa2a70fb6) @@ -52,33 +52,36 @@ /*! * \brief Settings::doRead * \details Reads all the configuration files + * \return non-zero, error value on error, and zero on success. */ int Settings::read() { - int err = Settings::Settings_Error::eError_None; + int err = Settings::Settings_Error::eError_None; QStringList fileFilter = QStringList() << QString("*.%1").arg(_settingsExt); QFileInfoList settingFiles = FileHandler::find (Storage::Settings_Path(), fileFilter); QStringList settingFolders = FileHandler::subFolders(Storage::Settings_Path()); if ( ! settingFolders.count() ) { err = Settings::Settings_Error::eError_No_SettingsFolder; - LOG_DEBUG(errorMessage(err).arg(Storage::Settings_Path())); + LOG_APPED_PO(errorMessage(err).arg(Storage::Settings_Path())); return err; } for ( QString &settingFolder : settingFolders ) { QString folder = settingFolder.prepend(Storage::Settings_Path()); settingFiles += FileHandler::find(folder, fileFilter); } + // DEBUG: // settingFiles = // { // QFileInfo("/home/denali/Projects/application/resources/settings/Confirm/Confirm.conf"), // QFileInfo("/home/denali/Projects/application/resources/settings/Alarms/Alarms.conf") // }; + if ( ! settingFiles.count() ) { err = Settings::Settings_Error::eError_No_SettingsFile; - LOG_DEBUG(errorMessage(err).arg(Storage::Settings_Path())); + LOG_APPED_PO(errorMessage(err).arg(Storage::Settings_Path())); return err; } @@ -88,13 +91,20 @@ QFile file(settingFile.absoluteFilePath()); if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) { - err = Settings::Settings_Error::eError_ConfigFileReadFail; - LOG_DEBUG(errorMessage(err).arg(Storage::Settings_Path())); + err = Settings::Settings_Error::eError_Read; + LOG_APPED_PO(errorMessage(err).arg(Storage::Settings_Path())); return err; } + Detail detail; detail.content = file.readAll().trimmed(); - if (detail.content.isEmpty()) continue; + if (detail.content.isEmpty()) { + //TODO Do not error out for now, the list of the config files which can be empty or not needs to be defined. + // err = Settings::Settings_Error::eError_Empty; + LOG_APPED_PO(errorMessage(Settings::Settings_Error::eError_Empty).arg(settingFile.fileName())); + continue; + } + detail.location = settingFile.absolutePath() + "/"; detail.category = QString(detail.location + settingFile.baseName()).remove(Storage::Settings_Path()); details += detail; @@ -128,7 +138,7 @@ else if ( line == attribute.arg(_duplicate_key_off ) ) { enableDuplicateKey = false ;} else { - LOG_APPED_UI(( "Unknown '" + line + "' attribute in %1").arg(detail.category)); + LOG_APPED_PO(( "Unknown '" + line + "' attribute in %1").arg(detail.category)); } }