~sil2100/unity-2d/precise-security

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/bfb.cpp

  • Committer: Aurelien Gateau
  • Date: 2010-11-10 08:57:29 UTC
  • mto: This revision was merged to the branch mainline in revision 284.
  • Revision ID: aurelien.gateau@canonical.com-20101110085729-fl1ye7impkqhm0w6
Added a section about const correct-ness

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2011 Canonical, Ltd.
3
 
 *
4
 
 * Authors:
5
 
 *  Aurélien Gâteau <aurelien.gateau@canonical.com>
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; version 3.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 */
19
 
 
20
 
#include "config.h"
21
 
#include "bfb.h"
22
 
 
23
 
// libunity-2d
24
 
#include <debug_p.h>
25
 
#include <unity2dtr.h>
26
 
 
27
 
// Qt
28
 
 
29
 
BfbItem::BfbItem()
30
 
: m_active(false), m_view(NULL)
31
 
{
32
 
}
33
 
 
34
 
BfbItem::~BfbItem()
35
 
{
36
 
}
37
 
 
38
 
bool BfbItem::active() const
39
 
{
40
 
    return m_active;
41
 
}
42
 
 
43
 
bool BfbItem::running() const
44
 
{
45
 
    return false;
46
 
}
47
 
 
48
 
int BfbItem::windowCount() const
49
 
{
50
 
    return 0;
51
 
}
52
 
 
53
 
bool BfbItem::urgent() const
54
 
{
55
 
    return false;
56
 
}
57
 
 
58
 
QString BfbItem::name() const
59
 
{
60
 
    return u2dTr("Dash home");
61
 
}
62
 
 
63
 
QString BfbItem::icon() const
64
 
{
65
 
    return QString(UNITY_DIR) + "5/launcher_bfb.png";
66
 
}
67
 
 
68
 
bool BfbItem::launching() const
69
 
{
70
 
    return false;
71
 
}
72
 
 
73
 
QObject* BfbItem::dashView() const
74
 
{
75
 
    return m_view;
76
 
}
77
 
 
78
 
void BfbItem::setDashView(QObject* view)
79
 
{
80
 
    if (m_view != NULL) {
81
 
        disconnect(view);
82
 
    }
83
 
    m_view = view;
84
 
    if (m_view != NULL) {
85
 
        connect(view, SIGNAL(dashActiveChanged(bool)), this, SLOT(slotDashActiveChanged(bool)));
86
 
    }
87
 
}
88
 
 
89
 
void BfbItem::activate()
90
 
{
91
 
    Q_ASSERT(m_view != NULL);
92
 
    if (m_view != NULL) {
93
 
        QMetaObject::invokeMethod(m_view, "toggleDash");
94
 
    }
95
 
}
96
 
 
97
 
void BfbItem::createMenuActions()
98
 
{
99
 
}
100
 
 
101
 
void BfbItem::slotDashActiveChanged(bool active)
102
 
{
103
 
    if (m_active != active) {
104
 
        m_active = active;
105
 
        Q_EMIT activeChanged(m_active);
106
 
    }
107
 
}
108
 
 
109
 
////////////////////////////////////////////////////////////
110
 
BfbModel::BfbModel(QObject* parent)
111
 
: QAbstractListModel(parent)
112
 
, m_bfbItem(new BfbItem)
113
 
{
114
 
}
115
 
 
116
 
BfbModel::~BfbModel()
117
 
{
118
 
    delete m_bfbItem;
119
 
}
120
 
 
121
 
int BfbModel::rowCount(const QModelIndex& /*parent*/) const
122
 
{
123
 
    return 1;
124
 
}
125
 
 
126
 
QVariant BfbModel::data(const QModelIndex& index, int /*role*/) const
127
 
{
128
 
    if (!index.isValid()) {
129
 
        return QVariant();
130
 
    }
131
 
 
132
 
    return QVariant::fromValue(m_bfbItem);
133
 
}
134
 
 
135
 
QObject* BfbModel::dashView() const
136
 
{
137
 
    return m_bfbItem->dashView();
138
 
}
139
 
 
140
 
void BfbModel::setDashView(QObject* view)
141
 
{
142
 
    m_bfbItem->setDashView(view);
143
 
}
144
 
 
145
 
#include <bfb.moc>