File indexing completed on 2024-05-05 05:48:56
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 "levelPrintPage.h" 0008 0009 #include <KLocalizedString> 0010 0011 #include <QButtonGroup> 0012 #include <QCheckBox> 0013 #include <QGridLayout> 0014 #include <QLabel> 0015 0016 #include "ksystemlog_debug.h" 0017 #include "logLevel.h" 0018 #include "logViewWidgetItem.h" 0019 0020 #include "globals.h" 0021 0022 LevelPrintPage::LevelPrintPage(QWidget *parent) 0023 : QWidget(parent) 0024 { 0025 setWindowTitle(i18n("Log Level Printing")); 0026 0027 mPageLayout = new QVBoxLayout(this); 0028 0029 mLblChoose = new QLabel(this); 0030 // m_lblChoose->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, 0031 // m_lblChoose->sizePolicy().hasHeightForWidth() ) ); 0032 mLblChoose->setText(i18n("Choose which log levels you wish to print in color.")); 0033 mPageLayout->addWidget(mLblChoose); 0034 0035 mBtnGroup = new QButtonGroup(this); 0036 /* 0037 i18n("Log Levels"), 0038 m_btnGroup->setColumnLayout(0, Qt::Vertical ); 0039 m_btnGroup->layout()->setSpacing( 6 ); 0040 m_btnGroup->layout()->setMargin( 11 ); 0041 m_btnGroupLayout = new QGridLayout( m_btnGroup->layout() ); 0042 m_btnGroupLayout->setAlignment( Qt::AlignTop ); 0043 */ 0044 0045 int row = 0; 0046 int col = 0; 0047 const auto logLevels = Globals::instance().logLevels(); 0048 mLevelCheckBoxes.reserve(logLevels.count()); 0049 for (LogLevel *level : logLevels) { 0050 auto button = new QCheckBox(level->name(), this); //, m_btnGroup, 0 0051 0052 mLevelCheckBoxes.append(button); 0053 mBtnGroup->addButton(button, level->id()); 0054 mBtnGroupLayout->addWidget(button, row, col); 0055 0056 qCDebug(KSYSTEMLOG) << "name: " << level->name() << " id: " << level->id(); 0057 0058 row++; 0059 if (row >= 4) { 0060 row = 0; 0061 col++; 0062 } 0063 } 0064 0065 // m_pageLayout->addWidget(m_btnGroup); 0066 } 0067 0068 LevelPrintPage::~LevelPrintPage() 0069 { 0070 // no need to delete child widgets, Qt does it all for us 0071 } 0072 0073 /* QPrinter Port: comment out as dialog page is not currently being used, so not ported 0074 0075 void LevelPrintPage::getOptions( QMap<QString,QString>& opts, bool incldef ) { 0076 foreach(LogLevel* level, Globals::instance().logLevels()) { 0077 QString key = "kde-ksystemlog-print_" + level->name(); 0078 0079 0080 QCheckBox* checkBox = static_cast<QCheckBox*>(m_btnGroup->find(level->id())); 0081 if(checkBox) { 0082 if (checkBox->isChecked()) 0083 opts[ key ] = "1"; 0084 else 0085 opts[ key ] = "0"; 0086 } 0087 0088 } 0089 } 0090 0091 void LevelPrintPage::setOptions( const QMap<QString,QString>& opts ) { 0092 foreach(LogLevel* level, Globals::instance().logLevels()) { 0093 QString key = "kde-ksystemlog-print_" + level->name(); 0094 QString use = opts[ key ]; 0095 0096 int chk = use.toInt(); 0097 0098 0099 QCheckBox* checkBox = static_cast<QCheckBox*>(m_btnGroup->find(level->id())); 0100 if(checkBox) { 0101 if(chk) 0102 checkBox->setChecked(true); 0103 else 0104 checkBox->setChecked(false); 0105 } 0106 0107 0108 } 0109 } 0110 0111 */ 0112 0113 bool LevelPrintPage::isValid(QString & /*msg*/) 0114 { 0115 return true; 0116 }