1 #include "auditConfigurationWidget.h" 2 3 #include <KLocalizedString> 4 5 #include "globals.h" 6 7 #include "ksystemlog_debug.h" 8 #include "logLevelFileList.h" 9 10 #include "auditConfiguration.h" 11 #include "auditLogMode.h" 12 AuditConfigurationWidget()13AuditConfigurationWidget::AuditConfigurationWidget() 14 : LogModeConfigurationWidget(i18n("Audit Log"), QStringLiteral(AUDIT_MODE_ICON), i18n("Audit Log")) 15 { 16 QVBoxLayout *layout = new QVBoxLayout(this); 17 18 const QString description = i18n("<p>These files will be analyzed to show the <b>Audit logs</b>.</p>"); 19 20 fileList = new LogLevelFileList(this, description); 21 22 connect(fileList, &FileList::fileListChanged, this, &LogModeConfigurationWidget::configurationChanged); 23 24 layout->addWidget(fileList); 25 } 26 isValid() const27bool AuditConfigurationWidget::isValid() const 28 { 29 if (!fileList->isEmpty()) { 30 qCDebug(KSYSTEMLOG) << "Audit configuration valid"; 31 return true; 32 } 33 34 qCDebug(KSYSTEMLOG) << "Audit configuration not valid"; 35 return false; 36 } 37 saveConfig()38void AuditConfigurationWidget::saveConfig() 39 { 40 qCDebug(KSYSTEMLOG) << "Saving config from Audit Options..."; 41 42 AuditConfiguration *auditConfiguration = Globals::instance().findLogMode(QStringLiteral(AUDIT_LOG_MODE_ID))->logModeConfiguration<AuditConfiguration *>(); 43 auditConfiguration->setLogFilesPaths(fileList->paths()); 44 auditConfiguration->setLogFilesLevels(fileList->levels()); 45 } 46 readConfig()47void AuditConfigurationWidget::readConfig() 48 { 49 AuditConfiguration *auditConfiguration = Globals::instance().findLogMode(QStringLiteral(AUDIT_LOG_MODE_ID))->logModeConfiguration<AuditConfiguration *>(); 50 fileList->removeAllItems(); 51 fileList->addPaths(auditConfiguration->logFilesPaths(), auditConfiguration->logFilesLevels()); 52 } 53 defaultConfig()54void AuditConfigurationWidget::defaultConfig() 55 { 56 readConfig(); 57 } 58