author | llornkcor <llornkcor> | 2002-04-14 21:40:33 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-14 21:40:33 (UTC) |
commit | f519bc8b0dd5e1f183b8eb2b0c7f59787afe130c (patch) (unidiff) | |
tree | 137200abe04002cbcd27176352ab2f5ec0d4f636 | |
parent | 9c779ca27c9e44c2bae69892d060e628e5ea5bd3 (diff) | |
download | opie-f519bc8b0dd5e1f183b8eb2b0c7f59787afe130c.zip opie-f519bc8b0dd5e1f183b8eb2b0c7f59787afe130c.tar.gz opie-f519bc8b0dd5e1f183b8eb2b0c7f59787afe130c.tar.bz2 |
fixed trying to open .desktop files- give user a choice: .desktop or file linked too
-rw-r--r-- | core/apps/textedit/textedit.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index cc3ccbc..834bd8c 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -261,694 +261,703 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
261 | editBar = bar; | 261 | editBar = bar; |
262 | 262 | ||
263 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 263 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
264 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 264 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
265 | a->addTo( bar ); | 265 | a->addTo( bar ); |
266 | a->addTo( file ); | 266 | a->addTo( file ); |
267 | 267 | ||
268 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 268 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
269 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 269 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
270 | a->addTo( bar ); | 270 | a->addTo( bar ); |
271 | a->addTo( file ); | 271 | a->addTo( file ); |
272 | 272 | ||
273 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 273 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
274 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 274 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
275 | file->insertSeparator(); | 275 | file->insertSeparator(); |
276 | a->addTo( file ); | 276 | a->addTo( file ); |
277 | 277 | ||
278 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 278 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
279 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 279 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
280 | a->addTo( file ); | 280 | a->addTo( file ); |
281 | 281 | ||
282 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 282 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
283 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 283 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
284 | a->addTo( editBar ); | 284 | a->addTo( editBar ); |
285 | a->addTo( edit ); | 285 | a->addTo( edit ); |
286 | 286 | ||
287 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 287 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
288 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 288 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
289 | a->addTo( editBar ); | 289 | a->addTo( editBar ); |
290 | a->addTo( edit ); | 290 | a->addTo( edit ); |
291 | 291 | ||
292 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 292 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
293 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 293 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
294 | a->addTo( editBar ); | 294 | a->addTo( editBar ); |
295 | a->addTo( edit ); | 295 | a->addTo( edit ); |
296 | 296 | ||
297 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 297 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
298 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 298 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
299 | edit->insertSeparator(); | 299 | edit->insertSeparator(); |
300 | a->addTo( bar ); | 300 | a->addTo( bar ); |
301 | a->addTo( edit ); | 301 | a->addTo( edit ); |
302 | 302 | ||
303 | int defsize; | 303 | int defsize; |
304 | bool defb, defi, wrap; | 304 | bool defb, defi, wrap; |
305 | 305 | ||
306 | Config cfg("TextEdit"); | 306 | Config cfg("TextEdit"); |
307 | cfg.setGroup("View"); | 307 | cfg.setGroup("View"); |
308 | defsize = cfg.readNumEntry("FontSize",10); | 308 | defsize = cfg.readNumEntry("FontSize",10); |
309 | defb = cfg.readBoolEntry("Bold",FALSE); | 309 | defb = cfg.readBoolEntry("Bold",FALSE); |
310 | defi = cfg.readBoolEntry("Italic",FALSE); | 310 | defi = cfg.readBoolEntry("Italic",FALSE); |
311 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 311 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
312 | 312 | ||
313 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 313 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
314 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 314 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
315 | zin->addTo( font ); | 315 | zin->addTo( font ); |
316 | 316 | ||
317 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 317 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
318 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 318 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
319 | zout->addTo( font ); | 319 | zout->addTo( font ); |
320 | 320 | ||
321 | font->insertSeparator(); | 321 | font->insertSeparator(); |
322 | 322 | ||
323 | #if 0 | 323 | #if 0 |
324 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 324 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
325 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 325 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
326 | ba->setToggleAction(TRUE); | 326 | ba->setToggleAction(TRUE); |
327 | ba->addTo( font ); | 327 | ba->addTo( font ); |
328 | 328 | ||
329 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 329 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
330 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 330 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
331 | ia->setToggleAction(TRUE); | 331 | ia->setToggleAction(TRUE); |
332 | ia->addTo( font ); | 332 | ia->addTo( font ); |
333 | 333 | ||
334 | ba->setOn(defb); | 334 | ba->setOn(defb); |
335 | ia->setOn(defi); | 335 | ia->setOn(defi); |
336 | 336 | ||
337 | font->insertSeparator(); | 337 | font->insertSeparator(); |
338 | #endif | 338 | #endif |
339 | 339 | ||
340 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 340 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
341 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 341 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
342 | wa->setToggleAction(TRUE); | 342 | wa->setToggleAction(TRUE); |
343 | wa->addTo( font ); | 343 | wa->addTo( font ); |
344 | 344 | ||
345 | font->insertSeparator(); | 345 | font->insertSeparator(); |
346 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 346 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
347 | 347 | ||
348 | font->insertSeparator(); | 348 | font->insertSeparator(); |
349 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 349 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
350 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 350 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
351 | nStart->setToggleAction(TRUE); | 351 | nStart->setToggleAction(TRUE); |
352 | nStart->addTo( font ); | 352 | nStart->addTo( font ); |
353 | 353 | ||
354 | mb->insertItem( tr( "File" ), file ); | 354 | mb->insertItem( tr( "File" ), file ); |
355 | mb->insertItem( tr( "Edit" ), edit ); | 355 | mb->insertItem( tr( "Edit" ), edit ); |
356 | mb->insertItem( tr( "View" ), font ); | 356 | mb->insertItem( tr( "View" ), font ); |
357 | 357 | ||
358 | searchBar = new QPEToolBar(this); | 358 | searchBar = new QPEToolBar(this); |
359 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 359 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
360 | 360 | ||
361 | searchBar->setHorizontalStretchable( TRUE ); | 361 | searchBar->setHorizontalStretchable( TRUE ); |
362 | 362 | ||
363 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 363 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
364 | searchBar->setStretchableWidget( searchEdit ); | 364 | searchBar->setStretchableWidget( searchEdit ); |
365 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 365 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
366 | this, SLOT( search() ) ); | 366 | this, SLOT( search() ) ); |
367 | 367 | ||
368 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 368 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
369 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 369 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
370 | a->addTo( searchBar ); | 370 | a->addTo( searchBar ); |
371 | a->addTo( edit ); | 371 | a->addTo( edit ); |
372 | 372 | ||
373 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 373 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
374 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 374 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
375 | a->addTo( searchBar ); | 375 | a->addTo( searchBar ); |
376 | 376 | ||
377 | edit->insertSeparator(); | 377 | edit->insertSeparator(); |
378 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 378 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
379 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 379 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
380 | a->addTo( edit ); | 380 | a->addTo( edit ); |
381 | 381 | ||
382 | searchBar->hide(); | 382 | searchBar->hide(); |
383 | 383 | ||
384 | editor = new QpeEditor( this ); | 384 | editor = new QpeEditor( this ); |
385 | setCentralWidget( editor ); | 385 | setCentralWidget( editor ); |
386 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 386 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
387 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 387 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
388 | 388 | ||
389 | // resize( 200, 300 ); | 389 | // resize( 200, 300 ); |
390 | 390 | ||
391 | // setFontSize(defsize,TRUE); | 391 | // setFontSize(defsize,TRUE); |
392 | FontDatabase fdb; | 392 | FontDatabase fdb; |
393 | QFont defaultFont=editor->font(); | 393 | QFont defaultFont=editor->font(); |
394 | QFontInfo fontInfo(defaultFont); | 394 | QFontInfo fontInfo(defaultFont); |
395 | 395 | ||
396 | cfg.setGroup("Font"); | 396 | cfg.setGroup("Font"); |
397 | QString family = cfg.readEntry("Family", fontInfo.family()); | 397 | QString family = cfg.readEntry("Family", fontInfo.family()); |
398 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 398 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
399 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 399 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
400 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 400 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
401 | 401 | ||
402 | defaultFont = fdb.font(family,style,i_size,charSet); | 402 | defaultFont = fdb.font(family,style,i_size,charSet); |
403 | editor->setFont( defaultFont); | 403 | editor->setFont( defaultFont); |
404 | 404 | ||
405 | wa->setOn(wrap); | 405 | wa->setOn(wrap); |
406 | updateCaption(); | 406 | updateCaption(); |
407 | 407 | ||
408 | cfg.setGroup("View"); | 408 | cfg.setGroup("View"); |
409 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 409 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
410 | nStart->setOn(TRUE); | 410 | nStart->setOn(TRUE); |
411 | fileNew(); | 411 | fileNew(); |
412 | } else { | 412 | } else { |
413 | fileOpen(); | 413 | fileOpen(); |
414 | } | 414 | } |
415 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 415 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
416 | } | 416 | } |
417 | 417 | ||
418 | void TextEdit::cleanUp() | 418 | void TextEdit::cleanUp() |
419 | { | 419 | { |
420 | // save(); | 420 | // save(); |
421 | Config cfg("TextEdit"); | 421 | Config cfg("TextEdit"); |
422 | cfg.setGroup("View"); | 422 | cfg.setGroup("View"); |
423 | QFont f = editor->font(); | 423 | QFont f = editor->font(); |
424 | cfg.writeEntry("FontSize",f.pointSize()); | 424 | cfg.writeEntry("FontSize",f.pointSize()); |
425 | cfg.writeEntry("Bold",f.bold()); | 425 | cfg.writeEntry("Bold",f.bold()); |
426 | cfg.writeEntry("Italic",f.italic()); | 426 | cfg.writeEntry("Italic",f.italic()); |
427 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 427 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
428 | cfg.writeEntry( "FileView", viewSelection ); | 428 | cfg.writeEntry( "FileView", viewSelection ); |
429 | 429 | ||
430 | } | 430 | } |
431 | 431 | ||
432 | TextEdit::~TextEdit() | 432 | TextEdit::~TextEdit() |
433 | { | 433 | { |
434 | } | 434 | } |
435 | 435 | ||
436 | void TextEdit::zoomIn() | 436 | void TextEdit::zoomIn() |
437 | { | 437 | { |
438 | setFontSize(editor->font().pointSize()+1,FALSE); | 438 | setFontSize(editor->font().pointSize()+1,FALSE); |
439 | } | 439 | } |
440 | 440 | ||
441 | void TextEdit::zoomOut() | 441 | void TextEdit::zoomOut() |
442 | { | 442 | { |
443 | setFontSize(editor->font().pointSize()-1,TRUE); | 443 | setFontSize(editor->font().pointSize()-1,TRUE); |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 447 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
448 | { | 448 | { |
449 | int s=10; | 449 | int s=10; |
450 | for (int i=0; i<nfontsizes; i++) { | 450 | for (int i=0; i<nfontsizes; i++) { |
451 | if ( fontsize[i] == sz ) { | 451 | if ( fontsize[i] == sz ) { |
452 | s = sz; | 452 | s = sz; |
453 | break; | 453 | break; |
454 | } else if ( round_down_not_up ) { | 454 | } else if ( round_down_not_up ) { |
455 | if ( fontsize[i] < sz ) | 455 | if ( fontsize[i] < sz ) |
456 | s = fontsize[i]; | 456 | s = fontsize[i]; |
457 | } else { | 457 | } else { |
458 | if ( fontsize[i] > sz ) { | 458 | if ( fontsize[i] > sz ) { |
459 | s = fontsize[i]; | 459 | s = fontsize[i]; |
460 | break; | 460 | break; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | } | 463 | } |
464 | 464 | ||
465 | QFont f = editor->font(); | 465 | QFont f = editor->font(); |
466 | f.setPointSize(s); | 466 | f.setPointSize(s); |
467 | editor->setFont(f); | 467 | editor->setFont(f); |
468 | 468 | ||
469 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 469 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
470 | zout->setEnabled(s != fontsize[0]); | 470 | zout->setEnabled(s != fontsize[0]); |
471 | } | 471 | } |
472 | 472 | ||
473 | void TextEdit::setBold(bool y) | 473 | void TextEdit::setBold(bool y) |
474 | { | 474 | { |
475 | QFont f = editor->font(); | 475 | QFont f = editor->font(); |
476 | f.setBold(y); | 476 | f.setBold(y); |
477 | editor->setFont(f); | 477 | editor->setFont(f); |
478 | } | 478 | } |
479 | 479 | ||
480 | void TextEdit::setItalic(bool y) | 480 | void TextEdit::setItalic(bool y) |
481 | { | 481 | { |
482 | QFont f = editor->font(); | 482 | QFont f = editor->font(); |
483 | f.setItalic(y); | 483 | f.setItalic(y); |
484 | editor->setFont(f); | 484 | editor->setFont(f); |
485 | } | 485 | } |
486 | 486 | ||
487 | void TextEdit::setWordWrap(bool y) | 487 | void TextEdit::setWordWrap(bool y) |
488 | { | 488 | { |
489 | bool state = editor->edited(); | 489 | bool state = editor->edited(); |
490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
491 | editor->setEdited( state ); | 491 | editor->setEdited( state ); |
492 | } | 492 | } |
493 | 493 | ||
494 | void TextEdit::fileNew() | 494 | void TextEdit::fileNew() |
495 | { | 495 | { |
496 | // if( !bFromDocView ) { | 496 | // if( !bFromDocView ) { |
497 | // saveAs(); | 497 | // saveAs(); |
498 | // } | 498 | // } |
499 | newFile(DocLnk()); | 499 | newFile(DocLnk()); |
500 | } | 500 | } |
501 | 501 | ||
502 | void TextEdit::fileOpen() | 502 | void TextEdit::fileOpen() |
503 | { | 503 | { |
504 | // OFileSelector *fileSelector; | 504 | // OFileSelector *fileSelector; |
505 | // fileSelector = new OFileSelector( this, 1,1,"/","", "text/*"); | 505 | // fileSelector = new OFileSelector( this, 1,1,"/","", "text/*"); |
506 | //fileSelector->showMaximized(); | 506 | //fileSelector->showMaximized(); |
507 | QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this ); | 507 | QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this ); |
508 | if(!str.isEmpty() ) | 508 | if(!str.isEmpty() ) |
509 | openFile( str ); | 509 | openFile( str ); |
510 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // | 510 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // |
511 | // browseForFiles->setFileView( viewSelection ); | 511 | // browseForFiles->setFileView( viewSelection ); |
512 | // browseForFiles->showMaximized(); | 512 | // browseForFiles->showMaximized(); |
513 | // // if( result != -1 ) | 513 | // // if( result != -1 ) |
514 | 514 | ||
515 | // if( browseForFiles->exec() != -1 ) { | 515 | // if( browseForFiles->exec() != -1 ) { |
516 | // QString selFile = browseForFiles->selectedFileName; | 516 | // QString selFile = browseForFiles->selectedFileName; |
517 | // QStringList fileList = browseForFiles->fileList; | 517 | // QStringList fileList = browseForFiles->fileList; |
518 | // qDebug(selFile); | 518 | // qDebug(selFile); |
519 | // QStringList::ConstIterator f; | 519 | // QStringList::ConstIterator f; |
520 | // QString fileTemp; | 520 | // QString fileTemp; |
521 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 521 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
522 | // fileTemp = *f; | 522 | // fileTemp = *f; |
523 | // fileTemp.right( fileTemp.length()-5); | 523 | // fileTemp.right( fileTemp.length()-5); |
524 | // QString fileName = fileTemp; | 524 | // QString fileName = fileTemp; |
525 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 525 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
526 | // currentFileName = fileName; | 526 | // currentFileName = fileName; |
527 | // qDebug("please open "+currentFileName); | 527 | // qDebug("please open "+currentFileName); |
528 | // openFile(str ); | 528 | // openFile(str ); |
529 | // } | 529 | // } |
530 | // } | 530 | // } |
531 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); | 531 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); |
532 | // } | 532 | // } |
533 | // delete browseForFiles; | 533 | // delete browseForFiles; |
534 | // editor->setEdited( FALSE); | 534 | // editor->setEdited( FALSE); |
535 | // edited1=FALSE; | 535 | // edited1=FALSE; |
536 | // edited=FALSE; | 536 | // edited=FALSE; |
537 | // if(caption().left(1)=="*") | 537 | // if(caption().left(1)=="*") |
538 | // setCaption(caption().right(caption().length()-1)); | 538 | // setCaption(caption().right(caption().length()-1)); |
539 | // doSearchBar(); | 539 | // doSearchBar(); |
540 | } | 540 | } |
541 | 541 | ||
542 | void TextEdit::doSearchBar() | 542 | void TextEdit::doSearchBar() |
543 | { | 543 | { |
544 | Config cfg("TextEdit"); | 544 | Config cfg("TextEdit"); |
545 | cfg.setGroup("View"); | 545 | cfg.setGroup("View"); |
546 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 546 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
547 | searchBar->hide(); | 547 | searchBar->hide(); |
548 | } | 548 | } |
549 | 549 | ||
550 | #if 0 | 550 | #if 0 |
551 | void TextEdit::slotFind() | 551 | void TextEdit::slotFind() |
552 | { | 552 | { |
553 | FindDialog frmFind( tr("Text Editor"), this ); | 553 | FindDialog frmFind( tr("Text Editor"), this ); |
554 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 554 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
555 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 555 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
556 | 556 | ||
557 | //case sensitive, backwards, [category] | 557 | //case sensitive, backwards, [category] |
558 | 558 | ||
559 | connect( editor, SIGNAL(notFound()), | 559 | connect( editor, SIGNAL(notFound()), |
560 | &frmFind, SLOT(slotNotFound()) ); | 560 | &frmFind, SLOT(slotNotFound()) ); |
561 | connect( editor, SIGNAL(searchWrapped()), | 561 | connect( editor, SIGNAL(searchWrapped()), |
562 | &frmFind, SLOT(slotWrapAround()) ); | 562 | &frmFind, SLOT(slotWrapAround()) ); |
563 | 563 | ||
564 | frmFind.exec(); | 564 | frmFind.exec(); |
565 | 565 | ||
566 | 566 | ||
567 | } | 567 | } |
568 | #endif | 568 | #endif |
569 | 569 | ||
570 | void TextEdit::fileRevert() | 570 | void TextEdit::fileRevert() |
571 | { | 571 | { |
572 | clear(); | 572 | clear(); |
573 | fileOpen(); | 573 | fileOpen(); |
574 | } | 574 | } |
575 | 575 | ||
576 | void TextEdit::editCut() | 576 | void TextEdit::editCut() |
577 | { | 577 | { |
578 | #ifndef QT_NO_CLIPBOARD | 578 | #ifndef QT_NO_CLIPBOARD |
579 | editor->cut(); | 579 | editor->cut(); |
580 | #endif | 580 | #endif |
581 | } | 581 | } |
582 | 582 | ||
583 | void TextEdit::editCopy() | 583 | void TextEdit::editCopy() |
584 | { | 584 | { |
585 | #ifndef QT_NO_CLIPBOARD | 585 | #ifndef QT_NO_CLIPBOARD |
586 | editor->copy(); | 586 | editor->copy(); |
587 | #endif | 587 | #endif |
588 | } | 588 | } |
589 | 589 | ||
590 | void TextEdit::editPaste() | 590 | void TextEdit::editPaste() |
591 | { | 591 | { |
592 | #ifndef QT_NO_CLIPBOARD | 592 | #ifndef QT_NO_CLIPBOARD |
593 | editor->paste(); | 593 | editor->paste(); |
594 | #endif | 594 | #endif |
595 | } | 595 | } |
596 | 596 | ||
597 | void TextEdit::editFind() | 597 | void TextEdit::editFind() |
598 | { | 598 | { |
599 | searchBar->show(); | 599 | searchBar->show(); |
600 | searchVisible = TRUE; | 600 | searchVisible = TRUE; |
601 | searchEdit->setFocus(); | 601 | searchEdit->setFocus(); |
602 | Config cfg("TextEdit"); | 602 | Config cfg("TextEdit"); |
603 | cfg.setGroup("View"); | 603 | cfg.setGroup("View"); |
604 | cfg.writeEntry("SearchBar","Opened"); | 604 | cfg.writeEntry("SearchBar","Opened"); |
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void TextEdit::findNext() | 608 | void TextEdit::findNext() |
609 | { | 609 | { |
610 | editor->find( searchEdit->text(), FALSE, FALSE ); | 610 | editor->find( searchEdit->text(), FALSE, FALSE ); |
611 | 611 | ||
612 | } | 612 | } |
613 | 613 | ||
614 | void TextEdit::findClose() | 614 | void TextEdit::findClose() |
615 | { | 615 | { |
616 | searchVisible = FALSE; | 616 | searchVisible = FALSE; |
617 | searchBar->hide(); | 617 | searchBar->hide(); |
618 | Config cfg("TextEdit"); | 618 | Config cfg("TextEdit"); |
619 | cfg.setGroup("View"); | 619 | cfg.setGroup("View"); |
620 | cfg.writeEntry("SearchBar","Closed"); | 620 | cfg.writeEntry("SearchBar","Closed"); |
621 | cfg.write(); | 621 | cfg.write(); |
622 | } | 622 | } |
623 | 623 | ||
624 | void TextEdit::search() | 624 | void TextEdit::search() |
625 | { | 625 | { |
626 | editor->find( searchEdit->text(), FALSE, FALSE ); | 626 | editor->find( searchEdit->text(), FALSE, FALSE ); |
627 | } | 627 | } |
628 | 628 | ||
629 | void TextEdit::newFile( const DocLnk &f ) | 629 | void TextEdit::newFile( const DocLnk &f ) |
630 | { | 630 | { |
631 | DocLnk nf = f; | 631 | DocLnk nf = f; |
632 | nf.setType("text/plain"); | 632 | nf.setType("text/plain"); |
633 | clear(); | 633 | clear(); |
634 | setWState (WState_Reserved1 ); | 634 | setWState (WState_Reserved1 ); |
635 | editor->setFocus(); | 635 | editor->setFocus(); |
636 | doc = new DocLnk(nf); | 636 | doc = new DocLnk(nf); |
637 | currentFileName = "Unnamed"; | 637 | currentFileName = "Unnamed"; |
638 | qDebug("newFile "+currentFileName); | 638 | qDebug("newFile "+currentFileName); |
639 | updateCaption( currentFileName); | 639 | updateCaption( currentFileName); |
640 | // editor->setEdited( FALSE); | 640 | // editor->setEdited( FALSE); |
641 | } | 641 | } |
642 | 642 | ||
643 | void TextEdit::openFile( const QString &f ) | 643 | void TextEdit::openFile( const QString &f ) |
644 | { | 644 | { |
645 | 645 | qDebug("filename is "+ f); | |
646 | QString filer; | ||
646 | // bFromDocView = TRUE; | 647 | // bFromDocView = TRUE; |
648 | if(f.find(".desktop",0,TRUE)) { | ||
649 | switch ( QMessageBox::warning(this,tr("Text Editor"), | ||
650 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), | ||
651 | tr(".desktop File"),tr("Link"),0,0,1) ) { | ||
652 | case 0: | ||
653 | filer = f; | ||
654 | break; | ||
655 | case 1: | ||
656 | DocLnk sf(f); | ||
657 | filer = sf.file(); | ||
658 | break; | ||
659 | } | ||
660 | } | ||
647 | DocLnk nf; | 661 | DocLnk nf; |
648 | nf.setType("text/plain"); | 662 | nf.setType("text/plain"); |
649 | nf.setFile(f); | 663 | nf.setFile(filer); |
650 | currentFileName=f; | 664 | currentFileName=filer; |
651 | QFileInfo fi( currentFileName); | 665 | QFileInfo fi( currentFileName); |
652 | nf.setName(fi.baseName()); | 666 | nf.setName(fi.baseName()); |
653 | qDebug("openFile string"+currentFileName); | 667 | qDebug("openFile string "+currentFileName); |
654 | 668 | ||
655 | openFile(nf); | 669 | openFile(nf); |
656 | showEditTools(); | 670 | showEditTools(); |
657 | // Show filename in caption | 671 | // Show filename in caption |
658 | QString name = f; | 672 | QString name = filer; |
659 | int sep = name.findRev( '/' ); | 673 | int sep = name.findRev( '/' ); |
660 | if ( sep > 0 ) | 674 | if ( sep > 0 ) |
661 | name = name.mid( sep+1 ); | 675 | name = name.mid( sep+1 ); |
662 | updateCaption( name ); | 676 | updateCaption( name ); |
663 | } | 677 | } |
664 | 678 | ||
665 | void TextEdit::openFile( const DocLnk &f ) | 679 | void TextEdit::openFile( const DocLnk &f ) |
666 | { | 680 | { |
667 | // clear(); | 681 | // clear(); |
668 | // bFromDocView = TRUE; | 682 | // bFromDocView = TRUE; |
669 | FileManager fm; | 683 | FileManager fm; |
670 | QString txt; | 684 | QString txt; |
671 | currentFileName=f.name(); | 685 | currentFileName=f.name(); |
672 | qDebug("openFile doclnk " + currentFileName); | 686 | qDebug("openFile doclnk " + currentFileName); |
673 | if ( !fm.loadFile( f, txt ) ) { | 687 | if ( !fm.loadFile( f, txt ) ) { |
674 | // ####### could be a new file | 688 | // ####### could be a new file |
675 | qDebug( "Cannot open file" ); | 689 | qDebug( "Cannot open file" ); |
676 | } | 690 | } |
677 | // fileNew(); | 691 | // fileNew(); |
678 | if ( doc ) | 692 | if ( doc ) |
679 | delete doc; | 693 | delete doc; |
680 | doc = new DocLnk(f); | 694 | doc = new DocLnk(f); |
681 | editor->setText(txt); | 695 | editor->setText(txt); |
682 | editor->setEdited( FALSE); | 696 | editor->setEdited( FALSE); |
683 | edited1=FALSE; | 697 | edited1=FALSE; |
684 | edited=FALSE; | 698 | edited=FALSE; |
685 | 699 | ||
686 | doc->setName(currentFileName); | 700 | doc->setName(currentFileName); |
687 | updateCaption(); | 701 | updateCaption(); |
688 | } | 702 | } |
689 | 703 | ||
690 | void TextEdit::showEditTools() | 704 | void TextEdit::showEditTools() |
691 | { | 705 | { |
692 | // if ( !doc ) | 706 | // if ( !doc ) |
693 | // close(); | 707 | // close(); |
694 | // clear(); | 708 | // clear(); |
695 | menu->show(); | 709 | menu->show(); |
696 | editBar->show(); | 710 | editBar->show(); |
697 | if ( searchVisible ) | 711 | if ( searchVisible ) |
698 | searchBar->show(); | 712 | searchBar->show(); |
699 | // updateCaption(); | 713 | // updateCaption(); |
700 | setWState (WState_Reserved1 ); | 714 | setWState (WState_Reserved1 ); |
701 | } | 715 | } |
702 | 716 | ||
703 | /*! | 717 | /*! |
704 | unprompted save */ | 718 | unprompted save */ |
705 | bool TextEdit::save() | 719 | bool TextEdit::save() |
706 | { | 720 | { |
707 | QString file = doc->file(); | 721 | QString file = doc->file(); |
708 | qDebug("saver file "+file); | 722 | qDebug("saver file "+file); |
709 | QString name= doc->name(); | 723 | QString name= doc->name(); |
710 | qDebug("File named "+name); | 724 | qDebug("File named "+name); |
711 | QString rt = editor->text(); | 725 | QString rt = editor->text(); |
712 | if( !rt.isEmpty() ) { | 726 | if( !rt.isEmpty() ) { |
713 | if(name.isEmpty()) { | 727 | if(name.isEmpty()) { |
714 | saveAs(); | 728 | saveAs(); |
715 | } else { | 729 | } else { |
716 | currentFileName= name ; | 730 | currentFileName= name ; |
717 | qDebug("saveFile "+currentFileName); | 731 | qDebug("saveFile "+currentFileName); |
718 | 732 | ||
719 | struct stat buf; | 733 | struct stat buf; |
720 | mode_t mode; | 734 | mode_t mode; |
721 | stat(file.latin1(), &buf); | 735 | stat(file.latin1(), &buf); |
722 | mode = buf.st_mode; | 736 | mode = buf.st_mode; |
723 | 737 | ||
724 | doc->setName( name); | 738 | doc->setName( name); |
725 | FileManager fm; | 739 | FileManager fm; |
726 | if ( !fm.saveFile( *doc, rt ) ) { | 740 | if ( !fm.saveFile( *doc, rt ) ) { |
727 | return false; | 741 | return false; |
728 | } | 742 | } |
729 | editor->setEdited( FALSE); | 743 | editor->setEdited( FALSE); |
730 | edited1=FALSE; | 744 | edited1=FALSE; |
731 | edited=FALSE; | 745 | edited=FALSE; |
732 | if(caption().left(1)=="*") | 746 | if(caption().left(1)=="*") |
733 | setCaption(caption().right(caption().length()-1)); | 747 | setCaption(caption().right(caption().length()-1)); |
734 | 748 | ||
735 | 749 | ||
736 | chmod( file.latin1(), mode); | 750 | chmod( file.latin1(), mode); |
737 | } | 751 | } |
738 | return true; | 752 | return true; |
739 | } | 753 | } |
740 | return false; | 754 | return false; |
741 | } | 755 | } |
742 | 756 | ||
743 | /*! | 757 | /*! |
744 | prompted save */ | 758 | prompted save */ |
745 | bool TextEdit::saveAs() | 759 | bool TextEdit::saveAs() |
746 | { | 760 | { |
747 | // qDebug("saveAsFile "+currentFileName); | 761 | // qDebug("saveAsFile "+currentFileName); |
748 | // case of nothing to save... | 762 | // case of nothing to save... |
749 | if ( !doc )//|| !bFromDocView) | 763 | if ( !doc )//|| !bFromDocView) |
750 | { | 764 | { |
751 | qDebug("no doc"); | 765 | qDebug("no doc"); |
752 | return true; | 766 | return true; |
753 | } | 767 | } |
754 | if ( !editor->edited() ) { | 768 | if ( !editor->edited() ) { |
755 | delete doc; | 769 | delete doc; |
756 | doc = 0; | 770 | doc = 0; |
757 | return true; | 771 | return true; |
758 | } | 772 | } |
759 | 773 | ||
760 | QString rt = editor->text(); | 774 | QString rt = editor->text(); |
761 | qDebug(currentFileName); | 775 | qDebug(currentFileName); |
762 | 776 | ||
763 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { | 777 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { |
764 | qDebug("do silly TT filename thing"); | 778 | qDebug("do silly TT filename thing"); |
765 | if ( doc->name().isEmpty() ) { | 779 | if ( doc->name().isEmpty() ) { |
766 | QString pt = rt.simplifyWhiteSpace(); | 780 | QString pt = rt.simplifyWhiteSpace(); |
767 | int i = pt.find( ' ' ); | 781 | int i = pt.find( ' ' ); |
768 | QString docname = pt; | 782 | QString docname = pt; |
769 | if ( i > 0 ) | 783 | if ( i > 0 ) |
770 | docname = pt.left( i ); | 784 | docname = pt.left( i ); |
771 | // remove "." at the beginning | 785 | // remove "." at the beginning |
772 | while( docname.startsWith( "." ) ) | 786 | while( docname.startsWith( "." ) ) |
773 | docname = docname.mid( 1 ); | 787 | docname = docname.mid( 1 ); |
774 | docname.replace( QRegExp("/"), "_" ); | 788 | docname.replace( QRegExp("/"), "_" ); |
775 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 789 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
776 | if ( docname.length() > 40 ) | 790 | if ( docname.length() > 40 ) |
777 | docname = docname.left(40); | 791 | docname = docname.left(40); |
778 | if ( docname.isEmpty() ) | 792 | if ( docname.isEmpty() ) |
779 | docname = tr("Unnamed"); | 793 | docname = tr("Unnamed"); |
780 | doc->setName(docname); | 794 | doc->setName(docname); |
781 | currentFileName=docname; | 795 | currentFileName=docname; |
782 | } | 796 | } |
783 | } | 797 | } |
784 | 798 | ||
785 | 799 | ||
786 | fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName); | 800 | fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName); |
787 | qDebug("wanna save filename "+currentFileName); | 801 | qDebug("wanna save filename "+currentFileName); |
788 | fileSaveDlg->exec(); | 802 | fileSaveDlg->exec(); |
789 | if( fileSaveDlg->result() == 1 ) { | 803 | if( fileSaveDlg->result() == 1 ) { |
790 | QString fileNm=fileSaveDlg->selectedFileName; | 804 | QString fileNm=fileSaveDlg->selectedFileName; |
791 | qDebug("saving filename "+fileNm); | 805 | qDebug("saving filename "+fileNm); |
792 | QFileInfo fi(fileNm); | 806 | QFileInfo fi(fileNm); |
793 | currentFileName=fi.fileName(); | 807 | currentFileName=fi.fileName(); |
794 | if(doc) { | 808 | if(doc) { |
795 | // QString file = doc->file(); | 809 | // QString file = doc->file(); |
796 | // doc->removeFiles(); | 810 | // doc->removeFiles(); |
797 | delete doc; | 811 | delete doc; |
798 | DocLnk nf; | 812 | DocLnk nf; |
799 | nf.setType("text/plain"); | 813 | nf.setType("text/plain"); |
800 | nf.setFile( fileNm); | 814 | nf.setFile( fileNm); |
801 | doc = new DocLnk(nf); | 815 | doc = new DocLnk(nf); |
802 | // editor->setText(rt); | 816 | // editor->setText(rt); |
803 | // qDebug("openFile doclnk "+currentFileName); | 817 | // qDebug("openFile doclnk "+currentFileName); |
804 | doc->setName( currentFileName); | 818 | doc->setName( currentFileName); |
805 | updateCaption( currentFileName); | 819 | updateCaption( currentFileName); |
806 | 820 | ||
807 | FileManager fm; | 821 | FileManager fm; |
808 | if ( !fm.saveFile( *doc, rt ) ) { | 822 | if ( !fm.saveFile( *doc, rt ) ) { |
809 | return false; | 823 | return false; |
810 | } | 824 | } |
811 | if( fileSaveDlg->filePermCheck->isChecked() ) { | 825 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
812 | filePermissions *filePerm; | 826 | filePermissions *filePerm; |
813 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); | 827 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); |
814 | filePerm->exec(); | 828 | filePerm->exec(); |
815 | 829 | ||
816 | if( filePerm) | 830 | if( filePerm) |
817 | delete filePerm; | 831 | delete filePerm; |
818 | } | 832 | } |
819 | } | 833 | } |
820 | } | 834 | } |
821 | editor->setEdited(TRUE); | 835 | editor->setEdited(TRUE); |
822 | edited1=FALSE; | 836 | edited1=FALSE; |
823 | edited=TRUE; | 837 | edited=TRUE; |
824 | if(caption().left(1)=="*") | 838 | if(caption().left(1)=="*") |
825 | setCaption(caption().right(caption().length()-1)); | 839 | setCaption(caption().right(caption().length()-1)); |
826 | 840 | ||
827 | if(fileSaveDlg) | 841 | if(fileSaveDlg) |
828 | delete fileSaveDlg; | 842 | delete fileSaveDlg; |
829 | return true; | 843 | return true; |
830 | } //end saveAs | 844 | } //end saveAs |
831 | 845 | ||
832 | void TextEdit::clear() | 846 | void TextEdit::clear() |
833 | { | 847 | { |
834 | delete doc; | 848 | delete doc; |
835 | doc = 0; | 849 | doc = 0; |
836 | editor->clear(); | 850 | editor->clear(); |
837 | } | 851 | } |
838 | 852 | ||
839 | void TextEdit::updateCaption( const QString &name ) | 853 | void TextEdit::updateCaption( const QString &name ) |
840 | { | 854 | { |
841 | if ( !doc ) | 855 | if ( !doc ) |
842 | setCaption( tr("Text Editor") ); | 856 | setCaption( tr("Text Editor") ); |
843 | else { | 857 | else { |
844 | QString s = name; | 858 | QString s = name; |
845 | if ( s.isNull() ) | 859 | if ( s.isNull() ) |
846 | s = doc->name(); | 860 | s = doc->name(); |
847 | if ( s.isEmpty() ) { | 861 | if ( s.isEmpty() ) { |
848 | s = tr( "Unnamed" ); | 862 | s = tr( "Unnamed" ); |
849 | currentFileName=s; | 863 | currentFileName=s; |
850 | } | 864 | } |
851 | if(s.left(1) == "/") | 865 | if(s.left(1) == "/") |
852 | s = s.right(s.length()-1); | 866 | s = s.right(s.length()-1); |
853 | setCaption( s + " - " + tr("Text Editor") ); | 867 | setCaption( s + " - " + tr("Text Editor") ); |
854 | } | 868 | } |
855 | } | 869 | } |
856 | 870 | ||
857 | void TextEdit::setDocument(const QString& fileref) | 871 | void TextEdit::setDocument(const QString& fileref) |
858 | { | 872 | { |
859 | bFromDocView = TRUE; | 873 | bFromDocView = TRUE; |
860 | if(fileref.find(".desktop",0,TRUE) == -1) { | 874 | openFile(fileref); |
861 | openFile(fileref); | ||
862 | } else { | ||
863 | qDebug("is desktop file"); | ||
864 | openFile(DocLnk(fileref)); | ||
865 | } | ||
866 | editor->setEdited(TRUE); | 875 | editor->setEdited(TRUE); |
867 | edited1=FALSE; | 876 | edited1=FALSE; |
868 | edited=TRUE; | 877 | edited=TRUE; |
869 | doSearchBar(); | 878 | doSearchBar(); |
870 | } | 879 | } |
871 | 880 | ||
872 | void TextEdit::closeEvent( QCloseEvent *e ) | 881 | void TextEdit::closeEvent( QCloseEvent *e ) |
873 | { | 882 | { |
874 | bFromDocView = FALSE; | 883 | bFromDocView = FALSE; |
875 | e->accept(); | 884 | e->accept(); |
876 | } | 885 | } |
877 | 886 | ||
878 | void TextEdit::accept() | 887 | void TextEdit::accept() |
879 | { | 888 | { |
880 | //if(caption() !="Unnamed") | 889 | //if(caption() !="Unnamed") |
881 | if(edited1) | 890 | if(edited1) |
882 | saveAs(); | 891 | saveAs(); |
883 | exit(0); | 892 | exit(0); |
884 | 893 | ||
885 | } | 894 | } |
886 | 895 | ||
887 | void TextEdit::changeFont() { | 896 | void TextEdit::changeFont() { |
888 | FontDatabase fdb; | 897 | FontDatabase fdb; |
889 | QFont defaultFont=editor->font(); | 898 | QFont defaultFont=editor->font(); |
890 | QFontInfo fontInfo(defaultFont); | 899 | QFontInfo fontInfo(defaultFont); |
891 | Config cfg("TextEdit"); | 900 | Config cfg("TextEdit"); |
892 | cfg.setGroup("Font"); | 901 | cfg.setGroup("Font"); |
893 | QString family = cfg.readEntry("Family", fontInfo.family()); | 902 | QString family = cfg.readEntry("Family", fontInfo.family()); |
894 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 903 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
895 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 904 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
896 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 905 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
897 | 906 | ||
898 | defaultFont = fdb.font(family,style,i_size,charSet); | 907 | defaultFont = fdb.font(family,style,i_size,charSet); |
899 | 908 | ||
900 | FontDialog *fontDlg; | 909 | FontDialog *fontDlg; |
901 | fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); | 910 | fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); |
902 | 911 | ||
903 | fontDlg->exec(); | 912 | fontDlg->exec(); |
904 | 913 | ||
905 | QFont myFont=fontDlg->selectedFont; | 914 | QFont myFont=fontDlg->selectedFont; |
906 | editor->setFont( myFont); | 915 | editor->setFont( myFont); |
907 | delete fontDlg; | 916 | delete fontDlg; |
908 | 917 | ||
909 | } | 918 | } |
910 | 919 | ||
911 | void TextEdit::editDelete() | 920 | void TextEdit::editDelete() |
912 | { | 921 | { |
913 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { | 922 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { |
914 | case 0: | 923 | case 0: |
915 | if(doc) { | 924 | if(doc) { |
916 | doc->removeFiles(); | 925 | doc->removeFiles(); |
917 | clear(); | 926 | clear(); |
918 | setCaption( tr("Text Editor") ); | 927 | setCaption( tr("Text Editor") ); |
919 | } | 928 | } |
920 | break; | 929 | break; |
921 | case 1: | 930 | case 1: |
922 | // exit | 931 | // exit |
923 | break; | 932 | break; |
924 | }; | 933 | }; |
925 | } | 934 | } |
926 | 935 | ||
927 | void TextEdit::changeStartConfig( bool b ) { | 936 | void TextEdit::changeStartConfig( bool b ) { |
928 | 937 | ||
929 | Config cfg("TextEdit"); | 938 | Config cfg("TextEdit"); |
930 | cfg.setGroup("View"); | 939 | cfg.setGroup("View"); |
931 | if(b) { | 940 | if(b) { |
932 | qDebug("bool"); | 941 | qDebug("bool"); |
933 | cfg.writeEntry("startNew","TRUE"); | 942 | cfg.writeEntry("startNew","TRUE"); |
934 | } else { | 943 | } else { |
935 | cfg.writeEntry("startNew","FALSE"); | 944 | cfg.writeEntry("startNew","FALSE"); |
936 | } | 945 | } |
937 | update(); | 946 | update(); |
938 | } | 947 | } |
939 | 948 | ||
940 | void TextEdit::editorChanged() { | 949 | void TextEdit::editorChanged() { |
941 | if(editor->edited() && edited && !edited1) { | 950 | if(editor->edited() && edited && !edited1) { |
942 | setCaption( "*"+caption()); | 951 | setCaption( "*"+caption()); |
943 | edited1=TRUE; | 952 | edited1=TRUE; |
944 | } | 953 | } |
945 | edited=TRUE; | 954 | edited=TRUE; |
946 | } | 955 | } |
947 | 956 | ||
948 | void TextEdit::receive(const QCString&msg, const QByteArray&) { | 957 | void TextEdit::receive(const QCString&msg, const QByteArray&) { |
949 | qDebug("QCop "+msg); | 958 | qDebug("QCop "+msg); |
950 | if ( msg == "setDocument(QString)" ) { | 959 | if ( msg == "setDocument(QString)" ) { |
951 | qDebug("bugger all"); | 960 | qDebug("bugger all"); |
952 | } | 961 | } |
953 | 962 | ||
954 | } | 963 | } |