File indexing completed on 2024-05-12 05:28:35
0001 ////////////////////////////////////////////////////////////////////////////// 0002 // breezeexceptionmodel.cpp 0003 // ------------------- 0004 // 0005 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0006 // 0007 // SPDX-License-Identifier: MIT 0008 ////////////////////////////////////////////////////////////////////////////// 0009 0010 #include "breezeexceptionmodel.h" 0011 0012 #include <KLocalizedString> 0013 0014 namespace Breeze 0015 { 0016 //_______________________________________________ 0017 const QString ExceptionModel::m_columnTitles[ExceptionModel::nColumns] = {QStringLiteral(""), i18n("Exception Type"), i18n("Regular Expression")}; 0018 0019 //__________________________________________________________________ 0020 QVariant ExceptionModel::data(const QModelIndex &index, int role) const 0021 { 0022 // check index, role and column 0023 if (!index.isValid()) { 0024 return QVariant(); 0025 } 0026 0027 // retrieve associated file info 0028 const InternalSettingsPtr &configuration(get(index)); 0029 0030 // return text associated to file and column 0031 if (role == Qt::DisplayRole) { 0032 switch (index.column()) { 0033 case ColumnType: { 0034 switch (configuration->exceptionType()) { 0035 case InternalSettings::ExceptionWindowTitle: 0036 return i18n("Window Title"); 0037 0038 default: 0039 case InternalSettings::ExceptionWindowClassName: 0040 return i18n("Window Class Name"); 0041 } 0042 } 0043 0044 case ColumnRegExp: 0045 return configuration->exceptionPattern(); 0046 default: 0047 return QVariant(); 0048 break; 0049 } 0050 0051 } else if (role == Qt::CheckStateRole && index.column() == ColumnEnabled) { 0052 return configuration->enabled() ? Qt::Checked : Qt::Unchecked; 0053 0054 } else if (role == Qt::ToolTipRole && index.column() == ColumnEnabled) { 0055 return i18n("Enable/disable this exception"); 0056 } 0057 0058 return QVariant(); 0059 } 0060 0061 //__________________________________________________________________ 0062 QVariant ExceptionModel::headerData(int section, Qt::Orientation orientation, int role) const 0063 { 0064 if (orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < nColumns) { 0065 return m_columnTitles[section]; 0066 } 0067 0068 // return empty 0069 return QVariant(); 0070 } 0071 0072 }