summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index c9178a5..086fdb6 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,237 +1,239 @@
1/********************************************************************** 1/**********************************************************************
2// textedit.cpp 2// textedit.cpp
3** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 4**
5** This file is part of Opie Environment. 5** This file is part of Opie Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12**********************************************************************/ 12**********************************************************************/
13// changes added by L. J. Potter Sun 02-17-2002 21:31:31 13// changes added by L. J. Potter Sun 02-17-2002 21:31:31
14 14
15#include "textedit.h" 15#include "textedit.h"
16#include "filePermissions.h" 16#include "filePermissions.h"
17 17
18/* OPIE */ 18/* OPIE */
19#include <opie2/odebug.h> 19#include <opie2/odebug.h>
20#include <opie2/ofileselector.h> 20#include <opie2/ofileselector.h>
21#include <opie2/ofiledialog.h> 21#include <opie2/ofiledialog.h>
22#include <opie2/ofontselector.h> 22#include <opie2/ofontselector.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26using namespace Opie::Core; 26
27using namespace Opie::Ui;
28 27
29/* QT */ 28/* QT */
30#include <qmenubar.h> 29#include <qmenubar.h>
31#include <qtoolbar.h> 30#include <qtoolbar.h>
32#include <qtextstream.h> 31#include <qtextstream.h>
33#include <qclipboard.h> 32#include <qclipboard.h>
34#include <qaction.h> 33#include <qaction.h>
35#include <qlineedit.h> 34#include <qlineedit.h>
36#include <qmessagebox.h> 35#include <qmessagebox.h>
37#include <qlayout.h> 36#include <qlayout.h>
38#include <qtimer.h> 37#include <qtimer.h>
39#include <qdir.h> 38#include <qdir.h>
40 39
41/* STD */ 40/* STD */
42#include <unistd.h> 41#include <unistd.h>
43#include <sys/stat.h> 42#include <sys/stat.h>
44#include <stdlib.h> //getenv 43#include <stdlib.h> //getenv
45 44
45using namespace Opie::Core;
46using namespace Opie::Ui;
47
46#if QT_VERSION < 300 48#if QT_VERSION < 300
47class QpeEditor : public QMultiLineEdit 49class QpeEditor : public QMultiLineEdit
48{ 50{
49 51
50public: 52public:
51 QpeEditor( QWidget *parent, const char * name = 0 ) 53 QpeEditor( QWidget *parent, const char * name = 0 )
52 : QMultiLineEdit( parent, name ) { 54 : QMultiLineEdit( parent, name ) {
53 clearTableFlags(); 55 clearTableFlags();
54 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 56 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
55} 57}
56 58
57 void find( const QString &txt, bool caseSensitive, 59 void find( const QString &txt, bool caseSensitive,
58 bool backwards ); 60 bool backwards );
59protected: 61protected:
60 bool markIt; 62 bool markIt;
61 int line1, line2, col1, col2; 63 int line1, line2, col1, col2;
62 void mousePressEvent( QMouseEvent * ); 64 void mousePressEvent( QMouseEvent * );
63 void mouseReleaseEvent( QMouseEvent * ); 65 void mouseReleaseEvent( QMouseEvent * );
64 66
65//public slots: 67//public slots:
66 /* 68 /*
67signals: 69signals:
68 void notFound(); 70 void notFound();
69 void searchWrapped(); 71 void searchWrapped();
70 */ 72 */
71 73
72private: 74private:
73 75
74}; 76};
75 77
76void QpeEditor::mousePressEvent( QMouseEvent *e ) { 78void QpeEditor::mousePressEvent( QMouseEvent *e ) {
77 switch(e->button()) { 79 switch(e->button()) {
78 case RightButton: 80 case RightButton:
79 { //rediculous workaround for qt popup menu 81 { //rediculous workaround for qt popup menu
80 //and the hold right click mechanism 82 //and the hold right click mechanism
81 this->setSelection( line1, col1, line2, col2); 83 this->setSelection( line1, col1, line2, col2);
82 QMultiLineEdit::mousePressEvent( e ); 84 QMultiLineEdit::mousePressEvent( e );
83 markIt = false; 85 markIt = false;
84 } 86 }
85 break; 87 break;
86 default: 88 default:
87 { 89 {
88 if(!markIt) { 90 if(!markIt) {
89 int line, col; 91 int line, col;
90 this->getCursorPosition(&line, &col); 92 this->getCursorPosition(&line, &col);
91 line1=line2=line; 93 line1=line2=line;
92 col1=col2=col; 94 col1=col2=col;
93 } 95 }
94 QMultiLineEdit::mousePressEvent( e ); 96 QMultiLineEdit::mousePressEvent( e );
95 } 97 }
96 break; 98 break;
97 }; 99 };
98} 100}
99 101
100void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { 102void QpeEditor::mouseReleaseEvent( QMouseEvent * ) {
101 if(this->hasMarkedText()) { 103 if(this->hasMarkedText()) {
102 markIt = true; 104 markIt = true;
103 this->getMarkedRegion( &line1, &col1, &line2, & col2 ); 105 this->getMarkedRegion( &line1, &col1, &line2, & col2 );
104 } else { 106 } else {
105 markIt = false; 107 markIt = false;
106 } 108 }
107} 109}
108 110
109void QpeEditor::find ( const QString &txt, bool caseSensitive, 111void QpeEditor::find ( const QString &txt, bool caseSensitive,
110 bool backwards ) 112 bool backwards )
111{ 113{
112 static bool wrap = false; 114 static bool wrap = false;
113 int line, col; 115 int line, col;
114 if ( wrap ) { 116 if ( wrap ) {
115 if ( !backwards ) 117 if ( !backwards )
116 line = col = 0; 118 line = col = 0;
117 wrap = false; 119 wrap = false;
118 // emit searchWrapped(); 120 // emit searchWrapped();
119 } else { 121 } else {
120 getCursorPosition( &line, &col ); 122 getCursorPosition( &line, &col );
121 } 123 }
122 //ignore backwards for now.... 124 //ignore backwards for now....
123 if ( !backwards ) { 125 if ( !backwards ) {
124 for ( ; ; ) { 126 for ( ; ; ) {
125 if ( line >= numLines() ) { 127 if ( line >= numLines() ) {
126 wrap = true; 128 wrap = true;
127 //emit notFound(); 129 //emit notFound();
128 break; 130 break;
129 } 131 }
130 int findCol = getString( line )->find( txt, col, caseSensitive ); 132 int findCol = getString( line )->find( txt, col, caseSensitive );
131 if ( findCol >= 0 ) { 133 if ( findCol >= 0 ) {
132 setCursorPosition( line, findCol, false ); 134 setCursorPosition( line, findCol, false );
133 col = findCol + txt.length(); 135 col = findCol + txt.length();
134 setCursorPosition( line, col, true ); 136 setCursorPosition( line, col, true );
135 137
136 //found = true; 138 //found = true;
137 break; 139 break;
138 } 140 }
139 line++; 141 line++;
140 col = 0; 142 col = 0;
141 } 143 }
142 } 144 }
143} 145}
144 146
145 147
146#else 148#else
147 149
148#error "Must make a QpeEditor that inherits QTextEdit" 150#error "Must make a QpeEditor that inherits QTextEdit"
149 151
150#endif 152#endif
151 153
152 154
153static const int nfontsizes = 6; 155static const int nfontsizes = 6;
154static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 156static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
155 157
156TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 158TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
157 : QMainWindow( parent, name, f ), bFromDocView( false ) 159 : QMainWindow( parent, name, f ), bFromDocView( false )
158{ 160{
159 doc = 0; 161 doc = 0;
160 edited=false; 162 edited=false;
161 fromSetDocument=false; 163 fromSetDocument=false;
162 164
163 setToolBarsMovable( false ); 165 setToolBarsMovable( false );
164 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 166 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
165 167
166 channel = new QCopChannel( "QPE/Application/textedit", this ); 168 channel = new QCopChannel( "QPE/Application/textedit", this );
167 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 169 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
168 this, SLOT(receive(const QCString&,const QByteArray&)) ); 170 this, SLOT(receive(const QCString&,const QByteArray&)) );
169 171
170 setIcon( Resource::loadPixmap( "TextEditor" ) ); 172 setIcon( Resource::loadPixmap( "TextEditor" ) );
171 173
172 QToolBar *bar = new QToolBar( this ); 174 QToolBar *bar = new QToolBar( this );
173 bar->setHorizontalStretchable( true ); 175 bar->setHorizontalStretchable( true );
174 menu = bar; 176 menu = bar;
175 177
176 QMenuBar *mb = new QMenuBar( bar ); 178 QMenuBar *mb = new QMenuBar( bar );
177 QPopupMenu *file = new QPopupMenu( this ); 179 QPopupMenu *file = new QPopupMenu( this );
178 QPopupMenu *edit = new QPopupMenu( this ); 180 QPopupMenu *edit = new QPopupMenu( this );
179 QPopupMenu *advancedMenu = new QPopupMenu(this); 181 QPopupMenu *advancedMenu = new QPopupMenu(this);
180 182
181 font = new QPopupMenu( this ); 183 font = new QPopupMenu( this );
182 184
183 bar = new QToolBar( this ); 185 bar = new QToolBar( this );
184 editBar = bar; 186 editBar = bar;
185 187
186 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 188 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
187 QString::null, 0, this, 0 ); 189 QString::null, 0, this, 0 );
188 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 190 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
189// a->addTo( bar ); 191// a->addTo( bar );
190 a->addTo( file ); 192 a->addTo( file );
191 193
192 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), 194 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ),
193 QString::null, 0, this, 0 ); 195 QString::null, 0, this, 0 );
194 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 196 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
195 a->addTo( bar ); 197 a->addTo( bar );
196 a->addTo( file ); 198 a->addTo( file );
197 199
198 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , 200 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") ,
199 QString::null, 0, this, 0 ); 201 QString::null, 0, this, 0 );
200 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 202 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
201 file->insertSeparator(); 203 file->insertSeparator();
202 a->addTo( bar ); 204 a->addTo( bar );
203 a->addTo( file ); 205 a->addTo( file );
204 206
205 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , 207 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") ,
206 QString::null, 0, this, 0 ); 208 QString::null, 0, this, 0 );
207 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 209 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
208 a->addTo( file ); 210 a->addTo( file );
209 211
210 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), 212 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ),
211 QString::null, 0, this, 0 ); 213 QString::null, 0, this, 0 );
212 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 214 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
213 a->addTo( editBar ); 215 a->addTo( editBar );
214 a->addTo( edit ); 216 a->addTo( edit );
215 217
216 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), 218 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ),
217 QString::null, 0, this, 0 ); 219 QString::null, 0, this, 0 );
218 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 220 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
219 a->addTo( editBar ); 221 a->addTo( editBar );
220 a->addTo( edit ); 222 a->addTo( edit );
221 223
222 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), 224 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ),
223 QString::null, 0, this, 0 ); 225 QString::null, 0, this, 0 );
224 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 226 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
225 a->addTo( editBar ); 227 a->addTo( editBar );
226 a->addTo( edit ); 228 a->addTo( edit );
227 229
228 230
229#ifndef QT_NO_CLIPBOARD 231#ifndef QT_NO_CLIPBOARD
230 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), 232 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ),
231 QString::null, 0, this, 0 ); 233 QString::null, 0, this, 0 );
232 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); 234 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
233 a->addTo( edit ); 235 a->addTo( edit );
234#endif 236#endif
235 237
236 a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), 238 a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ),
237 QString::null, 0, this, 0 ); 239 QString::null, 0, this, 0 );