diff --git a/src/detailDialog.cpp b/src/detailDialog.cpp index e188c83..e01747d 100644 --- a/src/detailDialog.cpp +++ b/src/detailDialog.cpp @@ -1,140 +1,140 @@ /*************************************************************************** * KSystemLog, a system log viewer tool * * Copyright (C) 2007 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "detailDialog.h" // Qt includes #include #include #include #include #include #include "logViewWidget.h" #include "logViewWidgetItem.h" #include "logLine.h" #include "logging.h" DetailDialog::DetailDialog(QWidget *parent) : QDialog(parent) , logViewWidget(nullptr) { setupUi(this); previous->setText(i18n("&Previous")); previous->setIcon(QIcon::fromTheme(QStringLiteral("arrow-up"))); connect(previous, &QAbstractButton::clicked, this, &DetailDialog::previousItem); next->setText(i18n("&Next")); next->setIcon(QIcon::fromTheme(QStringLiteral("arrow-down"))); connect(next, &QAbstractButton::clicked, this, &DetailDialog::nextItem); KGuiItem::assign(closeButton, KStandardGuiItem::close()); connect(closeButton, &QAbstractButton::clicked, this, &QWidget::close); } DetailDialog::~DetailDialog() { } void DetailDialog::selectionChanged(LogViewWidget *logViewWidget) { this->logViewWidget = logViewWidget; updateDetails(); } // TODO Try to find a method that reload (an resize) correctly the content of the detail dialog void DetailDialog::updateDetails() { // logDebug() << "Updating Detail Dialog..."; // Get the current-last item selected LogViewWidgetItem *item = logViewWidget->lastSelectedItem(); if (item == nullptr) { logDebug() << "No item found."; return; } - icon->setPixmap(item->logLine()->logLevel()->icon()); + icon->setPixmap(item->logLine()->logLevel()->icon().pixmap(style()->pixelMetric(QStyle::PM_LargeIconSize))); header->setText(item->logLine()->formattedText()); message->setText(item->logLine()->logItems().last()); if (logViewWidget->topLevelItem(logViewWidget->indexOfTopLevelItem(item) - 1) == nullptr) previous->setEnabled(false); else previous->setEnabled(true); if (logViewWidget->topLevelItem(logViewWidget->indexOfTopLevelItem(item) + 1) == nullptr) next->setEnabled(false); else next->setEnabled(true); /* header->adjustSize(); this->adjustSize(); */ } void DetailDialog::moveToItem(int direction) { if (direction < 0) logDebug() << "Go to previous item..."; else logDebug() << "Go to next item..."; // Get the current-last item selected LogViewWidgetItem *item = logViewWidget->lastSelectedItem(); if (item == nullptr) { logDebug() << "No item found."; return; } QTreeWidgetItem *destinationItem = logViewWidget->topLevelItem(logViewWidget->indexOfTopLevelItem(item) + direction); if (destinationItem == nullptr) { if (direction < 0) logDebug() << "No previous item found."; else logDebug() << "No next item found."; return; } item->setSelected(false); destinationItem->setSelected(true); logViewWidget->scrollToItem(destinationItem); updateDetails(); } void DetailDialog::previousItem() { moveToItem(-1); } void DetailDialog::nextItem() { moveToItem(1); } diff --git a/src/lib/logLevel.cpp b/src/lib/logLevel.cpp index e4e241f..4e6f0d1 100644 --- a/src/lib/logLevel.cpp +++ b/src/lib/logLevel.cpp @@ -1,77 +1,69 @@ /*************************************************************************** * KSystemLog, a system log viewer tool * * Copyright (C) 2007 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "logLevel.h" #include #include class LogLevelPrivate { public: int id; QString name; - QString icon; - QColor color; - QPixmap pixmap; + QIcon icon; }; LogLevel::LogLevel(int id, const QString &nm, const QString &ic, const QColor &col, QObject *parent) : QObject(parent), d(new LogLevelPrivate()) { d->id = id; d->name = nm; - d->icon = ic; d->color = col; - d->pixmap = QIcon::fromTheme(ic).pixmap(KIconLoader::SizeSmall); + d->icon = QIcon::fromTheme(ic); } LogLevel::~LogLevel() { delete d; } int LogLevel::id() const { return d->id; } QString LogLevel::name() const { return d->name; } -QString LogLevel::icon() const -{ - return d->icon; -} - QColor LogLevel::color() const { return d->color; } -QPixmap LogLevel::pixmap() const +QIcon LogLevel::icon() const { - return d->pixmap; + return d->icon; } diff --git a/src/lib/logLevel.h b/src/lib/logLevel.h index f91d6e4..fa6beaa 100644 --- a/src/lib/logLevel.h +++ b/src/lib/logLevel.h @@ -1,51 +1,49 @@ /*************************************************************************** * KSystemLog, a system log viewer tool * * Copyright (C) 2007 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef LOG_LEVEL_H #define LOG_LEVEL_H #include #include #include class LogLevelPrivate; class LogLevel : QObject { public: explicit LogLevel(int id, const QString &name, const QString &icon, const QColor &color, QObject *parent = nullptr); virtual ~LogLevel(); int id() const; QString name() const; - QString icon() const; - QColor color() const; - QPixmap pixmap() const; + QIcon icon() const; private: LogLevelPrivate *const d; }; #endif diff --git a/src/lib/logModeItemBuilder.cpp b/src/lib/logModeItemBuilder.cpp index adc4caa..78ec173 100644 --- a/src/lib/logModeItemBuilder.cpp +++ b/src/lib/logModeItemBuilder.cpp @@ -1,110 +1,110 @@ /*************************************************************************** * KSystemLog, a system log viewer tool * * Copyright (C) 2007 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "logModeItemBuilder.h" #include #include "logging.h" #include "logLine.h" #include "logViewWidgetItem.h" #include "logMode.h" #include "ksystemlogConfig.h" LogModeItemBuilder::LogModeItemBuilder() { } LogModeItemBuilder::~LogModeItemBuilder() { } QString LogModeItemBuilder::formatDate(const QDateTime &dateTime) const { return Globals::instance().formatDate((Globals::DateFormat)KSystemLogConfig::dateFormat(), dateTime); } void LogModeItemBuilder::prepareItem(LogViewWidgetItem *item) const { LogLine *line = item->logLine(); item->setText(0, formatDate(line->time())); item->setData(0, Qt::UserRole, line->logLevel()->id()); int i = 1; foreach (const QString &label, line->logItems()) { item->setText(i, label); i++; } - item->setIcon(0, line->logLevel()->pixmap()); + item->setIcon(0, line->logLevel()->icon()); } QString LogModeItemBuilder::createFormattedText(LogLine *line) const { QString result; QListIterator it(line->logItems()); result.append(QLatin1String("")); result.append(labelMessageFormat(i18n("Date:"), formatDate(line->time()))); result.append(labelMessageFormat(i18n("Hostname:"), it.next())); result.append(labelMessageFormat(i18n("Process:"), it.next())); result.append(labelMessageFormat(i18n("Level:"), line->logLevel()->name())); result.append(labelMessageFormat(i18n("Original file:"), line->sourceFileName())); result.append(QLatin1String("
")); return result; } QString LogModeItemBuilder::createToolTipText(LogLine *line) const { QString result; result.append(QLatin1String("")); result.append(labelMessageFormat(i18n("Date:"), formatDate(line->time()))); result.append(labelMessageFormat(i18n("Level:"), line->logLevel()->name())); result.append(labelMessageFormat(i18n("Original file:"), line->sourceFileName())); result.append(QLatin1String("
")); return result; } QString LogModeItemBuilder::labelMessageFormat(const QString &label, const QString &value) const { return (QLatin1String("") + label + QLatin1String("") + messageFormat(value) + QLatin1String("")); } QString LogModeItemBuilder::messageFormat(const QString &message) const { QString transformation(message); transformation.replace(QRegExp(QStringLiteral("&")), QStringLiteral("&")); transformation.replace(QRegExp(QStringLiteral("<")), QStringLiteral("<")); transformation.replace(QRegExp(QStringLiteral(">")), QStringLiteral(">")); return transformation; } diff --git a/src/loggerDialog.cpp b/src/loggerDialog.cpp index 94c7a33..4a7f2f0 100644 --- a/src/loggerDialog.cpp +++ b/src/loggerDialog.cpp @@ -1,272 +1,272 @@ /*************************************************************************** * KSystemLog, a system log viewer tool * * Copyright (C) 2007 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "loggerDialog.h" #include #include #include // Project includes #include "logging.h" #include "logLevel.h" #include "globals.h" class LoggerDialogPrivate { public: QMap facilities; QMap priorities; QMap priorityIcons; }; LoggerDialog::LoggerDialog(QWidget *parent) : QDialog(parent) , d(new LoggerDialogPrivate()) { setupUi(this); connect(buttonOK, &QAbstractButton::clicked, this, &LoggerDialog::sendMessage); connect(buttonCancel, &QAbstractButton::clicked, this, &QWidget::hide); connect(tagActivation, &QAbstractButton::toggled, this, &LoggerDialog::changeTagActivation); connect(fileActivation, &QAbstractButton::toggled, this, &LoggerDialog::changeFileActivation); connect(messageActivation, &QAbstractButton::toggled, this, &LoggerDialog::changeMessageActivation); connect(file, &KUrlRequester::textChanged, this, &LoggerDialog::textChanged); connect(message, &QLineEdit::textChanged, this, &LoggerDialog::textChanged); connect(tag, &QLineEdit::textChanged, this, &LoggerDialog::textChanged); buildMaps(); // Fill the priority ComboBox QList prioKeys(d->priorities.keys()); QList::Iterator itPriority; for (itPriority = prioKeys.begin(); itPriority != prioKeys.end(); ++itPriority) { priority->addItem(d->priorityIcons[*itPriority], *itPriority); } // Select the right priority for (int i = 0; i < priority->count(); ++i) { if (priority->itemText(i) == Globals::instance().noticeLogLevel()->name()) { priority->setCurrentIndex(i); break; } } // Fill the priority ComboBox QList keys(d->facilities.keys()); QList::Iterator itFacility; for (itFacility = keys.begin(); itFacility != keys.end(); ++itFacility) { facility->addItem(*itFacility); } // Select the right facility for (int i = 0; i < facility->count(); ++i) { if (facility->itemText(i) == i18n("User")) { facility->setCurrentIndex(i); break; } } tag->setEnabled(false); } LoggerDialog::~LoggerDialog() { delete d; } void LoggerDialog::initialize() { logDebug() << "Initializing Logger dialog..."; message->clear(); message->setFocus(); } void LoggerDialog::buildMaps() { // Fill the facility map d->facilities[i18n("Authentication")] = QStringLiteral("auth"); d->facilities[i18n("Private Authentication")] = QStringLiteral("authpriv"); d->facilities[i18n("Cron")] = QStringLiteral("cron"); d->facilities[i18n("Daemon")] = QStringLiteral("daemon"); d->facilities[i18n("FTP")] = QStringLiteral("ftp"); d->facilities[i18n("Kernel")] = QStringLiteral("kern"); d->facilities[i18n("LPR")] = QStringLiteral("lpr"); d->facilities[i18n("Mail")] = QStringLiteral("mail"); d->facilities[i18n("News")] = QStringLiteral("news"); d->facilities[i18n("Syslog")] = QStringLiteral("syslog"); d->facilities[i18n("User")] = QStringLiteral("user"); d->facilities[i18n("UUCP")] = QStringLiteral("uucp"); d->facilities[i18n("Local 0")] = QStringLiteral("local0"); d->facilities[i18n("Local 1")] = QStringLiteral("local1"); d->facilities[i18n("Local 2")] = QStringLiteral("local2"); d->facilities[i18n("Local 3")] = QStringLiteral("local3"); d->facilities[i18n("Local 4")] = QStringLiteral("local4"); d->facilities[i18n("Local 5")] = QStringLiteral("local5"); d->facilities[i18n("Local 6")] = QStringLiteral("local6"); d->facilities[i18n("Local 7")] = QStringLiteral("local7"); // Fill the priority map d->priorities[Globals::instance().debugLogLevel()->name()] = QStringLiteral("debug"); d->priorities[Globals::instance().informationLogLevel()->name()] = QStringLiteral("info"); d->priorities[Globals::instance().noticeLogLevel()->name()] = QStringLiteral("notice"); d->priorities[Globals::instance().warningLogLevel()->name()] = QStringLiteral("warning"); d->priorities[Globals::instance().errorLogLevel()->name()] = QStringLiteral("err"); d->priorities[Globals::instance().criticalLogLevel()->name()] = QStringLiteral("crit"); d->priorities[Globals::instance().alertLogLevel()->name()] = QStringLiteral("alert"); d->priorities[Globals::instance().emergencyLogLevel()->name()] = QStringLiteral("emerg"); // Fill the priority icon map d->priorityIcons[Globals::instance().debugLogLevel()->name()] - = Globals::instance().debugLogLevel()->icon(); + = Globals::instance().debugLogLevel()->icon().name(); d->priorityIcons[Globals::instance().informationLogLevel()->name()] - = Globals::instance().informationLogLevel()->icon(); + = Globals::instance().informationLogLevel()->icon().name(); d->priorityIcons[Globals::instance().noticeLogLevel()->name()] - = Globals::instance().noticeLogLevel()->icon(); + = Globals::instance().noticeLogLevel()->icon().name(); d->priorityIcons[Globals::instance().warningLogLevel()->name()] - = Globals::instance().warningLogLevel()->icon(); + = Globals::instance().warningLogLevel()->icon().name(); d->priorityIcons[Globals::instance().errorLogLevel()->name()] - = Globals::instance().errorLogLevel()->icon(); + = Globals::instance().errorLogLevel()->icon().name(); d->priorityIcons[Globals::instance().criticalLogLevel()->name()] - = Globals::instance().criticalLogLevel()->icon(); + = Globals::instance().criticalLogLevel()->icon().name(); d->priorityIcons[Globals::instance().alertLogLevel()->name()] - = Globals::instance().alertLogLevel()->icon(); + = Globals::instance().alertLogLevel()->icon().name(); d->priorityIcons[Globals::instance().emergencyLogLevel()->name()] - = Globals::instance().emergencyLogLevel()->icon(); + = Globals::instance().emergencyLogLevel()->icon().name(); } void LoggerDialog::textChanged() { if (fileActivation->isChecked() && file->url().isEmpty()) { buttonOK->setEnabled(false); return; } if (tagActivation->isChecked() && tag->text().isEmpty()) { buttonOK->setEnabled(false); return; } if (messageActivation->isChecked() && message->text().isEmpty()) { buttonOK->setEnabled(false); return; } buttonOK->setEnabled(true); } void LoggerDialog::changeTagActivation(bool activation) { tag->setEnabled(activation); textChanged(); } void LoggerDialog::changeFileActivation(bool activation) { file->setEnabled(activation); textChanged(); } void LoggerDialog::changeMessageActivation(bool activation) { message->setEnabled(activation); textChanged(); } void LoggerDialog::sendMessage() { QProcess process; QStringList arguments; if (useProcessIdentifier->isChecked()) { arguments << QStringLiteral("-i"); } if (tagActivation->isChecked()) { arguments << QStringLiteral("-t"); arguments << tag->text(); } QString prioritySelected = priority->currentText(); if (prioritySelected != Globals::instance().noLogLevel()->name()) { arguments << QStringLiteral("-p"); QString p(d->facilities[facility->currentText()]); p += QLatin1Char('.'); p += d->priorities[priority->currentText()]; arguments << p; } // If we read the content of a file if (fileActivation->isChecked()) { arguments << QStringLiteral("-f"); arguments << file->url().path(); } // Else, the user types the content of its message else { // Remove bad "\n" characters arguments << message->text().replace(QLatin1String("\n"), QLatin1String(" ")); } // QProcess::Block, QProcess::Stdout process.start(QStringLiteral("logger"), arguments); // If the launching of the command failed if (process.error() == QProcess::FailedToStart) { KMessageBox::error(this, i18n( "Unable to find the 'logger' command on your system. Please type " "'logger' in a Konsole to determine whether this command is installed."), i18n("Command not found")); return; } if (process.exitStatus() == QProcess::CrashExit) { KMessageBox::error(this, i18n("The 'logger' command has not been properly exited."), i18n("Execution problem")); return; } // No such file or directory if (process.exitCode() == 1) { KMessageBox::error(this, i18n("This file does not exist, please choose another."), i18n("File not valid")); return; } // Hide the Logger Dialog hide(); } diff --git a/src/modes/base/logLevelFileList.cpp b/src/modes/base/logLevelFileList.cpp index 87437e9..c847982 100644 --- a/src/modes/base/logLevelFileList.cpp +++ b/src/modes/base/logLevelFileList.cpp @@ -1,199 +1,199 @@ /*************************************************************************** * KSystemLog, a system log viewer tool * * Copyright (C) 2007 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "logLevelFileList.h" #include #include #include #include // KDE includes #include #include #include #include #include #include "defaults.h" #include "logging.h" #include "globals.h" #include "logLevel.h" #include "logLevelSelectionDialog.h" int LogLevelFileList::LogLevelRole = 33; LogLevelFileList::LogLevelFileList(QWidget *parent, const QString &description) : FileList(parent, description) { logDebug() << "Initializing specific file list..."; changeItem = new QPushButton(i18n("&Change Status...")); changeItem->setToolTip(i18n("Change the level of the current file(s)")); changeItem->setWhatsThis(i18n( "Changes the level of the current file(s). See KSystemLog documentation for more information about " "each log level.")); // Insert the button just after the "Modify File" button buttonsLayout()->insertWidget(2, changeItem); QAction *action = fileListHelper.prepareButtonAndAction( changeItem, QIcon::fromTheme(QStringLiteral("favorites")), this, SLOT(changeItemType())); // Insert the action just after the "Modify File" action fileList->insertAction(fileList->actions().at(2), action); changeItem->setEnabled(false); connect(fileList, &QListWidget::itemSelectionChanged, this, &LogLevelFileList::updateSpecificButtons); connect(this, &FileList::fileListChanged, this, &LogLevelFileList::updateSpecificButtons); disconnect(fileList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(modifyItem(QListWidgetItem*))); connect(fileList, &QListWidget::itemDoubleClicked, this, &LogLevelFileList::changeItemType); updateSpecificButtons(); logDebug() << "Specific file list initialized"; } LogLevelFileList::~LogLevelFileList() { // changeItem is managed automatically } void LogLevelFileList::insertItem(LogLevel *level, const QString &itemText, bool missing) { - QListWidgetItem *item = new QListWidgetItem(QIcon(level->pixmap()), itemText, fileList); + QListWidgetItem *item = new QListWidgetItem(level->icon(), itemText, fileList); if (missing) item->setForeground(Qt::red); item->setData(LogLevelFileList::LogLevelRole, level->id()); } void LogLevelFileList::addItem() { // Open a standard Filedialog QList urls = fileListHelper.openUrls(); QStringList paths = fileListHelper.findPaths(urls); foreach (const QString &path, paths) { insertItem(Globals::instance().informationLogLevel(), path); } emit fileListChanged(); } void LogLevelFileList::updateSpecificButtons() { if (fileList->selectedItems().count() > 0) changeItem->setEnabled(true); else changeItem->setEnabled(false); } void LogLevelFileList::changeItemType() { logDebug() << "Changing item type..."; LogLevelSelectionDialog logLevelSelectionDialog(this); QListWidget *logLevels = logLevelSelectionDialog.logLevels(); foreach (LogLevel *level, Globals::instance().logLevels()) { - logLevels->addItem(new QListWidgetItem(QIcon(level->pixmap()), level->name())); + logLevels->addItem(new QListWidgetItem(level->icon(), level->name())); } int choice = logLevelSelectionDialog.exec(); if (choice == QDialog::Accepted) { QList selectedLogLevels = logLevels->selectedItems(); if (selectedLogLevels.isEmpty() == false) { QListWidgetItem *logLevel = selectedLogLevels.at(0); int selectedLogLevel = logLevels->row(logLevel); QList selectedItems = fileList->selectedItems(); foreach (QListWidgetItem *item, selectedItems) { item->setIcon(logLevel->icon()); item->setData(LogLevelFileList::LogLevelRole, selectedLogLevel); } emit fileListChanged(); } } } LogLevel *LogLevelFileList::level(int i) { return Globals::instance().logLevels().at( fileList->item(i)->data(LogLevelFileList::LogLevelRole).toInt()); } QList LogLevelFileList::levels() { QList levels; int count = fileList->count(); for (int i = 0; i < count; i++) { levels.append(this->level(i)->id()); } return levels; } void LogLevelFileList::addPaths(const QStringList &stringList, const QList &valueList) { // A little security test if (stringList.size() != valueList.size()) { logDebug() << i18n("The two arrays size are different, skipping the reading of generic paths."); return; } QListIterator itString(stringList); QListIterator itInt = (valueList); bool missingFiles = false; while (itString.hasNext()) { int valueInt = itInt.next(); QString valueString = itString.next(); bool missingFile = false; QFileInfo checkFile(valueString); if (!checkFile.exists()) { missingFiles = true; missingFile = true; } LogLevel *level; if (valueInt >= 0 && valueInt < (int)Globals::instance().logLevels().count()) level = Globals::instance().logLevels().at(valueInt); else level = Globals::instance().informationLogLevel(); insertItem(level, valueString, missingFile); } warningBox->setVisible(missingFiles); emit fileListChanged(); } diff --git a/src/modes/xorg/xorgItemBuilder.h b/src/modes/xorg/xorgItemBuilder.h index 27cc0b1..71338ff 100644 --- a/src/modes/xorg/xorgItemBuilder.h +++ b/src/modes/xorg/xorgItemBuilder.h @@ -1,89 +1,89 @@ /*************************************************************************** * KSystemLog, a system log viewer tool * * Copyright (C) 2007 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef XORG_ITEM_BUILDER_H #define XORG_ITEM_BUILDER_H #include #include #include "logging.h" #include "logLine.h" #include "logViewWidgetItem.h" #include "logMode.h" #include "logModeItemBuilder.h" class LogLine; class XorgItemBuilder : public LogModeItemBuilder { public: XorgItemBuilder() {} virtual ~XorgItemBuilder() {} void prepareItem(LogViewWidgetItem *item) const override { LogLine *line = item->logLine(); item->setText(0, QLatin1String("")); int i = 1; foreach (const QString &label, line->logItems()) { item->setText(i, label); i++; } - item->setIcon(0, line->logLevel()->pixmap()); + item->setIcon(0, line->logLevel()->icon()); } QString createToolTipText(LogLine *line) const override { QString result; QListIterator it(line->logItems()); result.append(QLatin1String("")); QString type = it.next(); if (type.isEmpty()) result.append(labelMessageFormat(i18n("Type:"), i18n("none"))); else result.append(labelMessageFormat(i18n("Type:"), type)); result.append(labelMessageFormat(i18n("Original file:"), line->sourceFileName())); result.append(QLatin1String("
")); return result; } QString createFormattedText(LogLine *line) const override { // It uses the same formating than the tool tip return createToolTipText(line); } }; #endif // _XORG_ITEM_BUILDER_H diff --git a/src/modes/xsession/xsessionItemBuilder.h b/src/modes/xsession/xsessionItemBuilder.h index 1156e8c..634b1d9 100644 --- a/src/modes/xsession/xsessionItemBuilder.h +++ b/src/modes/xsession/xsessionItemBuilder.h @@ -1,89 +1,89 @@ /*************************************************************************** * KSystemLog, a system log viewer tool * * Copyright (C) 2007 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef X_SESSION_ITEM_BUILDER_H #define X_SESSION_ITEM_BUILDER_H #include #include #include "logging.h" #include "logLine.h" #include "logViewWidgetItem.h" #include "logMode.h" #include "logModeItemBuilder.h" class LogLine; class XSessionItemBuilder : public LogModeItemBuilder { public: XSessionItemBuilder() {} ~XSessionItemBuilder() override {} void prepareItem(LogViewWidgetItem *item) const override { LogLine *line = item->logLine(); item->setText(0, QLatin1String("")); int i = 1; foreach (const QString &label, line->logItems()) { item->setText(i, label); i++; } - item->setIcon(0, QIcon(line->logLevel()->pixmap())); + item->setIcon(0, line->logLevel()->icon()); } QString createToolTipText(LogLine *line) const override { QString result; QListIterator it(line->logItems()); result.append(QLatin1String("")); QString type = it.next(); if (type.isEmpty()) result.append(labelMessageFormat(i18n("Program:"), i18n("none"))); else result.append(labelMessageFormat(i18n("Program:"), type)); result.append(labelMessageFormat(i18n("Original file:"), line->sourceFileName())); result.append(QLatin1String("
")); return result; } QString createFormattedText(LogLine *line) const override { // It uses the same formating than the tool tip return createToolTipText(line); } }; #endif // _X_SESSION_ITEM_BUILDER_H