File indexing completed on 2024-05-12 05:48:40

0001 /*
0002     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "postfixConfigurationWidget.h"
0008 
0009 PostfixConfigurationWidget::PostfixConfigurationWidget()
0010     : LogModeConfigurationWidget(i18n("Postfix Log"), QStringLiteral(POSTFIX_MODE_ICON), i18n("Postfix Log"))
0011 {
0012     auto layout = new QVBoxLayout(this);
0013 
0014     const QString description = i18n("<p>These files will be analyzed to show the <b>Postfix Logs</b>.</p>");
0015 
0016     mLileList = new LogLevelFileList(this, description);
0017 
0018     connect(mLileList, &FileList::fileListChanged, this, &LogModeConfigurationWidget::configurationChanged);
0019 
0020     layout->addWidget(mLileList);
0021 }
0022 
0023 bool PostfixConfigurationWidget::isValid() const
0024 {
0025     if (!mLileList->isEmpty()) {
0026         qCDebug(KSYSTEMLOG) << "Postfix configuration valid";
0027         return true;
0028     }
0029 
0030     qCDebug(KSYSTEMLOG) << "Postfix configuration not valid";
0031     return false;
0032 }
0033 
0034 void PostfixConfigurationWidget::saveConfig()
0035 {
0036     qCDebug(KSYSTEMLOG) << "Saving config from Postfix Options...";
0037 
0038     auto *configuration = Globals::instance().findLogMode(QStringLiteral(POSTFIX_LOG_MODE_ID))->logModeConfiguration<PostfixConfiguration *>();
0039     configuration->setLogFilesPaths(mLileList->paths());
0040     configuration->setLogFilesLevels(mLileList->levels());
0041 }
0042 
0043 void PostfixConfigurationWidget::readConfig()
0044 {
0045     auto *configuration = Globals::instance().findLogMode(QStringLiteral(POSTFIX_LOG_MODE_ID))->logModeConfiguration<PostfixConfiguration *>();
0046 
0047     mLileList->removeAllItems();
0048 
0049     mLileList->addPaths(configuration->logFilesPaths(), configuration->logFilesLevels());
0050 }
0051 
0052 void PostfixConfigurationWidget::defaultConfig()
0053 {
0054     // TODO Find a way to read the configuration per default
0055     readConfig();
0056 }
0057 
0058 #include "moc_postfixConfigurationWidget.cpp"