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

ktexteditor.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
00003    Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 
00022 #include "ktexteditor.h"
00023 
00024 using namespace KTextEditor;
00025 
00026 class View::ViewPrivate
00027 {
00028 public:
00029   ViewPrivate()
00030   {
00031   }
00032   ~ViewPrivate()
00033   {
00034   }
00035 
00036   Document *m_doc;
00037   bool m_bContextPopup;
00038 };
00039 
00040 View::View( Document *doc, QWidget *parent, const char *name )
00041 : QWidget( parent, name )
00042 {
00043   d = new ViewPrivate;
00044   d->m_doc = doc;
00045   d->m_bContextPopup = true;
00046 }
00047 
00048 View::~View()
00049 {
00050   delete d;
00051 }
00052 
00053 Document *View::document() const
00054 {
00055   return d->m_doc;
00056 }
00057 
00058 void View::insertText( const QString &text, bool mark )
00059 {
00060   int line, col;
00061   getCursorPosition( &line, &col );
00062   document()->insertAt( text, line, col, mark );
00063 } 
00064 
00065 void View::setInternalContextMenuEnabled( bool b )
00066 {
00067   d->m_bContextPopup = b;
00068 }
00069 
00070 bool View::internalContextMenuEnabled() const
00071 {
00072   return d->m_bContextPopup;
00073 }
00074 
00075 class Document::DocumentPrivate
00076 {
00077 public:
00078   DocumentPrivate()
00079   {
00080   }
00081   ~DocumentPrivate()
00082   {
00083   }
00084 
00085 };
00086 
00087 Document::Document( QObject *parent, const char *name )
00088  : QObject(parent,name)
00089 {
00090   d = new DocumentPrivate;
00091 }
00092 
00093 Document::~Document()
00094 {
00095   //one never knows...
00096   QListIterator<View> it( m_views );
00097 
00098   for (; it.current(); ++it )
00099     disconnect( it.current(), SIGNAL( destroyed() ),
00100                 this, SLOT( slotViewDestroyed() ) );
00101 
00102   delete d;
00103 }
00104 
00105 QList<View> Document::views() const
00106 {
00107   return m_views;
00108 }
00109 
00110 void Document::addView( View *view )
00111 {
00112   if ( !view )
00113     return;
00114 
00115   if ( m_views.findRef( view ) != -1 )
00116     return;
00117 
00118   m_views.append( view );
00119   connect( view, SIGNAL( destroyed() ),
00120            this, SLOT( slotViewDestroyed() ) );
00121 }
00122 
00123 void Document::removeView( View *view )
00124 {
00125   if ( !view )
00126     return;
00127 
00128   disconnect( view, SIGNAL( destroyed() ),
00129               this, SLOT( slotViewDestroyed() ) );
00130 
00131   m_views.removeRef( view );
00132 }
00133 
00134 void Document::slotViewDestroyed()
00135 {
00136   const View *view = static_cast<const View *>( sender() );
00137   m_views.removeRef( view );
00138 }
00139 
00140 

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