~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/clients/oxygen/oxygenexception.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef oxygenexception_h
 
2
#define oxygenexception_h
 
3
 
 
4
//////////////////////////////////////////////////////////////////////////////
 
5
// oxygenexception.h
 
6
// window decoration exception
 
7
// -------------------
 
8
//
 
9
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
 
10
//
 
11
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
12
// of this software and associated documentation files (the "Software"), to
 
13
// deal in the Software without restriction, including without limitation the
 
14
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 
15
// sell copies of the Software, and to permit persons to whom the Software is
 
16
// furnished to do so, subject to the following conditions:
 
17
//
 
18
// The above copyright notice and this permission notice shall be included in
 
19
// all copies or substantial portions of the Software.
 
20
//
 
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
24
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
26
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 
27
// IN THE SOFTWARE.
 
28
//////////////////////////////////////////////////////////////////////////////
 
29
 
 
30
#include <QtCore/QRegExp>
 
31
#include "oxygenconfiguration.h"
 
32
 
 
33
 
 
34
namespace OxygenConfig
 
35
{
 
36
 
 
37
    //! needed for exceptions
 
38
    static const QString TYPE = "Type";
 
39
    static const QString PATTERN = "Pattern";
 
40
    static const QString ENABLED = "Enabled";
 
41
    static const QString MASK = "Mask";
 
42
 
 
43
}
 
44
 
 
45
namespace Oxygen
 
46
{
 
47
 
 
48
    //! oxygen exception
 
49
    class Exception: public Configuration
 
50
    {
 
51
 
 
52
        public:
 
53
 
 
54
        //! exception type
 
55
        enum Type {
 
56
            WindowTitle,
 
57
            WindowClassName
 
58
        };
 
59
 
 
60
        //! mask
 
61
        enum AttributesMask {
 
62
            None = 0,
 
63
            TitleAlignment = 1<<0,
 
64
            DrawSeparator = 1<<2,
 
65
            TitleOutline = 1<<3,
 
66
            FrameBorder = 1<<4,
 
67
            BlendColor = 1<<5,
 
68
            SizeGripMode = 1<<6,
 
69
            All = TitleAlignment|DrawSeparator|TitleOutline|FrameBorder|BlendColor|SizeGripMode
 
70
        };
 
71
 
 
72
        //! constructor
 
73
        Exception( Configuration configuration = Configuration() ):
 
74
            Configuration( configuration ),
 
75
            _enabled( true ),
 
76
            _type( WindowClassName ),
 
77
            _mask( None )
 
78
        {}
 
79
 
 
80
        //! constructor
 
81
        Exception( KConfigGroup );
 
82
 
 
83
        //! destructor
 
84
        virtual ~Exception( void )
 
85
        {}
 
86
 
 
87
        //! equal to operator
 
88
        bool operator == (const Exception& exception ) const
 
89
        {
 
90
            return
 
91
                enabled() == exception.enabled() &&
 
92
                type() == exception.type() &&
 
93
                regExp().pattern() == exception.regExp().pattern() &&
 
94
                mask() == exception.mask() &&
 
95
                Configuration::operator == ( exception );
 
96
        }
 
97
 
 
98
        //! less than operator
 
99
        bool operator < (const Exception& exception ) const
 
100
        {
 
101
            if( enabled() != exception.enabled() ) return enabled() < exception.enabled();
 
102
            else if( mask() != exception.mask() ) return mask() < exception.mask();
 
103
            else if( type() != exception.type() ) return type() < exception.type();
 
104
            else return regExp().pattern() < exception.regExp().pattern();
 
105
        }
 
106
 
 
107
        //! write to kconfig group
 
108
        virtual void write( KConfigGroup& ) const;
 
109
 
 
110
        //!@name enability
 
111
        //@{
 
112
 
 
113
        bool enabled( void ) const
 
114
        { return _enabled; }
 
115
 
 
116
        void setEnabled( bool enabled )
 
117
        { _enabled = enabled; }
 
118
 
 
119
        //@}
 
120
 
 
121
        //!@name exception type
 
122
        //@{
 
123
 
 
124
        static QString typeName( Type, bool );
 
125
        static Type type( const QString& name, bool );
 
126
 
 
127
        virtual QString typeName( bool translated ) const
 
128
        { return typeName( type(), translated ); }
 
129
 
 
130
        virtual Type type( void ) const
 
131
        { return _type; }
 
132
 
 
133
        virtual void setType( Type value )
 
134
        { _type = value; }
 
135
 
 
136
        //@}
 
137
 
 
138
        //!@name regular expression
 
139
        //@{
 
140
 
 
141
        virtual QRegExp regExp( void ) const
 
142
        { return _regExp; }
 
143
 
 
144
        virtual QRegExp& regExp( void )
 
145
        { return _regExp; }
 
146
 
 
147
        //@}
 
148
 
 
149
 
 
150
        //! mask
 
151
        //!@{
 
152
 
 
153
        unsigned int mask( void ) const
 
154
        { return _mask; }
 
155
 
 
156
        void setMask( unsigned int mask )
 
157
        { _mask = mask; }
 
158
 
 
159
        //@}
 
160
 
 
161
        private:
 
162
 
 
163
        //! enability
 
164
        bool _enabled;
 
165
 
 
166
        //! exception type
 
167
        Type _type;
 
168
 
 
169
        //! regular expression to match window caption
 
170
        QRegExp _regExp;
 
171
 
 
172
        //! attributes mask
 
173
        unsigned int _mask;
 
174
 
 
175
    };
 
176
 
 
177
 
 
178
 
 
179
}
 
180
 
 
181
#endif