1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
//////////////////////////////////////////////////////////////////////////////
// breezeexceptionmodel.cpp
// -------------------
//
// SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////
#include "breezeexceptionmodel.h"
#include <KLocalizedString>
namespace Breeze
{
//_______________________________________________
const QString ExceptionModel::m_columnTitles[ExceptionModel::nColumns] = {QStringLiteral(""), i18n("Exception Type"), i18n("Regular Expression")};
//__________________________________________________________________
QVariant ExceptionModel::data(const QModelIndex &index, int role) const
{
// check index, role and column
if (!index.isValid()) {
return QVariant();
}
// retrieve associated file info
const InternalSettingsPtr &configuration(get(index));
// return text associated to file and column
if (role == Qt::DisplayRole) {
switch (index.column()) {
case ColumnType: {
switch (configuration->exceptionType()) {
case InternalSettings::ExceptionWindowTitle:
return i18n("Window Title");
default:
case InternalSettings::ExceptionWindowClassName:
return i18n("Window Class Name");
}
}
case ColumnRegExp:
return configuration->exceptionPattern();
default:
return QVariant();
break;
}
} else if (role == Qt::CheckStateRole && index.column() == ColumnEnabled) {
return configuration->enabled() ? Qt::Checked : Qt::Unchecked;
} else if (role == Qt::ToolTipRole && index.column() == ColumnEnabled) {
return i18n("Enable/disable this exception");
}
return QVariant();
}
//__________________________________________________________________
QVariant ExceptionModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < nColumns) {
return m_columnTitles[section];
}
// return empty
return QVariant();
}
}
|