File indexing completed on 2024-05-19 05:49:11

0001 /*
0002     KApacheLog, a apache log viewer tool
0003     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "acpidConfigurationWidget.h"
0009 
0010 AcpidConfigurationWidget::AcpidConfigurationWidget()
0011     : LogModeConfigurationWidget(i18n("Acpid Log"), QStringLiteral(ACPID_MODE_ICON), i18n("Acpid Log"))
0012 {
0013     auto layout = new QHBoxLayout(this);
0014 
0015     mFileList = new FileList(this, i18n("<p>These files will be analyzed to show the <b>Acpid log</b>.</p>"));
0016     connect(mFileList, &FileList::fileListChanged, this, &LogModeConfigurationWidget::configurationChanged);
0017     layout->addWidget(mFileList);
0018 }
0019 
0020 void AcpidConfigurationWidget::saveConfig()
0021 {
0022     auto *acpidConfiguration = Globals::instance().findLogMode(QStringLiteral(ACPID_LOG_MODE_ID))->logModeConfiguration<AcpidConfiguration *>();
0023 
0024     acpidConfiguration->setAcpidPaths(mFileList->paths());
0025 }
0026 
0027 void AcpidConfigurationWidget::readConfig()
0028 {
0029     auto *acpidConfiguration = Globals::instance().findLogMode(QStringLiteral(ACPID_LOG_MODE_ID))->logModeConfiguration<AcpidConfiguration *>();
0030 
0031     mFileList->removeAllItems();
0032 
0033     mFileList->addPaths(acpidConfiguration->acpidPaths());
0034 }
0035 
0036 void AcpidConfigurationWidget::defaultConfig()
0037 {
0038     // TODO Find a way to read the configuration per default
0039     readConfig();
0040 }
0041 
0042 bool AcpidConfigurationWidget::isValid() const
0043 {
0044     if (!mFileList->isEmpty()) {
0045         return true;
0046     }
0047 
0048     return false;
0049 }
0050 
0051 #include "moc_acpidConfigurationWidget.cpp"