File indexing completed on 2024-05-19 05:49:12
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 "apacheConfigurationWidget.h" 0009 0010 ApacheConfigurationWidget::ApacheConfigurationWidget() 0011 : LogModeConfigurationWidget(i18n("Apache Log"), QStringLiteral(APACHE_MODE_ICON), i18n("Apache Log")) 0012 { 0013 auto layout = new QHBoxLayout(this); 0014 0015 mApacheFileList = new MultipleFileList(this, 0016 i18n("<p>These files will be analyzed to show the <b>Apache log</b> " 0017 "and the <b>Apache Access log</b>.</p>")); 0018 0019 mApachePathsId = mApacheFileList->addCategory(i18n("Apache Log Files"), i18n("Add Apache File...")); 0020 mApacheAccessPathsId = mApacheFileList->addCategory(i18n("Apache Access Log Files"), i18n("Add Apache Access File...")); 0021 0022 connect(mApacheFileList, &MultipleFileList::fileListChanged, this, &LogModeConfigurationWidget::configurationChanged); 0023 0024 layout->addWidget(mApacheFileList); 0025 } 0026 0027 void ApacheConfigurationWidget::saveConfig() 0028 { 0029 qCDebug(KSYSTEMLOG) << "Saving config from Apache Options..."; 0030 0031 auto *apacheConfiguration = Globals::instance().findLogMode(QStringLiteral(APACHE_LOG_MODE_ID))->logModeConfiguration<ApacheConfiguration *>(); 0032 apacheConfiguration->setApachePaths(mApacheFileList->paths(mApachePathsId)); 0033 apacheConfiguration->setApacheAccessPaths(mApacheFileList->paths(mApacheAccessPathsId)); 0034 } 0035 0036 void ApacheConfigurationWidget::defaultConfig() 0037 { 0038 // TODO Find a way to read the configuration per default 0039 readConfig(); 0040 } 0041 0042 void ApacheConfigurationWidget::readConfig() 0043 { 0044 auto *apacheConfiguration = Globals::instance().findLogMode(QStringLiteral(APACHE_LOG_MODE_ID))->logModeConfiguration<ApacheConfiguration *>(); 0045 0046 mApacheFileList->removeAllItems(); 0047 0048 mApacheFileList->addPaths(mApachePathsId, apacheConfiguration->apachePaths()); 0049 mApacheFileList->addPaths(mApacheAccessPathsId, apacheConfiguration->apacheAccessPaths()); 0050 } 0051 0052 bool ApacheConfigurationWidget::isValid() const 0053 { 0054 if (mApacheFileList->isOneOfCategoryEmpty()) { 0055 qCDebug(KSYSTEMLOG) << "Apache configuration not valid"; 0056 return false; 0057 } 0058 0059 qCDebug(KSYSTEMLOG) << "Apache configuration valid"; 0060 return true; 0061 } 0062 0063 #include "moc_apacheConfigurationWidget.cpp"