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

« back to all changes in this revision

Viewing changes to plasma/generic/dataengines/tasks/virtualdesktopssource.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 Matthieu Gallien <matthieu_gallien@yahoo.fr>
 
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; either
 
6
 * version 2 of the License, or (at your option) any later version.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details
 
12
 *
 
13
 * You should have received a copy of the GNU Library General Public
 
14
 * License along with this program; if not, write to the
 
15
 * Free Software Foundation, Inc.,
 
16
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
17
 */
 
18
 
 
19
#include "virtualdesktopssource.h"
 
20
 
 
21
#include <KDE/KWindowSystem>
 
22
 
 
23
VirtualDesktopsSource::VirtualDesktopsSource() : Plasma::DataContainer()
 
24
{
 
25
    setObjectName( QLatin1String("virtualDesktops" ));
 
26
    connect(KWindowSystem::self(), SIGNAL(numberOfDesktopsChanged(int)), this, SLOT(updateDesktopNumber(int)));
 
27
    connect(KWindowSystem::self(), SIGNAL(desktopNamesChanged()), this, SLOT(updateDesktopNames()));
 
28
    updateDesktopNumber(KWindowSystem::self()->numberOfDesktops());
 
29
    updateDesktopNames();
 
30
}
 
31
 
 
32
VirtualDesktopsSource::~VirtualDesktopsSource()
 
33
{
 
34
    disconnect(KWindowSystem::self(), SIGNAL(numberOfDesktopsChanged(int)), this, SLOT(updateDesktopNumber(int)));
 
35
}
 
36
 
 
37
void VirtualDesktopsSource::updateDesktopNumber(int desktop)
 
38
{
 
39
    setData("number", desktop);
 
40
    checkForUpdate();
 
41
}
 
42
 
 
43
void VirtualDesktopsSource::updateDesktopNames()
 
44
{
 
45
    QList<QVariant> desktopNames;
 
46
    for (int i = 0; i < KWindowSystem::self()->numberOfDesktops(); i++) {
 
47
        desktopNames.append(KWindowSystem::self()->desktopName(i + 1));
 
48
    }
 
49
    setData("names", desktopNames);
 
50
    checkForUpdate();
 
51
}