~ubuntu-branches/ubuntu/utopic/qmenumodel/utopic-proposed

« back to all changes in this revision

Viewing changes to libqmenumodel/src/unitymenuaction.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-08-12 18:38:17 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20130812183817-iu42w3g66bork08k
Tags: upstream-0.2.6+13.10.20130812
ImportĀ upstreamĀ versionĀ 0.2.6+13.10.20130812

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
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 Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authors:
 
17
 *      Nick Dedekind <nick.dedekind@canonical.com>
 
18
 */
 
19
 
 
20
#include "unitymenuaction.h"
 
21
#include "unitymenumodel.h"
 
22
 
 
23
UnityMenuAction::UnityMenuAction(QObject* parent)
 
24
    : QObject(parent),
 
25
      m_model(NULL),
 
26
      m_index(-1)
 
27
{
 
28
}
 
29
 
 
30
int UnityMenuAction::index() const
 
31
{
 
32
    return m_index;
 
33
}
 
34
 
 
35
void UnityMenuAction::setIndex(int index)
 
36
{
 
37
    if (m_index != index) {
 
38
        m_index = index;
 
39
        Q_EMIT indexChanged(index);
 
40
    }
 
41
}
 
42
 
 
43
UnityMenuModel* UnityMenuAction::model() const
 
44
{
 
45
    return m_model;
 
46
}
 
47
 
 
48
void UnityMenuAction::setModel(UnityMenuModel* model)
 
49
{
 
50
    if (m_model != model) {
 
51
        if (m_model) {
 
52
            disconnect(m_model);
 
53
        }
 
54
        m_model = model;
 
55
 
 
56
        connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SIGNAL(stateChanged()));
 
57
 
 
58
        Q_EMIT modelChanged(model);
 
59
    }
 
60
}