qskinny/inputcontext/QskInputCompositionModel.h

65 lines
1.7 KiB
C
Raw Normal View History

2018-02-06 13:55:35 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
2017-07-21 16:21:34 +00:00
#ifndef QSK_INPUT_COMPOSITION_MODEL_H
#define QSK_INPUT_COMPOSITION_MODEL_H
#include <QObject>
#include <memory>
2018-03-14 16:30:39 +00:00
class QInputMethodEvent;
2018-04-04 13:19:51 +00:00
class QskInputContext;
2017-07-21 16:21:34 +00:00
class QskInputCompositionModel : public QObject
{
Q_OBJECT
Q_PROPERTY( QVector< Qt::Key > groups READ groups NOTIFY groupsChanged )
public:
2018-04-04 13:19:51 +00:00
QskInputCompositionModel( QskInputContext* context );
2017-07-21 16:21:34 +00:00
virtual ~QskInputCompositionModel();
// to determine whether to show the suggestion bar:
virtual bool supportsSuggestions() const;
2017-07-21 16:21:34 +00:00
void commit( const QString& );
virtual void commitCandidate( int );
2017-07-21 16:21:34 +00:00
void composeKey( Qt::Key );
void clearPreedit();
virtual int candidateCount() const;
virtual QString candidate( int ) const;
2017-07-21 16:21:34 +00:00
int groupIndex() const;
void setGroupIndex( int groupIndex );
2017-07-21 16:21:34 +00:00
virtual bool nextGroupIndex( int&, bool = true ) const;
virtual QVector< Qt::Key > groups() const;
protected:
// Used for text composition
virtual bool hasIntermediate() const;
virtual QString polishPreedit( const QString& preedit );
virtual bool isComposable( const QStringRef& preedit ) const;
2018-04-04 13:19:51 +00:00
QskInputContext* context() const;
2017-07-21 16:21:34 +00:00
Q_SIGNALS:
void groupsChanged( const QVector< Qt::Key >& );
void candidatesChanged();
private:
2018-03-14 16:30:39 +00:00
void sendCompositionEvent( QInputMethodEvent* e );
2018-04-04 13:19:51 +00:00
void sendKeyEvents( int key );
2017-07-21 16:21:34 +00:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif