diff options
author | Tobias Markmann <tm@ayena.de> | 2017-06-26 03:58:09 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-06-26 09:13:57 (GMT) |
commit | 38b577abe56c76805e2f2bebb5194bee28359145 (patch) | |
tree | cb05fdfd725936c1fbe42e9245220befeadc8f6f /Swift/QtUI/QtTextEdit.h | |
parent | 96528818b201c5a250701b58bb9c4d11048b237e (diff) | |
download | swift-38b577abe56c76805e2f2bebb5194bee28359145.zip swift-38b577abe56c76805e2f2bebb5194bee28359145.tar.bz2 |
Use size_t instead of int in SpellParser::PositionPair
Use of int required a lot of casts when using the indices
with std::string methods. Furthermore code used -1 as
error code, which should have used std::optional for invalid
PoistionPair instnaces.
Test-Information:
All tests pass on Debian Stretch with clang-3.9.
Change-Id: Ic5c44ed606deb58b6123d654f25fc50f047dfbc8
Diffstat (limited to 'Swift/QtUI/QtTextEdit.h')
-rw-r--r-- | Swift/QtUI/QtTextEdit.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Swift/QtUI/QtTextEdit.h b/Swift/QtUI/QtTextEdit.h index 7ce5d88..178f258 100644 --- a/Swift/QtUI/QtTextEdit.h +++ b/Swift/QtUI/QtTextEdit.h @@ -1,70 +1,72 @@ /* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <boost/optional.hpp> + #include <QPointer> #include <QTextEdit> #include <Swift/Controllers/Settings/SettingsProvider.h> #include <SwifTools/SpellParser.h> #include <Swift/QtUI/QtSpellCheckHighlighter.h> namespace Swift { class SpellChecker; class QtSpellCheckerWindow; class QtTextEdit : public QTextEdit { Q_OBJECT public: QtTextEdit(SettingsProvider* settings, QWidget* parent = nullptr); virtual ~QtTextEdit(); virtual QSize sizeHint() const; void setEmphasiseFocus(bool emphasise); void setCorrectionHighlight(bool coorectionHighlight); signals: void wordCorrected(QString& word); void returnPressed(); void unhandledKeyPressEvent(QKeyEvent* event); void receivedFocus(); void lostFocus(); void itemDropped(QDropEvent* event); public slots: void handleSettingChanged(const std::string& settings); protected: virtual void keyPressEvent(QKeyEvent* event); virtual void focusInEvent(QFocusEvent* event); virtual void focusOutEvent(QFocusEvent* event); virtual void contextMenuEvent(QContextMenuEvent* event); virtual void dropEvent(QDropEvent* event); private slots: void handleTextChanged(); private: void addSuggestions(QMenu* menu, QContextMenuEvent* event); - void replaceMisspelledWord(const QString& word, int cursorPosition); + void replaceMisspelledWord(const QString& word, size_t cursorPosition); void setUpSpellChecker(); void spellCheckerSettingsWindow(); - PositionPair getWordFromCursor(int cursorPosition); + boost::optional<PositionPair> getWordFromCursor(size_t cursorPosition); void updateStyleSheet(); private: SpellChecker* checker_; QtSpellCheckHighlighter* highlighter_; std::vector<QAction*> replaceWordActions_; SettingsProvider* settings_; QPointer<QtSpellCheckerWindow> spellCheckerWindow_; bool emphasiseFocus_ = false; bool correctionHighlight_ = false; }; } |