From e97a6da57804aa14907dec327fbae71bff9b383e Mon Sep 17 00:00:00 2001 From: jowenn Date: Sun, 10 Nov 2002 21:08:01 +0000 Subject: import of tiny kate. (saving not possible yet) --- (limited to 'noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp') diff --git a/noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp b/noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp new file mode 100644 index 0000000..6b4d86d --- a/dev/null +++ b/noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp @@ -0,0 +1,140 @@ +/* This file is part of the KDE project + Copyright (C) 2000 Simon Hausmann + Copyright (C) 2002 Joseph Wenninger + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + + +#include "ktexteditor.h" + +using namespace KTextEditor; + +class View::ViewPrivate +{ +public: + ViewPrivate() + { + } + ~ViewPrivate() + { + } + + Document *m_doc; + bool m_bContextPopup; +}; + +View::View( Document *doc, QWidget *parent, const char *name ) +: QWidget( parent, name ) +{ + d = new ViewPrivate; + d->m_doc = doc; + d->m_bContextPopup = true; +} + +View::~View() +{ + delete d; +} + +Document *View::document() const +{ + return d->m_doc; +} + +void View::insertText( const QString &text, bool mark ) +{ + int line, col; + getCursorPosition( &line, &col ); + document()->insertAt( text, line, col, mark ); +} + +void View::setInternalContextMenuEnabled( bool b ) +{ + d->m_bContextPopup = b; +} + +bool View::internalContextMenuEnabled() const +{ + return d->m_bContextPopup; +} + +class Document::DocumentPrivate +{ +public: + DocumentPrivate() + { + } + ~DocumentPrivate() + { + } + +}; + +Document::Document( QObject *parent, const char *name ) + : QObject(parent,name) +{ + d = new DocumentPrivate; +} + +Document::~Document() +{ + //one never knows... + QListIterator it( m_views ); + + for (; it.current(); ++it ) + disconnect( it.current(), SIGNAL( destroyed() ), + this, SLOT( slotViewDestroyed() ) ); + + delete d; +} + +QList Document::views() const +{ + return m_views; +} + +void Document::addView( View *view ) +{ + if ( !view ) + return; + + if ( m_views.findRef( view ) != -1 ) + return; + + m_views.append( view ); + connect( view, SIGNAL( destroyed() ), + this, SLOT( slotViewDestroyed() ) ); +} + +void Document::removeView( View *view ) +{ + if ( !view ) + return; + + disconnect( view, SIGNAL( destroyed() ), + this, SLOT( slotViewDestroyed() ) ); + + m_views.removeRef( view ); +} + +void Document::slotViewDestroyed() +{ + const View *view = static_cast( sender() ); + m_views.removeRef( view ); +} + + -- cgit v0.9.0.2