author | jowenn <jowenn> | 2002-11-10 21:08:01 (UTC) |
---|---|---|
committer | jowenn <jowenn> | 2002-11-10 21:08:01 (UTC) |
commit | e97a6da57804aa14907dec327fbae71bff9b383e (patch) (unidiff) | |
tree | 15f6ee292dba24bdda72f5c72f6d2224c3516763 /noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp | |
parent | 7c012ee8cd16d8befacc6f6750711443fac0fd5e (diff) | |
download | opie-e97a6da57804aa14907dec327fbae71bff9b383e.zip opie-e97a6da57804aa14907dec327fbae71bff9b383e.tar.gz opie-e97a6da57804aa14907dec327fbae71bff9b383e.tar.bz2 |
import of tiny kate. (saving not possible yet)
Diffstat (limited to 'noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/ktexteditor/ktexteditor.cpp | 140 |
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 | |||
24 | using namespace KTextEditor; | ||
25 | |||
26 | class View::ViewPrivate | ||
27 | { | ||
28 | public: | ||
29 | ViewPrivate() | ||
30 | { | ||
31 | } | ||
32 | ~ViewPrivate() | ||
33 | { | ||
34 | } | ||
35 | |||
36 | Document *m_doc; | ||
37 | bool m_bContextPopup; | ||
38 | }; | ||
39 | |||
40 | View::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 | |||
48 | View::~View() | ||
49 | { | ||
50 | delete d; | ||
51 | } | ||
52 | |||
53 | Document *View::document() const | ||
54 | { | ||
55 | return d->m_doc; | ||
56 | } | ||
57 | |||
58 | void 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 | |||
65 | void View::setInternalContextMenuEnabled( bool b ) | ||
66 | { | ||
67 | d->m_bContextPopup = b; | ||
68 | } | ||
69 | |||
70 | bool View::internalContextMenuEnabled() const | ||
71 | { | ||
72 | return d->m_bContextPopup; | ||
73 | } | ||
74 | |||
75 | class Document::DocumentPrivate | ||
76 | { | ||
77 | public: | ||
78 | DocumentPrivate() | ||
79 | { | ||
80 | } | ||
81 | ~DocumentPrivate() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | }; | ||
86 | |||
87 | Document::Document( QObject *parent, const char *name ) | ||
88 | : QObject(parent,name) | ||
89 | { | ||
90 | d = new DocumentPrivate; | ||
91 | } | ||
92 | |||
93 | Document::~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 | |||
105 | QList<View> Document::views() const | ||
106 | { | ||
107 | return m_views; | ||
108 | } | ||
109 | |||
110 | void 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 | |||
123 | void 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 | |||
134 | void Document::slotViewDestroyed() | ||
135 | { | ||
136 | const View *view = static_cast<const View *>( sender() ); | ||
137 | m_views.removeRef( view ); | ||
138 | } | ||
139 | |||
140 | |||