| 1 | /* |
|---|---|
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 1999 Carsten Pfeiffer <pfeiffer@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef KCOMPLETION_PRIVATE_H |
| 9 | #define KCOMPLETION_PRIVATE_H |
| 10 | |
| 11 | #include "kcompletion.h" |
| 12 | #include "kcompletionmatcheswrapper_p.h" |
| 13 | #include "kcomptreenode_p.h" |
| 14 | |
| 15 | #include <kcompletionmatches.h> |
| 16 | |
| 17 | #include <QSharedPointer> |
| 18 | #include <kzoneallocator_p.h> |
| 19 | |
| 20 | class KCompletionPrivate |
| 21 | { |
| 22 | public: |
| 23 | explicit KCompletionPrivate(KCompletion *parent) |
| 24 | : q_ptr(parent) |
| 25 | , completionMode(KCompletion::CompletionPopup) |
| 26 | , treeNodeAllocator(KCompTreeNode::allocator()) // keep strong-ref to allocator instance |
| 27 | , m_treeRoot(new KCompTreeNode) |
| 28 | , hasMultipleMatches(false) |
| 29 | , beep(true) |
| 30 | , ignoreCase(false) |
| 31 | , shouldAutoSuggest(true) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | ~KCompletionPrivate() = default; |
| 36 | |
| 37 | void addWeightedItem(const QString &); |
| 38 | QString findCompletion(const QString &string); |
| 39 | |
| 40 | // The default sorting function, sorts alphabetically |
| 41 | static void defaultSort(QStringList &); |
| 42 | |
| 43 | // Pointer to sorter function |
| 44 | KCompletion::SorterFunction sorterFunction{defaultSort}; |
| 45 | |
| 46 | // list used for nextMatch() and previousMatch() |
| 47 | KCompletionMatchesWrapper matches{sorterFunction}; |
| 48 | |
| 49 | KCompletion *const q_ptr; |
| 50 | KCompletion::CompletionMode completionMode; |
| 51 | |
| 52 | QSharedPointer<KZoneAllocator> treeNodeAllocator; |
| 53 | |
| 54 | QString lastString; |
| 55 | QString lastMatch; |
| 56 | QString currentMatch; |
| 57 | std::unique_ptr<KCompTreeNode> m_treeRoot; |
| 58 | int rotationIndex = 0; |
| 59 | // TODO: Change hasMultipleMatches to bitfield after moving findAllCompletions() |
| 60 | // to KCompletionMatchesPrivate |
| 61 | KCompletion::CompOrder order : 3; |
| 62 | bool hasMultipleMatches; |
| 63 | bool beep : 1; |
| 64 | bool ignoreCase : 1; |
| 65 | bool shouldAutoSuggest : 1; |
| 66 | Q_DECLARE_PUBLIC(KCompletion) |
| 67 | }; |
| 68 | |
| 69 | #endif // KCOMPLETION_PRIVATE_H |
| 70 |
