File indexing completed on 2024-06-02 05:24:08
0001 /* 0002 accessibility/accessiblerichtextlabel_p.h 0003 0004 This file is part of Kleopatra, the KDE keymanager 0005 SPDX-FileCopyrightText: 2021 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 <QAccessibleWidget> 0014 0015 class QLabel; 0016 0017 namespace Kleo 0018 { 0019 class AnchorProvider; 0020 0021 class AccessibleRichTextLabel : public QAccessibleWidget, public QAccessibleTextInterface 0022 { 0023 public: 0024 explicit AccessibleRichTextLabel(QWidget *o); 0025 ~AccessibleRichTextLabel() override; 0026 0027 void *interface_cast(QAccessible::InterfaceType t) override; 0028 QAccessible::State state() const override; 0029 QString text(QAccessible::Text t) const override; 0030 0031 // relations 0032 QAccessibleInterface *focusChild() const override; 0033 0034 // navigation, hierarchy 0035 QAccessibleInterface *child(int index) const override; 0036 int childCount() const override; 0037 int indexOfChild(const QAccessibleInterface *child) const override; 0038 0039 // QAccessibleTextInterface 0040 // selection 0041 void selection(int selectionIndex, int *startOffset, int *endOffset) const override; 0042 int selectionCount() const override; 0043 void addSelection(int startOffset, int endOffset) override; 0044 void removeSelection(int selectionIndex) override; 0045 void setSelection(int selectionIndex, int startOffset, int endOffset) override; 0046 0047 // cursor 0048 int cursorPosition() const override; 0049 void setCursorPosition(int position) override; 0050 0051 // text 0052 QString text(int startOffset, int endOffset) const override; 0053 int characterCount() const override; 0054 0055 // character <-> geometry 0056 QRect characterRect(int offset) const override; 0057 int offsetAtPoint(const QPoint &point) const override; 0058 0059 void scrollToSubstring(int startIndex, int endIndex) override; 0060 QString attributes(int offset, int *startOffset, int *endOffset) const override; 0061 0062 private: 0063 struct ChildData; 0064 0065 QLabel *label() const; 0066 AnchorProvider *anchorProvider() const; 0067 QString displayText() const; 0068 0069 std::vector<ChildData> &childCache() const; 0070 void clearChildCache() const; 0071 0072 mutable std::vector<ChildData> mChildCache; 0073 }; 0074 0075 }