| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# ktextbrowser.cpp

    00001 /*  This file is part of the KDE Libraries
    00002  *  Copyright (C) 1999-2000 Espen Sand (espen@kde.org)
    00003  *
    00004  *  This library is free software; you can redistribute it and/or
    00005  *  modify it under the terms of the GNU Library General Public
    00006  *  License as published by the Free Software Foundation; either
    00007  *  version 2 of the License, or (at your option) any later version.
    00008  *
    00009  *  This library is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  *  Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this library; see the file COPYING.LIB.  If not, write to
    00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  */
    00019
    00020 /*
    00021 ****************************************************************************
    00022 *
    00023 * $Log: ktextbrowser.cpp,v $
    00024 * Revision 1.13  2002/07/25 07:31:47  raabe
    00025 * -      kapp->invokeMailer( name, QString::null );
    00026 * +      kapp->invokeMailer( KURL( name ) );
    00027 *
    00028 * ...so that it properly handles those exceptional mail links which start
    00029 * with mailto:
    00030 *
    00031 * Revision 1.12  2002/05/26 11:50:10  pfeiffer
    00032 * a QTextEdit derived class that offers
    00033 * - deleting of words via standard KDE shortcuts
    00034 * - zooming or fast scrolling via Ctrl-Wheelscroll
    00035 * - cursor autohiding
    00036 *
    00037 * KTextBrowser: use KGlobalSettings for zoom/scroll
    00038 *
    00039 * Revision 1.11  2002/03/04 00:51:51  lunakl
    00040 * Keep BC changes (the patch is almost 100KiB of boring stuff
    00041 * ... anybody willing to review? ;) ).
    00042 *
    00043 * Revision 1.10  2001/11/24 01:19:04  pfeiffer
    00044 * make the wheelmouse work the same way as in KDE2, i.e. Ctrl-Wheel
    00045 * scrolls faster, instead of zooming. Do we need to make this configurable?
    00046 * I for one find myself scrolling much more often than zooming.
    00047 *
    00048 * Revision 1.9  2001/10/10 17:40:39  mueller
    00049 * CVS_SILENT: fixincludes
    00050 *
    00051 * Revision 1.8  2000/06/01 09:36:12  gehrmab
    00052 * We like orthogonal APIs
    00053 *
    00054 * Revision 1.7  2000/05/26 04:20:33  granroth
    00055 * Use the KCursor::handCursor instead of the Qt hand cursor with
    00056 * KTextBrowser.  This is for consistency.
    00057 *
    00058 * There is a little bit of flicker when it switches to the hand, though.
    00059 * That's because it first switches to the Qt version in the
    00060 * QTextBrowser code and I use that in the KTextBrowser version to know
    00061 * when to switch to the hand.  I couldn't figure out any other way to do
    00062 * this without completely reimplementing all of the enter events -- what
    00063 * a pain.
    00064 *
    00065 * Revision 1.6  2000/01/03 18:48:57  espen
    00066 * The widget will ignore a key sequence
    00067 * containing F1. Since this widget is used
    00068 * in dialogs (eg KDialogBase), F1 and Shift+F1
    00069 * can be used to start the help operation.
    00070 *
    00071 *
    00072 ****************************************************************************
    00073 */
    00074
    00075
    00076 #include <kapplication.h>
    00077 #include <kglobalsettings.h>
    00078 #include <ktextbrowser.h>
    00079 #include <kcursor.h>
    00080 #include <kurl.h>
    00081
    00082 KTextBrowser::KTextBrowser( QWidget *parent, const char *name,
    00083                             bool notifyClick )
    00084   : QTextBrowser( parent, name ), mNotifyClick(notifyClick)
    00085 {
    00086   //
    00087   //1999-10-04 Espen Sand: Not required anymore ?
    00088   //connect( this, SIGNAL(highlighted(const QString &)),
    00089   //   this, SLOT(refChanged(const QString &)));
    00090 }
    00091
    00092 KTextBrowser::~KTextBrowser( void )
    00093 {
    00094 }
    00095
    00096
    00097 void KTextBrowser::setNotifyClick( bool notifyClick )
    00098 {
    00099   mNotifyClick = notifyClick;
    00100 }
    00101
    00102
    00103 bool KTextBrowser::isNotifyClick() const
    00104 {
    00105   return mNotifyClick;
    00106 }
    00107
    00108
    00109 void KTextBrowser::setSource( const QString& name )
    00110 {
    00111   if( name.isNull() == true )
    00112   {
    00113     return;
    00114   }
    00115
    00116   if( name.contains('@') == true )
    00117   {
    00118     if( mNotifyClick == false )
    00119     {
    00120       kapp->invokeMailer( KURL( name ) );
    00121     }
    00122     else
    00123     {
    00124       emit mailClick( QString::null, name );
    00125     }
    00126   }
    00127   else
    00128   {
    00129     if( mNotifyClick == false )
    00130     {
    00131       kapp->invokeBrowser( name );
    00132     }
    00133     else
    00134     {
    00135       emit urlClick( name );
    00136     }
    00137   }
    00138 }
    00139
    00140
    00141 void KTextBrowser::keyPressEvent(QKeyEvent *e)
    00142 {
    00143   if( e->key() == Key_Escape )
    00144   {
    00145     e->ignore();
    00146   }
    00147   else if( e->key() == Key_F1 )
    00148   {
    00149     e->ignore();
    00150   }
    00151   else
    00152   {
    00153     QTextBrowser::keyPressEvent(e);
    00154   }
    00155 }
    00156
    00157 void KTextBrowser::viewportMouseMoveEvent( QMouseEvent* e)
    00158 {
    00159   // do this first so we get the right type of cursor
    00160   QTextBrowser::viewportMouseMoveEvent(e);
    00161
    00162   if ( viewport()->cursor().shape() == PointingHandCursor )
    00163     viewport()->setCursor( KCursor::handCursor() );
    00164 }
    00165
    00166 void KTextBrowser::contentsWheelEvent( QWheelEvent *e )
    00167 {
    00168     if ( KGlobalSettings::wheelMouseZooms() )
    00169         QTextBrowser::contentsWheelEvent( e );
    00170     else // thanks, we don't want to zoom, so skip QTextEdit's impl.
    00171         QScrollView::contentsWheelEvent( e );
    00172 }
    00173
    00174 void KTextBrowser::virtual_hook( int, void* )
    00175 { /*BASE::virtual_hook( id, data );*/ }
    00176
    00177 #include "ktextbrowser.moc"

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:57:47 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001