summaryrefslogtreecommitdiff
path: root/core/apps/textedit/textedit.cpp
Unidiff
Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 55725cc..b54da34 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -118,98 +118,98 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
118 } else { 118 } else {
119 getCursorPosition( &line, &col ); 119 getCursorPosition( &line, &col );
120 } 120 }
121 //ignore backwards for now.... 121 //ignore backwards for now....
122 if ( !backwards ) { 122 if ( !backwards ) {
123 for ( ; ; ) { 123 for ( ; ; ) {
124 if ( line >= numLines() ) { 124 if ( line >= numLines() ) {
125 wrap = true; 125 wrap = true;
126 //emit notFound(); 126 //emit notFound();
127 break; 127 break;
128 } 128 }
129 int findCol = getString( line )->find( txt, col, caseSensitive ); 129 int findCol = getString( line )->find( txt, col, caseSensitive );
130 if ( findCol >= 0 ) { 130 if ( findCol >= 0 ) {
131 setCursorPosition( line, findCol, false ); 131 setCursorPosition( line, findCol, false );
132 col = findCol + txt.length(); 132 col = findCol + txt.length();
133 setCursorPosition( line, col, true ); 133 setCursorPosition( line, col, true );
134 134
135 //found = true; 135 //found = true;
136 break; 136 break;
137 } 137 }
138 line++; 138 line++;
139 col = 0; 139 col = 0;
140 } 140 }
141 } 141 }
142} 142}
143 143
144 144
145#else 145#else
146 146
147#error "Must make a QpeEditor that inherits QTextEdit" 147#error "Must make a QpeEditor that inherits QTextEdit"
148 148
149#endif 149#endif
150 150
151 151
152static const int nfontsizes = 6; 152static const int nfontsizes = 6;
153static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 153static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
154 154
155TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 155TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
156 : QMainWindow( parent, name, f ), bFromDocView( false ) 156 : QMainWindow( parent, name, f ), bFromDocView( false )
157{ 157{
158 doc = 0; 158 doc = 0;
159 edited=false; 159 edited=false;
160 fromSetDocument=false; 160 fromSetDocument=false;
161 161
162 setToolBarsMovable( false ); 162 setToolBarsMovable( false );
163 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 163 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
164 164
165 channel = new QCopChannel( "QPE/Application/textedit", this ); 165 channel = new QCopChannel( "QPE/Application/textedit", this );
166 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 166 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
167 this, SLOT(receive(const QCString&, const QByteArray&)) ); 167 this, SLOT(receive(const QCString&,const QByteArray&)) );
168 168
169 setIcon( Resource::loadPixmap( "TextEditor" ) ); 169 setIcon( Resource::loadPixmap( "TextEditor" ) );
170 170
171 QToolBar *bar = new QToolBar( this ); 171 QToolBar *bar = new QToolBar( this );
172 bar->setHorizontalStretchable( true ); 172 bar->setHorizontalStretchable( true );
173 menu = bar; 173 menu = bar;
174 174
175 QMenuBar *mb = new QMenuBar( bar ); 175 QMenuBar *mb = new QMenuBar( bar );
176 QPopupMenu *file = new QPopupMenu( this ); 176 QPopupMenu *file = new QPopupMenu( this );
177 QPopupMenu *edit = new QPopupMenu( this ); 177 QPopupMenu *edit = new QPopupMenu( this );
178 QPopupMenu *advancedMenu = new QPopupMenu(this); 178 QPopupMenu *advancedMenu = new QPopupMenu(this);
179 179
180 font = new QPopupMenu( this ); 180 font = new QPopupMenu( this );
181 181
182 bar = new QToolBar( this ); 182 bar = new QToolBar( this );
183 editBar = bar; 183 editBar = bar;
184 184
185 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 185 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
186 QString::null, 0, this, 0 ); 186 QString::null, 0, this, 0 );
187 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 187 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
188// a->addTo( bar ); 188// a->addTo( bar );
189 a->addTo( file ); 189 a->addTo( file );
190 190
191 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), 191 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ),
192 QString::null, 0, this, 0 ); 192 QString::null, 0, this, 0 );
193 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 193 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
194 a->addTo( bar ); 194 a->addTo( bar );
195 a->addTo( file ); 195 a->addTo( file );
196 196
197 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , 197 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") ,
198 QString::null, 0, this, 0 ); 198 QString::null, 0, this, 0 );
199 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 199 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
200 file->insertSeparator(); 200 file->insertSeparator();
201 a->addTo( bar ); 201 a->addTo( bar );
202 a->addTo( file ); 202 a->addTo( file );
203 203
204 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , 204 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") ,
205 QString::null, 0, this, 0 ); 205 QString::null, 0, this, 0 );
206 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 206 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
207 a->addTo( file ); 207 a->addTo( file );
208 208
209 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), 209 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ),
210 QString::null, 0, this, 0 ); 210 QString::null, 0, this, 0 );
211 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 211 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
212 a->addTo( editBar ); 212 a->addTo( editBar );
213 a->addTo( edit ); 213 a->addTo( edit );
214 214
215 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), 215 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ),
@@ -280,97 +280,97 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
280 this, SLOT( doPrompt(bool) ) ); 280 this, SLOT( doPrompt(bool) ) );
281 nAdvanced->setToggleAction(true); 281 nAdvanced->setToggleAction(true);
282 nAdvanced->addTo( advancedMenu ); 282 nAdvanced->addTo( advancedMenu );
283 283
284 desktopAction = new QAction( tr("Always open linked file"), 284 desktopAction = new QAction( tr("Always open linked file"),
285 QString::null, 0, this, 0 ); 285 QString::null, 0, this, 0 );
286 connect( desktopAction, SIGNAL( toggled(bool) ), 286 connect( desktopAction, SIGNAL( toggled(bool) ),
287 this, SLOT( doDesktop(bool) ) ); 287 this, SLOT( doDesktop(bool) ) );
288 desktopAction->setToggleAction(true); 288 desktopAction->setToggleAction(true);
289 desktopAction->addTo( advancedMenu); 289 desktopAction->addTo( advancedMenu);
290 290
291 filePermAction = new QAction( tr("File Permissions"), 291 filePermAction = new QAction( tr("File Permissions"),
292 QString::null, 0, this, 0 ); 292 QString::null, 0, this, 0 );
293 connect( filePermAction, SIGNAL( toggled(bool) ), 293 connect( filePermAction, SIGNAL( toggled(bool) ),
294 this, SLOT( doFilePerms(bool) ) ); 294 this, SLOT( doFilePerms(bool) ) );
295 filePermAction->setToggleAction(true); 295 filePermAction->setToggleAction(true);
296 filePermAction->addTo( advancedMenu); 296 filePermAction->addTo( advancedMenu);
297 297
298 searchBarAction = new QAction( tr("Search Bar Open"), 298 searchBarAction = new QAction( tr("Search Bar Open"),
299 QString::null, 0, this, 0 ); 299 QString::null, 0, this, 0 );
300 connect( searchBarAction, SIGNAL( toggled(bool) ), 300 connect( searchBarAction, SIGNAL( toggled(bool) ),
301 this, SLOT( setSearchBar(bool) ) ); 301 this, SLOT( setSearchBar(bool) ) );
302 searchBarAction->setToggleAction(true); 302 searchBarAction->setToggleAction(true);
303 searchBarAction->addTo( advancedMenu); 303 searchBarAction->addTo( advancedMenu);
304 304
305 nAutoSave = new QAction( tr("Auto Save 5 min."), 305 nAutoSave = new QAction( tr("Auto Save 5 min."),
306 QString::null, 0, this, 0 ); 306 QString::null, 0, this, 0 );
307 connect( nAutoSave, SIGNAL( toggled(bool) ), 307 connect( nAutoSave, SIGNAL( toggled(bool) ),
308 this, SLOT( doTimer(bool) ) ); 308 this, SLOT( doTimer(bool) ) );
309 nAutoSave->setToggleAction(true); 309 nAutoSave->setToggleAction(true);
310 nAutoSave->addTo( advancedMenu); 310 nAutoSave->addTo( advancedMenu);
311 311
312 312
313 //font->insertSeparator(); 313 //font->insertSeparator();
314 314
315 //font->insertItem(tr("About"), this, SLOT( doAbout()) ); 315 //font->insertItem(tr("About"), this, SLOT( doAbout()) );
316 316
317 mb->insertItem( tr( "File" ), file ); 317 mb->insertItem( tr( "File" ), file );
318 mb->insertItem( tr( "Edit" ), edit ); 318 mb->insertItem( tr( "Edit" ), edit );
319 mb->insertItem( tr( "View" ), font ); 319 mb->insertItem( tr( "View" ), font );
320 320
321 searchBar = new QToolBar(this); 321 searchBar = new QToolBar(this);
322 addToolBar( searchBar, "Search", QMainWindow::Top, true ); 322 addToolBar( searchBar, "Search", QMainWindow::Top, true );
323 323
324 searchBar->setHorizontalStretchable( true ); 324 searchBar->setHorizontalStretchable( true );
325 325
326 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 326 searchEdit = new QLineEdit( searchBar, "searchEdit" );
327 searchBar->setStretchableWidget( searchEdit ); 327 searchBar->setStretchableWidget( searchEdit );
328 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 328 connect( searchEdit, SIGNAL( textChanged(const QString&) ),
329 this, SLOT( search() ) ); 329 this, SLOT( search() ) );
330 330
331 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), 331 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ),
332 QString::null, 0, this, 0 ); 332 QString::null, 0, this, 0 );
333 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 333 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
334 a->addTo( searchBar ); 334 a->addTo( searchBar );
335 a->addTo( edit ); 335 a->addTo( edit );
336 336
337 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), 337 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ),
338 QString::null, 0, this, 0 ); 338 QString::null, 0, this, 0 );
339 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 339 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
340 a->addTo( searchBar ); 340 a->addTo( searchBar );
341 341
342 edit->insertSeparator(); 342 edit->insertSeparator();
343 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), 343 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ),
344 QString::null, 0, this, 0 ); 344 QString::null, 0, this, 0 );
345 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 345 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
346 a->addTo( edit ); 346 a->addTo( edit );
347 347
348 searchBar->hide(); 348 searchBar->hide();
349 349
350 editor = new QpeEditor( this ); 350 editor = new QpeEditor( this );
351 setCentralWidget( editor ); 351 setCentralWidget( editor );
352 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 352 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
353 connect( editor, SIGNAL( textChanged() ), 353 connect( editor, SIGNAL( textChanged() ),
354 this, SLOT( editorChanged() ) ); 354 this, SLOT( editorChanged() ) );
355 355
356 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); 356 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);
357 357
358 Config cfg("TextEdit"); 358 Config cfg("TextEdit");
359 cfg. setGroup ( "Font" ); 359 cfg. setGroup ( "Font" );
360 360
361 QFont defaultFont = editor-> font ( ); 361 QFont defaultFont = editor-> font ( );
362 362
363 QString family = cfg. readEntry ( "Family", defaultFont. family ( )); 363 QString family = cfg. readEntry ( "Family", defaultFont. family ( ));
364 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); 364 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( ));
365 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); 365 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( ));
366 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); 366 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));
367 367
368 defaultFont = QFont ( family, size, weight, italic ); 368 defaultFont = QFont ( family, size, weight, italic );
369 editor-> setFont ( defaultFont ); 369 editor-> setFont ( defaultFont );
370// updateCaption(); 370// updateCaption();
371 371
372 cfg.setGroup ( "View" ); 372 cfg.setGroup ( "View" );
373 373
374 promptExit = cfg.readBoolEntry ( "PromptExit", false ); 374 promptExit = cfg.readBoolEntry ( "PromptExit", false );
375 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); 375 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true );
376 filePerms = cfg.readBoolEntry ( "FilePermissions", false ); 376 filePerms = cfg.readBoolEntry ( "FilePermissions", false );
@@ -538,98 +538,98 @@ void TextEdit::setSearchBar(bool b) {
538 cfg.setGroup("View"); 538 cfg.setGroup("View");
539 cfg.writeEntry ( "SearchBar", b ); 539 cfg.writeEntry ( "SearchBar", b );
540 searchBarAction->setOn(b); 540 searchBarAction->setOn(b);
541 if(b) 541 if(b)
542 searchBar->show(); 542 searchBar->show();
543 else 543 else
544 searchBar->hide(); 544 searchBar->hide();
545 editor->setFocus(); 545 editor->setFocus();
546} 546}
547 547
548void TextEdit::fileNew() { 548void TextEdit::fileNew() {
549// if( !bFromDocView ) { 549// if( !bFromDocView ) {
550// saveAs(); 550// saveAs();
551// } 551// }
552 newFile(DocLnk()); 552 newFile(DocLnk());
553} 553}
554 554
555void TextEdit::fileOpen() { 555void TextEdit::fileOpen() {
556 Config cfg("TextEdit"); 556 Config cfg("TextEdit");
557 cfg. setGroup ( "View" ); 557 cfg. setGroup ( "View" );
558 QMap<QString, QStringList> map; 558 QMap<QString, QStringList> map;
559 map.insert(tr("All"), QStringList() ); 559 map.insert(tr("All"), QStringList() );
560 QStringList text; 560 QStringList text;
561 text << "text/*"; 561 text << "text/*";
562 map.insert(tr("Text"), text ); 562 map.insert(tr("Text"), text );
563 text << "*"; 563 text << "*";
564 map.insert(tr("All"), text ); 564 map.insert(tr("All"), text );
565 QString str = OFileDialog::getOpenFileName( 2, 565 QString str = OFileDialog::getOpenFileName( 2,
566 QString::null , 566 QString::null ,
567 QString::null, map); 567 QString::null, map);
568 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 568 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
569 { 569 {
570 openFile( str ); 570 openFile( str );
571 } 571 }
572 else 572 else
573 updateCaption(); 573 updateCaption();
574} 574}
575 575
576void TextEdit::doSearchBar() { 576void TextEdit::doSearchBar() {
577 if(!useSearchBar) 577 if(!useSearchBar)
578 searchBar->hide(); 578 searchBar->hide();
579 else 579 else
580 searchBar->show(); 580 searchBar->show();
581} 581}
582 582
583#if 0 583#if 0
584void TextEdit::slotFind() { 584void TextEdit::slotFind() {
585 FindDialog frmFind( tr("Text Editor"), this ); 585 FindDialog frmFind( tr("Text Editor"), this );
586 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 586 connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)),
587 editor, SLOT(slotDoFind( const QString&,bool,bool))); 587 editor, SLOT(slotDoFind(const QString&,bool,bool)));
588 588
589 //case sensitive, backwards, [category] 589 //case sensitive, backwards, [category]
590 590
591 connect( editor, SIGNAL(notFound()), 591 connect( editor, SIGNAL(notFound()),
592 &frmFind, SLOT(slotNotFound()) ); 592 &frmFind, SLOT(slotNotFound()) );
593 connect( editor, SIGNAL(searchWrapped()), 593 connect( editor, SIGNAL(searchWrapped()),
594 &frmFind, SLOT(slotWrapAround()) ); 594 &frmFind, SLOT(slotWrapAround()) );
595 595
596 frmFind.exec(); 596 frmFind.exec();
597 597
598 598
599} 599}
600#endif 600#endif
601 601
602void TextEdit::fileRevert() { 602void TextEdit::fileRevert() {
603 clear(); 603 clear();
604 fileOpen(); 604 fileOpen();
605} 605}
606 606
607void TextEdit::editCut() { 607void TextEdit::editCut() {
608#ifndef QT_NO_CLIPBOARD 608#ifndef QT_NO_CLIPBOARD
609 editor->cut(); 609 editor->cut();
610#endif 610#endif
611} 611}
612 612
613void TextEdit::editCopy() { 613void TextEdit::editCopy() {
614#ifndef QT_NO_CLIPBOARD 614#ifndef QT_NO_CLIPBOARD
615 editor->copy(); 615 editor->copy();
616#endif 616#endif
617} 617}
618 618
619void TextEdit::editPaste() { 619void TextEdit::editPaste() {
620#ifndef QT_NO_CLIPBOARD 620#ifndef QT_NO_CLIPBOARD
621 editor->paste(); 621 editor->paste();
622#endif 622#endif
623} 623}
624 624
625void TextEdit::editFind() { 625void TextEdit::editFind() {
626 searchBar->show(); 626 searchBar->show();
627 searchEdit->setFocus(); 627 searchEdit->setFocus();
628} 628}
629 629
630void TextEdit::findNext() { 630void TextEdit::findNext() {
631 editor->find( searchEdit->text(), false, false ); 631 editor->find( searchEdit->text(), false, false );
632 632
633} 633}
634 634
635void TextEdit::findClose() { 635void TextEdit::findClose() {