Mapper  0.9.0
API documentation
Classes | Public Types | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
OpenOrienteering::TextObjectEditorHelper Class Reference

Helper class for editing the text of a TextObject. More...

#include <text_object_editor_helper.h>

Inheritance diagram for OpenOrienteering::TextObjectEditorHelper:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::TextObjectEditorHelper:
Collaboration graph
[legend]

Classes

class  BatchEdit
 Establishes a scoped batch edit context and handles state change signals. More...
 

Public Types

enum  BatchEditAction {
  NoInputMethodAction = 0x00, UpdateInputProperties = 0x01, UpdateAllProperties = 0x02, ResetInputMethod = 0x03,
  CommitPreedit = 0x10
}
 Actions which may be performed on batch edit start or end. More...
 
template<typename T >
using not_null = T
 Indicates arguments which must not be nullptr. More...
 

Signals

void stateChanged ()
 Emitted when the text object or the selection is modified. More...
 
void finished ()
 Emitted when editing is finished. More...
 

Public Member Functions

 TextObjectEditorHelper (not_null< TextObject *> text_object, not_null< MapEditorController *> editor)
 
 ~TextObjectEditorHelper () override
 
TextObjectobject () const
 Returns the text object which is edited by this object. More...
 
QVariant inputMethodQuery (Qt::InputMethodQuery property, const QVariant &argument) const
 
bool inputMethodEvent (QInputMethodEvent *event)
 
bool mousePressEvent (QMouseEvent *event, const MapCoordF &map_coord, MapWidget *widget)
 
bool mouseMoveEvent (QMouseEvent *event, const MapCoordF &map_coord, MapWidget *widget)
 
bool mouseReleaseEvent (QMouseEvent *event, const MapCoordF &map_coord, MapWidget *widget)
 
bool keyPressEvent (QKeyEvent *event)
 
bool keyReleaseEvent (QKeyEvent *event)
 
void draw (QPainter *painter, MapWidget *widget)
 
void includeDirtyRect (QRectF &rect) const
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 QObject (QObject *parent)
 
virtual ~QObject ()
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectListchildren () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

Protected Member Functions

bool isPreediting () const
 Returns true when the input method is composing input. More...
 
void commitPreedit ()
 Applies the current preedit string. More...
 
void commitStateChange ()
 Emits state change signals and updates the input method. More...
 
void updateDisplayText ()
 Updates the object's text from the current pristine text, cursor, and preedit string. More...
 
bool setSelection (int anchor, int cursor)
 Sets the position of the selection anchor and of the cursor. More...
 
bool setSelection (int anchor, int cursor, int line_position)
 Sets the position of the selection anchor, the cursor, and the reference position for linewise selection. More...
 
QString selectionText () const
 Returns the text of the current selection. More...
 
void replaceSelectionText (const QString &replacement)
 Inserts text in place of the current selection. More...
 
int blockStart () const
 Returns the absolute position where the current "block" starts (in the input method sense). More...
 
int blockEnd () const
 Returns the absolute position where the current "block" ends (in the input method sense). More...
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Friends

class BatchEdit
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Helper class for editing the text of a TextObject.

This class is meant to be used by tools (DrawTextTool, EditPointTool) in the following way:

Member Typedef Documentation

◆ not_null

template<typename T >
using OpenOrienteering::TextObjectEditorHelper::not_null = T

Indicates arguments which must not be nullptr.

Todo:
Use the Guideline Support Library

Member Enumeration Documentation

◆ BatchEditAction

Actions which may be performed on batch edit start or end.

Enumerator
NoInputMethodAction 

On end, emit state change signal, but don't notify the input method.

UpdateInputProperties 

On end, update commonly changed input properties.

UpdateAllProperties 

On end, update all input properties.

ResetInputMethod 

On end, reset input method (alternative to updating).

CommitPreedit 

On start, commit the preedit string.

Constructor & Destructor Documentation

◆ TextObjectEditorHelper()

OpenOrienteering::TextObjectEditorHelper::TextObjectEditorHelper ( not_null< TextObject *>  text_object,
not_null< MapEditorController *>  editor 
)

◆ ~TextObjectEditorHelper()

OpenOrienteering::TextObjectEditorHelper::~TextObjectEditorHelper ( )
override

Member Function Documentation

◆ blockEnd()

int OpenOrienteering::TextObjectEditorHelper::blockEnd ( ) const
protected

Returns the absolute position where the current "block" ends (in the input method sense).

◆ blockStart()

int OpenOrienteering::TextObjectEditorHelper::blockStart ( ) const
protected

Returns the absolute position where the current "block" starts (in the input method sense).

◆ commitPreedit()

void OpenOrienteering::TextObjectEditorHelper::commitPreedit ( )
protected

Applies the current preedit string.

Normally not called directly but during construction of a BatchEdit object.

◆ commitStateChange()

void OpenOrienteering::TextObjectEditorHelper::commitStateChange ( )
protected

Emits state change signals and updates the input method.

Normally not called directly but during destruction of a BatchEdit object.

◆ draw()

void OpenOrienteering::TextObjectEditorHelper::draw ( QPainter painter,
MapWidget widget 
)

◆ finished

void OpenOrienteering::TextObjectEditorHelper::finished ( )
signal

Emitted when editing is finished.

◆ includeDirtyRect()

void OpenOrienteering::TextObjectEditorHelper::includeDirtyRect ( QRectF rect) const

◆ inputMethodEvent()

bool OpenOrienteering::TextObjectEditorHelper::inputMethodEvent ( QInputMethodEvent event)

◆ inputMethodQuery()

QVariant OpenOrienteering::TextObjectEditorHelper::inputMethodQuery ( Qt::InputMethodQuery  property,
const QVariant argument 
) const

◆ isPreediting()

bool OpenOrienteering::TextObjectEditorHelper::isPreediting ( ) const
inlineprotected

Returns true when the input method is composing input.

◆ keyPressEvent()

bool OpenOrienteering::TextObjectEditorHelper::keyPressEvent ( QKeyEvent event)

◆ keyReleaseEvent()

bool OpenOrienteering::TextObjectEditorHelper::keyReleaseEvent ( QKeyEvent event)

◆ mouseMoveEvent()

bool OpenOrienteering::TextObjectEditorHelper::mouseMoveEvent ( QMouseEvent event,
const MapCoordF map_coord,
MapWidget widget 
)

◆ mousePressEvent()

bool OpenOrienteering::TextObjectEditorHelper::mousePressEvent ( QMouseEvent event,
const MapCoordF map_coord,
MapWidget widget 
)

◆ mouseReleaseEvent()

bool OpenOrienteering::TextObjectEditorHelper::mouseReleaseEvent ( QMouseEvent event,
const MapCoordF map_coord,
MapWidget widget 
)

◆ object()

TextObject * OpenOrienteering::TextObjectEditorHelper::object ( ) const
inline

Returns the text object which is edited by this object.

◆ replaceSelectionText()

void OpenOrienteering::TextObjectEditorHelper::replaceSelectionText ( const QString replacement)
protected

Inserts text in place of the current selection.

After this, the selection will be empty, and the cursor will be placed at the end of the replacement text.

Must be called in a batch edit context.

◆ selectionText()

QString OpenOrienteering::TextObjectEditorHelper::selectionText ( ) const
protected

Returns the text of the current selection.

◆ setSelection() [1/2]

bool OpenOrienteering::TextObjectEditorHelper::setSelection ( int  anchor,
int  cursor 
)
protected

Sets the position of the selection anchor and of the cursor.

The text between the anchor position and the cursor position is the current selection. Setting both parameters to the same value results in an empty selection.

The reference position for linewise selection is set to the cursor position.

Must be called in a batch edit context.

Returns
True iff there actually was a change.

◆ setSelection() [2/2]

bool OpenOrienteering::TextObjectEditorHelper::setSelection ( int  anchor,
int  cursor,
int  line_position 
)
protected

Sets the position of the selection anchor, the cursor, and the reference position for linewise selection.

Must be called in a batch edit context.

Returns
True iff there actually was a change.

◆ stateChanged

void OpenOrienteering::TextObjectEditorHelper::stateChanged ( )
signal

Emitted when the text object or the selection is modified.

This includes movements of the cursor when the selection is empty.

◆ updateDisplayText()

void OpenOrienteering::TextObjectEditorHelper::updateDisplayText ( )
protected

Updates the object's text from the current pristine text, cursor, and preedit string.

Friends And Related Function Documentation

◆ BatchEdit

friend class BatchEdit
friend

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