summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-12-20 22:55:01 (UTC)
committer llornkcor <llornkcor>2002-12-20 22:55:01 (UTC)
commit48efd0d81aad0c3d0a64baabbc46fde593eb086c (patch) (unidiff)
treefbf4aa16a389770f065f48e9888e1cd292f81a9f
parent3e67f4998a4957420d7f890268dc5f816e142468 (diff)
downloadopie-48efd0d81aad0c3d0a64baabbc46fde593eb086c.zip
opie-48efd0d81aad0c3d0a64baabbc46fde593eb086c.tar.gz
opie-48efd0d81aad0c3d0a64baabbc46fde593eb086c.tar.bz2
sic workaround hack for now. fixes bug #569
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp163
1 files changed, 102 insertions, 61 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 4f4f994..dc0d61b 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,5 +1,6 @@
1/********************************************************************** 1/**********************************************************************
2// textedit.cpp
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 4**
4** This file is part of Qtopia Environment. 5** This file is part of Opie Environment.
5** 6**
@@ -10,21 +11,7 @@
10** 11**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/ 12**********************************************************************/
20// changes added by L. J. Potter Sun 02-17-2002 21:31:31 13// changes added by L. J. Potter Sun 02-17-2002 21:31:31
21/*
22 useAdvancedfeatures =
23 1) do not prompt on cancel, even if text is edited.
24 2) prompt user is .desktop file
25 3) prompt user for File Permissions on saveAs
26 */
27#include "textedit.h" 14#include "textedit.h"
28#include "filePermissions.h" 15#include "filePermissions.h"
29//#include "fontDialog.h" 16
30 17
@@ -45,2 +32,3 @@
45 32
33#include <qpoint.h>
46#include <qtextstream.h> 34#include <qtextstream.h>
@@ -171,8 +159,8 @@ class QpeEditor : public QMultiLineEdit
171{ 159{
172 // Q_OBJECT 160
173public: 161public:
174 QpeEditor( QWidget *parent, const char * name = 0 ) 162 QpeEditor( QWidget *parent, const char * name = 0 )
175 : QMultiLineEdit( parent, name ) { 163 : QMultiLineEdit( parent, name ) {
176 clearTableFlags(); 164 clearTableFlags();
177 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 165 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
178} 166}
@@ -181,2 +169,8 @@ public:
181 bool backwards ); 169 bool backwards );
170protected:
171 bool markIt;
172 int line1, line2, col1, col2;
173 void mousePressEvent( QMouseEvent * );
174 void mouseReleaseEvent( QMouseEvent * );
175
182//public slots: 176//public slots:
@@ -192,2 +186,34 @@ private:
192 186
187void QpeEditor::mousePressEvent( QMouseEvent *e ) {
188 switch(e->button()) {
189 case RightButton:
190 { //rediculous workaround for qt popup menu
191 //and the hold right click mechanism
192 this->setSelection( line1, col1, line2, col2);
193 QMultiLineEdit::mousePressEvent( e );
194 markIt = false;
195 }
196 break;
197 default:
198 {
199 if(!markIt) {
200 int line, col;
201 this->getCursorPosition(&line, &col);
202 line1=line2=line;
203 col1=col2=col;
204 }
205 QMultiLineEdit::mousePressEvent( e );
206 }
207 break;
208 };
209}
210
211void QpeEditor::mouseReleaseEvent( QMouseEvent * ) {
212 if(this->hasMarkedText()) {
213 markIt = true;
214 this->getMarkedRegion( &line1, &col1, &line2, & col2 );
215 } else {
216 markIt = false;
217 }
218}
193 219
@@ -270,3 +296,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
270 296
271 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 297 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
298 QString::null, 0, this, 0 );
272 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 299 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
@@ -275,3 +302,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
275 302
276 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 303 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ),
304 QString::null, 0, this, 0 );
277 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 305 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
@@ -280,3 +308,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
280 308
281 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 309 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) ,
310 QString::null, 0, this, 0 );
282 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 311 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
@@ -286,3 +315,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
286 315
287 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 316 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) ,
317 QString::null, 0, this, 0 );
288 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 318 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
@@ -290,3 +320,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
290 320
291 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 321 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ),
322 QString::null, 0, this, 0 );
292 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 323 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
@@ -295,3 +326,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
295 326
296 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 327 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ),
328 QString::null, 0, this, 0 );
297 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 329 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
@@ -300,3 +332,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
300 332
301 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 333 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ),
334 QString::null, 0, this, 0 );
302 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 335 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
@@ -307,3 +340,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
307#ifndef QT_NO_CLIPBOARD 340#ifndef QT_NO_CLIPBOARD
308 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 341 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ),
342 QString::null, 0, this, 0 );
309 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); 343 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
@@ -312,3 +346,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
312 346
313 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 347 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ),
348 QString::null, 0, this, 0 );
314 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 349 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
@@ -328,3 +363,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
328 font->insertSeparator(); 363 font->insertSeparator();
329// font->insertSeparator(); 364
330 font->insertItem(tr("Font"), this, SLOT(changeFont()) ); 365 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
@@ -334,4 +369,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
334 369
335 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); 370 QAction *wa = new QAction( tr("Wrap lines"),
336 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 371 QString::null, 0, this, 0 );
372 connect( wa, SIGNAL( toggled(bool) ),
373 this, SLOT( setWordWrap(bool) ) );
337 wa->setToggleAction(true); 374 wa->setToggleAction(true);
@@ -339,4 +376,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
339 376
340 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); 377 nStart = new QAction( tr("Start with new file"),
341 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 378 QString::null, 0, this, 0 );
379 connect( nStart, SIGNAL( toggled(bool) ),
380 this, SLOT( changeStartConfig(bool) ) );
342 nStart->setToggleAction(true); 381 nStart->setToggleAction(true);
@@ -345,4 +384,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
345 384
346 nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); 385 nAdvanced = new QAction( tr("Prompt on Exit"),
347 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); 386 QString::null, 0, this, 0 );
387 connect( nAdvanced, SIGNAL( toggled(bool) ),
388 this, SLOT( doPrompt(bool) ) );
348 nAdvanced->setToggleAction(true); 389 nAdvanced->setToggleAction(true);
@@ -350,4 +391,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
350 391
351 desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); 392 desktopAction = new QAction( tr("Always open linked file"),
352 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); 393 QString::null, 0, this, 0 );
394 connect( desktopAction, SIGNAL( toggled(bool) ),
395 this, SLOT( doDesktop(bool) ) );
353 desktopAction->setToggleAction(true); 396 desktopAction->setToggleAction(true);
@@ -355,4 +398,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
355 398
356 filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); 399 filePermAction = new QAction( tr("File Permissions"),
357 connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); 400 QString::null, 0, this, 0 );
401 connect( filePermAction, SIGNAL( toggled(bool) ),
402 this, SLOT( doFilePerms(bool) ) );
358 filePermAction->setToggleAction(true); 403 filePermAction->setToggleAction(true);
@@ -360,4 +405,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
360 405
361 searchBarAction = new QAction( tr("Search Bar Open"), QString::null, 0, this, 0 ); 406 searchBarAction = new QAction( tr("Search Bar Open"),
362 connect( searchBarAction, SIGNAL( toggled(bool) ), this, SLOT( setSearchBar(bool) ) ); 407 QString::null, 0, this, 0 );
408 connect( searchBarAction, SIGNAL( toggled(bool) ),
409 this, SLOT( setSearchBar(bool) ) );
363 searchBarAction->setToggleAction(true); 410 searchBarAction->setToggleAction(true);
@@ -384,3 +431,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
384 431
385 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 432 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ),
433 QString::null, 0, this, 0 );
386 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 434 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
@@ -389,3 +437,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
389 437
390 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 438 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ),
439 QString::null, 0, this, 0 );
391 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 440 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
@@ -394,3 +443,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
394 edit->insertSeparator(); 443 edit->insertSeparator();
395 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 444 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ),
445 QString::null, 0, this, 0 );
396 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 446 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
@@ -403,3 +453,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
403 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 453 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
404 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 454 connect( editor, SIGNAL( textChanged() ),
455 this, SLOT( editorChanged() ) );
456
405 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); 457 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);
@@ -451,10 +503,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
451 edited1=false; 503 edited1=false;
452
453// if(startWithNew ) {
454 openDotFile(""); 504 openDotFile("");
455// fileNew();
456// }
457// else {
458// fileOpen();
459// }
460 } 505 }
@@ -462,3 +507,2 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
462 viewSelection = cfg.readNumEntry( "FileView", 0 ); 507 viewSelection = cfg.readNumEntry( "FileView", 0 );
463// setCaption(tr("Text Editor"));
464} 508}
@@ -466,3 +510,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
466TextEdit::~TextEdit() { 510TextEdit::~TextEdit() {
467// qDebug("destr"); 511 qWarning("textedit d'tor");
512 delete editor;
468} 513}
@@ -470,3 +515,2 @@ TextEdit::~TextEdit() {
470void TextEdit::closeEvent(QCloseEvent *) { 515void TextEdit::closeEvent(QCloseEvent *) {
471// qDebug("closing here");
472 if( edited1 && promptExit) 516 if( edited1 && promptExit)
@@ -477,3 +521,2 @@ void TextEdit::closeEvent(QCloseEvent *) {
477void TextEdit::cleanUp() { 521void TextEdit::cleanUp() {
478// qDebug("cleanUp");// save();
479 522
@@ -501,3 +544,2 @@ void TextEdit::cleanUp() {
501void TextEdit::accept() { 544void TextEdit::accept() {
502// qDebug("accept");
503 if( edited1) 545 if( edited1)
@@ -792,3 +834,3 @@ bool TextEdit::save() {
792 saveAs(); 834 saveAs();
793 return; 835 return false;
794 } 836 }
@@ -1055,3 +1097,3 @@ void TextEdit::editorChanged() {
1055 1097
1056void TextEdit::receive(const QCString&msg, const QByteArray &data) { 1098void TextEdit::receive(const QCString&msg, const QByteArray &) {
1057 qDebug("QCop "+msg); 1099 qDebug("QCop "+msg);
@@ -1100,2 +1142 @@ void TextEdit::editPasteTimeDate() {
1100} }
1101