Advanced search (second part)

This commit is contained in:
Jakub Melka
2020-01-04 17:58:55 +01:00
parent 54ea7dcb7d
commit bf4ede1574
6 changed files with 274 additions and 29 deletions

View File

@ -163,6 +163,9 @@ struct PDFCharacterPointer
/// Returns true, if character pointer is valid and points to the correct location
bool isValid() const { return pageIndex > -1; }
/// Returns true, if character belongs to same block
bool hasSameBlock(const PDFCharacterPointer& other) const;
/// Returns true, if character belongs to same line
bool hasSameLine(const PDFCharacterPointer& other) const;
@ -187,6 +190,8 @@ private:
struct PDFFindResult
{
bool operator<(const PDFFindResult& other) const;
/// Matched string during search
QString matched;
@ -222,6 +227,10 @@ public:
/// \param caseSensitivity Case sensitivity
PDFFindResults find(const QString& text, Qt::CaseSensitivity caseSensitivity) const;
/// Finds regular expression matches in current text flow. All text occurences are returned.
/// \param expression Regular expression to be matched
PDFFindResults find(const QRegularExpression& expression) const;
/// Merge data from \p next flow (i.e. connect two consecutive flows)
void merge(const PDFTextFlow& next);
@ -297,7 +306,7 @@ private:
/// For writing, mutex is used to synchronize asynchronous writes, for reading
/// no mutex is used at all. For this reason, both reading/writing at the same time
/// is prohibited, it is not thread safe.
class PDFTextLayoutStorage
class PDFFORQTLIBSHARED_EXPORT PDFTextLayoutStorage
{
public:
explicit inline PDFTextLayoutStorage() = default;
@ -320,6 +329,17 @@ public:
/// \param mutex Mutex for locking (calls of setTextLayout from multiple threads)
void setTextLayout(PDFInteger pageIndex, const PDFTextLayout& layout, QMutex* mutex);
/// Finds simple text in all pages. All text occurences are returned.
/// \param text Text to be found
/// \param caseSensitivity Case sensitivity
/// \param flowFlags Text flow flags
PDFFindResults find(const QString& text, Qt::CaseSensitivity caseSensitivity, PDFTextFlow::FlowFlags flowFlags) const;
/// Finds regular expression matches in current text flow. All text occurences are returned.
/// \param expression Regular expression to be matched
/// \param flowFlags Text flow flags
PDFFindResults find(const QRegularExpression& expression, PDFTextFlow::FlowFlags flowFlags) const;
private:
std::vector<int> m_offsets;
QByteArray m_textLayouts;