00001 /* 00002 This file is part of the Opie Project 00003 00004 Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 00005 Inspired by the KDE completion classes which are 00006 Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org> 00007 =. 00008 .=l. 00009 .>+-= 00010 _;:, .> :=|. This program is free software; you can 00011 .> <`_, > . <= redistribute it and/or modify it under 00012 :`=1 )Y*s>-.-- : the terms of the GNU Library General Public 00013 .="- .-=="i, .._ License as published by the Free Software 00014 - . .-<_> .<> Foundation; either version 2 of the License, 00015 ._= =} : or (at your option) any later version. 00016 .%`+i> _;_. 00017 .i_,=:_. -<s. This program is distributed in the hope that 00018 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 00019 : .. .:, . . . without even the implied warranty of 00020 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 00021 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 00022 ..}^=.= = ; Library General Public License for more 00023 ++= -. .` .: details. 00024 : = ...= . :.=- 00025 -. .:....=;==+<; You should have received a copy of the GNU 00026 -_. . . )=. = Library General Public License along with 00027 -- :-=` this library; see the file COPYING.LIB. 00028 If not, write to the Free Software Foundation, 00029 Inc., 59 Temple Place - Suite 330, 00030 Boston, MA 02111-1307, USA. 00031 */ 00032 00033 #ifndef OCOMPLETIONBASE_H 00034 #define OCOMPLETIONBASE_H 00035 00051 class OCompletionBase 00052 { 00053 00054 public: 00055 00061 enum KeyBindingType { 00065 TextCompletion, 00069 PrevCompletionMatch, 00073 NextCompletionMatch, 00077 SubstringCompletion 00078 }; 00079 00080 00081 // Map for the key binding types mentioned above. 00082 typedef QMap<KeyBindingType, OShortcut> KeyBindingMap; 00083 00087 OCompletionBase(); 00088 00092 virtual ~OCompletionBase(); 00093 00115 OCompletion* completionObject( bool hsig = true ); 00116 00139 virtual void setCompletionObject( OCompletion* /*compObj*/, bool hsig = true ); 00140 00153 virtual void setHandleSignals( bool /*handle*/ ); 00154 00164 bool isCompletionObjectAutoDeleted() const { 00165 return m_delegate ? m_delegate->isCompletionObjectAutoDeleted() : m_bAutoDelCompObj; 00166 } 00167 00177 void setAutoDeleteCompletionObject( bool autoDelete ) { 00178 if ( m_delegate ) 00179 m_delegate->setAutoDeleteCompletionObject( autoDelete ); 00180 else 00181 m_bAutoDelCompObj = autoDelete; 00182 } 00183 00204 void setEnableSignals( bool enable ) { 00205 if ( m_delegate ) 00206 m_delegate->setEnableSignals( enable ); 00207 else 00208 m_bEmitSignals = enable; 00209 } 00210 00216 bool handleSignals() const { return m_delegate ? m_delegate->handleSignals() : m_bHandleSignals; } 00217 00223 bool emitSignals() const { return m_delegate ? m_delegate->emitSignals() : m_bEmitSignals; } 00224 00245 virtual void setCompletionMode( OGlobalSettings::Completion mode ); 00246 00255 OGlobalSettings::Completion completionMode() const { 00256 return m_delegate ? m_delegate->completionMode() : m_iCompletionMode; 00257 } 00258 00292 bool setKeyBinding( KeyBindingType /*item*/ , const OShortcut& cut ); 00293 00305 const OShortcut& getKeyBinding( KeyBindingType item ) const { 00306 return m_delegate ? m_delegate->getKeyBinding( item ) : m_keyMap[ item ]; 00307 } 00308 00320 void useGlobalKeyBindings(); 00321 00336 virtual void setCompletedText( const QString& text ) = 0; 00337 00343 virtual void setCompletedItems( const QStringList& items ) = 0; 00344 00356 OCompletion* compObj() const { return m_delegate ? m_delegate->compObj() : (OCompletion*) m_pCompObj; } 00357 00358 protected: 00367 KeyBindingMap getKeyBindings() const { return m_delegate ? m_delegate->getKeyBindings() : m_keyMap; } 00368 00369 void setDelegate( OCompletionBase *delegate ); 00370 OCompletionBase *delegate() const { return m_delegate; } 00371 00372 private: 00373 // This method simply sets the autodelete boolean for 00374 // the completion object, the emit signals and handle 00375 // signals internally flags to the provided values. 00376 void setup( bool, bool, bool ); 00377 00378 // Flag that determined whether the completion object 00379 // should be deleted when this object is destroyed. 00380 bool m_bAutoDelCompObj; 00381 // Determines whether this widget handles completion signals 00382 // internally or not 00383 bool m_bHandleSignals; 00384 // Determines whether this widget fires rotation signals 00385 bool m_bEmitSignals; 00386 // Stores the completion mode locally. 00387 OGlobalSettings::Completion m_iCompletionMode; 00388 // Pointer to Completion object. 00389 QGuardedPtr<OCompletion> m_pCompObj; 00390 // Keybindings 00391 KeyBindingMap m_keyMap; 00392 // we may act as a proxy to another OCompletionBase object 00393 OCompletionBase *m_delegate; 00394 00395 // FIXME: Revise this for Opie? 00396 //protected: 00397 // virtual void virtual_hook( int id, void* data ); 00398 private: 00399 OCompletionBasePrivate *d; 00400 }; 00401 00402 #endif // OCOMPLETIONBASE_H 00403
1.4.2