summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index a66b967..cc3ccbc 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,104 +1,106 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// changes added by L. J. Potter Sun 02-17-2002 21:31:31 20// changes added by L. J. Potter Sun 02-17-2002 21:31:31
21 21
22#include "textedit.h" 22#include "textedit.h"
23#include "fileBrowser.h" 23#include "fileBrowser.h"
24#include "fileSaver.h" 24#include "fileSaver.h"
25#include "filePermissions.h" 25#include "filePermissions.h"
26 26
27#include "fontDialog.h" 27#include "fontDialog.h"
28 28
29#include <qpe/fontdatabase.h> 29#include <qpe/fontdatabase.h>
30#include <qpe/global.h> 30#include <qpe/global.h>
31#include <qpe/fileselector.h> 31#include <qpe/fileselector.h>
32#include <qpe/applnk.h> 32#include <qpe/applnk.h>
33#include <qpe/resource.h> 33#include <qpe/resource.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/qpemenubar.h> 36#include <qpe/qpemenubar.h>
37#include <qpe/qpetoolbar.h> 37#include <qpe/qpetoolbar.h>
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39//#include <qpe/finddialog.h> 39//#include <qpe/finddialog.h>
40
40#include <opie/ofileselector.h> 41#include <opie/ofileselector.h>
42#include <opie/ofiledialog.h>
41 43
42#include <qstringlist.h> 44#include <qstringlist.h>
43#include <qaction.h> 45#include <qaction.h>
44#include <qcolordialog.h> 46#include <qcolordialog.h>
45#include <qfileinfo.h> 47#include <qfileinfo.h>
46#include <qlineedit.h> 48#include <qlineedit.h>
47#include <qmessagebox.h> 49#include <qmessagebox.h>
48#include <qobjectlist.h> 50#include <qobjectlist.h>
49#include <qpopupmenu.h> 51#include <qpopupmenu.h>
50#include <qspinbox.h> 52#include <qspinbox.h>
51#include <qtoolbutton.h> 53#include <qtoolbutton.h>
52#include <qwidgetstack.h> 54#include <qwidgetstack.h>
53#include <qcheckbox.h> 55#include <qcheckbox.h>
54#include <qcombo.h> 56#include <qcombo.h>
55#include <unistd.h> 57#include <unistd.h>
56#include <sys/stat.h> 58#include <sys/stat.h>
57 59
58#include <stdlib.h> //getenv 60#include <stdlib.h> //getenv
59/* XPM */ 61/* XPM */
60static char * filesave_xpm[] = { 62static char * filesave_xpm[] = {
61"16 16 78 1", 63"16 16 78 1",
62" c None", 64" c None",
63". c #343434", 65". c #343434",
64"+ c #A0A0A0", 66"+ c #A0A0A0",
65"@ c #565656", 67"@ c #565656",
66"# c #9E9E9E", 68"# c #9E9E9E",
67"$ c #525252", 69"$ c #525252",
68"% c #929292", 70"% c #929292",
69"& c #676767", 71"& c #676767",
70"* c #848484", 72"* c #848484",
71"= c #666666", 73"= c #666666",
72"- c #D8D8D8", 74"- c #D8D8D8",
73"; c #FFFFFF", 75"; c #FFFFFF",
74"> c #DBDBDB", 76"> c #DBDBDB",
75", c #636363", 77", c #636363",
76"' c #989898", 78"' c #989898",
77") c #2D2D2D", 79") c #2D2D2D",
78"! c #909090", 80"! c #909090",
79"~ c #AEAEAE", 81"~ c #AEAEAE",
80"{ c #EAEAEA", 82"{ c #EAEAEA",
81"] c #575757", 83"] c #575757",
82"^ c #585858", 84"^ c #585858",
83"/ c #8A8A8A", 85"/ c #8A8A8A",
84"( c #828282", 86"( c #828282",
85"_ c #6F6F6F", 87"_ c #6F6F6F",
86": c #C9C9C9", 88": c #C9C9C9",
87"< c #050505", 89"< c #050505",
88"[ c #292929", 90"[ c #292929",
89"} c #777777", 91"} c #777777",
90"| c #616161", 92"| c #616161",
91"1 c #3A3A3A", 93"1 c #3A3A3A",
92"2 c #BEBEBE", 94"2 c #BEBEBE",
93"3 c #2C2C2C", 95"3 c #2C2C2C",
94"4 c #7C7C7C", 96"4 c #7C7C7C",
95"5 c #F6F6F6", 97"5 c #F6F6F6",
96"6 c #FCFCFC", 98"6 c #FCFCFC",
97"7 c #6B6B6B", 99"7 c #6B6B6B",
98"8 c #959595", 100"8 c #959595",
99"9 c #4F4F4F", 101"9 c #4F4F4F",
100"0 c #808080", 102"0 c #808080",
101"a c #767676", 103"a c #767676",
102"b c #818181", 104"b c #818181",
103"c c #B8B8B8", 105"c c #B8B8B8",
104"d c #FBFBFB", 106"d c #FBFBFB",
@@ -438,151 +440,153 @@ void TextEdit::zoomIn()
438 440
439void TextEdit::zoomOut() 441void TextEdit::zoomOut()
440{ 442{
441 setFontSize(editor->font().pointSize()-1,TRUE); 443 setFontSize(editor->font().pointSize()-1,TRUE);
442} 444}
443 445
444 446
445void TextEdit::setFontSize(int sz, bool round_down_not_up) 447void TextEdit::setFontSize(int sz, bool round_down_not_up)
446{ 448{
447 int s=10; 449 int s=10;
448 for (int i=0; i<nfontsizes; i++) { 450 for (int i=0; i<nfontsizes; i++) {
449 if ( fontsize[i] == sz ) { 451 if ( fontsize[i] == sz ) {
450 s = sz; 452 s = sz;
451 break; 453 break;
452 } else if ( round_down_not_up ) { 454 } else if ( round_down_not_up ) {
453 if ( fontsize[i] < sz ) 455 if ( fontsize[i] < sz )
454 s = fontsize[i]; 456 s = fontsize[i];
455 } else { 457 } else {
456 if ( fontsize[i] > sz ) { 458 if ( fontsize[i] > sz ) {
457 s = fontsize[i]; 459 s = fontsize[i];
458 break; 460 break;
459 } 461 }
460 } 462 }
461 } 463 }
462 464
463 QFont f = editor->font(); 465 QFont f = editor->font();
464 f.setPointSize(s); 466 f.setPointSize(s);
465 editor->setFont(f); 467 editor->setFont(f);
466 468
467 zin->setEnabled(s != fontsize[nfontsizes-1]); 469 zin->setEnabled(s != fontsize[nfontsizes-1]);
468 zout->setEnabled(s != fontsize[0]); 470 zout->setEnabled(s != fontsize[0]);
469} 471}
470 472
471void TextEdit::setBold(bool y) 473void TextEdit::setBold(bool y)
472{ 474{
473 QFont f = editor->font(); 475 QFont f = editor->font();
474 f.setBold(y); 476 f.setBold(y);
475 editor->setFont(f); 477 editor->setFont(f);
476} 478}
477 479
478void TextEdit::setItalic(bool y) 480void TextEdit::setItalic(bool y)
479{ 481{
480 QFont f = editor->font(); 482 QFont f = editor->font();
481 f.setItalic(y); 483 f.setItalic(y);
482 editor->setFont(f); 484 editor->setFont(f);
483} 485}
484 486
485void TextEdit::setWordWrap(bool y) 487void TextEdit::setWordWrap(bool y)
486{ 488{
487 bool state = editor->edited(); 489 bool state = editor->edited();
488 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 490 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
489 editor->setEdited( state ); 491 editor->setEdited( state );
490} 492}
491 493
492void TextEdit::fileNew() 494void TextEdit::fileNew()
493{ 495{
494// if( !bFromDocView ) { 496// if( !bFromDocView ) {
495// saveAs(); 497// saveAs();
496// } 498// }
497 newFile(DocLnk()); 499 newFile(DocLnk());
498} 500}
499 501
500void TextEdit::fileOpen() 502void TextEdit::fileOpen()
501{ 503{
502 OFileSelector *fileSelector; 504 // OFileSelector *fileSelector;
503 fileSelector = new OFileSelector( this, 1,1,"/","", "text/*"); 505 // fileSelector = new OFileSelector( this, 1,1,"/","", "text/*");
504 fileSelector->showMaximized(); 506 //fileSelector->showMaximized();
505 507 QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this );
508 if(!str.isEmpty() )
509 openFile( str );
506// browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // 510// browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); //
507// browseForFiles->setFileView( viewSelection ); 511// browseForFiles->setFileView( viewSelection );
508// browseForFiles->showMaximized(); 512// browseForFiles->showMaximized();
509// // if( result != -1 ) 513// // if( result != -1 )
510 514
511// if( browseForFiles->exec() != -1 ) { 515// if( browseForFiles->exec() != -1 ) {
512// QString selFile = browseForFiles->selectedFileName; 516// QString selFile = browseForFiles->selectedFileName;
513// QStringList fileList = browseForFiles->fileList; 517// QStringList fileList = browseForFiles->fileList;
514// qDebug(selFile); 518// qDebug(selFile);
515// QStringList::ConstIterator f; 519// QStringList::ConstIterator f;
516// QString fileTemp; 520// QString fileTemp;
517// for ( f = fileList.begin(); f != fileList.end(); f++ ) { 521// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
518// fileTemp = *f; 522// fileTemp = *f;
519// fileTemp.right( fileTemp.length()-5); 523// fileTemp.right( fileTemp.length()-5);
520// QString fileName = fileTemp; 524// QString fileName = fileTemp;
521// if( fileName != "Unnamed" || fileName != "Empty Text" ) { 525// if( fileName != "Unnamed" || fileName != "Empty Text" ) {
522// currentFileName = fileName; 526// currentFileName = fileName;
523// qDebug("please open "+currentFileName); 527// qDebug("please open "+currentFileName);
524// openFile(fileName ); 528// openFile(str );
525// } 529// }
526// } 530// }
527// viewSelection = browseForFiles->SelectionCombo->currentItem(); 531// viewSelection = browseForFiles->SelectionCombo->currentItem();
528// } 532// }
529// delete browseForFiles; 533// delete browseForFiles;
530// editor->setEdited( FALSE); 534// editor->setEdited( FALSE);
531// edited1=FALSE; 535// edited1=FALSE;
532// edited=FALSE; 536// edited=FALSE;
533// if(caption().left(1)=="*") 537// if(caption().left(1)=="*")
534// setCaption(caption().right(caption().length()-1)); 538// setCaption(caption().right(caption().length()-1));
535// doSearchBar(); 539// doSearchBar();
536} 540}
537 541
538void TextEdit::doSearchBar() 542void TextEdit::doSearchBar()
539{ 543{
540 Config cfg("TextEdit"); 544 Config cfg("TextEdit");
541 cfg.setGroup("View"); 545 cfg.setGroup("View");
542 if(cfg.readEntry("SearchBar","Closed") != "Opened") 546 if(cfg.readEntry("SearchBar","Closed") != "Opened")
543 searchBar->hide(); 547 searchBar->hide();
544} 548}
545 549
546#if 0 550#if 0
547void TextEdit::slotFind() 551void TextEdit::slotFind()
548{ 552{
549 FindDialog frmFind( tr("Text Editor"), this ); 553 FindDialog frmFind( tr("Text Editor"), this );
550 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 554 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
551 editor, SLOT(slotDoFind( const QString&,bool,bool))); 555 editor, SLOT(slotDoFind( const QString&,bool,bool)));
552 556
553 //case sensitive, backwards, [category] 557 //case sensitive, backwards, [category]
554 558
555 connect( editor, SIGNAL(notFound()), 559 connect( editor, SIGNAL(notFound()),
556 &frmFind, SLOT(slotNotFound()) ); 560 &frmFind, SLOT(slotNotFound()) );
557 connect( editor, SIGNAL(searchWrapped()), 561 connect( editor, SIGNAL(searchWrapped()),
558 &frmFind, SLOT(slotWrapAround()) ); 562 &frmFind, SLOT(slotWrapAround()) );
559 563
560 frmFind.exec(); 564 frmFind.exec();
561 565
562 566
563} 567}
564#endif 568#endif
565 569
566void TextEdit::fileRevert() 570void TextEdit::fileRevert()
567{ 571{
568 clear(); 572 clear();
569 fileOpen(); 573 fileOpen();
570} 574}
571 575
572void TextEdit::editCut() 576void TextEdit::editCut()
573{ 577{
574#ifndef QT_NO_CLIPBOARD 578#ifndef QT_NO_CLIPBOARD
575 editor->cut(); 579 editor->cut();
576#endif 580#endif
577} 581}
578 582
579void TextEdit::editCopy() 583void TextEdit::editCopy()
580{ 584{
581#ifndef QT_NO_CLIPBOARD 585#ifndef QT_NO_CLIPBOARD
582 editor->copy(); 586 editor->copy();
583#endif 587#endif
584} 588}
585 589
586void TextEdit::editPaste() 590void TextEdit::editPaste()
587{ 591{
588#ifndef QT_NO_CLIPBOARD 592#ifndef QT_NO_CLIPBOARD