Reintroduce selectionStart, selectionEnd
This commit is contained in:
@@ -242,3 +242,33 @@ CompletionModel *ChatDocumentHandler::completionModel() const
|
|||||||
{
|
{
|
||||||
return m_completionModel;
|
return m_completionModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ChatDocumentHandler::selectionStart() const
|
||||||
|
{
|
||||||
|
return m_selectionStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatDocumentHandler::setSelectionStart(int position)
|
||||||
|
{
|
||||||
|
if (position == m_selectionStart) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_selectionStart = position;
|
||||||
|
Q_EMIT selectionStartChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ChatDocumentHandler::selectionEnd() const
|
||||||
|
{
|
||||||
|
return m_selectionEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatDocumentHandler::setSelectionEnd(int position)
|
||||||
|
{
|
||||||
|
if (position == m_selectionEnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_selectionEnd = position;
|
||||||
|
Q_EMIT selectionEndChanged();
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ class ChatDocumentHandler : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QQuickTextDocument *document READ document WRITE setDocument NOTIFY documentChanged)
|
Q_PROPERTY(QQuickTextDocument *document READ document WRITE setDocument NOTIFY documentChanged)
|
||||||
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
|
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
|
||||||
|
Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
|
||||||
|
Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
|
||||||
|
|
||||||
Q_PROPERTY(CompletionModel *completionModel READ completionModel NOTIFY completionModelChanged)
|
Q_PROPERTY(CompletionModel *completionModel READ completionModel NOTIFY completionModelChanged)
|
||||||
|
|
||||||
Q_PROPERTY(NeoChatRoom *room READ room NOTIFY roomChanged)
|
Q_PROPERTY(NeoChatRoom *room READ room NOTIFY roomChanged)
|
||||||
@@ -42,6 +45,12 @@ public:
|
|||||||
[[nodiscard]] int cursorPosition() const;
|
[[nodiscard]] int cursorPosition() const;
|
||||||
void setCursorPosition(int position);
|
void setCursorPosition(int position);
|
||||||
|
|
||||||
|
[[nodiscard]] int selectionStart() const;
|
||||||
|
void setSelectionStart(int position);
|
||||||
|
|
||||||
|
[[nodiscard]] int selectionEnd() const;
|
||||||
|
void setSelectionEnd(int position);
|
||||||
|
|
||||||
[[nodiscard]] NeoChatRoom *room() const;
|
[[nodiscard]] NeoChatRoom *room() const;
|
||||||
void setRoom(NeoChatRoom *room);
|
void setRoom(NeoChatRoom *room);
|
||||||
|
|
||||||
@@ -54,6 +63,8 @@ Q_SIGNALS:
|
|||||||
void cursorPositionChanged();
|
void cursorPositionChanged();
|
||||||
void roomChanged();
|
void roomChanged();
|
||||||
void completionModelChanged();
|
void completionModelChanged();
|
||||||
|
void selectionStartChanged();
|
||||||
|
void selectionEndChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int completionStartIndex() const;
|
int completionStartIndex() const;
|
||||||
@@ -64,6 +75,8 @@ private:
|
|||||||
bool completionVisible = false;
|
bool completionVisible = false;
|
||||||
|
|
||||||
int m_cursorPosition;
|
int m_cursorPosition;
|
||||||
|
int m_selectionStart;
|
||||||
|
int m_selectionEnd;
|
||||||
|
|
||||||
SyntaxHighlighter *m_highlighter = nullptr;
|
SyntaxHighlighter *m_highlighter = nullptr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user