Qt 4.8
Public Functions | Static Public Functions | Private Slots | Properties | Static Private Attributes | Friends | List of all members
QWSKbPrivate Class Reference
Inheritance diagram for QWSKbPrivate:
QObject

Public Functions

void beginAutoRepeat (int uni, int code, Qt::KeyboardModifiers mod)
 
void endAutoRepeat ()
 
bool loadKeymap (const QString &file)
 
 QWSKbPrivate (QWSKeyboardHandler *h, const QString &device)
 
void unloadKeymap ()
 
 ~QWSKbPrivate ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static Qt::KeyboardModifiers toQtModifiers (quint8 mod)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Private Slots

void autoRepeat ()
 

Properties

int m_ar_delay
 
int m_ar_keycode
 
Qt::KeyboardModifiers m_ar_modifier
 
int m_ar_period
 
QTimerm_ar_timer
 
int m_ar_unicode
 
int m_composing
 
quint16 m_dead_unicode
 
bool m_do_compose
 
QWSKeyboardHandlerm_handler
 
const QWSKeyboard::Composingm_keycompose
 
int m_keycompose_size
 
const QWSKeyboard::Mappingm_keymap
 
int m_keymap_size
 
quint8 m_locks [3]
 
quint8 m_modifiers
 
bool m_no_zap
 

Static Private Attributes

static const QWSKeyboard::Composing s_keycompose_default []
 
static const QWSKeyboard::Mapping s_keymap_default []
 

Friends

class QWSKeyboardHandler
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 69 of file qkbd_qws.cpp.

Constructors and Destructors

◆ QWSKbPrivate()

QWSKbPrivate::QWSKbPrivate ( QWSKeyboardHandler h,
const QString device 
)
inline

Definition at line 73 of file qkbd_qws.cpp.

Referenced by QWSKeyboardHandler::QWSKeyboardHandler().

74  : m_handler(h), m_modifiers(0), m_composing(0), m_dead_unicode(0xffff),
75  m_no_zap(false), m_do_compose(false),
77  {
78  m_ar_timer = new QTimer(this);
80  connect(m_ar_timer, SIGNAL(timeout()), SLOT(autoRepeat()));
81  m_ar_delay = 400;
82  m_ar_period = 80;
83 
84  memset(m_locks, 0, sizeof(m_locks));
85 
86  QString keymap;
87  QStringList args = device.split(QLatin1Char(':'));
88  foreach (const QString &arg, args) {
89  if (arg.startsWith(QLatin1String("keymap=")))
90  keymap = arg.mid(7);
91  else if (arg == QLatin1String("disable-zap"))
92  m_no_zap = true;
93  else if (arg == QLatin1String("enable-compose"))
94  m_do_compose = true;
95  else if (arg.startsWith(QLatin1String("repeat-delay=")))
96  m_ar_delay = arg.mid(13).toInt();
97  else if (arg.startsWith(QLatin1String("repeat-rate=")))
98  m_ar_period = arg.mid(12).toInt();
99  }
100 
101  if (keymap.isEmpty() || !loadKeymap(keymap))
102  unloadKeymap();
103  }
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
#define SLOT(a)
Definition: qobjectdefs.h:226
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
quint8 m_locks[3]
Definition: qkbd_qws.cpp:161
bool m_do_compose
Definition: qkbd_qws.cpp:166
quint16 m_dead_unicode
Definition: qkbd_qws.cpp:163
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QTimer * m_ar_timer
Definition: qkbd_qws.cpp:157
void autoRepeat()
Definition: qkbd_qws.cpp:141
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
void unloadKeymap()
Definition: qkbd_qws.cpp:185
bool loadKeymap(const QString &file)
Definition: qkbd_qws.cpp:204
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
const QWSKeyboard::Mapping * m_keymap
Definition: qkbd_qws.cpp:168
int m_keycompose_size
Definition: qkbd_qws.cpp:171
QWSKeyboardHandler * m_handler
Definition: qkbd_qws.cpp:149
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
const QWSKeyboard::Composing * m_keycompose
Definition: qkbd_qws.cpp:170
int m_keymap_size
Definition: qkbd_qws.cpp:169
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
quint8 m_modifiers
Definition: qkbd_qws.cpp:160
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ ~QWSKbPrivate()

QWSKbPrivate::~QWSKbPrivate ( )
inline

Definition at line 105 of file qkbd_qws.cpp.

106  {
107  unloadKeymap();
108  }
void unloadKeymap()
Definition: qkbd_qws.cpp:185

Functions

◆ autoRepeat

void QWSKbPrivate::autoRepeat ( )
inlineprivateslot

Definition at line 141 of file qkbd_qws.cpp.

Referenced by QWSKbPrivate().

142  {
146  }
QTimer * m_ar_timer
Definition: qkbd_qws.cpp:157
QWSKeyboardHandler * m_handler
Definition: qkbd_qws.cpp:149
Qt::KeyboardModifiers m_ar_modifier
Definition: qkbd_qws.cpp:154
int m_ar_keycode
Definition: qkbd_qws.cpp:153
int m_ar_unicode
Definition: qkbd_qws.cpp:152
virtual void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat)
Sends a key event to the Qt for Embedded Linux server application.
Definition: qkbd_qws.cpp:363
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249

◆ beginAutoRepeat()

void QWSKbPrivate::beginAutoRepeat ( int  uni,
int  code,
Qt::KeyboardModifiers  mod 
)
inline

Definition at line 110 of file qkbd_qws.cpp.

111  {
112  m_ar_unicode = uni;
113  m_ar_keycode = code;
114  m_ar_modifier = mod;
116  }
QTimer * m_ar_timer
Definition: qkbd_qws.cpp:157
Qt::KeyboardModifiers m_ar_modifier
Definition: qkbd_qws.cpp:154
int m_ar_keycode
Definition: qkbd_qws.cpp:153
int m_ar_unicode
Definition: qkbd_qws.cpp:152
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249

◆ endAutoRepeat()

void QWSKbPrivate::endAutoRepeat ( )
inline

Definition at line 118 of file qkbd_qws.cpp.

119  {
120  m_ar_timer->stop();
121  }
QTimer * m_ar_timer
Definition: qkbd_qws.cpp:157
void stop()
Stops the timer.
Definition: qtimer.cpp:284

◆ loadKeymap()

bool QWSKbPrivate::loadKeymap ( const QString file)

Definition at line 204 of file qkbd_qws.cpp.

Referenced by QWSKbPrivate(), and toQtModifiers().

205 {
206  QFile f(file);
207 
208  if (!f.open(QIODevice::ReadOnly)) {
209  qWarning("Could not open keymap file '%s'", qPrintable(file));
210  return false;
211  }
212 
213  // .qmap files have a very simple structure:
214  // quint32 magic (QWSKeyboard::FileMagic)
215  // quint32 version (1)
216  // quint32 keymap_size (# of struct QWSKeyboard::Mappings)
217  // quint32 keycompose_size (# of struct QWSKeyboard::Composings)
218  // all QWSKeyboard::Mappings via QDataStream::operator(<<|>>)
219  // all QWSKeyboard::Composings via QDataStream::operator(<<|>>)
220 
221  quint32 qmap_magic, qmap_version, qmap_keymap_size, qmap_keycompose_size;
222 
223  QDataStream ds(&f);
224 
225  ds >> qmap_magic >> qmap_version >> qmap_keymap_size >> qmap_keycompose_size;
226 
227  if (ds.status() != QDataStream::Ok || qmap_magic != QWSKeyboard::FileMagic || qmap_version != 1 || qmap_keymap_size == 0) {
228  qWarning("'%s' is not a valid .qmap keymap file.", qPrintable(file));
229  return false;
230  }
231 
232  QWSKeyboard::Mapping *qmap_keymap = new QWSKeyboard::Mapping[qmap_keymap_size];
233  QWSKeyboard::Composing *qmap_keycompose = qmap_keycompose_size ? new QWSKeyboard::Composing[qmap_keycompose_size] : 0;
234 
235  for (quint32 i = 0; i < qmap_keymap_size; ++i)
236  ds >> qmap_keymap[i];
237  for (quint32 i = 0; i < qmap_keycompose_size; ++i)
238  ds >> qmap_keycompose[i];
239 
240  if (ds.status() != QDataStream::Ok) {
241  delete [] qmap_keymap;
242  delete [] qmap_keycompose;
243 
244  qWarning("Keymap file '%s' can not be loaded.", qPrintable(file));
245  return false;
246  }
247 
248  // unload currently active and clear state
249  unloadKeymap();
250 
251  m_keymap = qmap_keymap;
252  m_keymap_size = qmap_keymap_size;
253  m_keycompose = qmap_keycompose;
254  m_keycompose_size = qmap_keycompose_size;
255 
256  m_do_compose = true;
257 
258  return true;
259 }
bool m_do_compose
Definition: qkbd_qws.cpp:166
void unloadKeymap()
Definition: qkbd_qws.cpp:185
Q_CORE_EXPORT void qWarning(const char *,...)
const QWSKeyboard::Mapping * m_keymap
Definition: qkbd_qws.cpp:168
int m_keycompose_size
Definition: qkbd_qws.cpp:171
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
const QWSKeyboard::Composing * m_keycompose
Definition: qkbd_qws.cpp:170
int m_keymap_size
Definition: qkbd_qws.cpp:169
unsigned int quint32
Definition: qglobal.h:938
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
#define qPrintable(string)
Definition: qglobal.h:1750
const quint32 FileMagic
Definition: qkbd_qws_p.h:61

◆ toQtModifiers()

static Qt::KeyboardModifiers QWSKbPrivate::toQtModifiers ( quint8  mod)
inlinestatic

◆ unloadKeymap()

void QWSKbPrivate::unloadKeymap ( )

Definition at line 185 of file qkbd_qws.cpp.

Referenced by loadKeymap(), QWSKbPrivate(), toQtModifiers(), and ~QWSKbPrivate().

186 {
188  delete [] m_keymap;
190  delete [] m_keycompose;
191 
193  m_keymap_size = sizeof(s_keymap_default) / sizeof(s_keymap_default[0]);
196 
197  // reset state, so we could switch keymaps at runtime
198  m_modifiers = 0;
199  memset(m_locks, 0, sizeof(m_locks));
200  m_composing = 0;
201  m_dead_unicode = 0xffff;
202 }
quint8 m_locks[3]
Definition: qkbd_qws.cpp:161
quint16 m_dead_unicode
Definition: qkbd_qws.cpp:163
const QWSKeyboard::Mapping * m_keymap
Definition: qkbd_qws.cpp:168
int m_keycompose_size
Definition: qkbd_qws.cpp:171
const QWSKeyboard::Composing * m_keycompose
Definition: qkbd_qws.cpp:170
int m_keymap_size
Definition: qkbd_qws.cpp:169
quint8 m_modifiers
Definition: qkbd_qws.cpp:160
static const QWSKeyboard::Composing s_keycompose_default[]
Definition: qkbd_qws.cpp:174
static const QWSKeyboard::Mapping s_keymap_default[]
Definition: qkbd_qws.cpp:173

Friends and Related Functions

◆ QWSKeyboardHandler

friend class QWSKeyboardHandler
friend

Definition at line 176 of file qkbd_qws.cpp.

Properties

◆ m_ar_delay

int QWSKbPrivate::m_ar_delay
private

Definition at line 155 of file qkbd_qws.cpp.

Referenced by beginAutoRepeat(), and QWSKbPrivate().

◆ m_ar_keycode

int QWSKbPrivate::m_ar_keycode
private

Definition at line 153 of file qkbd_qws.cpp.

Referenced by autoRepeat(), and beginAutoRepeat().

◆ m_ar_modifier

Qt::KeyboardModifiers QWSKbPrivate::m_ar_modifier
private

Definition at line 154 of file qkbd_qws.cpp.

Referenced by autoRepeat(), and beginAutoRepeat().

◆ m_ar_period

int QWSKbPrivate::m_ar_period
private

Definition at line 156 of file qkbd_qws.cpp.

Referenced by autoRepeat(), and QWSKbPrivate().

◆ m_ar_timer

QTimer* QWSKbPrivate::m_ar_timer
private

Definition at line 157 of file qkbd_qws.cpp.

Referenced by autoRepeat(), beginAutoRepeat(), endAutoRepeat(), and QWSKbPrivate().

◆ m_ar_unicode

int QWSKbPrivate::m_ar_unicode
private

Definition at line 152 of file qkbd_qws.cpp.

Referenced by autoRepeat(), and beginAutoRepeat().

◆ m_composing

int QWSKbPrivate::m_composing
private

Definition at line 162 of file qkbd_qws.cpp.

Referenced by unloadKeymap().

◆ m_dead_unicode

quint16 QWSKbPrivate::m_dead_unicode
private

Definition at line 163 of file qkbd_qws.cpp.

Referenced by unloadKeymap().

◆ m_do_compose

bool QWSKbPrivate::m_do_compose
private

Definition at line 166 of file qkbd_qws.cpp.

Referenced by loadKeymap(), and QWSKbPrivate().

◆ m_handler

QWSKeyboardHandler* QWSKbPrivate::m_handler
private

Definition at line 149 of file qkbd_qws.cpp.

Referenced by autoRepeat().

◆ m_keycompose

const QWSKeyboard::Composing* QWSKbPrivate::m_keycompose
private

Definition at line 170 of file qkbd_qws.cpp.

Referenced by loadKeymap(), and unloadKeymap().

◆ m_keycompose_size

int QWSKbPrivate::m_keycompose_size
private

Definition at line 171 of file qkbd_qws.cpp.

Referenced by loadKeymap(), QWSKeyboardHandler::processKeycode(), and unloadKeymap().

◆ m_keymap

const QWSKeyboard::Mapping* QWSKbPrivate::m_keymap
private

Definition at line 168 of file qkbd_qws.cpp.

Referenced by loadKeymap(), and unloadKeymap().

◆ m_keymap_size

int QWSKbPrivate::m_keymap_size
private

Definition at line 169 of file qkbd_qws.cpp.

Referenced by loadKeymap(), and unloadKeymap().

◆ m_locks

quint8 QWSKbPrivate::m_locks[3]
private

Definition at line 161 of file qkbd_qws.cpp.

Referenced by QWSKbPrivate(), and unloadKeymap().

◆ m_modifiers

quint8 QWSKbPrivate::m_modifiers
private

Definition at line 160 of file qkbd_qws.cpp.

Referenced by unloadKeymap().

◆ m_no_zap

bool QWSKbPrivate::m_no_zap
private

Definition at line 165 of file qkbd_qws.cpp.

Referenced by QWSKbPrivate().

◆ s_keycompose_default

const QWSKeyboard::Composing QWSKbPrivate::s_keycompose_default
staticprivate

Definition at line 174 of file qkbd_qws.cpp.

Referenced by unloadKeymap().

◆ s_keymap_default

const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default
staticprivate

Definition at line 173 of file qkbd_qws.cpp.

Referenced by unloadKeymap().


The documentation for this class was generated from the following files: