kdeui Library API Documentation

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 #include <kapplication.h>
00022 #include <kglobalsettings.h>
00023 #include <ktextbrowser.h>
00024 #include <kcursor.h>
00025 #include <kurl.h>
00026 
00027 KTextBrowser::KTextBrowser( QWidget *parent, const char *name,
00028                 bool notifyClick )
00029   : QTextBrowser( parent, name ), mNotifyClick(notifyClick)
00030 {
00031   //
00032   //1999-10-04 Espen Sand: Not required anymore ?
00033   //connect( this, SIGNAL(highlighted(const QString &)),
00034   //   this, SLOT(refChanged(const QString &)));
00035 }
00036 
00037 KTextBrowser::~KTextBrowser( void )
00038 {
00039 }
00040 
00041 
00042 void KTextBrowser::setNotifyClick( bool notifyClick )
00043 {
00044   mNotifyClick = notifyClick;
00045 }
00046 
00047 
00048 bool KTextBrowser::isNotifyClick() const
00049 {
00050   return mNotifyClick;
00051 }
00052 
00053 
00054 void KTextBrowser::setSource( const QString& name )
00055 {
00056   if( name.isNull() == true )
00057   {
00058     return;
00059   }
00060 
00061   if( name.contains('@') == true )
00062   {
00063     if( mNotifyClick == false )
00064     {
00065       kapp->invokeMailer( KURL( name ) );
00066     }
00067     else
00068     {
00069       emit mailClick( QString::null, name );
00070     }
00071   }
00072   else
00073   {
00074     if( mNotifyClick == false )
00075     {
00076       kapp->invokeBrowser( name );
00077     }
00078     else
00079     {
00080       emit urlClick( name );
00081     }
00082   }
00083 }
00084 
00085 
00086 void KTextBrowser::keyPressEvent(QKeyEvent *e)
00087 {
00088   if( e->key() == Key_Escape )
00089   {
00090     e->ignore();
00091   }
00092   else if( e->key() == Key_F1 )
00093   {
00094     e->ignore();
00095   }
00096   else
00097   {
00098     QTextBrowser::keyPressEvent(e);
00099   }
00100 }
00101 
00102 void KTextBrowser::viewportMouseMoveEvent( QMouseEvent* e)
00103 {
00104   // do this first so we get the right type of cursor
00105   QTextBrowser::viewportMouseMoveEvent(e);
00106 
00107   if ( viewport()->cursor().shape() == PointingHandCursor )
00108     viewport()->setCursor( KCursor::handCursor() );
00109 }
00110 
00111 void KTextBrowser::contentsWheelEvent( QWheelEvent *e )
00112 {
00113     if ( KGlobalSettings::wheelMouseZooms() )
00114         QTextBrowser::contentsWheelEvent( e );
00115     else // thanks, we don't want to zoom, so skip QTextEdit's impl.
00116         QScrollView::contentsWheelEvent( e );
00117 }
00118 
00119 void KTextBrowser::virtual_hook( int, void* )
00120 { /*BASE::virtual_hook( id, data );*/ }
00121 
00122 #include "ktextbrowser.moc"
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Jan 21 09:57:29 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003