okular/core/textpage_p.h
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

80 lines
2.8 KiB
C++

/***************************************************************************
* Copyright (C) 2006 by Tobias Koenig <tokoe@kde.org> *
* Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef _OKULAR_TEXTPAGE_P_H_
#define _OKULAR_TEXTPAGE_P_H_
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QPair>
#include <QtGui/QTransform>
class SearchPoint;
class TinyTextEntity;
class RegionText;
namespace Okular
{
class PagePrivate;
typedef QList< TinyTextEntity* > TextList;
/**
* Returns whether the two strings match.
* Satisfies the condition that if two strings match then their lengths are equal.
*/
typedef bool ( *TextComparisonFunction )( const QStringRef & from, const QStringRef & to );
/**
* A list of RegionText. It keeps a bunch of TextList with their bounding rectangles
*/
typedef QList<RegionText> RegionTextList;
class TextPagePrivate
{
public:
TextPagePrivate();
~TextPagePrivate();
RegularAreaRect * findTextInternalForward( int searchID, const QString &query,
TextComparisonFunction comparer,
const TextList::ConstIterator &start,
int start_offset,
const TextList::ConstIterator &end);
RegularAreaRect * findTextInternalBackward( int searchID, const QString &query,
TextComparisonFunction comparer,
const TextList::ConstIterator &start,
int start_offset,
const TextList::ConstIterator &end );
/**
* Copy a TextList to m_words, the pointers of list are adopted
*/
void setWordList(const TextList &list);
/**
* Make necessary modifications in the TextList to make the text order correct, so
* that textselection works fine
*/
void correctTextOrder();
// variables those can be accessed directly from TextPage
TextList m_words;
QMap< int, SearchPoint* > m_searchPoints;
PagePrivate *m_page;
private:
RegularAreaRect * searchPointToArea(const SearchPoint* sp);
};
}
#endif