Update KJots to use KTextEdit #88
Merged
mio
merged 1 commits from feat/kjots-use-ktextedit
into master
4 weeks ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'feat/kjots-use-ktextedit'
Deleting a branch is permanent. It CANNOT be undone. Continue?
KEdit
is deprecated andKTextEdit
is one of the replacements.KTextEdit
doesn't provide the find & replace functionality, so we have to re-implement that inKJotsEdit
.I assume you meant
KEdit
is deprecated.Regarding the missing functionality, are you going to do more work for it or is this the final version of the PR?
My mistake, I did mean KEdit (I'll update the commit later). And yes, I'll be updating the PR to add the missing functionality.
c123c504c7
tocff47abe19
3 months agoUpdate: The
search
andrepeatSearch
are almost working, there is a small issue withrepeatSearch
where the data isn't correctly reset when the current entry is changed. Should be an easy fix.Still need to implement the
replace
function.cff47abe19
to162cbc5c1e
2 months ago162cbc5c1e
to4f4e4fba50
2 months agoWIP: Update KJots to use KTextEditto Update KJots to use KTextEdit 2 months agoI will have a look at this on Thursday.
: KTextEdit(parent, name)
, m_entry(nullptr)
, m_find(nullptr)
, m_findDialog(nullptr)
m_findDialog
andm_replaceDialog
don't seem to bedelete
d anywhere in the code. Should that be added inKJotsEdit::~KJotsEdit()
as well?I had thought it would be okay since they both have a parent set when constructed, but it's been updated anyway to be sure.
Oh yeah, my bad! Once they get a parent, they will be destroyed when the parent also get destructed, because of the TQObject hierarchy. Deleting them explicitly is then wrong, it would cause a double-free error. Sorry for putting you on the wrong track. We need to revert to the original code.
No worries :-)
I have reverted the code.
4f4e4fba50
to45d184c9df
2 months ago45d184c9df
tob1a4e9bfe2
2 months agoI did a test. The new "standard" find/replace dialogs are nice, compared to the smaller original ones. Most things seem to work fine, but I found a problem with regex search.
I tried something like
^.*search_text.*$
and the whole text was selected instead of a single line. I tried the same search in Kate, on the same text and only a single like was selected instead. Do you see the same issue?Another little issue: search for a word (even without regex). Continue the search till the end of the document. Press
F3
again and KJots will ask to start searching from the beginning of the document again. Say yes, but notice how nothing is searched. It is necessary to pressF3
again to actually get a search from the beginning of the document.This does not happen in the original KJots, not it happens in Kate. In both cases after confirming the "search from the beginning of the document", the first match get found and selected.
Yep, happens for me as well. I'll take a look at this. It could be an issue with how the highlighting is performed, or the conversion between index and paragraph/index. (
TQTextEdit
uses paragraph/index-from-paragraph-start whileKFind
andKReplace
use index-from-text-start.)It seems that Kate doesn't use the
KFind
andKReplace
classes that I opted for here, instead opting for a custom implementation. So it could be an issue with those classes, although this is unlikely.Good point! I agree that it should automatically start the search again.
After looking into it a bit more, this seems to be a limitation of TQRegExp which doesn't support multi-line matching.
Not sure I have the right understanding of "looping with a regexp that searches for newlines", but I'll take a look at splitting the text into lines if the regex option is selected.
As an aside: I wonder if adding an option to change the behaviour of
^
and$
should be added to TQRegExp? I think most people nowadays would expect they match the start/end of a line, not the entire string.b1a4e9bfe2
to048b0fad79
2 months agoMade some changes so find/replace now operates on paragraphs, rather than the whole text. This allows the regex
^.*some_text.*$
to work as expected. I've also fixed clicking "Continue" from the final "Find Next" dialog so it will perform a search automatically.Great, will do a new test and feedback, probably tomorrow.
If I understand correctly from your comments, the issue may not be in TQRegExp but the fact that KJots search treats the whole book as a single string? Haven't looked into the code, nor into how you fixed that, so I am jsut asking out of curiosity.
No worries, take your time :-)
Pretty much. KJots was passing the entire contents of the entry as a single string, which caused the issue you experienced with the regex, since
^
and$
in TQRegExp match the start and end of the string respectively. The solution was to iterate through each paragraph (which are separated by newlines) and pass them to TQRegExp.My comment was whether TQRegExp should support a multi-line mode, since it's a common modifier in other regex engines. It's not important for this PR, just a thought.
That could indeed be handy. We can also look at Qt4/5/6 and see if something like that has already been implemented. It may be as easy as a backport of some code.
I did a new test. The regex issue with ^ and $ and the issue with search from begin/end of file are now fixed. Well done.
A couple of more points I picked up during testing and that we can improve:
F3
search again in the selected direction. I think users expectShift+F3
to search in the opposite direction, like it does in Kate. In KJotsShift+F3
does not do anythingThe first two points are probably easy fixes, the third one may need a bit more time. Once all are fixed, I think the functionality will be pretty good and we can look at a final review and merge, unless some other things pop up in the meanwhile.
Side note: I did not know this app, I was using KNotes or Kate to take simple notes. KJots fits in very nicely for that purpose :-)
048b0fad79
to695097feae
2 months agoUpdate KJots to use KTextEditto WIP: Update KJots to use KTextEdit 2 months ago695097feae
to816b354fab
2 months agoThis wasn't originally in KJots, but I've added it in the most recent push since it does make sense to support both forward and backwards searching.
There was an issue with the final count shown (when you reach the end of the document) as it counts the number of times the
highlight()
signal is emitted. Meaning if you swapped between searching forwards and backwards, you would likely end up with an incorrect number of matches.This was "fixed" by not including the count in the final dialog, which I think works just as well. Just wanted to point this out in case you notice.
I'll take a look at implementing these over the next couple of days. As you say, it's probably the last one that might take some extra time.
It is nice! I find it much easier to organize my notes, which were previously written on various little note pads laying around. (Especially since I never left enough blank pages between topics for when I revisited them 😅)
Same here, I pretty much started using it immediately and replaced all my KNotes that were flying around on my desktop ;-)
Ping me here when you are done with those remaining points, I will do a further test then.
816b354fab
toe85ec2a502
2 months agoe85ec2a502
toa04dccc7fc
2 months agoa04dccc7fc
to6390e70e98
2 months agoWIP: Update KJots to use KTextEditto Update KJots to use KTextEdit 2 months agoOkay @MicheleC, should be good for another look now ( when you get a chance :-) )
Thanks @mio, I was actually wondering last night where we were up to with this one.
I have done a new test and here is the next round of feedback, with reference to the 3 items I highlighted here:
F3
again in Kate will try to search again for the same not found text. PressingF3
in KJots brings up the search dialog instead. I would say Kate's behavior is consistent regardless of whether the string is found or not, while KJots behaves slightliy different in the two scenarios. It is not a big thing, what is your opinion about it?Ctrl+F
, theSelected text
checkbox should be checked by default when the search dialog opens (see Kate's behavior)End of selection reached
while KJots saysEnd of document reached
which is a bit misleadingItem 3's points should be fixed.
Item 2's point is debatable, so I am interested in your opinion on that. IMO we should fix it too, but I don't want to force it :-)
That does make sense, considering the action is called "Find Again", one might expect it to perform the search again even if nothing was found the last run. Will fix.
I can implement the first point, no problem. The second one would probably be better addressed in the KFind class. (Kate uses its own dialog, whereas this patch uses the
shouldRestart
method provided by KFind.)Great, thanks!
👍
Sounds good to me. This way we can probably also simplify the Kate code afterwards.
Let's fix the first two items and then merge this PR. Subsequently you can fix the last point in KFind as you suggested.
6390e70e98
to90fa625622
1 month agoOkay, should be good for another check now @MicheleC
I have done another tests and both item 1 and 2 are ok. Item 3 we will address on a separate PR.
I ran into one more bug during testing. Say you have the following text somewhere in kjots:
Select the three lines with
if
s and search forif
. Repeat a few searches and stop for example of the firstif
on the middle line. All works fine so far. Note thatif
is selected. Now pressCtrl+f
to open the search dialog again and search for example foro
: you would expect a failed search since the selection is nowif
, instead all theo
s in the middle line are found. Note theo
s on the other lines are correctly not found.Try the same in Kate and you will see no
o
s are found at all because the selection does not contain anyo
.I think this is really the last bug, I ran into it by mistake actually 😰
Nice! I'll take a look at fixing this today or tomorrow.
90fa625622
to8bf76d50ef
1 month agoThe new changes should address this. Let me know what you think when you get a chance.
Just done a new test. The latest commit fixes the issue described before but introduce a new problem :-(
Select some text, search forward for something that exists in it a few times. When you reach the end of the selection, you get prompted to start again from the beginning, say yes and everything works fine.
Repeat but searching backward: this time after you get asked to start again from the end of the document, the text is not found. Please note this only happens when searching in a selection. If you do a backward search on the whole document, everything works just fine.
I know I am a bit picky in my testing, but I think it is important we commit good code after proper testing rather than rushing an incomplete/buggy solution. Please bear with me :-)
8bf76d50ef
to61af9b57bf
1 month agoHmm, I don't experience this. Are you searching with the "Find backwards" option checked or by pressing SHIFT+F3? (or both?)
Don't worry about it! I appreciate you taking the time to test it so thoroughly :-)
I checked the "Find backbard" checkbox in the Find dialog and then use F3 for repeated searches. I haven't tried Shift+F3 in this case, I can build again and do another test if you want.
Thanks 🤝
61af9b57bf
toe1c413a8a9
1 month agoIf you don't mind. Even when trying with both methods, I still don't have the same issue.
The latest version fixed an issue with searching in selected text where starting/ending a selection halfway through a line wasn't working correctly. (It would continue to search outside of the selection).
Not sure if this will fix your issue as well.
The last commit seems to fix the last issue, so we can finally proceed and merge this PR. Great job and thanks for all the adjustments along the way @mio.
We can also backport to R14.1.x.
7279656192
into master 4 weeks agoThanks for reviewing @MicheleC!
Reviewers
7279656192
.