File indexing completed on 2024-05-05 05:48:57

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 "logMode.h"
0008 
0009 #include <QAction>
0010 #include <QFileInfo>
0011 
0012 #include "logModeItemBuilder.h"
0013 #include "multipleActions.h"
0014 
0015 LogMode::LogMode(const QString &id, const QString &name, const QString &iconName)
0016     : d(new LogModePrivate())
0017 {
0018     d->id = id;
0019     d->name = name;
0020     d->icon = QIcon::fromTheme(iconName);
0021     d->logFilesExist = true;
0022 }
0023 
0024 LogMode::~LogMode()
0025 {
0026     delete d->action;
0027 
0028     delete d->itemBuilder;
0029 
0030     delete d;
0031 }
0032 
0033 QString LogMode::id() const
0034 {
0035     return d->id;
0036 }
0037 
0038 QString LogMode::name() const
0039 {
0040     return d->name;
0041 }
0042 
0043 QIcon LogMode::icon() const
0044 {
0045     return d->icon;
0046 }
0047 
0048 QAction *LogMode::action() const
0049 {
0050     return d->action;
0051 }
0052 
0053 LogModeItemBuilder *LogMode::itemBuilder() const
0054 {
0055     return d->itemBuilder;
0056 }
0057 
0058 bool LogMode::filesExist() const
0059 {
0060     return d->logFilesExist;
0061 }
0062 
0063 LogModeConfigurationWidget *LogMode::logModeConfigurationWidget() const
0064 {
0065     return d->logModeConfigurationWidget;
0066 }
0067 
0068 LogModeConfiguration *LogMode::innerConfiguration() const
0069 {
0070     return d->logModeConfiguration.data();
0071 }
0072 
0073 QAction *LogMode::createDefaultAction()
0074 {
0075     auto action = new QAction(d->icon, d->name, this);
0076     ActionData data;
0077     data.id = d->id;
0078     action->setData(QVariant::fromValue(data));
0079 
0080     return action;
0081 }
0082 
0083 void LogMode::checkLogFilesPresence(const QStringList &paths)
0084 {
0085     d->logFilesExist = false;
0086     for (const QString &path : paths) {
0087         QFileInfo const fileInfo(path);
0088         if (fileInfo.exists()) {
0089             d->logFilesExist = true;
0090         }
0091     }
0092 }
0093 
0094 #include "moc_logMode.cpp"