~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to examples/apps/settings/selectentrycombobox.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of Maliit framework
2
 
 *
3
 
 * Copyright (C) 2012 Openismus GmbH
4
 
 *
5
 
 * Contact: maliit-discuss@lists.maliit.org
6
 
 *
7
 
 * This library is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU Lesser General Public
9
 
 * License as published by the Free Software Foundation; either
10
 
 * version 2.1 of the licence, or (at your option) any later version.
11
 
 *
12
 
 * This library is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
 * Lesser General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with this library; if not, write to the
19
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
 * Boston, MA 02111-1307, USA.
21
 
 */
22
 
 
23
 
#include "selectentrycombobox.h"
24
 
 
25
 
SelectEntryComboBox::SelectEntryComboBox(const QSharedPointer<Maliit::SettingsEntry>& entry)
26
 
    : m_entry(entry)
27
 
{
28
 
    if (m_entry) {
29
 
        const QStringList values(entry->attributes()[Maliit::SettingEntryAttributes::valueDomain].toStringList());
30
 
        const QStringList descriptions(entry->attributes()[Maliit::SettingEntryAttributes::valueDomainDescriptions].toStringList());
31
 
 
32
 
        for (int index(0); index < values.count(); ++index) {
33
 
            addItem(descriptions[index], values[index]);
34
 
        }
35
 
 
36
 
        onValueChanged();
37
 
 
38
 
        connect(this, SIGNAL(currentIndexChanged(int)),
39
 
                this, SLOT(onSelected(int)));
40
 
 
41
 
        connect(m_entry.data(), SIGNAL(valueChanged()),
42
 
                this, SLOT(onValueChanged()));
43
 
    } else {
44
 
        setDisabled(true);
45
 
    }
46
 
}
47
 
 
48
 
void SelectEntryComboBox::onSelected(int index)
49
 
{
50
 
    if (m_entry) {
51
 
        m_entry->set(itemData(index));
52
 
    }
53
 
}
54
 
 
55
 
void SelectEntryComboBox::onValueChanged()
56
 
{
57
 
    if (m_entry) {
58
 
        setCurrentIndex(findData(m_entry->value()));
59
 
    }
60
 
}