add more spacing
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / conditions / condition.cpp
blobbf82279f60f69fe07cefbf333f3b28063b3c6650
1 /*
2 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
3 Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "conditions.h"
22 #include <KDE/KConfigGroup>
23 #include <KDE/KDebug>
25 namespace KHotKeys {
27 Condition::Condition( Condition_list_base* parent_P )
28 : _parent( parent_P )
30 if( _parent )
31 _parent->append( this );
34 Condition::Condition( KConfigGroup&, Condition_list_base* parent_P )
35 : _parent( parent_P )
37 if( _parent )
38 _parent->append( this );
41 Condition* Condition::create_cfg_read( KConfigGroup& cfg_P, Condition_list_base* parent_P )
43 QString type = cfg_P.readEntry( "Type" );
44 if( type == "ACTIVE_WINDOW" )
45 return new Active_window_condition( cfg_P, parent_P );
46 if( type == "EXISTING_WINDOW" )
47 return new Existing_window_condition( cfg_P, parent_P );
48 if( type == "NOT" )
49 return new Not_condition( cfg_P, parent_P );
50 if( type == "AND" )
51 return new And_condition( cfg_P, parent_P );
52 if( type == "OR" )
53 return new Or_condition( cfg_P, parent_P );
54 kWarning() << "Unknown Condition type read from cfg file\n";
55 return NULL;
58 Condition::~Condition()
60 if( _parent )
61 _parent->remove( this );
65 void Condition::cfg_write( KConfigGroup& cfg_P ) const
67 cfg_P.writeEntry( "Type", "ERROR" );
70 void Condition::updated() const
72 if( !khotkeys_active())
73 return;
74 Q_ASSERT( _parent != NULL );
75 _parent->updated();
79 } // namespace KHotKeys