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

« back to all changes in this revision

Viewing changes to plasma/netbook/containments/sal/iconactioncollection.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 2010 Marco Martin <notmart@gmail.com>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library General Public License as
 
6
 *   published by the Free Software Foundation; either version 2, or
 
7
 *   (at your option) any later version.
 
8
 *
 
9
 *   This program 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
 
12
 *   GNU General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
#include <QAction>
 
21
 
 
22
#include "iconactioncollection.h"
 
23
 
 
24
 
 
25
IconActionCollection::IconActionCollection(Plasma::Applet *applet, QObject *parent)
 
26
      : QObject(parent),
 
27
        m_immutability(Plasma::Mutable)
 
28
{
 
29
    if (applet) {
 
30
        connect (applet, SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SLOT(immutabilityChanged(Plasma::ImmutabilityType)));
 
31
        m_immutability = Plasma::Mutable;
 
32
    }
 
33
}
 
34
 
 
35
IconActionCollection::~IconActionCollection()
 
36
 
37
}
 
38
 
 
39
void IconActionCollection::addAction(QAction *action)
 
40
{
 
41
    if (action) {
 
42
        m_actions.insert(action);
 
43
        connect (action, SIGNAL(destroyed(QObject *)), this, SLOT(actionDestroyed(QObject *)));
 
44
        action->setVisible(m_immutability == Plasma::Mutable);
 
45
        action->setEnabled(m_immutability == Plasma::Mutable);
 
46
    }
 
47
}
 
48
 
 
49
void IconActionCollection::removeAction(QAction *action)
 
50
{
 
51
    m_actions.remove(action);
 
52
}
 
53
 
 
54
 
 
55
 
 
56
QList<QAction *> IconActionCollection::actions() const
 
57
{
 
58
    return m_actions.toList();
 
59
}
 
60
 
 
61
 
 
62
 
 
63
void IconActionCollection::actionDestroyed(QObject *object)
 
64
{
 
65
    m_actions.remove(static_cast<QAction *>(object));
 
66
}
 
67
 
 
68
void IconActionCollection::immutabilityChanged(Plasma::ImmutabilityType immutability)
 
69
{
 
70
    m_immutability = immutability;
 
71
 
 
72
    foreach (QAction *action, m_actions) {
 
73
        action->setVisible(immutability == Plasma::Mutable);
 
74
        action->setEnabled(immutability == Plasma::Mutable);
 
75
    }
 
76
}
 
77
 
 
78
 
 
79
#include "iconactioncollection.moc"