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

« back to all changes in this revision

Viewing changes to khotkeys/libkhotkeysprivate/conditions/and_condition.cpp

  • 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
/*
 
2
   Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
 
3
   Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
 
4
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#include "conditions.h"
 
21
 
 
22
#include <KDE/KConfigGroup>
 
23
#include <KDE/KDebug>
 
24
 
 
25
namespace KHotKeys {
 
26
 
 
27
 
 
28
And_condition::And_condition( KConfigGroup& cfg_P, Condition_list_base* parent_P )
 
29
    : Condition_list_base( cfg_P, parent_P )
 
30
    {
 
31
    }
 
32
 
 
33
 
 
34
And_condition::And_condition( Condition_list_base* parent_P )
 
35
    : Condition_list_base( parent_P )
 
36
    {
 
37
    }
 
38
 
 
39
 
 
40
void And_condition::cfg_write( KConfigGroup& cfg_P ) const
 
41
    {
 
42
    kDebug() << description() << " with " << count() << " children";;
 
43
    base::cfg_write( cfg_P );
 
44
    cfg_P.writeEntry( "Type", "AND" ); // overwrites value set in base::cfg_write()
 
45
    }
 
46
 
 
47
 
 
48
And_condition* And_condition::copy() const
 
49
    {
 
50
    And_condition* ret = new And_condition();
 
51
    for (ConstIterator it=begin(); it!=end(); ++it)
 
52
        {
 
53
        ret->append((*it)->copy());
 
54
        }
 
55
    return ret;
 
56
    }
 
57
 
 
58
 
 
59
const QString And_condition::description() const
 
60
    {
 
61
    return i18nc( "And_condition", "And" );
 
62
    }
 
63
 
 
64
 
 
65
bool And_condition::match() const
 
66
    {
 
67
    for (ConstIterator it=begin(); it!=end(); ++it)
 
68
        {
 
69
        if (!(*it)->match())
 
70
            {
 
71
            return false;
 
72
            }
 
73
        }
 
74
    return true; // all true (or empty)
 
75
    }
 
76
 
 
77
 
 
78
} // namespace KHotKeys