2009-09-15 07:12:54 +00:00
|
|
|
#ifndef oxygenexception_h
|
|
|
|
#define oxygenexception_h
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-08-24 16:12:50 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-09-15 07:12:54 +00:00
|
|
|
// oxygenexception.h
|
2009-08-24 16:12:50 +00:00
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-25 04:15:13 +00:00
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
2009-08-24 16:12:50 +00:00
|
|
|
//
|
|
|
|
// 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
|
2009-09-09 00:55:55 +00:00
|
|
|
// IN THE SOFTWARE.
|
2009-08-24 16:12:50 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-09-20 07:42:03 +00:00
|
|
|
#include <QtCore/QRegExp>
|
2009-09-15 07:12:54 +00:00
|
|
|
#include "oxygenconfiguration.h"
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace OxygenConfig
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
//! needed for exceptions
|
|
|
|
static const QString TYPE = "Type";
|
|
|
|
static const QString PATTERN = "Pattern";
|
|
|
|
static const QString ENABLED = "Enabled";
|
|
|
|
static const QString MASK = "Mask";
|
|
|
|
|
2009-08-24 06:23:44 +00:00
|
|
|
}
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
//! oxygen exception
|
|
|
|
class Exception: public Configuration
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! exception type
|
|
|
|
enum Type {
|
|
|
|
WindowTitle,
|
|
|
|
WindowClassName
|
|
|
|
};
|
|
|
|
|
|
|
|
//! mask
|
|
|
|
enum AttributesMask {
|
|
|
|
None = 0,
|
|
|
|
TitleAlignment = 1<<0,
|
|
|
|
DrawSeparator = 1<<2,
|
|
|
|
TitleOutline = 1<<3,
|
|
|
|
FrameBorder = 1<<4,
|
|
|
|
BlendColor = 1<<5,
|
|
|
|
SizeGripMode = 1<<6,
|
|
|
|
All = TitleAlignment|DrawSeparator|TitleOutline|FrameBorder|BlendColor|SizeGripMode
|
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! constructor
|
|
|
|
Exception( Configuration configuration = Configuration() ):
|
|
|
|
Configuration( configuration ),
|
|
|
|
enabled_( true ),
|
|
|
|
type_( WindowClassName ),
|
|
|
|
mask_( None )
|
|
|
|
{}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! constructor
|
|
|
|
Exception( KConfigGroup );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! destructor
|
|
|
|
virtual ~Exception( void )
|
|
|
|
{}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! equal to operator
|
|
|
|
bool operator == (const Exception& exception ) const
|
|
|
|
{
|
|
|
|
return
|
|
|
|
enabled() == exception.enabled() &&
|
|
|
|
type() == exception.type() &&
|
|
|
|
regExp().pattern() == exception.regExp().pattern() &&
|
|
|
|
mask() == exception.mask() &&
|
|
|
|
Configuration::operator == ( exception );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! less than operator
|
|
|
|
bool operator < (const Exception& exception ) const
|
|
|
|
{
|
|
|
|
if( enabled() != exception.enabled() ) return enabled() < exception.enabled();
|
|
|
|
else if( mask() != exception.mask() ) return mask() < exception.mask();
|
|
|
|
else if( type() != exception.type() ) return type() < exception.type();
|
|
|
|
else return regExp().pattern() < exception.regExp().pattern();
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! write to kconfig group
|
|
|
|
virtual void write( KConfigGroup& ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//!@name enability
|
|
|
|
//@{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
bool enabled( void ) const
|
|
|
|
{ return enabled_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
void setEnabled( bool enabled )
|
|
|
|
{ enabled_ = enabled; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//@}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//!@name exception type
|
|
|
|
//@{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
static QString typeName( Type, bool );
|
|
|
|
static Type type( const QString& name, bool );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
virtual QString typeName( bool translated ) const
|
|
|
|
{ return typeName( type(), translated ); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
virtual Type type( void ) const
|
|
|
|
{ return type_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
virtual void setType( Type value )
|
|
|
|
{ type_ = value; }
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//@}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//!@name regular expression
|
|
|
|
//@{
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
virtual QRegExp regExp( void ) const
|
|
|
|
{ return regExp_; }
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
virtual QRegExp& regExp( void )
|
|
|
|
{ return regExp_; }
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//@}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! mask
|
|
|
|
//!@{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
unsigned int mask( void ) const
|
|
|
|
{ return mask_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
void setMask( unsigned int mask )
|
|
|
|
{ mask_ = mask; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//@}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
private:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! enability
|
|
|
|
bool enabled_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! exception type
|
|
|
|
Type type_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! regular expression to match window caption
|
|
|
|
QRegExp regExp_;
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! attributes mask
|
|
|
|
unsigned int mask_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-08-24 06:23:44 +00:00
|
|
|
}
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#endif
|