summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-17 04:12:20 (UTC)
committer llornkcor <llornkcor>2002-10-17 04:12:20 (UTC)
commit23fbd85de36bac6e8dff5e16a6e22ce19fe15187 (patch) (unidiff)
tree482f504e56bfcc78f3da73598190b9280a649871
parentac2f56d9be571ff2d8165f81fbea03d31c551779 (diff)
downloadopie-23fbd85de36bac6e8dff5e16a6e22ce19fe15187.zip
opie-23fbd85de36bac6e8dff5e16a6e22ce19fe15187.tar.gz
opie-23fbd85de36bac6e8dff5e16a6e22ce19fe15187.tar.bz2
added hold stylus default menu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index f3937b1..35f9d3c 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -142,512 +142,513 @@ static char * filesave_xpm[] = {
142"G c #7D7D7D", 142"G c #7D7D7D",
143"H c #000000", 143"H c #000000",
144"I c #404040", 144"I c #404040",
145"J c #858585", 145"J c #858585",
146"K c #323232", 146"K c #323232",
147"L c #D0D0D0", 147"L c #D0D0D0",
148"M c #1C1C1C", 148"M c #1C1C1C",
149" ...+ ", 149" ...+ ",
150" @#$%&..+ ", 150" @#$%&..+ ",
151" .*=-;;>,..+ ", 151" .*=-;;>,..+ ",
152" ')!~;;;;;;{]..", 152" ')!~;;;;;;{]..",
153" ^/(-;;;;;;;_:<", 153" ^/(-;;;;;;;_:<",
154" [}|;;;;;;;{12$", 154" [}|;;;;;;;{12$",
155" #34-55;;;;678$+", 155" #34-55;;;;678$+",
156" 90ab=c;dd;e1fg ", 156" 90ab=c;dd;e1fg ",
157" [ahij((kbl0mn$ ", 157" [ahij((kbl0mn$ ",
158" op^q^^7r&]s/$+ ", 158" op^q^^7r&]s/$+ ",
159"@btu;vbwxy]zAB ", 159"@btu;vbwxy]zAB ",
160"CzDEvEv;;DssF$ ", 160"CzDEvEv;;DssF$ ",
161"G.H{E{E{IxsJ$+ ", 161"G.H{E{E{IxsJ$+ ",
162" +...vEKxzLM ", 162" +...vEKxzLM ",
163" +...z]n$ ", 163" +...z]n$ ",
164" +... "}; 164" +... "};
165 165
166 166
167#if QT_VERSION < 300 167#if QT_VERSION < 300
168 168
169class QpeEditor : public QMultiLineEdit 169class QpeEditor : public QMultiLineEdit
170{ 170{
171 // Q_OBJECT 171 // Q_OBJECT
172public: 172public:
173 QpeEditor( QWidget *parent, const char * name = 0 ) 173 QpeEditor( QWidget *parent, const char * name = 0 )
174 : QMultiLineEdit( parent, name ) 174 : QMultiLineEdit( parent, name )
175 { 175 {
176 clearTableFlags(); 176 clearTableFlags();
177 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 177 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
178 } 178 }
179 179
180 void find( const QString &txt, bool caseSensitive, 180 void find( const QString &txt, bool caseSensitive,
181 bool backwards ); 181 bool backwards );
182//public slots: 182//public slots:
183 /* 183 /*
184signals: 184signals:
185 void notFound(); 185 void notFound();
186 void searchWrapped(); 186 void searchWrapped();
187 */ 187 */
188 188
189private: 189private:
190 190
191}; 191};
192 192
193 193
194void QpeEditor::find ( const QString &txt, bool caseSensitive, 194void QpeEditor::find ( const QString &txt, bool caseSensitive,
195 bool backwards ) 195 bool backwards )
196{ 196{
197 static bool wrap = FALSE; 197 static bool wrap = FALSE;
198 int line, col; 198 int line, col;
199 if ( wrap ) { 199 if ( wrap ) {
200 if ( !backwards ) 200 if ( !backwards )
201 line = col = 0; 201 line = col = 0;
202 wrap = FALSE; 202 wrap = FALSE;
203 // emit searchWrapped(); 203 // emit searchWrapped();
204 } else { 204 } else {
205 getCursorPosition( &line, &col ); 205 getCursorPosition( &line, &col );
206 } 206 }
207 //ignore backwards for now.... 207 //ignore backwards for now....
208 if ( !backwards ) { 208 if ( !backwards ) {
209 for ( ; ; ) { 209 for ( ; ; ) {
210 if ( line >= numLines() ) { 210 if ( line >= numLines() ) {
211 wrap = TRUE; 211 wrap = TRUE;
212 //emit notFound(); 212 //emit notFound();
213 break; 213 break;
214 } 214 }
215 int findCol = getString( line )->find( txt, col, caseSensitive ); 215 int findCol = getString( line )->find( txt, col, caseSensitive );
216 if ( findCol >= 0 ) { 216 if ( findCol >= 0 ) {
217 setCursorPosition( line, findCol, FALSE ); 217 setCursorPosition( line, findCol, FALSE );
218 col = findCol + txt.length(); 218 col = findCol + txt.length();
219 setCursorPosition( line, col, TRUE ); 219 setCursorPosition( line, col, TRUE );
220 220
221 //found = TRUE; 221 //found = TRUE;
222 break; 222 break;
223 } 223 }
224 line++; 224 line++;
225 col = 0; 225 col = 0;
226 } 226 }
227 227
228 } 228 }
229 229
230} 230}
231 231
232 232
233#else 233#else
234 234
235#error "Must make a QpeEditor that inherits QTextEdit" 235#error "Must make a QpeEditor that inherits QTextEdit"
236 236
237#endif 237#endif
238 238
239 239
240static const int nfontsizes = 6; 240static const int nfontsizes = 6;
241static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 241static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
242 242
243TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 243TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
244 : QMainWindow( parent, name, f ), bFromDocView( FALSE ) 244 : QMainWindow( parent, name, f ), bFromDocView( FALSE )
245{ 245{
246 doc = 0; 246 doc = 0;
247 edited=FALSE; 247 edited=FALSE;
248 edited1=FALSE; 248 edited1=FALSE;
249 setToolBarsMovable( FALSE ); 249 setToolBarsMovable( FALSE );
250 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 250 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
251 251
252 channel = new QCopChannel( "QPE/Application/textedit", this ); 252 channel = new QCopChannel( "QPE/Application/textedit", this );
253 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 253 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
254 this, SLOT(receive(const QCString&, const QByteArray&)) ); 254 this, SLOT(receive(const QCString&, const QByteArray&)) );
255 255
256 setIcon( Resource::loadPixmap( "TextEditor" ) ); 256 setIcon( Resource::loadPixmap( "TextEditor" ) );
257 257
258 QPEToolBar *bar = new QPEToolBar( this ); 258 QPEToolBar *bar = new QPEToolBar( this );
259 bar->setHorizontalStretchable( TRUE ); 259 bar->setHorizontalStretchable( TRUE );
260 menu = bar; 260 menu = bar;
261 261
262 QPEMenuBar *mb = new QPEMenuBar( bar ); 262 QPEMenuBar *mb = new QPEMenuBar( bar );
263 QPopupMenu *file = new QPopupMenu( this ); 263 QPopupMenu *file = new QPopupMenu( this );
264 QPopupMenu *edit = new QPopupMenu( this ); 264 QPopupMenu *edit = new QPopupMenu( this );
265 QPopupMenu *advancedMenu = new QPopupMenu(this); 265 QPopupMenu *advancedMenu = new QPopupMenu(this);
266 266
267 font = new QPopupMenu( this ); 267 font = new QPopupMenu( this );
268 268
269 bar = new QPEToolBar( this ); 269 bar = new QPEToolBar( this );
270 editBar = bar; 270 editBar = bar;
271 271
272 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 272 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
273 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 273 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
274 a->addTo( bar ); 274 a->addTo( bar );
275 a->addTo( file ); 275 a->addTo( file );
276 276
277 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 277 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
278 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 278 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
279 a->addTo( bar ); 279 a->addTo( bar );
280 a->addTo( file ); 280 a->addTo( file );
281 281
282 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 282 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
283 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 283 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
284 file->insertSeparator(); 284 file->insertSeparator();
285 a->addTo( file ); 285 a->addTo( file );
286 286
287 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 287 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
288 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 288 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
289 a->addTo( file ); 289 a->addTo( file );
290 290
291 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 291 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
292 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 292 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
293 a->addTo( editBar ); 293 a->addTo( editBar );
294 a->addTo( edit ); 294 a->addTo( edit );
295 295
296 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 296 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
297 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 297 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
298 a->addTo( editBar ); 298 a->addTo( editBar );
299 a->addTo( edit ); 299 a->addTo( edit );
300 300
301 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 301 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
302 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 302 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
303 a->addTo( editBar ); 303 a->addTo( editBar );
304 a->addTo( edit ); 304 a->addTo( edit );
305 305
306 306
307#ifndef QT_NO_CLIPBOARD 307#ifndef QT_NO_CLIPBOARD
308 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 308 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
309 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); 309 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
310 a->addTo( edit ); 310 a->addTo( edit );
311#endif 311#endif
312 312
313 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 313 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
314 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 314 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
315 edit->insertSeparator(); 315 edit->insertSeparator();
316 a->addTo( bar ); 316 a->addTo( bar );
317 a->addTo( edit ); 317 a->addTo( edit );
318 318
319 319
320 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 320 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
321 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 321 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
322 zin->addTo( font ); 322 zin->addTo( font );
323 323
324 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 324 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
325 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 325 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
326 zout->addTo( font ); 326 zout->addTo( font );
327 327
328 font->insertSeparator(); 328 font->insertSeparator();
329// font->insertSeparator(); 329// font->insertSeparator();
330 font->insertItem(tr("Font"), this, SLOT(changeFont()) ); 330 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
331 331
332 font->insertSeparator(); 332 font->insertSeparator();
333 font->insertItem(tr("Advanced Features"), advancedMenu); 333 font->insertItem(tr("Advanced Features"), advancedMenu);
334 334
335 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); 335 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
336 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 336 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
337 wa->setToggleAction(TRUE); 337 wa->setToggleAction(TRUE);
338 wa->addTo( advancedMenu); 338 wa->addTo( advancedMenu);
339 339
340 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); 340 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 );
341 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 341 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
342 nStart->setToggleAction(TRUE); 342 nStart->setToggleAction(TRUE);
343 nStart->addTo( advancedMenu ); 343 nStart->addTo( advancedMenu );
344 344
345 nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); 345 nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 );
346 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); 346 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) );
347 nAdvanced->setToggleAction(TRUE); 347 nAdvanced->setToggleAction(TRUE);
348 nAdvanced->addTo( advancedMenu ); 348 nAdvanced->addTo( advancedMenu );
349 349
350 desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); 350 desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 );
351 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); 351 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) );
352 desktopAction->setToggleAction(TRUE); 352 desktopAction->setToggleAction(TRUE);
353 desktopAction->addTo( advancedMenu); 353 desktopAction->addTo( advancedMenu);
354 354
355 filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); 355 filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 );
356 connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); 356 connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) );
357 filePermAction->setToggleAction(TRUE); 357 filePermAction->setToggleAction(TRUE);
358 filePermAction->addTo( advancedMenu); 358 filePermAction->addTo( advancedMenu);
359 359
360 font->insertSeparator(); 360 font->insertSeparator();
361 361
362 font->insertItem(tr("About"), this, SLOT( doAbout()) ); 362 font->insertItem(tr("About"), this, SLOT( doAbout()) );
363 363
364 mb->insertItem( tr( "File" ), file ); 364 mb->insertItem( tr( "File" ), file );
365 mb->insertItem( tr( "Edit" ), edit ); 365 mb->insertItem( tr( "Edit" ), edit );
366 mb->insertItem( tr( "View" ), font ); 366 mb->insertItem( tr( "View" ), font );
367 367
368 searchBar = new QPEToolBar(this); 368 searchBar = new QPEToolBar(this);
369 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 369 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
370 370
371 searchBar->setHorizontalStretchable( TRUE ); 371 searchBar->setHorizontalStretchable( TRUE );
372 372
373 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 373 searchEdit = new QLineEdit( searchBar, "searchEdit" );
374 searchBar->setStretchableWidget( searchEdit ); 374 searchBar->setStretchableWidget( searchEdit );
375 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 375 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
376 this, SLOT( search() ) ); 376 this, SLOT( search() ) );
377 377
378 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 378 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
379 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 379 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
380 a->addTo( searchBar ); 380 a->addTo( searchBar );
381 a->addTo( edit ); 381 a->addTo( edit );
382 382
383 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 383 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
384 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 384 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
385 a->addTo( searchBar ); 385 a->addTo( searchBar );
386 386
387 edit->insertSeparator(); 387 edit->insertSeparator();
388 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 388 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
389 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 389 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
390 a->addTo( edit ); 390 a->addTo( edit );
391 391
392 searchBar->hide(); 392 searchBar->hide();
393 393
394 editor = new QpeEditor( this ); 394 editor = new QpeEditor( this );
395 setCentralWidget( editor ); 395 setCentralWidget( editor );
396 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 396 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
397 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 397 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
398 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);
398 399
399 Config cfg("TextEdit"); 400 Config cfg("TextEdit");
400 cfg. setGroup ( "Font" ); 401 cfg. setGroup ( "Font" );
401 402
402 QFont defaultFont = editor-> font ( ); 403 QFont defaultFont = editor-> font ( );
403 404
404 QString family = cfg. readEntry ( "Family", defaultFont. family ( )); 405 QString family = cfg. readEntry ( "Family", defaultFont. family ( ));
405 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); 406 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( ));
406 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); 407 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( ));
407 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); 408 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));
408 409
409 defaultFont = QFont ( family, size, weight, italic ); 410 defaultFont = QFont ( family, size, weight, italic );
410 editor-> setFont ( defaultFont ); 411 editor-> setFont ( defaultFont );
411 412
412 updateCaption(); 413 updateCaption();
413 414
414 cfg.setGroup ( "View" ); 415 cfg.setGroup ( "View" );
415 416
416 promptExit = cfg. readBoolEntry ( "PromptExit", false ); 417 promptExit = cfg. readBoolEntry ( "PromptExit", false );
417 openDesktop = cfg. readBoolEntry ( "OpenDesktop", true ); 418 openDesktop = cfg. readBoolEntry ( "OpenDesktop", true );
418 filePerms = cfg. readBoolEntry ( "FilePermissions", false ); 419 filePerms = cfg. readBoolEntry ( "FilePermissions", false );
419 420
420 if(promptExit ) nAdvanced->setOn ( true ); 421 if(promptExit ) nAdvanced->setOn ( true );
421 if(openDesktop) desktopAction->setOn ( true ); 422 if(openDesktop) desktopAction->setOn ( true );
422 if(filePerms) filePermAction->setOn ( true ); 423 if(filePerms) filePermAction->setOn ( true );
423 424
424 bool wrap = cfg. readBoolEntry ( "Wrap", true ); 425 bool wrap = cfg. readBoolEntry ( "Wrap", true );
425 wa-> setOn ( wrap ); 426 wa-> setOn ( wrap );
426 setWordWrap ( wrap ); 427 setWordWrap ( wrap );
427 428
428 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 429 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
429 nStart->setOn(TRUE); 430 nStart->setOn(TRUE);
430 fileNew(); 431 fileNew();
431 } else { 432 } else {
432 fileOpen(); 433 fileOpen();
433 } 434 }
434 435
435 viewSelection = cfg.readNumEntry( "FileView", 0 ); 436 viewSelection = cfg.readNumEntry( "FileView", 0 );
436} 437}
437 438
438TextEdit::~TextEdit() { 439TextEdit::~TextEdit() {
439 if( edited1 & promptExit ) 440 if( edited1 & promptExit )
440 saveAs(); 441 saveAs();
441} 442}
442 443
443void TextEdit::cleanUp() { 444void TextEdit::cleanUp() {
444 qDebug("cleanUp");// save(); 445 qDebug("cleanUp");// save();
445 446
446 Config cfg ( "TextEdit" ); 447 Config cfg ( "TextEdit" );
447 cfg. setGroup ( "Font" ); 448 cfg. setGroup ( "Font" );
448 QFont f = editor->font(); 449 QFont f = editor->font();
449 cfg. writeEntry ( "Family", f. family ( )); 450 cfg. writeEntry ( "Family", f. family ( ));
450 cfg. writeEntry ( "Size", f. pointSize ( )); 451 cfg. writeEntry ( "Size", f. pointSize ( ));
451 cfg. writeEntry ( "Weight", f. weight ( )); 452 cfg. writeEntry ( "Weight", f. weight ( ));
452 cfg. writeEntry ( "Italic", f. italic ( )); 453 cfg. writeEntry ( "Italic", f. italic ( ));
453 454
454 cfg. setGroup ( "View" ); 455 cfg. setGroup ( "View" );
455 cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); 456 cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth );
456 cfg. writeEntry ( "FileView", viewSelection ); 457 cfg. writeEntry ( "FileView", viewSelection );
457 458
458 cfg. writeEntry ( "PromptExit", promptExit ); 459 cfg. writeEntry ( "PromptExit", promptExit );
459 cfg. writeEntry ( "OpenDesktop", openDesktop ); 460 cfg. writeEntry ( "OpenDesktop", openDesktop );
460 cfg. writeEntry ( "FilePermissions", filePerms ); 461 cfg. writeEntry ( "FilePermissions", filePerms );
461} 462}
462 463
463 464
464void TextEdit::accept() { 465void TextEdit::accept() {
465 if( edited1) 466 if( edited1)
466 saveAs(); 467 saveAs();
467 exit(0); 468 exit(0);
468} 469}
469 470
470void TextEdit::zoomIn() { 471void TextEdit::zoomIn() {
471 setFontSize(editor->font().pointSize()+1,FALSE); 472 setFontSize(editor->font().pointSize()+1,FALSE);
472} 473}
473 474
474void TextEdit::zoomOut() { 475void TextEdit::zoomOut() {
475 setFontSize(editor->font().pointSize()-1,TRUE); 476 setFontSize(editor->font().pointSize()-1,TRUE);
476} 477}
477 478
478 479
479void TextEdit::setFontSize(int sz, bool round_down_not_up) { 480void TextEdit::setFontSize(int sz, bool round_down_not_up) {
480 int s=10; 481 int s=10;
481 for (int i=0; i<nfontsizes; i++) { 482 for (int i=0; i<nfontsizes; i++) {
482 if ( fontsize[i] == sz ) { 483 if ( fontsize[i] == sz ) {
483 s = sz; 484 s = sz;
484 break; 485 break;
485 } else if ( round_down_not_up ) { 486 } else if ( round_down_not_up ) {
486 if ( fontsize[i] < sz ) 487 if ( fontsize[i] < sz )
487 s = fontsize[i]; 488 s = fontsize[i];
488 } else { 489 } else {
489 if ( fontsize[i] > sz ) { 490 if ( fontsize[i] > sz ) {
490 s = fontsize[i]; 491 s = fontsize[i];
491 break; 492 break;
492 } 493 }
493 } 494 }
494 } 495 }
495 496
496 QFont f = editor->font(); 497 QFont f = editor->font();
497 f.setPointSize(s); 498 f.setPointSize(s);
498 editor->setFont(f); 499 editor->setFont(f);
499 500
500 zin->setEnabled(s != fontsize[nfontsizes-1]); 501 zin->setEnabled(s != fontsize[nfontsizes-1]);
501 zout->setEnabled(s != fontsize[0]); 502 zout->setEnabled(s != fontsize[0]);
502} 503}
503 504
504void TextEdit::setBold(bool y) { 505void TextEdit::setBold(bool y) {
505 QFont f = editor->font(); 506 QFont f = editor->font();
506 f.setBold(y); 507 f.setBold(y);
507 editor->setFont(f); 508 editor->setFont(f);
508} 509}
509 510
510void TextEdit::setItalic(bool y) { 511void TextEdit::setItalic(bool y) {
511 QFont f = editor->font(); 512 QFont f = editor->font();
512 f.setItalic(y); 513 f.setItalic(y);
513 editor->setFont(f); 514 editor->setFont(f);
514} 515}
515 516
516void TextEdit::setWordWrap(bool y) { 517void TextEdit::setWordWrap(bool y) {
517 bool state = editor->edited(); 518 bool state = editor->edited();
518 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 519 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
519 editor->setEdited( state ); 520 editor->setEdited( state );
520} 521}
521 522
522void TextEdit::fileNew() { 523void TextEdit::fileNew() {
523// if( !bFromDocView ) { 524// if( !bFromDocView ) {
524// saveAs(); 525// saveAs();
525// } 526// }
526 newFile(DocLnk()); 527 newFile(DocLnk());
527} 528}
528 529
529void TextEdit::fileOpen() { 530void TextEdit::fileOpen() {
530 Config cfg("TextEdit"); 531 Config cfg("TextEdit");
531 cfg.setGroup("View"); 532 cfg.setGroup("View");
532 // bool b=FALSE; 533 // bool b=FALSE;
533 534
534 QMap<QString, QStringList> map; 535 QMap<QString, QStringList> map;
535 map.insert(tr("All"), QStringList() ); 536 map.insert(tr("All"), QStringList() );
536 QStringList text; 537 QStringList text;
537 text << "text/*"; 538 text << "text/*";
538 map.insert(tr("Text"), text ); 539 map.insert(tr("Text"), text );
539 text << "*"; 540 text << "*";
540 map.insert(tr("All"), text ); 541 map.insert(tr("All"), text );
541 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map); 542 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);
542 if(!str.isEmpty() ) 543 if(!str.isEmpty() )
543 openFile( str ); 544 openFile( str );
544 545
545} 546}
546 547
547void TextEdit::doSearchBar() { 548void TextEdit::doSearchBar() {
548 Config cfg("TextEdit"); 549 Config cfg("TextEdit");
549 cfg.setGroup("View"); 550 cfg.setGroup("View");
550 if(cfg.readEntry("SearchBar","Closed") != "Opened") 551 if(cfg.readEntry("SearchBar","Closed") != "Opened")
551 searchBar->hide(); 552 searchBar->hide();
552} 553}
553 554
554#if 0 555#if 0
555void TextEdit::slotFind() { 556void TextEdit::slotFind() {
556 FindDialog frmFind( tr("Text Editor"), this ); 557 FindDialog frmFind( tr("Text Editor"), this );
557 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 558 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
558 editor, SLOT(slotDoFind( const QString&,bool,bool))); 559 editor, SLOT(slotDoFind( const QString&,bool,bool)));
559 560
560 //case sensitive, backwards, [category] 561 //case sensitive, backwards, [category]
561 562
562 connect( editor, SIGNAL(notFound()), 563 connect( editor, SIGNAL(notFound()),
563 &frmFind, SLOT(slotNotFound()) ); 564 &frmFind, SLOT(slotNotFound()) );
564 connect( editor, SIGNAL(searchWrapped()), 565 connect( editor, SIGNAL(searchWrapped()),
565 &frmFind, SLOT(slotWrapAround()) ); 566 &frmFind, SLOT(slotWrapAround()) );
566 567
567 frmFind.exec(); 568 frmFind.exec();
568 569
569 570
570} 571}
571#endif 572#endif
572 573
573void TextEdit::fileRevert() { 574void TextEdit::fileRevert() {
574 clear(); 575 clear();
575 fileOpen(); 576 fileOpen();
576} 577}
577 578
578void TextEdit::editCut() { 579void TextEdit::editCut() {
579#ifndef QT_NO_CLIPBOARD 580#ifndef QT_NO_CLIPBOARD
580 editor->cut(); 581 editor->cut();
581#endif 582#endif
582} 583}
583 584
584void TextEdit::editCopy() { 585void TextEdit::editCopy() {
585#ifndef QT_NO_CLIPBOARD 586#ifndef QT_NO_CLIPBOARD
586 editor->copy(); 587 editor->copy();
587#endif 588#endif
588} 589}
589 590
590void TextEdit::editPaste() { 591void TextEdit::editPaste() {
591#ifndef QT_NO_CLIPBOARD 592#ifndef QT_NO_CLIPBOARD
592 editor->paste(); 593 editor->paste();
593#endif 594#endif
594} 595}
595 596
596void TextEdit::editFind() { 597void TextEdit::editFind() {
597 searchBar->show(); 598 searchBar->show();
598 searchVisible = TRUE; 599 searchVisible = TRUE;
599 searchEdit->setFocus(); 600 searchEdit->setFocus();
600 Config cfg("TextEdit"); 601 Config cfg("TextEdit");
601 cfg.setGroup("View"); 602 cfg.setGroup("View");
602 cfg.writeEntry("SearchBar","Opened"); 603 cfg.writeEntry("SearchBar","Opened");
603 604
604} 605}
605 606
606void TextEdit::findNext() { 607void TextEdit::findNext() {
607 editor->find( searchEdit->text(), FALSE, FALSE ); 608 editor->find( searchEdit->text(), FALSE, FALSE );
608 609
609} 610}
610 611
611void TextEdit::findClose() { 612void TextEdit::findClose() {
612 searchVisible = FALSE; 613 searchVisible = FALSE;
613 searchBar->hide(); 614 searchBar->hide();
614 Config cfg("TextEdit"); 615 Config cfg("TextEdit");
615 cfg.setGroup("View"); 616 cfg.setGroup("View");
616 cfg.writeEntry("SearchBar","Closed"); 617 cfg.writeEntry("SearchBar","Closed");
617 cfg.write(); 618 cfg.write();
618} 619}
619 620
620void TextEdit::search() { 621void TextEdit::search() {
621 editor->find( searchEdit->text(), FALSE, FALSE ); 622 editor->find( searchEdit->text(), FALSE, FALSE );
622} 623}
623 624
624void TextEdit::newFile( const DocLnk &f ) { 625void TextEdit::newFile( const DocLnk &f ) {
625 DocLnk nf = f; 626 DocLnk nf = f;
626 nf.setType("text/plain"); 627 nf.setType("text/plain");
627 clear(); 628 clear();
628 setWState (WState_Reserved1 ); 629 setWState (WState_Reserved1 );
629 editor->setFocus(); 630 editor->setFocus();
630 doc = new DocLnk(nf); 631 doc = new DocLnk(nf);
631 currentFileName = "Unnamed"; 632 currentFileName = "Unnamed";
632 qDebug("newFile "+currentFileName); 633 qDebug("newFile "+currentFileName);
633 updateCaption( currentFileName); 634 updateCaption( currentFileName);
634// editor->setEdited( FALSE); 635// editor->setEdited( FALSE);
635} 636}
636 637
637void TextEdit::openFile( const QString &f ) { 638void TextEdit::openFile( const QString &f ) {
638 qDebug("filename is "+ f); 639 qDebug("filename is "+ f);
639 QString filer; 640 QString filer;
640// bFromDocView = TRUE; 641// bFromDocView = TRUE;
641 if(f.find(".desktop",0,TRUE) != -1 && !openDesktop) { 642 if(f.find(".desktop",0,TRUE) != -1 && !openDesktop) {
642 switch ( QMessageBox::warning(this,tr("Text Editor"), 643 switch ( QMessageBox::warning(this,tr("Text Editor"),
643 tr("Text Editor has detected<BR>you selected a <B>.desktop</B> 644 tr("Text Editor has detected<BR>you selected a <B>.desktop</B>
644file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), 645file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
645 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 646 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
646 case 0: 647 case 0:
647 filer = f; 648 filer = f;
648 break; 649 break;
649 case 1: 650 case 1:
650 DocLnk sf(f); 651 DocLnk sf(f);
651 filer = sf.file(); 652 filer = sf.file();
652 break; 653 break;
653 } 654 }