• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

ktextbrowser.cpp

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  */
00019 
00020 
00021 #include <qpopupmenu.h>
00022 #include <kapplication.h>
00023 #include <kglobalsettings.h>
00024 #include <ktextbrowser.h>
00025 #include <kcursor.h>
00026 #include <kurl.h>
00027 #include <kiconloader.h>
00028 
00029 KTextBrowser::KTextBrowser( QWidget *parent, const char *name,
00030                 bool notifyClick )
00031   : QTextBrowser( parent, name ), mNotifyClick(notifyClick)
00032 {
00033   //
00034   //1999-10-04 Espen Sand: Not required anymore ?
00035   //connect( this, SIGNAL(highlighted(const QString &)),
00036   //   this, SLOT(refChanged(const QString &)));
00037 }
00038 
00039 KTextBrowser::~KTextBrowser( void )
00040 {
00041 }
00042 
00043 
00044 void KTextBrowser::setNotifyClick( bool notifyClick )
00045 {
00046   mNotifyClick = notifyClick;
00047 }
00048 
00049 
00050 bool KTextBrowser::isNotifyClick() const
00051 {
00052   return mNotifyClick;
00053 }
00054 
00055 
00056 void KTextBrowser::setSource( const QString& name )
00057 {
00058   if( name.isNull() )
00059   {
00060     return;
00061   }
00062 
00063   if( name.find('@') > -1 )
00064   {
00065     if( !mNotifyClick )
00066     {
00067       kapp->invokeMailer( KURL( name ) );
00068     }
00069     else
00070     {
00071       emit mailClick( QString::null, name );
00072     }
00073   }
00074   else
00075   {
00076     if( !mNotifyClick )
00077     {
00078       kapp->invokeBrowser( name );
00079     }
00080     else
00081     {
00082       emit urlClick( name );
00083     }
00084   }
00085 }
00086 
00087 
00088 void KTextBrowser::keyPressEvent(QKeyEvent *e)
00089 {
00090   if( e->key() == Key_Escape )
00091   {
00092     e->ignore();
00093   }
00094   else if( e->key() == Key_F1 )
00095   {
00096     e->ignore();
00097   }
00098   else
00099   {
00100     QTextBrowser::keyPressEvent(e);
00101   }
00102 }
00103 
00104 void KTextBrowser::viewportMouseMoveEvent( QMouseEvent* e)
00105 {
00106   // do this first so we get the right type of cursor
00107   QTextBrowser::viewportMouseMoveEvent(e);
00108 
00109   if ( viewport()->cursor().shape() == PointingHandCursor )
00110     viewport()->setCursor( KCursor::handCursor() );
00111 }
00112 
00113 void KTextBrowser::contentsWheelEvent( QWheelEvent *e )
00114 {
00115     if ( KGlobalSettings::wheelMouseZooms() )
00116         QTextBrowser::contentsWheelEvent( e );
00117     else // thanks, we don't want to zoom, so skip QTextEdit's impl.
00118         QScrollView::contentsWheelEvent( e );
00119 }
00120 
00121 QPopupMenu *KTextBrowser::createPopupMenu( const QPoint & pos )
00122 {
00123     enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll };
00124 
00125     QPopupMenu *popup = QTextBrowser::createPopupMenu( pos );
00126 
00127     if ( isReadOnly() )
00128       popup->changeItem( popup->idAt(0), SmallIconSet("editcopy"), popup->text( popup->idAt(0) ) );
00129     else {
00130       int id = popup->idAt(0);
00131       popup->changeItem( id - IdUndo, SmallIconSet("undo"), popup->text( id - IdUndo) );
00132       popup->changeItem( id - IdRedo, SmallIconSet("redo"), popup->text( id - IdRedo) );
00133       popup->changeItem( id - IdCut, SmallIconSet("editcut"), popup->text( id - IdCut) );
00134       popup->changeItem( id - IdCopy, SmallIconSet("editcopy"), popup->text( id - IdCopy) );
00135       popup->changeItem( id - IdPaste, SmallIconSet("editpaste"), popup->text( id - IdPaste) );
00136       popup->changeItem( id - IdClear, SmallIconSet("editclear"), popup->text( id - IdClear) );
00137     }
00138 
00139     return popup;
00140 }
00141 
00142 void KTextBrowser::virtual_hook( int, void* )
00143 { /*BASE::virtual_hook( id, data );*/ }
00144 
00145 #include "ktextbrowser.moc"

kdeui

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal