kwin/clients/oxygen/config/oxygenexceptionmodel.cpp
Martin Gräßlin 60c42b7a34 s/KLocale/KLocalizedString/g
Many headers included KLocale to use i18n and co. But those methods are
defined in KLocalizedString and not in KLocale.

With KF5 klocale.h does no longer include KLocalizedString causing lots
of compile errors.
2013-03-07 13:59:15 +01:00

105 lines
3.5 KiB
C++

//////////////////////////////////////////////////////////////////////////////
// oxygenexceptionmodel.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "oxygenexceptionmodel.h"
#include <KLocalizedString>
namespace Oxygen
{
//_______________________________________________
const QString ExceptionModel::_columnTitles[ ExceptionModel::nColumns ] =
{
"",
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 ConfigurationPtr& configuration( get(index) );
// return text associated to file and column
if( role == Qt::DisplayRole )
{
switch( index.column() )
{
case TYPE:
{
switch( configuration->exceptionType() )
{
case Configuration::ExceptionWindowTitle:
return i18n( "Window Title" );
default:
case Configuration::ExceptionWindowClassName:
return i18n( "Window Class Name" );
}
}
case REGEXP: return configuration->exceptionPattern();
default: return QVariant();
break;
}
} else if( role == Qt::CheckStateRole && index.column() == ENABLED ) {
return configuration->enabled() ? Qt::Checked : Qt::Unchecked;
} else if( role == Qt::ToolTipRole && index.column() == ENABLED ) {
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 _columnTitles[section]; }
// return empty
return QVariant();
}
}