Changeset View
Changeset View
Standalone View
Standalone View
core/textpage.cpp
Show First 20 Lines • Show All 292 Lines • ▼ Show 20 Line(s) | 288 | public: | |||
---|---|---|---|---|---|
293 | RegionText(const WordsWithCharacters &wordsWithCharacters, const QRect &area) | 293 | RegionText(const WordsWithCharacters &wordsWithCharacters, const QRect &area) | ||
294 | : m_region_wordWithCharacters(wordsWithCharacters), m_area(area) | 294 | : m_region_wordWithCharacters(wordsWithCharacters), m_area(area) | ||
295 | { | 295 | { | ||
296 | } | 296 | } | ||
297 | 297 | | |||
298 | inline QString string() const | 298 | inline QString string() const | ||
299 | { | 299 | { | ||
300 | QString res; | 300 | QString res; | ||
301 | foreach(const WordWithCharacters &word, m_region_wordWithCharacters) | 301 | for (const WordWithCharacters &word : qAsConst(m_region_wordWithCharacters)) { | ||
aacid: if the function is const, m_region_blabla is const already | |||||
302 | res += word.text(); | 302 | res += word.text(); | ||
303 | } | ||||
303 | return res; | 304 | return res; | ||
304 | } | 305 | } | ||
305 | 306 | | |||
306 | inline WordsWithCharacters text() const | 307 | inline WordsWithCharacters text() const | ||
307 | { | 308 | { | ||
308 | return m_region_wordWithCharacters; | 309 | return m_region_wordWithCharacters; | ||
309 | } | 310 | } | ||
310 | 311 | | |||
▲ Show 20 Lines • Show All 1595 Lines • ▼ Show 20 Line(s) | 1880 | { | |||
1906 | * Add spaces to the word | 1907 | * Add spaces to the word | ||
1907 | */ | 1908 | */ | ||
1908 | const WordsWithCharacters listWithWordsAndSpaces = addNecessarySpace(tree, pageWidth, pageHeight); | 1909 | const WordsWithCharacters listWithWordsAndSpaces = addNecessarySpace(tree, pageWidth, pageHeight); | ||
1909 | 1910 | | |||
1910 | /** | 1911 | /** | ||
1911 | * Break the words into characters | 1912 | * Break the words into characters | ||
1912 | */ | 1913 | */ | ||
1913 | TextList listOfCharacters; | 1914 | TextList listOfCharacters; | ||
1914 | foreach(const WordWithCharacters &word, listWithWordsAndSpaces) | 1915 | for (const WordWithCharacters &word : listWithWordsAndSpaces) | ||
1915 | { | 1916 | { | ||
1916 | delete word.word; | 1917 | delete word.word; | ||
1917 | listOfCharacters.append(word.characters); | 1918 | listOfCharacters.append(word.characters); | ||
1918 | } | 1919 | } | ||
1919 | setWordList(listOfCharacters); | 1920 | setWordList(listOfCharacters); | ||
1920 | } | 1921 | } | ||
1921 | 1922 | | |||
1922 | TextEntity::List TextPage::words(const RegularAreaRect *area, TextAreaInclusionBehaviour b) const | 1923 | TextEntity::List TextPage::words(const RegularAreaRect *area, TextAreaInclusionBehaviour b) const | ||
1923 | { | 1924 | { | ||
1924 | if ( area && area->isNull() ) | 1925 | if ( area && area->isNull() ) | ||
1925 | return TextEntity::List(); | 1926 | return TextEntity::List(); | ||
1926 | 1927 | | |||
1927 | TextEntity::List ret; | 1928 | TextEntity::List ret; | ||
1928 | if ( area ) | 1929 | if ( area ) | ||
1929 | { | 1930 | { | ||
1930 | foreach (TinyTextEntity *te, d->m_words) | 1931 | for (const TinyTextEntity *te : qAsConst(d->m_words)) | ||
1931 | { | 1932 | { | ||
1932 | if (b == AnyPixelTextAreaInclusionBehaviour) | 1933 | if (b == AnyPixelTextAreaInclusionBehaviour) | ||
1933 | { | 1934 | { | ||
1934 | if ( area->intersects( te->area ) ) | 1935 | if ( area->intersects( te->area ) ) | ||
1935 | { | 1936 | { | ||
1936 | ret.append( new TextEntity( te->text(), new Okular::NormalizedRect( te->area) ) ); | 1937 | ret.append( new TextEntity( te->text(), new Okular::NormalizedRect( te->area) ) ); | ||
1937 | } | 1938 | } | ||
1938 | } | 1939 | } | ||
1939 | else | 1940 | else | ||
1940 | { | 1941 | { | ||
1941 | const NormalizedPoint center = te->area.center(); | 1942 | const NormalizedPoint center = te->area.center(); | ||
1942 | if ( area->contains( center.x, center.y ) ) | 1943 | if ( area->contains( center.x, center.y ) ) | ||
1943 | { | 1944 | { | ||
1944 | ret.append( new TextEntity( te->text(), new Okular::NormalizedRect( te->area) ) ); | 1945 | ret.append( new TextEntity( te->text(), new Okular::NormalizedRect( te->area) ) ); | ||
1945 | } | 1946 | } | ||
1946 | } | 1947 | } | ||
1947 | } | 1948 | } | ||
1948 | } | 1949 | } | ||
1949 | else | 1950 | else | ||
1950 | { | 1951 | { | ||
1951 | foreach (TinyTextEntity *te, d->m_words) | 1952 | for (const TinyTextEntity *te : qAsConst(d->m_words)) | ||
1952 | { | 1953 | { | ||
1953 | ret.append( new TextEntity( te->text(), new Okular::NormalizedRect( te->area) ) ); | 1954 | ret.append( new TextEntity( te->text(), new Okular::NormalizedRect( te->area) ) ); | ||
1954 | } | 1955 | } | ||
1955 | } | 1956 | } | ||
1956 | return ret; | 1957 | return ret; | ||
1957 | } | 1958 | } | ||
1958 | 1959 | | |||
1959 | RegularAreaRect * TextPage::wordAt( const NormalizedPoint &p, QString *word ) const | 1960 | RegularAreaRect * TextPage::wordAt( const NormalizedPoint &p, QString *word ) const | ||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
if the function is const, m_region_blabla is const already