1
/* * This file is part of Maliit framework *
3
* Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: maliit-discuss@lists.maliit.org
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
15
// Based on minputmethodstate.h from libmeegotouch
17
#ifndef MALIIT_ATTRIBUTEEXTENSION_H
18
#define MALIIT_ATTRIBUTEEXTENSION_H
22
#include <QScopedPointer>
23
#include <QSharedPointer>
29
class AttributeExtensionPrivate;
31
/*! \ingroup libmaliit
32
* \brief Register extensions such as key overrides.
34
class AttributeExtension : public QObject
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.
46
explicit AttributeExtension(const QString &fileName = QString());
47
explicit AttributeExtension(int id, bool registerExtension = true);
48
virtual ~AttributeExtension();
50
// same as the constructors above, but returning a QSharedPointer
51
static QSharedPointer<AttributeExtension> create(int id);
53
// providing target name -> (item name -> (attribute name -> attribute value))
54
typedef QMap<QString, QVariant> ExtendedAttributeMap;
56
// returns all the registered extended attributes.
57
ExtendedAttributeMap attributes() const;
60
* \brief Returns the attribute extension definition file name.
61
* \return the file name of the attribute extension, or empty QString.
63
QString fileName() const;
66
* \brief Returns an unique identifier id for the attribute extension.
67
* \return the unique identifier id.
72
* \brief Return key corresponding to given parameters.
74
* \param target Attribute extension.
75
* \param targetItem Item name.
76
* \param attribute Attribute name.
80
static QString key(const QString &target,
81
const QString &targetItem,
82
const QString &attribute);
85
* \brief Update cached \a value of extended attribute corresponding to given \a key.
87
void updateAttribute(const QString &key,
88
const QVariant &value);
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.
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.
101
void setAttribute(const QString &key, const QVariant &value);
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.
109
void extendedAttributeChanged(const QString &key,
110
const QVariant &value);
115
Q_DISABLE_COPY(AttributeExtension)
117
const QScopedPointer<AttributeExtensionPrivate> d_ptr;
119
Q_DECLARE_PRIVATE(AttributeExtension)
122
} // namespace Maliit
124
#endif // MALIIT_ATTRIBUTEEXTENSION_H