summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp65
-rw-r--r--core/apps/textedit/textedit.pro2
2 files changed, 36 insertions, 31 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 943fecd..a66b967 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,135 +1,136 @@
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#include <opie/ofileselector.h>
40 41
41#include <qstringlist.h> 42#include <qstringlist.h>
42#include <qaction.h> 43#include <qaction.h>
43#include <qcolordialog.h> 44#include <qcolordialog.h>
44#include <qfileinfo.h> 45#include <qfileinfo.h>
45#include <qlineedit.h> 46#include <qlineedit.h>
46#include <qmessagebox.h> 47#include <qmessagebox.h>
47#include <qobjectlist.h> 48#include <qobjectlist.h>
48#include <qpopupmenu.h> 49#include <qpopupmenu.h>
49#include <qspinbox.h> 50#include <qspinbox.h>
50#include <qtoolbutton.h> 51#include <qtoolbutton.h>
51#include <qwidgetstack.h> 52#include <qwidgetstack.h>
52#include <qcheckbox.h> 53#include <qcheckbox.h>
53#include <qcombo.h> 54#include <qcombo.h>
54#include <unistd.h> 55#include <unistd.h>
55#include <sys/stat.h> 56#include <sys/stat.h>
56 57
57#include <stdlib.h> //getenv 58#include <stdlib.h> //getenv
58/* XPM */ 59/* XPM */
59static char * filesave_xpm[] = { 60static char * filesave_xpm[] = {
60"16 16 78 1", 61"16 16 78 1",
61" c None", 62" c None",
62". c #343434", 63". c #343434",
63"+ c #A0A0A0", 64"+ c #A0A0A0",
64"@ c #565656", 65"@ c #565656",
65"# c #9E9E9E", 66"# c #9E9E9E",
66"$ c #525252", 67"$ c #525252",
67"% c #929292", 68"% c #929292",
68"& c #676767", 69"& c #676767",
69"* c #848484", 70"* c #848484",
70"= c #666666", 71"= c #666666",
71"- c #D8D8D8", 72"- c #D8D8D8",
72"; c #FFFFFF", 73"; c #FFFFFF",
73"> c #DBDBDB", 74"> c #DBDBDB",
74", c #636363", 75", c #636363",
75"' c #989898", 76"' c #989898",
76") c #2D2D2D", 77") c #2D2D2D",
77"! c #909090", 78"! c #909090",
78"~ c #AEAEAE", 79"~ c #AEAEAE",
79"{ c #EAEAEA", 80"{ c #EAEAEA",
80"] c #575757", 81"] c #575757",
81"^ c #585858", 82"^ c #585858",
82"/ c #8A8A8A", 83"/ c #8A8A8A",
83"( c #828282", 84"( c #828282",
84"_ c #6F6F6F", 85"_ c #6F6F6F",
85": c #C9C9C9", 86": c #C9C9C9",
86"< c #050505", 87"< c #050505",
87"[ c #292929", 88"[ c #292929",
88"} c #777777", 89"} c #777777",
89"| c #616161", 90"| c #616161",
90"1 c #3A3A3A", 91"1 c #3A3A3A",
91"2 c #BEBEBE", 92"2 c #BEBEBE",
92"3 c #2C2C2C", 93"3 c #2C2C2C",
93"4 c #7C7C7C", 94"4 c #7C7C7C",
94"5 c #F6F6F6", 95"5 c #F6F6F6",
95"6 c #FCFCFC", 96"6 c #FCFCFC",
96"7 c #6B6B6B", 97"7 c #6B6B6B",
97"8 c #959595", 98"8 c #959595",
98"9 c #4F4F4F", 99"9 c #4F4F4F",
99"0 c #808080", 100"0 c #808080",
100"a c #767676", 101"a c #767676",
101"b c #818181", 102"b c #818181",
102"c c #B8B8B8", 103"c c #B8B8B8",
103"d c #FBFBFB", 104"d c #FBFBFB",
104"e c #F9F9F9", 105"e c #F9F9F9",
105"f c #CCCCCC", 106"f c #CCCCCC",
106"g c #030303", 107"g c #030303",
107"h c #737373", 108"h c #737373",
108"i c #7A7A7A", 109"i c #7A7A7A",
109"j c #7E7E7E", 110"j c #7E7E7E",
110"k c #6A6A6A", 111"k c #6A6A6A",
111"l c #FAFAFA", 112"l c #FAFAFA",
112"m c #505050", 113"m c #505050",
113"n c #9D9D9D", 114"n c #9D9D9D",
114"o c #333333", 115"o c #333333",
115"p c #7B7B7B", 116"p c #7B7B7B",
116"q c #787878", 117"q c #787878",
117"r c #696969", 118"r c #696969",
118"s c #494949", 119"s c #494949",
119"t c #555555", 120"t c #555555",
120"u c #949494", 121"u c #949494",
121"v c #E6E6E6", 122"v c #E6E6E6",
122"w c #424242", 123"w c #424242",
123"x c #515151", 124"x c #515151",
124"y c #535353", 125"y c #535353",
125"z c #3E3E3E", 126"z c #3E3E3E",
126"A c #D4D4D4", 127"A c #D4D4D4",
127"B c #0C0C0C", 128"B c #0C0C0C",
128"C c #353535", 129"C c #353535",
129"D c #474747", 130"D c #474747",
130"E c #ECECEC", 131"E c #ECECEC",
131"F c #919191", 132"F c #919191",
132"G c #7D7D7D", 133"G c #7D7D7D",
133"H c #000000", 134"H c #000000",
134"I c #404040", 135"I c #404040",
135"J c #858585", 136"J c #858585",
@@ -405,222 +406,226 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
405 cfg.setGroup("View"); 406 cfg.setGroup("View");
406 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 407 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
407 nStart->setOn(TRUE); 408 nStart->setOn(TRUE);
408 fileNew(); 409 fileNew();
409 } else { 410 } else {
410 fileOpen(); 411 fileOpen();
411 } 412 }
412 viewSelection = cfg.readNumEntry( "FileView", 0 ); 413 viewSelection = cfg.readNumEntry( "FileView", 0 );
413} 414}
414 415
415void TextEdit::cleanUp() 416void TextEdit::cleanUp()
416{ 417{
417// save(); 418// save();
418 Config cfg("TextEdit"); 419 Config cfg("TextEdit");
419 cfg.setGroup("View"); 420 cfg.setGroup("View");
420 QFont f = editor->font(); 421 QFont f = editor->font();
421 cfg.writeEntry("FontSize",f.pointSize()); 422 cfg.writeEntry("FontSize",f.pointSize());
422 cfg.writeEntry("Bold",f.bold()); 423 cfg.writeEntry("Bold",f.bold());
423 cfg.writeEntry("Italic",f.italic()); 424 cfg.writeEntry("Italic",f.italic());
424 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 425 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
425 cfg.writeEntry( "FileView", viewSelection ); 426 cfg.writeEntry( "FileView", viewSelection );
426 427
427} 428}
428 429
429TextEdit::~TextEdit() 430TextEdit::~TextEdit()
430{ 431{
431} 432}
432 433
433void TextEdit::zoomIn() 434void TextEdit::zoomIn()
434{ 435{
435 setFontSize(editor->font().pointSize()+1,FALSE); 436 setFontSize(editor->font().pointSize()+1,FALSE);
436} 437}
437 438
438void TextEdit::zoomOut() 439void TextEdit::zoomOut()
439{ 440{
440 setFontSize(editor->font().pointSize()-1,TRUE); 441 setFontSize(editor->font().pointSize()-1,TRUE);
441} 442}
442 443
443 444
444void TextEdit::setFontSize(int sz, bool round_down_not_up) 445void TextEdit::setFontSize(int sz, bool round_down_not_up)
445{ 446{
446 int s=10; 447 int s=10;
447 for (int i=0; i<nfontsizes; i++) { 448 for (int i=0; i<nfontsizes; i++) {
448 if ( fontsize[i] == sz ) { 449 if ( fontsize[i] == sz ) {
449 s = sz; 450 s = sz;
450 break; 451 break;
451 } else if ( round_down_not_up ) { 452 } else if ( round_down_not_up ) {
452 if ( fontsize[i] < sz ) 453 if ( fontsize[i] < sz )
453 s = fontsize[i]; 454 s = fontsize[i];
454 } else { 455 } else {
455 if ( fontsize[i] > sz ) { 456 if ( fontsize[i] > sz ) {
456 s = fontsize[i]; 457 s = fontsize[i];
457 break; 458 break;
458 } 459 }
459 } 460 }
460 } 461 }
461 462
462 QFont f = editor->font(); 463 QFont f = editor->font();
463 f.setPointSize(s); 464 f.setPointSize(s);
464 editor->setFont(f); 465 editor->setFont(f);
465 466
466 zin->setEnabled(s != fontsize[nfontsizes-1]); 467 zin->setEnabled(s != fontsize[nfontsizes-1]);
467 zout->setEnabled(s != fontsize[0]); 468 zout->setEnabled(s != fontsize[0]);
468} 469}
469 470
470void TextEdit::setBold(bool y) 471void TextEdit::setBold(bool y)
471{ 472{
472 QFont f = editor->font(); 473 QFont f = editor->font();
473 f.setBold(y); 474 f.setBold(y);
474 editor->setFont(f); 475 editor->setFont(f);
475} 476}
476 477
477void TextEdit::setItalic(bool y) 478void TextEdit::setItalic(bool y)
478{ 479{
479 QFont f = editor->font(); 480 QFont f = editor->font();
480 f.setItalic(y); 481 f.setItalic(y);
481 editor->setFont(f); 482 editor->setFont(f);
482} 483}
483 484
484void TextEdit::setWordWrap(bool y) 485void TextEdit::setWordWrap(bool y)
485{ 486{
486 bool state = editor->edited(); 487 bool state = editor->edited();
487 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 488 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
488 editor->setEdited( state ); 489 editor->setEdited( state );
489} 490}
490 491
491void TextEdit::fileNew() 492void TextEdit::fileNew()
492{ 493{
493// if( !bFromDocView ) { 494// if( !bFromDocView ) {
494// saveAs(); 495// saveAs();
495// } 496// }
496 newFile(DocLnk()); 497 newFile(DocLnk());
497} 498}
498 499
499void TextEdit::fileOpen() 500void TextEdit::fileOpen()
500{ 501{
501 browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // 502 OFileSelector *fileSelector;
502 browseForFiles->setFileView( viewSelection ); 503 fileSelector = new OFileSelector( this, 1,1,"/","", "text/*");
503 browseForFiles->showMaximized(); 504 fileSelector->showMaximized();
504// if( result != -1 ) 505
505 506// browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); //
506 if( browseForFiles->exec() != -1 ) { 507// browseForFiles->setFileView( viewSelection );
507 QString selFile = browseForFiles->selectedFileName; 508// browseForFiles->showMaximized();
508 QStringList fileList = browseForFiles->fileList; 509// // if( result != -1 )
509 qDebug(selFile); 510
510 QStringList::ConstIterator f; 511// if( browseForFiles->exec() != -1 ) {
511 QString fileTemp; 512// QString selFile = browseForFiles->selectedFileName;
512 for ( f = fileList.begin(); f != fileList.end(); f++ ) { 513// QStringList fileList = browseForFiles->fileList;
513 fileTemp = *f; 514// qDebug(selFile);
514 fileTemp.right( fileTemp.length()-5); 515// QStringList::ConstIterator f;
515 QString fileName = fileTemp; 516// QString fileTemp;
516 if( fileName != "Unnamed" || fileName != "Empty Text" ) { 517// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
517 currentFileName = fileName; 518// fileTemp = *f;
518 qDebug("please open "+currentFileName); 519// fileTemp.right( fileTemp.length()-5);
519 openFile(fileName ); 520// QString fileName = fileTemp;
520 } 521// if( fileName != "Unnamed" || fileName != "Empty Text" ) {
521 } 522// currentFileName = fileName;
522 viewSelection = browseForFiles->SelectionCombo->currentItem(); 523// qDebug("please open "+currentFileName);
523 } 524// openFile(fileName );
524 delete browseForFiles; 525// }
525 editor->setEdited( FALSE); 526// }
526 edited1=FALSE; 527// viewSelection = browseForFiles->SelectionCombo->currentItem();
527 edited=FALSE; 528// }
528 if(caption().left(1)=="*") 529// delete browseForFiles;
529 setCaption(caption().right(caption().length()-1)); 530// editor->setEdited( FALSE);
530 doSearchBar(); 531// edited1=FALSE;
532// edited=FALSE;
533// if(caption().left(1)=="*")
534// setCaption(caption().right(caption().length()-1));
535// doSearchBar();
531} 536}
532 537
533void TextEdit::doSearchBar() 538void TextEdit::doSearchBar()
534{ 539{
535 Config cfg("TextEdit"); 540 Config cfg("TextEdit");
536 cfg.setGroup("View"); 541 cfg.setGroup("View");
537 if(cfg.readEntry("SearchBar","Closed") != "Opened") 542 if(cfg.readEntry("SearchBar","Closed") != "Opened")
538 searchBar->hide(); 543 searchBar->hide();
539} 544}
540 545
541#if 0 546#if 0
542void TextEdit::slotFind() 547void TextEdit::slotFind()
543{ 548{
544 FindDialog frmFind( tr("Text Editor"), this ); 549 FindDialog frmFind( tr("Text Editor"), this );
545 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 550 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
546 editor, SLOT(slotDoFind( const QString&,bool,bool))); 551 editor, SLOT(slotDoFind( const QString&,bool,bool)));
547 552
548 //case sensitive, backwards, [category] 553 //case sensitive, backwards, [category]
549 554
550 connect( editor, SIGNAL(notFound()), 555 connect( editor, SIGNAL(notFound()),
551 &frmFind, SLOT(slotNotFound()) ); 556 &frmFind, SLOT(slotNotFound()) );
552 connect( editor, SIGNAL(searchWrapped()), 557 connect( editor, SIGNAL(searchWrapped()),
553 &frmFind, SLOT(slotWrapAround()) ); 558 &frmFind, SLOT(slotWrapAround()) );
554 559
555 frmFind.exec(); 560 frmFind.exec();
556 561
557 562
558} 563}
559#endif 564#endif
560 565
561void TextEdit::fileRevert() 566void TextEdit::fileRevert()
562{ 567{
563 clear(); 568 clear();
564 fileOpen(); 569 fileOpen();
565} 570}
566 571
567void TextEdit::editCut() 572void TextEdit::editCut()
568{ 573{
569#ifndef QT_NO_CLIPBOARD 574#ifndef QT_NO_CLIPBOARD
570 editor->cut(); 575 editor->cut();
571#endif 576#endif
572} 577}
573 578
574void TextEdit::editCopy() 579void TextEdit::editCopy()
575{ 580{
576#ifndef QT_NO_CLIPBOARD 581#ifndef QT_NO_CLIPBOARD
577 editor->copy(); 582 editor->copy();
578#endif 583#endif
579} 584}
580 585
581void TextEdit::editPaste() 586void TextEdit::editPaste()
582{ 587{
583#ifndef QT_NO_CLIPBOARD 588#ifndef QT_NO_CLIPBOARD
584 editor->paste(); 589 editor->paste();
585#endif 590#endif
586} 591}
587 592
588void TextEdit::editFind() 593void TextEdit::editFind()
589{ 594{
590 searchBar->show(); 595 searchBar->show();
591 searchVisible = TRUE; 596 searchVisible = TRUE;
592 searchEdit->setFocus(); 597 searchEdit->setFocus();
593 Config cfg("TextEdit"); 598 Config cfg("TextEdit");
594 cfg.setGroup("View"); 599 cfg.setGroup("View");
595 cfg.writeEntry("SearchBar","Opened"); 600 cfg.writeEntry("SearchBar","Opened");
596 601
597} 602}
598 603
599void TextEdit::findNext() 604void TextEdit::findNext()
600{ 605{
601 editor->find( searchEdit->text(), FALSE, FALSE ); 606 editor->find( searchEdit->text(), FALSE, FALSE );
602 607
603} 608}
604 609
605void TextEdit::findClose() 610void TextEdit::findClose()
606{ 611{
607 searchVisible = FALSE; 612 searchVisible = FALSE;
608 searchBar->hide(); 613 searchBar->hide();
609 Config cfg("TextEdit"); 614 Config cfg("TextEdit");
610 cfg.setGroup("View"); 615 cfg.setGroup("View");
611 cfg.writeEntry("SearchBar","Closed"); 616 cfg.writeEntry("SearchBar","Closed");
612 cfg.write(); 617 cfg.write();
613} 618}
614 619
615void TextEdit::search() 620void TextEdit::search()
616{ 621{
617 editor->find( searchEdit->text(), FALSE, FALSE ); 622 editor->find( searchEdit->text(), FALSE, FALSE );
618} 623}
619 624
620void TextEdit::newFile( const DocLnk &f ) 625void TextEdit::newFile( const DocLnk &f )
621{ 626{
622 DocLnk nf = f; 627 DocLnk nf = f;
623 nf.setType("text/plain"); 628 nf.setType("text/plain");
624 clear(); 629 clear();
625 setWState (WState_Reserved1 ); 630 setWState (WState_Reserved1 );
626 editor->setFocus(); 631 editor->setFocus();
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro
index fce76bd..aae7f89 100644
--- a/core/apps/textedit/textedit.pro
+++ b/core/apps/textedit/textedit.pro
@@ -1,24 +1,24 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3 3
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h 5HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h
6SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp 6SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp
7 7
8INCLUDEPATH += $(OPIEDIR)/include 8INCLUDEPATH += $(OPIEDIR)/include
9DEPENDPATH += $(OPIEDIR)/include 9DEPENDPATH += $(OPIEDIR)/include
10LIBS += -lqpe 10LIBS += -lqpe -lopie
11 11
12TARGET = textedit 12TARGET = textedit
13 13
14TRANSLATIONS += ../i18n/de/textedit.ts 14TRANSLATIONS += ../i18n/de/textedit.ts
15TRANSLATIONS += ../i18n/pt_BR/textedit.ts 15TRANSLATIONS += ../i18n/pt_BR/textedit.ts
16TRANSLATIONS += ../i18n/en/textedit.ts 16TRANSLATIONS += ../i18n/en/textedit.ts
17TRANSLATIONS += ../i18n/hu/textedit.ts 17TRANSLATIONS += ../i18n/hu/textedit.ts
18TRANSLATIONS += ../i18n/fr/textedit.ts 18TRANSLATIONS += ../i18n/fr/textedit.ts
19TRANSLATIONS += ../i18n/ja/textedit.ts 19TRANSLATIONS += ../i18n/ja/textedit.ts
20TRANSLATIONS += ../i18n/sl/textedit.ts 20TRANSLATIONS += ../i18n/sl/textedit.ts
21TRANSLATIONS += ../i18n/ko/textedit.ts 21TRANSLATIONS += ../i18n/ko/textedit.ts
22TRANSLATIONS += ../i18n/no/textedit.ts 22TRANSLATIONS += ../i18n/no/textedit.ts
23TRANSLATIONS += ../i18n/zh_CN/textedit.ts 23TRANSLATIONS += ../i18n/zh_CN/textedit.ts
24TRANSLATIONS += ../i18n/zh_TW/textedit.ts 24TRANSLATIONS += ../i18n/zh_TW/textedit.ts