Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

olineedit.h

Go to the documentation of this file.
00001 /*
00002   This file                  Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
00003     is part of the           Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>, Dawit Alemayehu <adawit@kde.org>
00004        Opie Project          Copyright (C) 1999 Preston Brown <pbrown@kde.org>, Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com>
00005                              Copyright (C) 1997 Sven Radej (sven.radej@iname.com)
00006               =.
00007             .=l.
00008            .>+-=
00009  _;:,     .>    :=|.         This program is free software; you can
00010 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00011 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00012 .="- .-=="i,     .._         License as published by the Free Software
00013  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00014      ._= =}       :          or (at your option) any later version.
00015     .%`+i>       _;_.
00016     .i_,=:_.      -<s.       This program is distributed in the hope that
00017      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00018     : ..    .:,     . . .    without even the implied warranty of
00019     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00020   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00021 ..}^=.=       =       ;      Library General Public License for more
00022 ++=   -.     .`     .:       details.
00023  :     =  ...= . :.=-
00024  -.   .:....=;==+<;          You should have received a copy of the GNU
00025   -_. . .   )=.  =           Library General Public License along with
00026     --        :-=`           this library; see the file COPYING.LIB.
00027                              If not, write to the Free Software Foundation,
00028                              Inc., 59 Temple Place - Suite 330,
00029                              Boston, MA 02111-1307, USA.
00030 
00031 */
00032 
00033 #ifndef OLINEEDIT_H
00034 #define OLINEEDIT_H
00035 
00036 /* QT */
00037 
00038 #include <qlineedit.h>
00039 
00040 /* OPIE */
00041 
00042 #include <opie2/ocompletion.h>
00043 #include <opie2/ocompletionbase.h>
00044 
00045 class QPopupMenu;
00046 
00047 class OCompletionBox;
00048 typedef QString KURL; //class KURL;
00049 
00150 class OLineEdit : public QLineEdit, public OCompletionBase
00151 {
00152     friend class OComboBox;
00153 
00154     Q_OBJECT
00155     Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
00156     Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
00157 
00158 public:
00159 
00168     OLineEdit( const QString &string, QWidget *parent, const char *name = 0 );
00169 
00177     OLineEdit ( QWidget *parent=0, const char *name=0 );
00178 
00182     virtual ~OLineEdit ();
00183 
00188     void setURL( const KURL& url );
00189 
00199     void cursorAtEnd() { end( false ); }
00200 
00209     virtual void setCompletionMode( OGlobalSettings::Completion mode );
00210 
00225     virtual void setContextMenuEnabled( bool showMenu ) {  m_bEnableMenu = showMenu; }
00226 
00230     bool isContextMenuEnabled() const { return m_bEnableMenu; }
00231 
00239     void setURLDropsEnabled( bool enable );
00240 
00244     bool isURLDropsEnabled() const;
00245 
00256     void setTrapReturnKey( bool trap );
00257 
00264     bool trapReturnKey() const;
00265 
00271     virtual bool eventFilter( QObject *, QEvent * );
00272 
00281     OCompletionBox * completionBox( bool create = true );
00282 
00286     virtual void setCompletionObject( OCompletion *, bool hsig = true );
00287 
00288 
00289 signals:
00290 
00298     void returnPressed( const QString& );
00299 
00307     void completion( const QString& );
00308 
00312     void substringCompletion( const QString& );
00313 
00325     void textRotation( OCompletionBase::KeyBindingType );
00326 
00331     void completionModeChanged( OGlobalSettings::Completion );
00332 
00345     void aboutToShowContextMenu( QPopupMenu* );
00346 
00347 public slots:
00348 
00352     virtual void setReadOnly(bool);
00353 
00364     void rotateText( OCompletionBase::KeyBindingType /* type */ );
00365 
00369     virtual void setCompletedText( const QString& );
00370 
00375     void setCompletedItems( const QStringList& items );
00376 
00381     virtual void clear();
00382     
00383 protected slots:
00384 
00389     virtual void makeCompletion( const QString& );
00390 
00394     void slotAboutToShow() {}
00395 
00399     void slotCancelled() {}
00400 
00401 protected:
00402 
00408     virtual void keyPressEvent( QKeyEvent * );
00409 
00415     virtual void mousePressEvent( QMouseEvent * );
00416 
00422     virtual void mouseDoubleClickEvent( QMouseEvent * );
00423 
00429     virtual QPopupMenu *createPopupMenu();
00430 
00436     //virtual void dropEvent( QDropEvent * );
00437 
00438     /*
00439     * This function simply sets the lineedit text and
00440     * highlights the text appropriately if the boolean
00441     * value is set to true.
00442     *
00443     * @param text
00444     * @param marked
00445     */
00446     virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ );
00447 
00451     virtual void create( WId = 0, bool initializeWindow = true,
00452                          bool destroyOldWindow = true );
00453 
00454 private slots:
00455     void completionMenuActivated( int id );
00456     void tripleClickTimeout();  // resets possibleTripleClick
00457 
00458 private:
00459     // Constants that represent the ID's of the popup menu.
00460     // TODO: See if we can replace this mess with KActionMenu
00461     // in the future though it's working lovely.
00462     enum MenuID {
00463         Default = 42,
00464         NoCompletion,
00465         AutoCompletion,
00466         ShellCompletion,
00467         PopupCompletion,
00468         SemiAutoCompletion
00469     };
00470 
00474     void init();
00475 
00479     void makeCompletionBox();
00480 
00485     //bool overrideAccel (const QKeyEvent* e);
00486 
00487     bool m_bEnableMenu;
00488 
00489     bool possibleTripleClick;  // set in mousePressEvent, deleted in tripleClickTimeout
00490 
00491 protected:
00492     //virtual void virtual_hook( int id, void* data );
00493 private:
00494     class OLineEditPrivate;
00495     OLineEditPrivate *d;
00496 };
00497 
00498 #endif

Generated on Sat Nov 5 16:16:30 2005 for OPIE by  doxygen 1.4.2