summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp
Unidiff
Diffstat (limited to 'noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp140
1 files changed, 140 insertions, 0 deletions
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 @@
1/* This file is part of the KDE project
2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
3 Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21
22#include "ktexteditor.h"
23
24using namespace KTextEditor;
25
26class View::ViewPrivate
27{
28public:
29 ViewPrivate()
30 {
31 }
32 ~ViewPrivate()
33 {
34 }
35
36 Document *m_doc;
37 bool m_bContextPopup;
38};
39
40View::View( Document *doc, QWidget *parent, const char *name )
41: QWidget( parent, name )
42{
43 d = new ViewPrivate;
44 d->m_doc = doc;
45 d->m_bContextPopup = true;
46}
47
48View::~View()
49{
50 delete d;
51}
52
53Document *View::document() const
54{
55 return d->m_doc;
56}
57
58void View::insertText( const QString &text, bool mark )
59{
60 int line, col;
61 getCursorPosition( &line, &col );
62 document()->insertAt( text, line, col, mark );
63}
64
65void View::setInternalContextMenuEnabled( bool b )
66{
67 d->m_bContextPopup = b;
68}
69
70bool View::internalContextMenuEnabled() const
71{
72 return d->m_bContextPopup;
73}
74
75class Document::DocumentPrivate
76{
77public:
78 DocumentPrivate()
79 {
80 }
81 ~DocumentPrivate()
82 {
83 }
84
85};
86
87Document::Document( QObject *parent, const char *name )
88 : QObject(parent,name)
89{
90 d = new DocumentPrivate;
91}
92
93Document::~Document()
94{
95 //one never knows...
96 QListIterator<View> it( m_views );
97
98 for (; it.current(); ++it )
99 disconnect( it.current(), SIGNAL( destroyed() ),
100 this, SLOT( slotViewDestroyed() ) );
101
102 delete d;
103}
104
105QList<View> Document::views() const
106{
107 return m_views;
108}
109
110void Document::addView( View *view )
111{
112 if ( !view )
113 return;
114
115 if ( m_views.findRef( view ) != -1 )
116 return;
117
118 m_views.append( view );
119 connect( view, SIGNAL( destroyed() ),
120 this, SLOT( slotViewDestroyed() ) );
121}
122
123void Document::removeView( View *view )
124{
125 if ( !view )
126 return;
127
128 disconnect( view, SIGNAL( destroyed() ),
129 this, SLOT( slotViewDestroyed() ) );
130
131 m_views.removeRef( view );
132}
133
134void Document::slotViewDestroyed()
135{
136 const View *view = static_cast<const View *>( sender() );
137 m_views.removeRef( view );
138}
139
140