diff options
| author | mio <stigma@disroot.org> | 2024-10-27 21:57:29 +1000 |
|---|---|---|
| committer | mio <stigma@disroot.org> | 2024-12-17 09:37:43 +1000 |
| commit | 7304b1a1e7ee4c175abb21e4d810c1f4d45ef7f1 (patch) | |
| tree | cecf044282f342b5e8cf76cdc37be3e71ba75234 /kjots/kjotsedit.h | |
| parent | f5130739bb3d0e8aac2c4864cf8ab0b870a09143 (diff) | |
| download | tdeutils-7304b1a1.tar.gz tdeutils-7304b1a1.zip | |
Update KJots to use KTextEdit
KEdit is deprecated and KTextEdit is one of the replacements. KTextEdit
doesn't provide the find & replace functionality, so we have to
re-implement that in KJotsEdit.
Signed-off-by: mio <stigma@disroot.org>
(cherry picked from commit 72796561928a42dbffd9dbb422523bb599896ca9)
Diffstat (limited to 'kjots/kjotsedit.h')
| -rw-r--r-- | kjots/kjotsedit.h | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/kjots/kjotsedit.h b/kjots/kjotsedit.h index 6506fab..75012f8 100644 --- a/kjots/kjotsedit.h +++ b/kjots/kjotsedit.h @@ -23,11 +23,16 @@ #ifndef __KJOTSEDIT_H #define __KJOTSEDIT_H -#include <keditcl.h> +#include <ktextedit.h> + +class KFind; +class KFindDialog; +class KReplace; +class KReplaceDialog; class TDEPopupMenu; class KJotsPage; -class KJotsEdit : public KEdit +class KJotsEdit : public KTextEdit { TQ_OBJECT @@ -41,14 +46,62 @@ class KJotsEdit : public KEdit signals: void findSuccessful(); + public slots: + // Create the initial KFindDialog. + void find(); + // Repeat the previous search. + // Creates KFindDialog if needed. + void findNext(); + // Repeat the previous search, but in the opposite direction. + // Creates KFindDialog if needed. + void findPrev(); + // Creates a KReplaceDialog + void replace(); + protected slots: - void openUrl(); + void openUrl(); + void slotFindHighlight(const TQString&, int, int); + void slotReplaceHighlight(const TQString&, int, int); + void slotDoFind(); + void slotDoReplace(); + void slotReplace(const TQString&, int, int, int); + void slotReplaceNext(); protected: virtual void mousePressEvent (TQMouseEvent *e); TDEPopupMenu *web_menu; KJotsPage *m_entry; //!< The entry we are editing. It needs to be kept informed. + + private: + + /* + * Keep track of the current cursor position for find/replace + * functionality, allowing us to increment easily. + */ + struct CursorPosition + { + // Current paragraph. + int paragraph; + // Index from start of current paragraph. + int paragraphIndex; + }; + + KFind *m_find; + KFindDialog *m_findDialog; + KReplace *m_replace; + KReplaceDialog *m_replaceDialog; + + // Maintaining two positions to allow replace while find still active. + CursorPosition m_findCursor{0, 0}; + CursorPosition m_replaceCursor{0, 0}; + + // Start and end position of selection, used to restart search with initial selection. + CursorPosition m_selectionStart{0, 0}; + CursorPosition m_selectionEnd{0, 0}; + + // Setup for m_findCursor/m_replaceCursor with m_find/m_replace + void setupCursor(CursorPosition*, const KFind*); }; #endif // __KJOTSEDIT_H |
