• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
kcompletion_private.h
1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Carsten Pfeiffer <pfeiffer@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20
21#ifndef KCOMPLETION_PRIVATE_H
22#define KCOMPLETION_PRIVATE_H
23
24#include <tqstring.h>
25#include <ksortablevaluelist.h>
26
27class TDECompTreeNode;
28
29#include <kallocator.h>
30
34class TDECORE_EXPORT TDECompTreeNodeList
35{
36public:
37 TDECompTreeNodeList() : first(0), last(0), m_count(0) {}
38 TDECompTreeNode *begin() const { return first; }
39 TDECompTreeNode *end() const { return last; }
40
41 TDECompTreeNode *at(uint index) const;
42 void append(TDECompTreeNode *item);
43 void prepend(TDECompTreeNode *item);
44 void insert(TDECompTreeNode *after, TDECompTreeNode *item);
45 TDECompTreeNode *remove(TDECompTreeNode *item);
46 uint count() const { return m_count; }
47
48private:
49 TDECompTreeNode *first, *last;
50 uint m_count;
51};
52
53typedef TDECompTreeNodeList TDECompTreeChildren;
54
84class TDECORE_EXPORT TDECompTreeNode : public TQChar
85{
86public:
87 TDECompTreeNode() : TQChar(), myWeight(0) {}
88 TDECompTreeNode( const TQChar& ch, uint weight = 0 )
89 : TQChar( ch ),
90 myWeight( weight ) {}
91 ~TDECompTreeNode();
92
93 void * operator new( size_t s ) {
94 return alloc.allocate( s );
95 }
96 void operator delete( void * s ) {
97 alloc.deallocate( s );
98 }
99
100 // Returns a child of this node matching ch, if available.
101 // Otherwise, returns 0L
102 inline TDECompTreeNode * find( const TQChar& ch ) const {
103 TDECompTreeNode * cur = myChildren.begin();
104 while (cur && (*cur != ch)) cur = cur->next;
105 return cur;
106 }
107 TDECompTreeNode * insert( const TQChar&, bool sorted );
108 void remove( const TQString& );
109
110 inline int childrenCount() const { return myChildren.count(); }
111
112 // weighting
113 inline void confirm() { myWeight++; }
114 inline void confirm(uint w) { myWeight += w; }
115 inline void decline() { myWeight--; }
116 inline uint weight() const { return myWeight; }
117
118 inline const TDECompTreeChildren * children() const {
119 return &myChildren;
120 }
121 inline const TDECompTreeNode * childAt(int index) const {
122 return myChildren.at(index);
123 }
124 inline const TDECompTreeNode * firstChild() const {
125 return myChildren.begin();
126 }
127 inline const TDECompTreeNode * lastChild() const {
128 return myChildren.end();
129 }
130
131 /* We want to handle a list of TDECompTreeNodes on our own, to not
132 need to use TQValueList<>. And to make it even more fast we don't
133 use an accessor, but just a public member. */
134 TDECompTreeNode *next;
135private:
136 uint myWeight;
137 TDECompTreeNodeList myChildren;
138 static TDEZoneAllocator alloc;
139};
140
141
142
143// some more helper stuff
144typedef KSortableValueList<TQString> TDECompletionMatchesList;
145
149class TDECORE_EXPORT TDECompletionMatchesWrapper
150{
151public:
152 TDECompletionMatchesWrapper( bool sort = false )
153 : sortedList( sort ? new TDECompletionMatchesList : 0L ),
154 dirty( false )
155 {}
156 ~TDECompletionMatchesWrapper() {
157 delete sortedList;
158 }
159
160 void setSorting( bool sort ) {
161 if ( sort && !sortedList )
162 sortedList = new TDECompletionMatchesList;
163 else if ( !sort ) {
164 delete sortedList;
165 sortedList = 0L;
166 }
167 stringList.clear();
168 dirty = false;
169 }
170
171 bool sorting() const {
172 return sortedList != 0L;
173 }
174
175 void append( int i, const TQString& string ) {
176 if ( sortedList )
177 sortedList->insert( i, string );
178 else
179 stringList.append( string );
180 dirty = true;
181 }
182
183 void clear() {
184 if ( sortedList )
185 sortedList->clear();
186 stringList.clear();
187 dirty = false;
188 }
189
190 uint count() const {
191 if ( sortedList )
192 return sortedList->count();
193 return stringList.count();
194 }
195
196 bool isEmpty() const {
197 return count() == 0;
198 }
199
200 TQString first() const {
201 return list().first();
202 }
203
204 TQString last() const {
205 return list().last();
206 }
207
208 TQStringList list() const;
209
210 mutable TQStringList stringList;
211 TDECompletionMatchesList *sortedList;
212 mutable bool dirty;
213};
214
215
216#endif // KCOMPLETION_PRIVATE_H
KSortableValueList
KSortableValueList is a special TQValueList for KSortableItem.
Definition: ksortablevaluelist.h:131
KSortableValueList::insert
void insert(Key i, const T &t)
Insert a KSortableItem with the given values.
Definition: ksortablevaluelist.h:138
TDECompTreeNode
A helper class for TDECompletion.
Definition: kcompletion_private.h:85
TDEZoneAllocator
Memory allocator for large groups of small objects.
Definition: kallocator.h:47
KStdAction::clear
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEStdAccel::end
const TDEShortcut & end()
Goto end of the document.
Definition: tdestdaccel.cpp:289
TDEStdAccel::insert
const TDEShortcut & insert()
Toggle insert/overwrite (with visual feedback, e.g.

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.