Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 9e6ba8d..107695a 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -16,65 +16,69 @@ | |||
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 "filePermissions.h" | 23 | #include "filePermissions.h" |
24 | #include "fontDialog.h" | 24 | #include "fontDialog.h" |
25 | 25 | ||
26 | #include <opie/ofileselector.h> | 26 | #include <opie/ofileselector.h> |
27 | #include <opie/ofiledialog.h> | 27 | #include <opie/ofiledialog.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 | 39 | ||
40 | #include <qdatetime.h> | ||
41 | #include <qclipboard.h> | ||
40 | #include <qstringlist.h> | 42 | #include <qstringlist.h> |
41 | #include <qaction.h> | 43 | #include <qaction.h> |
42 | #include <qcolordialog.h> | 44 | #include <qcolordialog.h> |
43 | #include <qfileinfo.h> | 45 | #include <qfileinfo.h> |
44 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
45 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
46 | #include <qobjectlist.h> | 48 | #include <qobjectlist.h> |
47 | #include <qpopupmenu.h> | 49 | #include <qpopupmenu.h> |
48 | #include <qspinbox.h> | 50 | #include <qspinbox.h> |
49 | #include <qtoolbutton.h> | 51 | #include <qtoolbutton.h> |
50 | #include <qwidgetstack.h> | 52 | #include <qwidgetstack.h> |
51 | #include <qcheckbox.h> | 53 | #include <qcheckbox.h> |
52 | #include <qcombo.h> | 54 | #include <qcombo.h> |
55 | |||
53 | #include <unistd.h> | 56 | #include <unistd.h> |
54 | #include <sys/stat.h> | 57 | #include <sys/stat.h> |
55 | |||
56 | #include <stdlib.h> //getenv | 58 | #include <stdlib.h> //getenv |
59 | |||
60 | |||
57 | /* XPM */ | 61 | /* XPM */ |
58 | static char * filesave_xpm[] = { | 62 | static char * filesave_xpm[] = { |
59 | "16 16 78 1", | 63 | "16 16 78 1", |
60 | " c None", | 64 | " c None", |
61 | ". c #343434", | 65 | ". c #343434", |
62 | "+ c #A0A0A0", | 66 | "+ c #A0A0A0", |
63 | "@ c #565656", | 67 | "@ c #565656", |
64 | "# c #9E9E9E", | 68 | "# c #9E9E9E", |
65 | "$ c #525252", | 69 | "$ c #525252", |
66 | "% c #929292", | 70 | "% c #929292", |
67 | "& c #676767", | 71 | "& c #676767", |
68 | "* c #848484", | 72 | "* c #848484", |
69 | "= c #666666", | 73 | "= c #666666", |
70 | "- c #D8D8D8", | 74 | "- c #D8D8D8", |
71 | "; c #FFFFFF", | 75 | "; c #FFFFFF", |
72 | "> c #DBDBDB", | 76 | "> c #DBDBDB", |
73 | ", c #636363", | 77 | ", c #636363", |
74 | "' c #989898", | 78 | "' c #989898", |
75 | ") c #2D2D2D", | 79 | ") c #2D2D2D", |
76 | "! c #909090", | 80 | "! c #909090", |
77 | "~ c #AEAEAE", | 81 | "~ c #AEAEAE", |
78 | "{ c #EAEAEA", | 82 | "{ c #EAEAEA", |
79 | "] c #575757", | 83 | "] c #575757", |
80 | "^ c #585858", | 84 | "^ c #585858", |
@@ -269,48 +273,55 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
269 | 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 ); |
270 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 274 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
271 | file->insertSeparator(); | 275 | file->insertSeparator(); |
272 | a->addTo( file ); | 276 | a->addTo( file ); |
273 | 277 | ||
274 | 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 ); |
275 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 279 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
276 | a->addTo( file ); | 280 | a->addTo( file ); |
277 | 281 | ||
278 | 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 ); |
279 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 283 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
280 | a->addTo( editBar ); | 284 | a->addTo( editBar ); |
281 | a->addTo( edit ); | 285 | a->addTo( edit ); |
282 | 286 | ||
283 | 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 ); |
284 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 288 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
285 | a->addTo( editBar ); | 289 | a->addTo( editBar ); |
286 | a->addTo( edit ); | 290 | a->addTo( edit ); |
287 | 291 | ||
288 | 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 ); |
289 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 293 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
290 | a->addTo( editBar ); | 294 | a->addTo( editBar ); |
291 | a->addTo( edit ); | 295 | a->addTo( edit ); |
292 | 296 | ||
297 | |||
298 | #ifndef QT_NO_CLIPBOARD | ||
299 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | ||
300 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | ||
301 | a->addTo( edit ); | ||
302 | #endif | ||
303 | |||
293 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 304 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
294 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 305 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
295 | edit->insertSeparator(); | 306 | edit->insertSeparator(); |
296 | a->addTo( bar ); | 307 | a->addTo( bar ); |
297 | a->addTo( edit ); | 308 | a->addTo( edit ); |
298 | 309 | ||
299 | int defsize; | 310 | int defsize; |
300 | bool defb, defi, wrap; | 311 | bool defb, defi, wrap; |
301 | 312 | ||
302 | Config cfg("TextEdit"); | 313 | Config cfg("TextEdit"); |
303 | cfg.setGroup("View"); | 314 | cfg.setGroup("View"); |
304 | defsize = cfg.readNumEntry("FontSize",10); | 315 | defsize = cfg.readNumEntry("FontSize",10); |
305 | defb = cfg.readBoolEntry("Bold",FALSE); | 316 | defb = cfg.readBoolEntry("Bold",FALSE); |
306 | defi = cfg.readBoolEntry("Italic",FALSE); | 317 | defi = cfg.readBoolEntry("Italic",FALSE); |
307 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 318 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
308 | 319 | ||
309 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 320 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
310 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 321 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
311 | zin->addTo( font ); | 322 | zin->addTo( font ); |
312 | 323 | ||
313 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 324 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
314 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 325 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
315 | zout->addTo( font ); | 326 | zout->addTo( font ); |
316 | 327 | ||
@@ -490,49 +501,49 @@ void TextEdit::setItalic(bool y) | |||
490 | QFont f = editor->font(); | 501 | QFont f = editor->font(); |
491 | f.setItalic(y); | 502 | f.setItalic(y); |
492 | editor->setFont(f); | 503 | editor->setFont(f); |
493 | } | 504 | } |
494 | 505 | ||
495 | void TextEdit::setWordWrap(bool y) | 506 | void TextEdit::setWordWrap(bool y) |
496 | { | 507 | { |
497 | bool state = editor->edited(); | 508 | bool state = editor->edited(); |
498 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 509 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
499 | editor->setEdited( state ); | 510 | editor->setEdited( state ); |
500 | } | 511 | } |
501 | 512 | ||
502 | void TextEdit::fileNew() | 513 | void TextEdit::fileNew() |
503 | { | 514 | { |
504 | // if( !bFromDocView ) { | 515 | // if( !bFromDocView ) { |
505 | // saveAs(); | 516 | // saveAs(); |
506 | // } | 517 | // } |
507 | newFile(DocLnk()); | 518 | newFile(DocLnk()); |
508 | } | 519 | } |
509 | 520 | ||
510 | void TextEdit::fileOpen() | 521 | void TextEdit::fileOpen() |
511 | { | 522 | { |
512 | Config cfg("TextEdit"); | 523 | Config cfg("TextEdit"); |
513 | cfg.setGroup("View"); | 524 | cfg.setGroup("View"); |
514 | bool b=FALSE; | 525 | // bool b=FALSE; |
515 | 526 | ||
516 | QMap<QString, QStringList> map; | 527 | QMap<QString, QStringList> map; |
517 | map.insert(tr("All"), QStringList() ); | 528 | map.insert(tr("All"), QStringList() ); |
518 | QStringList text; | 529 | QStringList text; |
519 | text << "text/*"; | 530 | text << "text/*"; |
520 | map.insert(tr("Text"), text ); | 531 | map.insert(tr("Text"), text ); |
521 | text << "*"; | 532 | text << "*"; |
522 | map.insert(tr("All"), text ); | 533 | map.insert(tr("All"), text ); |
523 | QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map); | 534 | QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map); |
524 | if(!str.isEmpty() ) | 535 | if(!str.isEmpty() ) |
525 | openFile( str ); | 536 | openFile( str ); |
526 | 537 | ||
527 | } | 538 | } |
528 | 539 | ||
529 | void TextEdit::doSearchBar() | 540 | void TextEdit::doSearchBar() |
530 | { | 541 | { |
531 | Config cfg("TextEdit"); | 542 | Config cfg("TextEdit"); |
532 | cfg.setGroup("View"); | 543 | cfg.setGroup("View"); |
533 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 544 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
534 | searchBar->hide(); | 545 | searchBar->hide(); |
535 | } | 546 | } |
536 | 547 | ||
537 | #if 0 | 548 | #if 0 |
538 | void TextEdit::slotFind() | 549 | void TextEdit::slotFind() |
@@ -961,24 +972,33 @@ void TextEdit::editorChanged() { | |||
961 | } | 972 | } |
962 | edited=TRUE; | 973 | edited=TRUE; |
963 | } | 974 | } |
964 | 975 | ||
965 | void TextEdit::receive(const QCString&msg, const QByteArray&) { | 976 | void TextEdit::receive(const QCString&msg, const QByteArray&) { |
966 | qDebug("QCop "+msg); | 977 | qDebug("QCop "+msg); |
967 | if ( msg == "setDocument(QString)" ) { | 978 | if ( msg == "setDocument(QString)" ) { |
968 | qDebug("bugger all"); | 979 | qDebug("bugger all"); |
969 | } | 980 | } |
970 | 981 | ||
971 | } | 982 | } |
972 | void TextEdit::doAbout() { | 983 | void TextEdit::doAbout() { |
973 | QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" | 984 | QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" |
974 | "2000 Trolltech AS, and\n" | 985 | "2000 Trolltech AS, and\n" |
975 | "2002 by L.J.Potter \nljp@llornkcor.com\n" | 986 | "2002 by L.J.Potter \nljp@llornkcor.com\n" |
976 | "and is licensed under the GPL"); | 987 | "and is licensed under the GPL"); |
977 | } | 988 | } |
978 | 989 | ||
979 | void TextEdit::doAdvanced(bool b) { | 990 | void TextEdit::doAdvanced(bool b) { |
980 | useAdvancedFeatures=b; | 991 | useAdvancedFeatures=b; |
981 | Config cfg("TextEdit"); | 992 | Config cfg("TextEdit"); |
982 | cfg.setGroup("View"); | 993 | cfg.setGroup("View"); |
983 | cfg.writeEntry("AdvancedFeatures",b); | 994 | cfg.writeEntry("AdvancedFeatures",b); |
984 | } | 995 | } |
996 | |||
997 | void TextEdit::editPasteTimeDate() { | ||
998 | #ifndef QT_NO_CLIPBOARD | ||
999 | QClipboard *cb = QApplication::clipboard(); | ||
1000 | QDateTime dt = QDateTime::currentDateTime(); | ||
1001 | cb->setText( dt.toString()); | ||
1002 | editor->paste(); | ||
1003 | #endif | ||
1004 | } | ||