1 /****************************************************************************
5 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
11 #ifndef _CONDITIONS_H_
12 #define _CONDITIONS_H_
14 #include "action_data/action_data_group.h"
18 // Needed for None below
22 #include <QtCore/QObject>
31 class Condition_list_base
;
33 class KDE_EXPORT Condition
35 Q_DISABLE_COPY( Condition
)
38 Condition( Condition_list_base
* parent_P
);
39 Condition( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
);
41 virtual bool match() const = 0;
42 virtual void updated() const; // called when the condition changes
43 virtual void cfg_write( KConfigGroup
& cfg_P
) const = 0;
44 virtual const QString
description() const = 0;
45 virtual Condition
* copy( Condition_list_base
* parent_P
) const = 0;
46 const Condition_list_base
* parent() const;
47 Condition_list_base
* parent();
48 static Condition
* create_cfg_read( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
);
50 Condition_list_base
* const _parent
;
53 class KDE_EXPORT Condition_list_base
54 : public Condition
, public Q3PtrList
< Condition
> // inheritance ?
56 typedef Condition base
;
58 Condition_list_base( Condition_list_base
* parent_P
);
59 Condition_list_base( const Q3PtrList
< Condition
>& children_P
,
60 Condition_list_base
* parent_P
);
61 Condition_list_base( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
);
62 virtual ~Condition_list_base();
63 virtual void cfg_write( KConfigGroup
& cfg_P
) const;
64 virtual bool accepts_children() const;
65 typedef Q3PtrListIterator
< Condition
> Iterator
;
68 class KDE_EXPORT Condition_list
69 : public Condition_list_base
71 typedef Condition_list_base base
;
73 Condition_list( const QString
& comment_P
, ActionDataBase
* data_P
);
74 Condition_list( KConfigGroup
& cfg_P
, ActionDataBase
* data_P
);
75 void cfg_write( KConfigGroup
& cfg_P
) const;
76 Condition_list
* copy( ActionDataBase
* data_P
) const;
77 virtual bool match() const;
78 const QString
& comment() const;
79 void set_data( ActionDataBase
* data_P
);
80 virtual void updated() const;
81 virtual Condition_list
* copy( Condition_list_base
* parent_P
) const;
82 virtual const QString
description() const;
88 class KDE_EXPORT Active_window_condition
89 : public QObject
, public Condition
92 typedef Condition base
;
94 Active_window_condition( Windowdef_list
* window_P
, Condition_list_base
* parent_P
);
95 Active_window_condition( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
);
96 virtual ~Active_window_condition();
97 virtual bool match() const;
98 virtual void cfg_write( KConfigGroup
& cfg_P
) const;
99 const Windowdef_list
* window() const;
100 virtual Active_window_condition
* copy( Condition_list_base
* parent_P
) const;
101 virtual const QString
description() const;
103 void active_window_changed( WId
);
107 Windowdef_list
* _window
;
111 class KDE_EXPORT Existing_window_condition
112 : public QObject
, public Condition
115 typedef Condition base
;
117 Existing_window_condition( Windowdef_list
* window_P
, Condition_list_base
* parent_P
);
118 Existing_window_condition( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
);
119 virtual ~Existing_window_condition();
120 virtual bool match() const;
121 virtual void cfg_write( KConfigGroup
& cfg_P
) const;
122 const Windowdef_list
* window() const;
123 virtual Existing_window_condition
* copy( Condition_list_base
* parent_P
) const;
124 virtual const QString
description() const;
126 void window_added( WId w_P
);
127 void window_removed( WId w_P
);
130 void set_match( WId w_P
= None
);
131 Windowdef_list
* _window
;
135 class KDE_EXPORT Not_condition
136 : public Condition_list_base
138 typedef Condition_list_base base
;
140 Not_condition( Condition_list_base
* parent_P
);
141 Not_condition( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
);
142 virtual bool match() const;
143 virtual void cfg_write( KConfigGroup
& cfg_P
) const;
144 virtual Not_condition
* copy( Condition_list_base
* parent_P
) const;
145 virtual const QString
description() const;
146 const Condition
* condition() const;
147 virtual bool accepts_children() const;
150 class KDE_EXPORT And_condition
151 : public Condition_list_base
153 typedef Condition_list_base base
;
155 And_condition( Condition_list_base
* parent_P
);
156 And_condition( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
);
157 virtual bool match() const;
158 virtual void cfg_write( KConfigGroup
& cfg_P
) const;
159 virtual And_condition
* copy( Condition_list_base
* parent_P
) const;
160 virtual const QString
description() const;
163 class KDE_EXPORT Or_condition
164 : public Condition_list_base
166 typedef Condition_list_base base
;
168 Or_condition( Condition_list_base
* parent_P
);
169 Or_condition( KConfigGroup
& cfg_P
, Condition_list_base
* parent_P
);
170 virtual bool match() const;
171 virtual void cfg_write( KConfigGroup
& cfg_P
) const;
172 virtual Or_condition
* copy( Condition_list_base
* parent_P
) const;
173 virtual const QString
description() const;
176 //***************************************************************************
178 //***************************************************************************
183 const Condition_list_base
* Condition::parent() const
189 Condition_list_base
* Condition::parent()
194 // Condition_list_base
197 Condition_list_base::Condition_list_base( Condition_list_base
* parent_P
)
198 : Condition( parent_P
), Q3PtrList
< Condition
>()
203 Condition_list_base::Condition_list_base( const Q3PtrList
< Condition
>& children_P
,
204 Condition_list_base
* parent_P
)
205 : Condition( parent_P
), Q3PtrList
< Condition
>( children_P
)
212 Condition_list::Condition_list( const QString
& comment_P
, ActionDataBase
* data_P
)
213 : Condition_list_base( NULL
), _comment( comment_P
), data( data_P
)
218 const QString
& Condition_list::comment() const
223 // Active_window_condition
226 Active_window_condition::Active_window_condition( Windowdef_list
* window_P
,
227 Condition_list_base
* parent_P
)
228 : Condition( parent_P
), _window( window_P
)
235 const Windowdef_list
* Active_window_condition::window() const
240 // Existing_window_condition
243 Existing_window_condition::Existing_window_condition( Windowdef_list
* window_P
,
244 Condition_list_base
* parent_P
)
245 : Condition( parent_P
), _window( window_P
), is_match( false )
252 const Windowdef_list
* Existing_window_condition::window() const
260 Not_condition::Not_condition( Condition_list_base
* parent_P
)
261 : Condition_list_base( parent_P
)
266 const Condition
* Not_condition::condition() const
274 And_condition::And_condition( Condition_list_base
* parent_P
)
275 : Condition_list_base( parent_P
)
282 Or_condition::Or_condition( Condition_list_base
* parent_P
)
283 : Condition_list_base( parent_P
)
287 } // namespace KHotKeys