Commit Graph

206 Commits

Author SHA1 Message Date
Sune Vuorela
d211a6a9e9 More cppcheck fixes 2024-06-26 12:48:44 +00:00
Wendi Gan
322fd2d54e fix Unicode Normalization: replace NFKC to NFC
Use NFC in copy, makeWord, and export functions, and NFKC for search operations.
NFKC may alter characters when copied or exported. For example ⑥ in pdf will be pasted as 6. So most instances are replaced with NFC.
To simplify matching during search operation, NFKC is used.

BUG: 466521
CCBUG: 473495
2024-05-24 10:02:50 +00:00
Sune Vuorela
56a2a8d3bd cleanups: Sprinkle in a bit unique_ptr
Document memory ownership with unique_ptr's and do a bit of code
cleanups.
2024-03-06 21:57:08 +00:00
Sune Vuorela
6cc2a08d6b Use std::swap 2024-03-04 23:56:46 +00:00
Sune Vuorela
2e008d437c Simplify textentity memory management
After trying to measure the effect of switching TinyTextEntity from a
custom SBO string type to just QString and getting a barely measurable
gain, TinyTextEntity kind of looked like TextEntity, so merge those two.

Also reduce the amount of new/deletes around TextEntities

Implement a string pool for some tiny strings, and various memory optimizations
2024-02-07 14:07:08 +00:00
Sune Vuorela
792425fc77 s/qAsConst/std::as_const/
We now definitely has std::as_const available and Qt has started nagging
about converting to std::as_const.

Implementation is the same for both functions, and qAsConst was a
stop-gap measure until std::as_const was sufficiently available.
2023-12-19 11:46:24 +00:00
Sune Vuorela
18200c87f7 Clazy: small and trivial things should be taken by copy 2023-12-18 22:56:22 +00:00
Sune Vuorela
a9717a8e5f Use CI environment for clang/clazy
In order to be able to also do this with Qt6 we can't currently rely on
'random distro' to be able to give us an environment sufficient for
running clang and clazy, so use the CI system setup instead

A side effect is that we get a newer clazy and clang-tidy and thus is a
few more issues to either ignore or fix.

Also, ask ninja to continue as long as possible rather than stop at
first error to be able to get succes in as few runs as possible
2023-12-15 09:39:03 +00:00
Sune Vuorela
32c804296a Get rid of QStringRef 2023-12-06 19:12:43 +00:00
Sune Vuorela
88fc4032ac Random collection of cppcheck fixes
- missing consts
 - shadowing of variable names
 - superflous code
 - tighter scoping of some variables
 and other such bits
2023-08-10 22:47:57 +00:00
Volker Krause
50d0703ae0 Enable readability-braces-around-statements 2022-03-09 23:29:56 +01:00
Albert Astals Cid
bed447f769 textpage: Don't use the page bounding rect as initial text rect
The bounding rect is *visual* and it can happen that we have
invisible text and thus the algorithm will get super confused
because there will be text items that are outside the text area
2021-08-27 06:52:28 +00:00
Alexander Lohnau
2f193a63de Convert license headers to SPDX 2021-06-10 08:11:56 +00:00
Albert Astals Cid
b1fa4caaf2 Merge remote-tracking branch 'origin/release/20.12' 2020-12-22 01:25:17 +01:00
Albert Astals Cid
d112682611 Make search work on documents that describe Å as A + ◌̊
BUGS: 430243
2020-12-21 22:32:39 +00:00
Alexander Lohnau
3c1fa441d9 Remove dead code
A lot of this code has been commented out for over
a decade and adds no value to the project.
It is only annoying when you look over it ;).

Same for the KNS2 support which was commented out.

Also some of the debug statements didn't even build
anymore, because the properties got removed/refactored.
2020-11-14 10:52:00 +01:00
Albert Astals Cid
19d98d6a74 Run clang-format
find . \( -name "*.cpp" -or -name "*.h"  -or -name "*.c"  -or -name "*.cc" \) -exec clang-format -i {} \;

If you reached this file doing a git blame, please see README.clang-format (added 2 commits in the future of this one)
2020-07-11 09:17:33 +02:00
Albert Astals Cid
9694113a96 Let the user type the hyphen if he wants when searching
It happens that sometimes the hypen is actually "part of the word" like
in one-third, so if there's one- at the end of a line
and third at the beginning of the next, we should still match and not
force the user to type onethird, even we will also match onethird since
there's no way to know if "hyphen at end of line" is supposed to be part
of the word or not

BUGS: 418520
2020-03-28 13:59:01 +00:00
Albert Astals Cid
dcf8f79481 Enable clazy isempty-vs-count and qhash-with-char-pointer-key 2020-02-21 17:09:46 +01:00
Albert Astals Cid
93540ac16d Enable most of clazy level2 2020-02-21 14:57:48 +01:00
Albert Astals Cid
468f4b64c2 CI: Enable clazy inefficient-qlist-soft 2020-02-19 23:44:41 +01:00
Albert Astals Cid
2da1cd736a CI: Enable clang-tidy modernize-loop-convert 2020-01-24 17:23:39 +01:00
Albert Astals Cid
b001ea2019 CI: Enable a bunch of bugprone- clang-tidy warnings 2019-12-24 10:18:16 +00:00
Ahmad Samir
ccf3a384c3 [core/*] replace foreach, deprecated, with range-for
The code compiles and okular seems to load and work as before, all unit
tests pass except (parttest and epubgeneratortest, but they fail on master
too).
2019-12-09 13:16:55 +00:00
Albert Astals Cid
da21543a50 Small performance improvements 2019-10-05 22:16:43 +02:00
David Hurka
c61a9587ec Improve documentation of TextEntity stuff
Summary:
This adds some important documentation on TextEntity and other classes, and improves some of the existing documentation.

This includes changing parameter names from ‘rect’ to ‘area’, because I found ‘rect’ misleading.

Test Plan: Run doxygen

Reviewers: #okular, aacid

Reviewed By: #okular, aacid

Subscribers: aacid, yurchor, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D21271
2019-07-21 10:49:51 +02:00
Laurent Montel
5a3a49c310 Port qSort to std::sort 2019-03-12 13:13:53 +01:00
Yuri Chornoivan
5478b2ec92 Fix minor typos 2018-11-14 21:12:15 +02:00
Yuri Chornoivan
c04ca1fa96 Fix minor EBN issues 2018-08-31 12:23:45 +03:00
Albert Astals Cid
4e6c9f8f7a Fix crash when accessing text page after save
text page was storing a pointer to a PagePrivate pointer but those die
after saving so we need to store a Page pointer since those are stable.

BUGS: 387247
2017-12-05 23:07:10 +01:00
Kevin Funk
a53a2402ca clang-tidy: modernize-use-nullptr run
Semi-ACK'd by Albert :)
2017-09-06 00:19:48 +02:00
Albert Astals Cid
fd5cc83e85 Fix warning in newer gcc versions 2017-07-27 16:57:40 +02:00
Martin T. H. Sandsmark
f05d42eac3 core: Fix build without implicit cast to/from ascii
See previous commits for details.
2016-07-11 22:07:57 +02:00
Montel Laurent
466eb79615 Use QStringLiteral 2015-10-29 13:37:11 +01:00
Frederik Gladhorn
6c602bf0e7 Use categorized logging even more 2014-09-16 23:38:25 +02:00
Frederik Gladhorn
9d89739972 Use categorized logging 2014-09-16 23:24:36 +02:00
Frederik Gladhorn
83d3f1f6b7 Revert "Some more kDebug->qDebug"
Seems like kDebug doesn't spam the user, so this needs to use qCDebug.

This reverts commit 34fbdf8c85.
2014-09-11 02:03:46 +02:00
Frederik Gladhorn
34fbdf8c85 Some more kDebug->qDebug 2014-09-09 18:17:36 +02:00
Jaan Vajakas
a80922d45e Improve XY Cut layout recognition code
It was a simple bug in the XY Cut layout recognition code that made it too eager to see columns everywhere.
Also removed the dependence of the layout analysis algorithms on the display DPI (introduced by the recently added feature of using KScreen) to make their behavior more predictable and reproducible.

BUGS: 326207
BUGS: 331090
FIXED-IN: 4.13.0
REVIEW: 115759
2014-02-25 23:59:41 +01:00
Jan Kundrát
2bd0ec5fda The doesConsumeX method was defined but never used
Having functions which are defined but not used serves no gain. This patch
therefore removes the extra method and updates the comment reference in the
second one to make it standalone.

REVIEW: 114959
2014-01-11 00:25:28 +01:00
Jaan Vajakas
dff8bf1b36 Improve searching code
Also simplified code a bit by removing unnecessary calls to toLower in TextPagePrivate::findTextInternalForward and TextPagePrivate::findTextInternalBackward I also fixed a small bug: the letter capital I with dot above (U+0130) did not match itself in case-insensitive mode on Qt 4.8.4 (U+0130 still does not match lowercase i (U+0069), which can be considered another bug, that I didn't fix (although this behavior conforms to the Unicode case folding rules)).

(I did not implement the Knuth-Morris-Pratt algorithm that I promised in a comment of Bug 323263 because on second thought I find that the win, if any, would probably be negligible except for some very special documents and special query strings.)

BUGS: 323262
BUGS: 323263
REVIEW: 112135
2013-10-18 16:30:07 +02:00
Albert Astals Cid
3485faf6dd Merge remote-tracking branch 'origin/KDE/4.9' 2012-12-12 23:41:53 +01:00
Albert Astals Cid
2002e0a4b0 Do not ignore spaces on backwards search
This ports a change we made to the forward search 4 years ago...
7183c172c2 for more reference

BUGS: 311232
FIXED-IN: 4.9.5
2012-12-12 23:40:41 +01:00
Albert Astals Cid
769e079e70 Merge remote-tracking branch 'origin/KDE/4.9' 2012-11-02 22:26:10 +01:00
Albert Astals Cid
d59ffb4a7a Fix crash when searching backwards
When searching backwards end is not actually words.end but words.begin (since the loop goes backwards) hence we can't pass end to stringLengthAdaptedWithHyphen
I've now renamed end to loop_end to make it a bit more clear.
BUGS: 309030
FIXED-IN: 4.9.4
2012-11-02 22:24:23 +01:00
Jan Binder
aa6ed8afc0 Replace deprecated QMatrix by QTransform
REVIEW: 105737
2012-09-08 17:06:02 +02:00
Albert Astals Cid
9ce6c55559 Don't be so noisy! 2012-07-11 22:44:12 +02:00
Albert Astals Cid
ea8ec188c9 Don't be so noisy! 2012-07-11 22:42:45 +02:00
Albert Astals Cid
9d805df013 Double click selects words
BUGS: 187347
FIXED-IN: 4.9,0
2012-03-25 23:48:47 +02:00
Albert Astals Cid
d34bc7f263 Do not cache end() of a QList you are removing stuff from...
...makes it crash :D
BUGS: 294633
FIXED-IN: 4.8.1
2012-02-22 23:23:47 +01:00