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

« back to all changes in this revision

Viewing changes to maliit/attributeextension.h

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: package-import@ubuntu.com-20130723194704-0o18p2ao0x9sa1zx
Tags: upstream-0.99.0+git20130615+97e8335
ImportĀ upstreamĀ versionĀ 0.99.0+git20130615+97e8335

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* * This file is part of Maliit framework *
2
 
 *
3
 
 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
4
 
 * All rights reserved.
5
 
 *
6
 
 * Contact: maliit-discuss@lists.maliit.org
7
 
 *
8
 
 * This library is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Lesser General Public
10
 
 * License version 2.1 as published by the Free Software Foundation
11
 
 * and appearing in the file LICENSE.LGPL included in the packaging
12
 
 * of this file.
13
 
 */
14
 
 
15
 
// Based on minputmethodstate.h from libmeegotouch
16
 
 
17
 
#ifndef MALIIT_ATTRIBUTEEXTENSION_H
18
 
#define MALIIT_ATTRIBUTEEXTENSION_H
19
 
 
20
 
#include <QMap>
21
 
#include <QObject>
22
 
#include <QScopedPointer>
23
 
#include <QSharedPointer>
24
 
#include <QString>
25
 
#include <QVariant>
26
 
 
27
 
namespace Maliit {
28
 
 
29
 
class AttributeExtensionPrivate;
30
 
 
31
 
/*! \ingroup libmaliit
32
 
 * \brief Register extensions such as key overrides.
33
 
 */
34
 
class AttributeExtension : public QObject
35
 
{
36
 
    Q_OBJECT
37
 
 
38
 
public:
39
 
    /*!
40
 
     * \brief Registers an attribute extension (toolbar contents, keyboard overrides) which is defined in \a fileName, and will be assigned to a text input widget (software input panel).
41
 
     * \param \a fileName is the file name of the attribute extension. The filename should be absolute. If the filename is relative, it
42
 
     *      will be looked up in the default directory provided by the framework.
43
 
     * \note if \a fileName is an empty string, then it means don't load any content, just get a new id.
44
 
     * \return the registered unique identifier of this attribute extension.
45
 
     */
46
 
    explicit AttributeExtension(const QString &fileName = QString());
47
 
    explicit AttributeExtension(int id, bool registerExtension = true);
48
 
    virtual ~AttributeExtension();
49
 
 
50
 
    // same as the constructors above, but returning a QSharedPointer
51
 
    static QSharedPointer<AttributeExtension> create(int id);
52
 
 
53
 
    // providing target name -> (item name -> (attribute name -> attribute value))
54
 
    typedef QMap<QString, QVariant> ExtendedAttributeMap;
55
 
 
56
 
    // returns all the registered extended attributes.
57
 
    ExtendedAttributeMap attributes() const;
58
 
 
59
 
    /*!
60
 
     * \brief Returns the attribute extension definition file name.
61
 
     * \return the file name of the attribute extension, or empty QString.
62
 
     */
63
 
    QString fileName() const;
64
 
 
65
 
    /*!
66
 
     * \brief Returns an unique identifier id for the attribute extension.
67
 
     * \return the unique identifier id.
68
 
     */
69
 
    int id() const;
70
 
 
71
 
    /*!
72
 
     * \brief Return key corresponding to given parameters.
73
 
     *
74
 
     * \param target Attribute extension.
75
 
     * \param targetItem Item name.
76
 
     * \param attribute Attribute name.
77
 
     *
78
 
     * \sa setAttribute()
79
 
     */
80
 
    static QString key(const QString &target,
81
 
                       const QString &targetItem,
82
 
                       const QString &attribute);
83
 
 
84
 
    /*!
85
 
     * \brief Update cached \a value of extended attribute corresponding to given \a key.
86
 
     */
87
 
    void updateAttribute(const QString &key,
88
 
                         const QVariant &value);
89
 
 
90
 
public Q_SLOTS:
91
 
    /*!
92
 
     * \brief Set the \a attribute of the \a targetItem in the input method registered attribute extension \a target to \a value.
93
 
     * \param key a string specifying the target for the attribute.
94
 
     * \param value new value.
95
 
     *
96
 
     * \note
97
 
     *  Every key begins with a slash character ('/') and is of the form /target/item/attribute
98
 
     *  Target "keys" is used for virtual keyboard keys, "toolbar" for toolbar contents.
99
 
     *  Additional targets can be added in the future.
100
 
     */
101
 
    void setAttribute(const QString &key, const QVariant &value);
102
 
 
103
 
Q_SIGNALS:
104
 
    /*!
105
 
     * \brief Informs application that input method server has changed the extended attribute.
106
 
     * \param key a string specifying the target for the attribute.
107
 
     * \param value new value.
108
 
     */
109
 
    void extendedAttributeChanged(const QString &key,
110
 
                                  const QVariant &value);
111
 
 
112
 
private Q_SLOTS:
113
 
 
114
 
private:
115
 
    Q_DISABLE_COPY(AttributeExtension)
116
 
 
117
 
    const QScopedPointer<AttributeExtensionPrivate> d_ptr;
118
 
 
119
 
    Q_DECLARE_PRIVATE(AttributeExtension)
120
 
};
121
 
 
122
 
} // namespace Maliit
123
 
 
124
 
#endif // MALIIT_ATTRIBUTEEXTENSION_H