File indexing completed on 2024-06-16 04:56:14
0001 /* 0002 view/anchorcache_p.h 0003 0004 This file is part of Kleopatra, the KDE keymanager 0005 SPDX-FileCopyrightText: 2022 g10 Code GmbH 0006 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 0013 #include <QString> 0014 0015 #include <vector> 0016 0017 class QString; 0018 0019 struct AnchorData { 0020 int start; 0021 int end; 0022 QString text; 0023 QString href; 0024 }; 0025 0026 class AnchorCache 0027 { 0028 public: 0029 void setText(const QString &text); 0030 void clear(); 0031 0032 int size() const; 0033 const AnchorData &operator[](int index) const; 0034 int findAnchor(int start) const; 0035 0036 private: 0037 const std::vector<AnchorData> &anchors() const; 0038 0039 private: 0040 QString mText; 0041 mutable bool mAnchorsValid = false; 0042 mutable std::vector<AnchorData> mAnchors; 0043 };