File indexing completed on 2024-04-28 03:53:08
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 1999 Carsten Pfeiffer <pfeiffer@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KCOMPLETION_PRIVATE_H 0009 #define KCOMPLETION_PRIVATE_H 0010 0011 #include "kcompletion.h" 0012 #include "kcompletionmatcheswrapper_p.h" 0013 #include "kcomptreenode_p.h" 0014 0015 #include <kcompletionmatches.h> 0016 0017 #include <QSharedPointer> 0018 #include <kzoneallocator_p.h> 0019 0020 class KCompletionPrivate 0021 { 0022 public: 0023 explicit KCompletionPrivate(KCompletion *parent) 0024 : q_ptr(parent) 0025 , completionMode(KCompletion::CompletionPopup) 0026 , treeNodeAllocator(KCompTreeNode::allocator()) // keep strong-ref to allocator instance 0027 , m_treeRoot(new KCompTreeNode) 0028 , hasMultipleMatches(false) 0029 , beep(true) 0030 , ignoreCase(false) 0031 , shouldAutoSuggest(true) 0032 { 0033 } 0034 0035 ~KCompletionPrivate() = default; 0036 0037 void addWeightedItem(const QString &); 0038 QString findCompletion(const QString &string); 0039 0040 // The default sorting function, sorts alphabetically 0041 static void defaultSort(QStringList &); 0042 0043 // Pointer to sorter function 0044 KCompletion::SorterFunction sorterFunction{defaultSort}; 0045 0046 // list used for nextMatch() and previousMatch() 0047 KCompletionMatchesWrapper matches{sorterFunction}; 0048 0049 KCompletion *const q_ptr; 0050 KCompletion::CompletionMode completionMode; 0051 0052 QSharedPointer<KZoneAllocator> treeNodeAllocator; 0053 0054 QString lastString; 0055 QString lastMatch; 0056 QString currentMatch; 0057 std::unique_ptr<KCompTreeNode> m_treeRoot; 0058 int rotationIndex = 0; 0059 // TODO: Change hasMultipleMatches to bitfield after moving findAllCompletions() 0060 // to KCompletionMatchesPrivate 0061 KCompletion::CompOrder order : 3; 0062 bool hasMultipleMatches; 0063 bool beep : 1; 0064 bool ignoreCase : 1; 0065 bool shouldAutoSuggest : 1; 0066 Q_DECLARE_PUBLIC(KCompletion) 0067 }; 0068 0069 #endif // KCOMPLETION_PRIVATE_H