summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-29 12:39:00 (UTC)
committer llornkcor <llornkcor>2002-06-29 12:39:00 (UTC)
commit2d3e1d2a51edeebfb6acea960cc4d505b4c72731 (patch) (unidiff)
tree26ac8e2f81ab8f131f217a01544d811dd6a5e881
parentd8508c23608ad28e0b37f26807ee35055fcabe38 (diff)
downloadopie-2d3e1d2a51edeebfb6acea960cc4d505b4c72731.zip
opie-2d3e1d2a51edeebfb6acea960cc4d505b4c72731.tar.gz
opie-2d3e1d2a51edeebfb6acea960cc4d505b4c72731.tar.bz2
convert to ofilesavedialog
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp634
-rw-r--r--core/apps/textedit/fileBrowser.h120
-rw-r--r--core/apps/textedit/fileSaver.cpp271
-rw-r--r--core/apps/textedit/fileSaver.h75
-rw-r--r--core/apps/textedit/textedit.cpp21
-rw-r--r--core/apps/textedit/textedit.h4
-rw-r--r--core/apps/textedit/textedit.pro30
7 files changed, 22 insertions, 1133 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
deleted file mode 100644
index 3798f90..0000000
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/dev/null
@@ -1,634 +0,0 @@
1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001
4**
5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**
13****************************************************************************/
14#define QTOPIA_INTERNAL_MIMEEXT
15#include "fileBrowser.h"
16//#include "inputDialog.h"
17
18#include <qpe/config.h>
19#include <qpe/resource.h>
20#include <qpe/fileselector.h>
21#include <qpe/qpeapplication.h>
22#include <qpe/menubutton.h>
23#include <qpe/mimetype.h>
24
25#include <qdict.h>
26#include <qwidgetstack.h>
27#include <qlistview.h>
28#include <qcombo.h>
29#include <qpushbutton.h>
30#include <qfile.h>
31#include <qmessagebox.h>
32#include <qlayout.h>
33#include <unistd.h>
34#include <qpopupmenu.h>
35#include <qlineedit.h>
36#include <qstringlist.h>
37
38#include <unistd.h>
39#include <stdlib.h>
40
41static int u_id = 1;
42static int get_unique_id()
43{
44 return u_id++;
45}
46
47fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter )
48 : QDialog( parent, name, modal, fl )
49{
50 if ( !name )
51 setName( "fileBrowser" );
52 setCaption(tr( name ) );
53
54// getMimeTypes();
55
56// mimeType = mimeFilter;
57// MimeType mt( mimeType);
58
59// if( mt.extension().isEmpty()) {
60
61// QStringList filterList;
62// filterList=QStringList::split(";",mimeFilter,FALSE);
63
64// for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) {
65// printf( "%s \n", (*it).latin1() );
66// }
67
68// filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*";
69
70// qDebug(filterStr);
71// } else {
72 filterStr = "*";//+ mt.extension();
73// qDebug("description "+mt.description());
74// qDebug( "id "+mt.id());
75// qDebug("extension "+mt.extension());
76// }
77// channel = new QCopChannel( "QPE/fileDialog", this );
78// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
79// this, SLOT(receive(const QCString&, const QByteArray&)) );
80
81 QGridLayout *layout = new QGridLayout( this );
82 layout->setSpacing( 4 );
83 layout->setMargin( 4 );
84
85 dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" );
86 dirPathCombo->setEditable(TRUE);
87
88 connect( dirPathCombo, SIGNAL( activated( const QString & ) ),
89 this, SLOT( dirPathComboActivated( const QString & ) ) );
90
91 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ),
92 this, SLOT( dirPathEditPressed( ) ) );
93
94 dirPathStringList << "/";
95// we can get the storage here
96
97 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 );
98
99 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
100 cdUpButton ->setMinimumSize( QSize( 20, 20 ) );
101 cdUpButton ->setMaximumSize( QSize( 20, 20 ) );
102 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
103 cdUpButton ->setFlat(TRUE);
104 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 );
105
106 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
107 docButton->setMinimumSize( QSize( 20, 20 ) );
108 docButton->setMaximumSize( QSize( 20, 20 ) );
109 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
110 docButton->setFlat(TRUE);
111 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
112
113 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
114 homeButton->setMinimumSize( QSize( 20, 20 ) );
115 homeButton->setMaximumSize( QSize( 20, 20 ) );
116 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
117 homeButton->setFlat(TRUE);
118 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 );
119
120 FileStack = new QWidgetStack( this );
121
122 ListView = new QListView( this, "ListView" );
123// ListView->setMinimumSize( QSize( 100, 25 ) );
124 ListView->addColumn( tr( "Name" ) );
125 ListView->setColumnWidth(0,120);
126 ListView->setSorting( 2, FALSE);
127 ListView->addColumn( tr( "Size" ) );
128 ListView->setColumnWidth(1,-1);
129 ListView->addColumn( "Date",-1);
130
131 ListView->setColumnWidthMode(0,QListView::Manual);
132 ListView->setColumnAlignment(1,QListView::AlignRight);
133 ListView->setColumnAlignment(2,QListView::AlignRight);
134 ListView->setAllColumnsShowFocus( TRUE );
135
136 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
137 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
138 this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
139
140 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
141
142 FileStack->addWidget( ListView, get_unique_id() );
143mimeType="text/plain";
144 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
145// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
146// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
147 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
148 this, SLOT( docOpen( const DocLnk & ) ) );
149 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
150
151 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
152 SelectionCombo->insertItem( tr( "Documents" ) );
153 SelectionCombo->insertItem( tr( "All files" ) );
154 SelectionCombo->insertItem( tr( "Hidden files" ) );
155// SelectionCombo->setMaximumWidth(120);
156 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 );
157
158 connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
159 this, SLOT( selectionChanged( const QString & ) ) );
160
161 typemb = new MenuButton(this);
162 typemb->setLabel(tr("Type: %1"));
163 typemb->setMinimumWidth(110);
164 typemb->setFixedHeight(22);
165 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 );
166 updateMimeTypeMenu() ;
167
168 currentDir.setPath(QDir::currentDirPath());
169 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
170 currentDir.setNameFilter(filterStr);
171
172 populateList();
173 move(0,15);
174}
175
176fileBrowser::~fileBrowser()
177{
178}
179
180void fileBrowser::setFileView( int selection )
181{
182 SelectionCombo->setCurrentItem( selection );
183 selectionChanged( SelectionCombo->currentText() );
184}
185
186void fileBrowser::populateList()
187{
188 ListView->clear();
189 QListViewItem * item;
190 bool isDir=FALSE;
191//qDebug(currentDir.canonicalPath());
192 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
193 currentDir.setMatchAllDirs(TRUE);
194
195// currentDir.setNameFilter("*.txt;*.etx");
196 QString fileL, fileS, fileDate;
197 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
198 QFileInfoListIterator it(*list);
199 QFileInfo *fi;
200 while ( (fi=it.current()) ) {
201 if (fi->isSymLink() ){
202 QString symLink=fi->readLink();
203// qDebug("Symlink detected "+symLink);
204 QFileInfo sym( symLink);
205 fileS.sprintf( "%10li", sym.size() );
206 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
207 fileDate = sym.lastModified().toString();
208 } else {
209// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
210 fileS.sprintf( "%10li", fi->size() );
211 fileL.sprintf( "%s",fi->fileName().data() );
212 fileDate= fi->lastModified().toString();
213 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
214 fileL+="/";
215 isDir=TRUE;
216// qDebug( fileL);
217 }
218 }
219 if(fileL !="./" && fi->exists()) {
220 item= new QListViewItem( ListView,fileL,fileS , fileDate);
221 QPixmap pm;
222
223 if(isDir || fileL.find("/",0,TRUE) != -1) {
224 if( !QDir( fi->filePath() ).isReadable())
225 pm = Resource::loadPixmap( "lockedfolder" );
226 else
227 pm= Resource::loadPixmap( "folder" );
228 item->setPixmap( 0,pm );
229 } else {
230 if( !fi->isReadable() )
231 pm = Resource::loadPixmap( "locked" );
232 else {
233 MimeType mt(fi->filePath());
234 pm=mt.pixmap();// sets the pixmap for the mimetype
235 if(pm.isNull())
236 pm = Resource::loadPixmap( "UnknownDocument-14" );
237 item->setPixmap( 0,pm);
238 }
239 }
240 if( fileL.find("->",0,TRUE) != -1) {
241 // overlay link image
242 pm= Resource::loadPixmap( "folder" );
243 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
244 QPainter painter( &pm );
245 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
246 pm.setMask( pm.createHeuristicMask( FALSE ) );
247 item->setPixmap( 0, pm);
248 }
249 }
250 isDir=FALSE;
251 ++it;
252// }
253 }
254 ListView->setSorting( 3, FALSE);
255 QString currentPath = currentDir.canonicalPath();
256
257 fillCombo( (const QString &)currentPath);
258// dirPathCombo->lineEdit()->setText(currentPath);
259
260// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
261// dirPathCombo->clear();
262// dirPathStringList.prepend(currentPath );
263// dirPathCombo->insertStringList( dirPathStringList,-1);
264// }
265}
266
267void fileBrowser::upDir()
268{
269 QString current = currentDir.canonicalPath();
270 QDir dir(current);
271 dir.cdUp();
272 current = dir.canonicalPath();
273 chdir( current.latin1() );
274 currentDir.cd( current, TRUE);
275 populateList();
276 update();
277}
278
279// you may want to switch these 2 functions. I like single clicks
280void fileBrowser::listClicked(QListViewItem *selectedItem)
281{
282 if(selectedItem) {
283 QString strItem=selectedItem->text(0);
284 QString strSize=selectedItem->text(1);
285// qDebug("strItem is "+strItem);
286 strSize.stripWhiteSpace();
287// qDebug(strSize);
288
289 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
290 // is symlink
291 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
292// qDebug("strItem symlink is "+strItem2);
293 if(QDir(strItem2).exists() ) {
294 currentDir.cd(strItem2, TRUE);
295 populateList();
296 }
297 } else { // not a symlink
298 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
299 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
300 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
301 currentDir.cd(strItem,FALSE);
302// qDebug("Path is "+strItem);
303 populateList();
304 } else {
305 currentDir.cdUp();
306 populateList();
307 }
308 if(QDir(strItem).exists()){
309 currentDir.cd(strItem, TRUE);
310 populateList();
311 }
312 } else {
313 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
314 if( QFile::exists(strItem ) ) {
315//currentDir.canonicalPath()
316 qDebug("We found our files!!"+strItem);
317 OnOK();
318 }
319 } //end not symlink
320 chdir(strItem.latin1());
321 }
322 }
323}
324
325void fileBrowser::OnOK()
326{
327 QListViewItemIterator it1( ListView);
328 for ( ; it1.current(); ++it1 ) {
329 if ( it1.current()->isSelected() ) {
330 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
331 qDebug("selected filename is "+selectedFileName);
332 fileList.append( selectedFileName );
333 }
334 }
335 accept();
336}
337
338void fileBrowser::homeButtonPushed() {
339 QString current = QDir::homeDirPath();
340 chdir( current.latin1() );
341 currentDir.cd( current, TRUE);
342 populateList();
343 update();
344}
345
346void fileBrowser::docButtonPushed() {
347 QString current = QPEApplication::documentDir();
348 chdir( current.latin1() );
349 currentDir.cd( current, TRUE);
350 populateList();
351 update();
352
353}
354
355void fileBrowser::selectionChanged( const QString &select )
356{
357 if ( select == "Documents") {
358 FileStack->raiseWidget( fileSelector );
359 dirPathCombo->hide();
360 cdUpButton->hide();
361 docButton->hide();
362 homeButton->hide();
363 } else {
364 if ( select == "All files" )
365 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All);
366 else
367 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
368
369 populateList();
370 update();
371 dirPathCombo->show();
372 cdUpButton->show();
373 docButton->show();
374 homeButton->show();
375 FileStack->raiseWidget( ListView );
376 }
377}
378
379void fileBrowser::docOpen( const DocLnk &doc )
380{
381 fileList.append( doc.file().latin1() );
382 accept();
383}
384
385void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
386{
387 switch (mouse) {
388 case 1:
389 break;
390 case 2:
391 showListMenu(item);
392 break;
393 };
394}
395
396void fileBrowser::showListMenu(QListViewItem *item) {
397
398 QPopupMenu m;// = new QPopupMenu( Local_View );
399 if(item) {
400 if( item->text(0).find("/",0,TRUE))
401 m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() ));
402 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() ));
403 m.insertItem( tr( "Rescan" ), this, SLOT( populateList() ));
404 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
405 m.insertSeparator();
406 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
407 } else {
408 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() ));
409 m.insertItem( tr( "Rescan" ), this, SLOT( populateList() ));
410
411 }
412 m.exec( QCursor::pos() );
413}
414
415void fileBrowser::doCd() {
416 listClicked( ListView->currentItem());
417}
418
419void fileBrowser::makDir() {
420 InputDialog *fileDlg;
421 fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
422 fileDlg->exec();
423 if( fileDlg->result() == 1 ) {
424 QString filename = fileDlg->LineEdit1->text();
425 qDebug("Make dir");
426 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
427 }
428 populateList();
429}
430
431void fileBrowser::localRename() {
432 QString curFile = ListView->currentItem()->text(0);
433 InputDialog *fileDlg;
434 fileDlg = new InputDialog(this,"Rename",TRUE, 0);
435 fileDlg->setTextEdit((const QString &) curFile);
436 fileDlg->exec();
437 if( fileDlg->result() == 1 ) {
438 QString oldname = currentDir.canonicalPath() + "/" + curFile;
439 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
440 if( rename(oldname.latin1(), newName.latin1())== -1)
441 QMessageBox::message("Note","Could not rename");
442 }
443 populateList();
444}
445
446void fileBrowser::localDelete() {
447 QString f = ListView->currentItem()->text(0);
448 if(QDir(f).exists() ) {
449 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+
450 " ?\nIt must be empty","Yes","No",0,0,1) ) {
451 case 0: {
452 f=currentDir.canonicalPath()+"/"+f;
453 QString cmd="rmdir "+f;
454 system( cmd.latin1());
455 populateList();
456 }
457 break;
458 case 1:
459 // exit
460 break;
461 };
462 } else {
463 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f
464 +" ?","Yes","No",0,0,1) ) {
465 case 0: {
466 f=currentDir.canonicalPath()+"/"+f;
467 QString cmd="rm "+f;
468 system( cmd.latin1());
469 populateList();
470 }
471 break;
472 case 1:
473 // exit
474 break;
475 };
476 }
477}
478
479void fileBrowser::updateMimeTypeMenu() {
480
481 disconnect( typemb, SIGNAL(selected(const QString&)),
482 this, SLOT(showType(const QString&)) );
483
484 QString prev;
485
486 // Type filter
487 QStringList types;
488 types << tr("All");
489 types << "--";
490 types += getMimeTypes();
491 prev = typemb->currentText();
492 typemb->clear();
493 typemb->insertItems(types);
494 // typemb->select(prev);
495
496 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
497}
498
499void fileBrowser::showType(const QString &t) {
500
501// qDebug("Show type "+t);
502 if(t.find("All",0,TRUE) != -1) {
503 filterStr = "*";
504 } else {
505 QStringList list = mimetypes.grep( t,TRUE);
506 QString ext;
507 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
508 mimeType =(*it);
509 MimeType mt(mimeType);
510
511// qDebug("mime "+mimeType);
512// qDebug("description "+mt.description());
513// qDebug( "id "+mt.id());
514// qDebug("extension "+mt.extension());
515
516 if( mt.extension().isEmpty())
517 filterStr = "*";
518 else
519 filterStr = "*."+ mt.extension()+" ";
520// printf( "%s \n", (*it).latin1() );
521 }
522 }
523 currentDir.setNameFilter(filterStr);
524
525 populateList();
526 update();
527// if(fileSelector) {
528// disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
529// delete fileSelector;
530 // }
531 // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
532// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
533// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
534 // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
535// fileSelector->reread();
536// if ( t == tr("All") ) {
537// icons->setTypeFilter("",TRUE);
538// } else {
539// icons->setTypeFilter(t+"/*",TRUE);
540// }
541
542}
543
544QStringList fileBrowser::getMimeTypes() {
545
546 QStringList r;
547 AppLnkSet apps( QPEApplication::qpeDir() + "apps" );
548 QFile file( QPEApplication::qpeDir()+"etc/available.mime");
549 file.open( IO_WriteOnly|IO_Truncate);//)
550 for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) {
551 AppLnk* l;
552 l = it.current();
553 QStringList maj = l->mimeTypes();
554 QStringList::ConstIterator f;
555 for ( f = maj.begin(); f != maj.end(); f++ ) {
556 QString temp = *f;
557 qDebug("type "+temp);
558 mimetypes << temp;
559 int sl = temp.find('/');
560 if (sl >= 0) {
561 QString k = temp;//.left(sl);
562 if( r.grep(k,TRUE).isEmpty() ) {
563 r << k;
564 k+="\n";
565 file.writeBlock( k.latin1(), k.length());
566 }
567 }
568 }
569 }
570 r.sort();
571 file.close();
572 return r;
573}
574
575void fileBrowser::receive( const QCString &msg, const QByteArray &data ) {
576// QDataStream stream( data, IO_ReadOnly );
577// if (msg == "keyRegister(int key, QString channel, QString message)")
578// {
579// int k;
580// QString c, m;
581// stream >> k;
582// stream >> c;
583// stream >> m;
584}
585
586void fileBrowser::dirPathComboActivated( const QString & current) {
587 chdir( current.latin1() );
588 currentDir.cd( current, TRUE);
589 populateList();
590 update();
591}
592
593void fileBrowser::dirPathEditPressed() {
594 QString current = dirPathCombo->lineEdit()->text();
595 chdir( current.latin1() );
596 currentDir.cd( current, TRUE);
597 populateList();
598 update();
599}
600
601void fileBrowser::fillCombo(const QString &currentPath) {
602
603 dirPathCombo->lineEdit()->setText(currentPath);
604
605 if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
606 dirPathCombo->clear();
607 dirPathStringList.prepend(currentPath );
608 dirPathCombo->insertStringList( dirPathStringList,-1);
609 }
610}
611
612
613InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
614 : QDialog( parent, name, modal, fl )
615{
616 if ( !name )
617 setName( "InputDialog" );
618 resize( 234, 50 );
619 setMaximumSize( QSize( 240, 50 ) );
620 setCaption( tr(name ) );
621
622 LineEdit1 = new QLineEdit( this, "LineEdit1" );
623 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
624}
625
626InputDialog::~InputDialog()
627{
628 inputText= LineEdit1->text();
629
630}
631
632void InputDialog::setTextEdit(const QString &string) {
633 LineEdit1->setText(string);
634}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
deleted file mode 100644
index 352cb51..0000000
--- a/core/apps/textedit/fileBrowser.h
+++ b/dev/null
@@ -1,120 +0,0 @@
1/****************************************************************************
2**
3** Created: Fri Dec 14 08:16:02 2001
4**
5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**
13copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com
14****************************************************************************/
15#ifndef FILEBROWSER_H
16#define FILEBROWSER_H
17
18//#include <qvariant.h>
19#include <qdialog.h>
20#include <qfile.h>
21#include <qdir.h>
22#include <qstringlist.h>
23#include <qlabel.h>
24#include <qstring.h>
25#include <qdict.h>
26
27#include <qpe/filemanager.h>
28
29#include <qvariant.h>
30#include <qdialog.h>
31#include <qregexp.h>
32
33
34class QLineEdit;
35class QVBoxLayout;
36class QHBoxLayout;
37class QGridLayout;
38class QListView;
39class QListViewItem;
40class QPushButton;
41class QComboBox;
42class QWidgetStack;
43class FileSelector;
44class QPoint;
45class MenuButton;
46
47
48class fileBrowser : public QDialog
49{
50 Q_OBJECT
51
52public:
53 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
54 ~fileBrowser();
55
56 QString selectedFileName;
57 QFile file;
58 QStringList fileList;
59 QComboBox *SelectionCombo;
60public slots:
61 void setFileView( int );
62
63private:
64// QDict<void> mimes;
65 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton;
66 QListView* ListView;
67 QLabel *dirLabel;
68 QString filterStr, mimeType;
69 QDir currentDir;
70 QStringList dirPathStringList, mimetypes;
71/* QListViewItem * item; */
72 QComboBox *dirPathCombo;
73 MenuButton *typemb;
74 QWidgetStack *FileStack;
75 FileSelector *fileSelector;
76 QRegExp tf;
77 QStringList getMimeTypes();
78 void fillCombo( const QString&);
79
80private slots:
81 void populateList();
82 void homeButtonPushed();
83 void docButtonPushed();
84 void ListPressed( int, QListViewItem *, const QPoint&, int);
85 void showListMenu(QListViewItem*);
86 void doCd();
87 void makDir();
88 void localRename();
89 void localDelete();
90 void receive( const QCString &msg, const QByteArray &data );
91 void dirPathComboActivated( const QString & );
92 void upDir();
93 void listClicked( QListViewItem * );
94 void selectionChanged( const QString & );
95 void OnOK();
96 void docOpen( const DocLnk & );
97 void updateMimeTypeMenu();
98 void showType(const QString &);
99 void dirPathEditPressed();
100
101protected slots:
102
103protected:
104
105};
106
107
108class InputDialog : public QDialog
109{
110 Q_OBJECT
111
112public:
113 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
114 ~InputDialog();
115 QString inputText;
116 QLineEdit* LineEdit1;
117 void setTextEdit(const QString &);
118};
119
120#endif // FILEBROWSER_H
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
deleted file mode 100644
index 209a258..0000000
--- a/core/apps/textedit/fileSaver.cpp
+++ b/dev/null
@@ -1,271 +0,0 @@
1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp
4**
5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**
13****************************************************************************/
14#include "fileSaver.h"
15#include <qpe/config.h>
16#include <qpe/resource.h>
17#include <qpe/mimetype.h>
18
19#include <qpe/qpeapplication.h>
20#include <qlistview.h>
21#include <qpushbutton.h>
22#include <qfile.h>
23#include <qmessagebox.h>
24#include <qlineedit.h>
25#include <qcheckbox.h>
26
27#include <unistd.h>
28
29fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName )
30 : QDialog( parent, name, modal, fl )
31{
32 if ( !name )
33 setName( tr("fileSaver"));
34 resize( 240, 280 );
35 setCaption(tr( name ) );
36 QFileInfo fi(currentFileName);
37 QString tmpFileName=fi.fileName();
38// qDebug( tmpFileName);
39 dirLabel = new QLabel(this, "DirLabel");
40 dirLabel->setText(currentDir.canonicalPath());
41 dirLabel->setGeometry(10,20,230,15);
42
43 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
44 homeButton->setGeometry(200,4,25,25);
45 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
46 homeButton->setFlat(TRUE);
47
48 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
49 docButton->setGeometry(170,4,25,25);
50 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
51
52 docButton->setFlat(TRUE);
53
54 hideButton = new QPushButton( Resource::loadIconSet("textedit/s_hidden"),"",this,"hideButton");
55 hideButton->setGeometry(140,4,25,25);
56 connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) );
57 hideButton->setToggleButton(TRUE);
58 hideButton->setFlat(TRUE);
59
60 ListView = new QListView( this, "ListView" );
61 ListView->addColumn( tr( "Name" ) );
62 ListView->setColumnWidth(0,120);
63 ListView->setSorting( 2, FALSE);
64 ListView->addColumn( tr( "Size" ) );
65 ListView->setColumnWidth(1,-1);
66 ListView->addColumn( tr("Date"),-1);
67
68 ListView->setColumnWidthMode(0,QListView::Manual);
69 ListView->setColumnAlignment(1,QListView::AlignRight);
70// ListView->setMultiSelection(true);
71// ListView->setSelectionMode(QListView::Extended);
72
73 ListView->setAllColumnsShowFocus( TRUE );
74 ListView->setGeometry( QRect( 10,35,220,125));
75
76 fileEdit= new QLineEdit(this);
77 fileEdit->setGeometry( QRect( 10, 162, 205, 17));
78
79 fileEdit->setText( tmpFileName);
80
81 filePermCheck = new QCheckBox( this, "SetFilePerms" );
82 filePermCheck->setText(tr("set file permissions"));
83 filePermCheck->setGeometry(10, 178, 150,17);
84 // signals and slots connections
85 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
86 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
87
88// tmpFileName=fi.FilePath();
89// qDebug( tmpFileName);
90 currentDir.setPath( QDir::currentDirPath() );
91 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
92 populateList();
93 move(0,15);
94 fileEdit->setFocus();
95}
96
97fileSaver::~fileSaver()
98{
99}
100
101void fileSaver::populateList()
102{
103 ListView->clear();
104 bool isDir=FALSE;
105 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
106 currentDir.setMatchAllDirs(TRUE);
107
108 currentDir.setNameFilter("*");
109 QString fileL, fileS, fileDate;
110 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
111 QFileInfoListIterator it(*list);
112 QFileInfo *fi;
113 while ( (fi=it.current()) ) {
114
115 if (fi->isSymLink() ){
116 QString symLink=fi->readLink();
117// qDebug("Symlink detected "+symLink);
118 QFileInfo sym( symLink);
119 fileS.sprintf( "%10li", sym.size() );
120 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
121
122 } else {
123// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
124 fileS.sprintf( "%10li", fi->size() );
125 fileL.sprintf( "%s",fi->fileName().data() );
126 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
127 fileL+="/";
128 isDir=TRUE;
129// qDebug(currentDir.canonicalPath()+fileL);
130 }
131 }
132 if(fileL !="./") {
133 item= new QListViewItem( ListView,fileL,fileS , fileDate);
134 QPixmap pm;
135
136 if(isDir || fileL.find("/",0,TRUE) != -1) {
137 if( !QDir( fi->filePath() ).isReadable())
138 pm = Resource::loadPixmap( "lockedfolder" );
139 else
140 pm= Resource::loadPixmap( "folder" );
141 item->setPixmap( 0,pm );
142 } else {
143 if( !fi->isReadable() )
144 pm = Resource::loadPixmap( "locked" );
145 else {
146 MimeType mt(fi->filePath());
147 pm=mt.pixmap();
148 if(pm.isNull())
149 pm = Resource::loadPixmap( "UnknownDocument-14" );
150 item->setPixmap( 0,pm);
151 }
152 }
153 if( fileL.find("->",0,TRUE) != -1) {
154 // overlay link image
155 pm= Resource::loadPixmap( "folder" );
156 QPixmap lnk = Resource::loadPixmap( "symlink" );
157 QPainter painter( &pm );
158 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
159 pm.setMask( pm.createHeuristicMask( FALSE ) );
160 item->setPixmap( 0, pm);
161 }
162 }
163 isDir=FALSE;
164 ++it;
165 }
166 ListView->setSorting( 2, FALSE);
167 dirLabel->setText(currentDir.canonicalPath());
168
169
170}
171
172void fileSaver::upDir()
173{
174// qDebug(currentDir.canonicalPath());
175}
176
177void fileSaver::listDoubleClicked(QListViewItem *selectedItem)
178{
179}
180
181void fileSaver::listClicked(QListViewItem *selectedItem)
182{
183 if(selectedItem != NULL) {
184 QString strItem=selectedItem->text(0);
185 QString strSize=selectedItem->text(1);
186// qDebug("strItem is "+strItem);
187 strSize.stripWhiteSpace();
188// qDebug(strSize);
189
190 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
191 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
192// qDebug("strItem symlink is "+strItem2);
193 if(QDir(strItem2).exists() ) {
194 currentDir.cd(strItem2, TRUE);
195 populateList();
196 }
197 } else { // not a symlink
198 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
199 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
200 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
201 currentDir.cd(strItem,FALSE);
202// qDebug("Path is "+strItem);
203 populateList();
204 } else {
205 currentDir.cdUp();
206 populateList();
207 }
208 if(QDir(strItem).exists()){
209 currentDir.cd(strItem, TRUE);
210 populateList();
211 }
212 } // else
213// if( QFile::exists(strItem ) ) {
214// qDebug("We found our files!!");
215
216// OnOK();
217 } //end not symlink
218 chdir(strItem.latin1());
219
220 }
221}
222
223
224void fileSaver::closeEvent( QCloseEvent *e )
225{
226 if(e->isAccepted()) {
227 e->accept();
228 } else {
229 qDebug("not accepted");
230 done(-1);
231 }
232}
233
234void fileSaver::accept() {
235 selectedFileName = fileEdit->text();
236 QString path = currentDir.canonicalPath()+"/" + selectedFileName;
237 if( path.find("//",0,TRUE) ==-1 ) {
238 selectedFileName = path;
239 } else {
240 selectedFileName = currentDir.canonicalPath()+selectedFileName;
241 }
242 qDebug("going to save "+selectedFileName);
243 done(1);
244}
245
246void fileSaver::homeButtonPushed() {
247 chdir( QDir::homeDirPath().latin1() );
248 currentDir.cd( QDir::homeDirPath(), TRUE);
249 populateList();
250 update();
251}
252void fileSaver::docButtonPushed() {
253 chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
254 currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
255 populateList();
256 update();
257
258}
259
260void fileSaver::hideButtonPushed(bool b) {
261 if (b)
262 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
263 else
264 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
265
266// chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
267// currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
268 populateList();
269 update();
270
271}
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h
deleted file mode 100644
index 195a775..0000000
--- a/core/apps/textedit/fileSaver.h
+++ b/dev/null
@@ -1,75 +0,0 @@
1/****************************************************************************
2**
3** Created: Fri Dec 14 08:16:02 2001 fileSaver.h
4**
5copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com
6
7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15****************************************************************************/
16#ifndef FILESAVER_H
17#define FILESAVER_H
18
19//#include <qvariant.h>
20#include <qdialog.h>
21#include <qfile.h>
22#include <qdir.h>
23#include <qstringlist.h>
24#include <qlabel.h>
25#include <qstring.h>
26
27class QVBoxLayout;
28class QHBoxLayout;
29class QGridLayout;
30class QListView;
31class QListViewItem;
32class QPushButton;
33class QLineEdit;
34class QCheckBox;
35
36class fileSaver : public QDialog
37{
38 Q_OBJECT
39
40public:
41 void populateList();
42 fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
43 ~fileSaver();
44 QLineEdit *fileEdit;
45
46 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton;
47 QListView* ListView;
48 QLabel *dirLabel;
49 QString selectedFileName, filterStr;
50 QDir currentDir;
51 QFile file;
52 QStringList fileList;
53 QCheckBox *filePermCheck;
54
55QListViewItem * item;
56public slots:
57 void homeButtonPushed();
58 void docButtonPushed();
59 void hideButtonPushed(bool);
60private:
61
62private slots:
63 void accept();
64 void upDir();
65 void listDoubleClicked(QListViewItem *);
66 void listClicked(QListViewItem *);
67 void closeEvent( QCloseEvent * );
68
69protected slots:
70
71protected:
72
73};
74
75#endif // FILESAVER_H
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 40ea501..b276cbb 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,407 +1,406 @@
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 "fileSaver.h"
24#include "filePermissions.h" 23#include "filePermissions.h"
25#include "fontDialog.h" 24#include "fontDialog.h"
26 25
27#include <opie/ofileselector.h> 26#include <opie/ofileselector.h>
28#include <opie/ofiledialog.h> 27#include <opie/ofiledialog.h>
29 28
30#include <qpe/fontdatabase.h> 29#include <qpe/fontdatabase.h>
31#include <qpe/global.h> 30#include <qpe/global.h>
32#include <qpe/fileselector.h> 31#include <qpe/fileselector.h>
33#include <qpe/applnk.h> 32#include <qpe/applnk.h>
34#include <qpe/resource.h> 33#include <qpe/resource.h>
35#include <qpe/config.h> 34#include <qpe/config.h>
36#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
37#include <qpe/qpemenubar.h> 36#include <qpe/qpemenubar.h>
38#include <qpe/qpetoolbar.h> 37#include <qpe/qpetoolbar.h>
39#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
40 39
41#include <qstringlist.h> 40#include <qstringlist.h>
42#include <qaction.h> 41#include <qaction.h>
43#include <qcolordialog.h> 42#include <qcolordialog.h>
44#include <qfileinfo.h> 43#include <qfileinfo.h>
45#include <qlineedit.h> 44#include <qlineedit.h>
46#include <qmessagebox.h> 45#include <qmessagebox.h>
47#include <qobjectlist.h> 46#include <qobjectlist.h>
48#include <qpopupmenu.h> 47#include <qpopupmenu.h>
49#include <qspinbox.h> 48#include <qspinbox.h>
50#include <qtoolbutton.h> 49#include <qtoolbutton.h>
51#include <qwidgetstack.h> 50#include <qwidgetstack.h>
52#include <qcheckbox.h> 51#include <qcheckbox.h>
53#include <qcombo.h> 52#include <qcombo.h>
54#include <unistd.h> 53#include <unistd.h>
55#include <sys/stat.h> 54#include <sys/stat.h>
56 55
57#include <stdlib.h> //getenv 56#include <stdlib.h> //getenv
58/* XPM */ 57/* XPM */
59static char * filesave_xpm[] = { 58static char * filesave_xpm[] = {
60"16 16 78 1", 59"16 16 78 1",
61" c None", 60" c None",
62". c #343434", 61". c #343434",
63"+ c #A0A0A0", 62"+ c #A0A0A0",
64"@ c #565656", 63"@ c #565656",
65"# c #9E9E9E", 64"# c #9E9E9E",
66"$ c #525252", 65"$ c #525252",
67"% c #929292", 66"% c #929292",
68"& c #676767", 67"& c #676767",
69"* c #848484", 68"* c #848484",
70"= c #666666", 69"= c #666666",
71"- c #D8D8D8", 70"- c #D8D8D8",
72"; c #FFFFFF", 71"; c #FFFFFF",
73"> c #DBDBDB", 72"> c #DBDBDB",
74", c #636363", 73", c #636363",
75"' c #989898", 74"' c #989898",
76") c #2D2D2D", 75") c #2D2D2D",
77"! c #909090", 76"! c #909090",
78"~ c #AEAEAE", 77"~ c #AEAEAE",
79"{ c #EAEAEA", 78"{ c #EAEAEA",
80"] c #575757", 79"] c #575757",
81"^ c #585858", 80"^ c #585858",
82"/ c #8A8A8A", 81"/ c #8A8A8A",
83"( c #828282", 82"( c #828282",
84"_ c #6F6F6F", 83"_ c #6F6F6F",
85": c #C9C9C9", 84": c #C9C9C9",
86"< c #050505", 85"< c #050505",
87"[ c #292929", 86"[ c #292929",
88"} c #777777", 87"} c #777777",
89"| c #616161", 88"| c #616161",
90"1 c #3A3A3A", 89"1 c #3A3A3A",
91"2 c #BEBEBE", 90"2 c #BEBEBE",
92"3 c #2C2C2C", 91"3 c #2C2C2C",
93"4 c #7C7C7C", 92"4 c #7C7C7C",
94"5 c #F6F6F6", 93"5 c #F6F6F6",
95"6 c #FCFCFC", 94"6 c #FCFCFC",
96"7 c #6B6B6B", 95"7 c #6B6B6B",
97"8 c #959595", 96"8 c #959595",
98"9 c #4F4F4F", 97"9 c #4F4F4F",
99"0 c #808080", 98"0 c #808080",
100"a c #767676", 99"a c #767676",
101"b c #818181", 100"b c #818181",
102"c c #B8B8B8", 101"c c #B8B8B8",
103"d c #FBFBFB", 102"d c #FBFBFB",
104"e c #F9F9F9", 103"e c #F9F9F9",
105"f c #CCCCCC", 104"f c #CCCCCC",
106"g c #030303", 105"g c #030303",
107"h c #737373", 106"h c #737373",
108"i c #7A7A7A", 107"i c #7A7A7A",
109"j c #7E7E7E", 108"j c #7E7E7E",
110"k c #6A6A6A", 109"k c #6A6A6A",
111"l c #FAFAFA", 110"l c #FAFAFA",
112"m c #505050", 111"m c #505050",
113"n c #9D9D9D", 112"n c #9D9D9D",
114"o c #333333", 113"o c #333333",
115"p c #7B7B7B", 114"p c #7B7B7B",
116"q c #787878", 115"q c #787878",
117"r c #696969", 116"r c #696969",
118"s c #494949", 117"s c #494949",
119"t c #555555", 118"t c #555555",
120"u c #949494", 119"u c #949494",
121"v c #E6E6E6", 120"v c #E6E6E6",
122"w c #424242", 121"w c #424242",
123"x c #515151", 122"x c #515151",
124"y c #535353", 123"y c #535353",
125"z c #3E3E3E", 124"z c #3E3E3E",
126"A c #D4D4D4", 125"A c #D4D4D4",
127"B c #0C0C0C", 126"B c #0C0C0C",
128"C c #353535", 127"C c #353535",
129"D c #474747", 128"D c #474747",
130"E c #ECECEC", 129"E c #ECECEC",
131"F c #919191", 130"F c #919191",
132"G c #7D7D7D", 131"G c #7D7D7D",
133"H c #000000", 132"H c #000000",
134"I c #404040", 133"I c #404040",
135"J c #858585", 134"J c #858585",
136"K c #323232", 135"K c #323232",
137"L c #D0D0D0", 136"L c #D0D0D0",
138"M c #1C1C1C", 137"M c #1C1C1C",
139" ...+ ", 138" ...+ ",
140" @#$%&..+ ", 139" @#$%&..+ ",
141" .*=-;;>,..+ ", 140" .*=-;;>,..+ ",
142" ')!~;;;;;;{]..", 141" ')!~;;;;;;{]..",
143" ^/(-;;;;;;;_:<", 142" ^/(-;;;;;;;_:<",
144" [}|;;;;;;;{12$", 143" [}|;;;;;;;{12$",
145" #34-55;;;;678$+", 144" #34-55;;;;678$+",
146" 90ab=c;dd;e1fg ", 145" 90ab=c;dd;e1fg ",
147" [ahij((kbl0mn$ ", 146" [ahij((kbl0mn$ ",
148" op^q^^7r&]s/$+ ", 147" op^q^^7r&]s/$+ ",
149"@btu;vbwxy]zAB ", 148"@btu;vbwxy]zAB ",
150"CzDEvEv;;DssF$ ", 149"CzDEvEv;;DssF$ ",
151"G.H{E{E{IxsJ$+ ", 150"G.H{E{E{IxsJ$+ ",
152" +...vEKxzLM ", 151" +...vEKxzLM ",
153" +...z]n$ ", 152" +...z]n$ ",
154" +... "}; 153" +... "};
155 154
156 155
157#if QT_VERSION < 300 156#if QT_VERSION < 300
158 157
159class QpeEditor : public QMultiLineEdit 158class QpeEditor : public QMultiLineEdit
160{ 159{
161 // Q_OBJECT 160 // Q_OBJECT
162public: 161public:
163 QpeEditor( QWidget *parent, const char * name = 0 ) 162 QpeEditor( QWidget *parent, const char * name = 0 )
164 : QMultiLineEdit( parent, name ) 163 : QMultiLineEdit( parent, name )
165 { 164 {
166 clearTableFlags(); 165 clearTableFlags();
167 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 166 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
168 } 167 }
169 168
170 void find( const QString &txt, bool caseSensitive, 169 void find( const QString &txt, bool caseSensitive,
171 bool backwards ); 170 bool backwards );
172//public slots: 171//public slots:
173 /* 172 /*
174signals: 173signals:
175 void notFound(); 174 void notFound();
176 void searchWrapped(); 175 void searchWrapped();
177 */ 176 */
178 177
179private: 178private:
180 179
181}; 180};
182 181
183 182
184void QpeEditor::find ( const QString &txt, bool caseSensitive, 183void QpeEditor::find ( const QString &txt, bool caseSensitive,
185 bool backwards ) 184 bool backwards )
186{ 185{
187 static bool wrap = FALSE; 186 static bool wrap = FALSE;
188 int line, col; 187 int line, col;
189 if ( wrap ) { 188 if ( wrap ) {
190 if ( !backwards ) 189 if ( !backwards )
191 line = col = 0; 190 line = col = 0;
192 wrap = FALSE; 191 wrap = FALSE;
193 // emit searchWrapped(); 192 // emit searchWrapped();
194 } else { 193 } else {
195 getCursorPosition( &line, &col ); 194 getCursorPosition( &line, &col );
196 } 195 }
197 //ignore backwards for now.... 196 //ignore backwards for now....
198 if ( !backwards ) { 197 if ( !backwards ) {
199 for ( ; ; ) { 198 for ( ; ; ) {
200 if ( line >= numLines() ) { 199 if ( line >= numLines() ) {
201 wrap = TRUE; 200 wrap = TRUE;
202 //emit notFound(); 201 //emit notFound();
203 break; 202 break;
204 } 203 }
205 int findCol = getString( line )->find( txt, col, caseSensitive ); 204 int findCol = getString( line )->find( txt, col, caseSensitive );
206 if ( findCol >= 0 ) { 205 if ( findCol >= 0 ) {
207 setCursorPosition( line, findCol, FALSE ); 206 setCursorPosition( line, findCol, FALSE );
208 col = findCol + txt.length(); 207 col = findCol + txt.length();
209 setCursorPosition( line, col, TRUE ); 208 setCursorPosition( line, col, TRUE );
210 209
211 //found = TRUE; 210 //found = TRUE;
212 break; 211 break;
213 } 212 }
214 line++; 213 line++;
215 col = 0; 214 col = 0;
216 } 215 }
217 216
218 } 217 }
219 218
220} 219}
221 220
222 221
223#else 222#else
224 223
225#error "Must make a QpeEditor that inherits QTextEdit" 224#error "Must make a QpeEditor that inherits QTextEdit"
226 225
227#endif 226#endif
228 227
229 228
230static const int nfontsizes = 6; 229static const int nfontsizes = 6;
231static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 230static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
232 231
233TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 232TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
234 : QMainWindow( parent, name, f ), bFromDocView( FALSE ) 233 : QMainWindow( parent, name, f ), bFromDocView( FALSE )
235{ 234{
236 doc = 0; 235 doc = 0;
237 edited=FALSE; 236 edited=FALSE;
238 edited1=FALSE; 237 edited1=FALSE;
239 setToolBarsMovable( FALSE ); 238 setToolBarsMovable( FALSE );
240 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 239 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
241 240
242 channel = new QCopChannel( "QPE/Application/textedit", this ); 241 channel = new QCopChannel( "QPE/Application/textedit", this );
243 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 242 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
244 this, SLOT(receive(const QCString&, const QByteArray&)) ); 243 this, SLOT(receive(const QCString&, const QByteArray&)) );
245 244
246 setIcon( Resource::loadPixmap( "TextEditor" ) ); 245 setIcon( Resource::loadPixmap( "TextEditor" ) );
247 246
248 QPEToolBar *bar = new QPEToolBar( this ); 247 QPEToolBar *bar = new QPEToolBar( this );
249 bar->setHorizontalStretchable( TRUE ); 248 bar->setHorizontalStretchable( TRUE );
250 menu = bar; 249 menu = bar;
251 250
252 QPEMenuBar *mb = new QPEMenuBar( bar ); 251 QPEMenuBar *mb = new QPEMenuBar( bar );
253 QPopupMenu *file = new QPopupMenu( this ); 252 QPopupMenu *file = new QPopupMenu( this );
254 QPopupMenu *edit = new QPopupMenu( this ); 253 QPopupMenu *edit = new QPopupMenu( this );
255 font = new QPopupMenu( this ); 254 font = new QPopupMenu( this );
256 255
257 bar = new QPEToolBar( this ); 256 bar = new QPEToolBar( this );
258 editBar = bar; 257 editBar = bar;
259 258
260 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 259 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
261 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 260 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
262 a->addTo( bar ); 261 a->addTo( bar );
263 a->addTo( file ); 262 a->addTo( file );
264 263
265 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 264 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
266 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 265 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
267 a->addTo( bar ); 266 a->addTo( bar );
268 a->addTo( file ); 267 a->addTo( file );
269 268
270 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 269 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
271 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 270 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
272 file->insertSeparator(); 271 file->insertSeparator();
273 a->addTo( file ); 272 a->addTo( file );
274 273
275 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 274 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
276 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 275 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
277 a->addTo( file ); 276 a->addTo( file );
278 277
279 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 278 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
280 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 279 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
281 a->addTo( editBar ); 280 a->addTo( editBar );
282 a->addTo( edit ); 281 a->addTo( edit );
283 282
284 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 283 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
285 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 284 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
286 a->addTo( editBar ); 285 a->addTo( editBar );
287 a->addTo( edit ); 286 a->addTo( edit );
288 287
289 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 288 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
290 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 289 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
291 a->addTo( editBar ); 290 a->addTo( editBar );
292 a->addTo( edit ); 291 a->addTo( edit );
293 292
294 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 293 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
295 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 294 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
296 edit->insertSeparator(); 295 edit->insertSeparator();
297 a->addTo( bar ); 296 a->addTo( bar );
298 a->addTo( edit ); 297 a->addTo( edit );
299 298
300 int defsize; 299 int defsize;
301 bool defb, defi, wrap; 300 bool defb, defi, wrap;
302 301
303 Config cfg("TextEdit"); 302 Config cfg("TextEdit");
304 cfg.setGroup("View"); 303 cfg.setGroup("View");
305 defsize = cfg.readNumEntry("FontSize",10); 304 defsize = cfg.readNumEntry("FontSize",10);
306 defb = cfg.readBoolEntry("Bold",FALSE); 305 defb = cfg.readBoolEntry("Bold",FALSE);
307 defi = cfg.readBoolEntry("Italic",FALSE); 306 defi = cfg.readBoolEntry("Italic",FALSE);
308 wrap = cfg.readBoolEntry("Wrap",TRUE); 307 wrap = cfg.readBoolEntry("Wrap",TRUE);
309 308
310 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 309 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
311 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 310 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
312 zin->addTo( font ); 311 zin->addTo( font );
313 312
314 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 313 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
315 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 314 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
316 zout->addTo( font ); 315 zout->addTo( font );
317 316
318 font->insertSeparator(); 317 font->insertSeparator();
319 318
320#if 0 319#if 0
321 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); 320 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 );
322 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); 321 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) );
323 ba->setToggleAction(TRUE); 322 ba->setToggleAction(TRUE);
324 ba->addTo( font ); 323 ba->addTo( font );
325 324
326 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); 325 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 );
327 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); 326 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) );
328 ia->setToggleAction(TRUE); 327 ia->setToggleAction(TRUE);
329 ia->addTo( font ); 328 ia->addTo( font );
330 329
331 ba->setOn(defb); 330 ba->setOn(defb);
332 ia->setOn(defi); 331 ia->setOn(defi);
333 332
334 font->insertSeparator(); 333 font->insertSeparator();
335#endif 334#endif
336 335
337 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); 336 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
338 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 337 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
339 wa->setToggleAction(TRUE); 338 wa->setToggleAction(TRUE);
340 wa->addTo( font ); 339 wa->addTo( font );
341 340
342 font->insertSeparator(); 341 font->insertSeparator();
343 font->insertItem(tr("Font"), this, SLOT(changeFont()) ); 342 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
344 343
345 font->insertSeparator(); 344 font->insertSeparator();
346 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); 345 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 );
347 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 346 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
348 nStart->setToggleAction(TRUE); 347 nStart->setToggleAction(TRUE);
349 nStart->addTo( font ); 348 nStart->addTo( font );
350 font->insertSeparator(); 349 font->insertSeparator();
351 font->insertItem(tr("About"), this, SLOT( doAbout()) ); 350 font->insertItem(tr("About"), this, SLOT( doAbout()) );
352 351
353 mb->insertItem( tr( "File" ), file ); 352 mb->insertItem( tr( "File" ), file );
354 mb->insertItem( tr( "Edit" ), edit ); 353 mb->insertItem( tr( "Edit" ), edit );
355 mb->insertItem( tr( "View" ), font ); 354 mb->insertItem( tr( "View" ), font );
356 355
357 searchBar = new QPEToolBar(this); 356 searchBar = new QPEToolBar(this);
358 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 357 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
359 358
360 searchBar->setHorizontalStretchable( TRUE ); 359 searchBar->setHorizontalStretchable( TRUE );
361 360
362 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 361 searchEdit = new QLineEdit( searchBar, "searchEdit" );
363 searchBar->setStretchableWidget( searchEdit ); 362 searchBar->setStretchableWidget( searchEdit );
364 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 363 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
365 this, SLOT( search() ) ); 364 this, SLOT( search() ) );
366 365
367 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 366 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
368 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 367 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
369 a->addTo( searchBar ); 368 a->addTo( searchBar );
370 a->addTo( edit ); 369 a->addTo( edit );
371 370
372 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 371 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
373 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 372 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
374 a->addTo( searchBar ); 373 a->addTo( searchBar );
375 374
376 edit->insertSeparator(); 375 edit->insertSeparator();
377 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 376 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
378 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 377 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
379 a->addTo( edit ); 378 a->addTo( edit );
380 379
381 searchBar->hide(); 380 searchBar->hide();
382 381
383 editor = new QpeEditor( this ); 382 editor = new QpeEditor( this );
384 setCentralWidget( editor ); 383 setCentralWidget( editor );
385 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 384 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
386 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 385 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
387 386
388// resize( 200, 300 ); 387// resize( 200, 300 );
389 388
390// setFontSize(defsize,TRUE); 389// setFontSize(defsize,TRUE);
391 FontDatabase fdb; 390 FontDatabase fdb;
392 QFont defaultFont=editor->font(); 391 QFont defaultFont=editor->font();
393 QFontInfo fontInfo(defaultFont); 392 QFontInfo fontInfo(defaultFont);
394 393
395 cfg.setGroup("Font"); 394 cfg.setGroup("Font");
396 QString family = cfg.readEntry("Family", fontInfo.family()); 395 QString family = cfg.readEntry("Family", fontInfo.family());
397 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 396 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
398 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 397 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
399 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 398 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
400 399
401 defaultFont = fdb.font(family,style,i_size,charSet); 400 defaultFont = fdb.font(family,style,i_size,charSet);
402 editor->setFont( defaultFont); 401 editor->setFont( defaultFont);
403 402
404 wa->setOn(wrap); 403 wa->setOn(wrap);
405 updateCaption(); 404 updateCaption();
406 405
407 cfg.setGroup("View"); 406 cfg.setGroup("View");
@@ -411,569 +410,559 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
411 } else { 410 } else {
412 fileOpen(); 411 fileOpen();
413 } 412 }
414 413
415 viewSelection = cfg.readNumEntry( "FileView", 0 ); 414 viewSelection = cfg.readNumEntry( "FileView", 0 );
416} 415}
417 416
418void TextEdit::cleanUp() 417void TextEdit::cleanUp()
419{ 418{
420// save(); 419// save();
421 Config cfg("TextEdit"); 420 Config cfg("TextEdit");
422 cfg.setGroup("View"); 421 cfg.setGroup("View");
423 QFont f = editor->font(); 422 QFont f = editor->font();
424 cfg.writeEntry("FontSize",f.pointSize()); 423 cfg.writeEntry("FontSize",f.pointSize());
425 cfg.writeEntry("Bold",f.bold()); 424 cfg.writeEntry("Bold",f.bold());
426 cfg.writeEntry("Italic",f.italic()); 425 cfg.writeEntry("Italic",f.italic());
427 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 426 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
428 cfg.writeEntry( "FileView", viewSelection ); 427 cfg.writeEntry( "FileView", viewSelection );
429 428
430} 429}
431 430
432TextEdit::~TextEdit() 431TextEdit::~TextEdit()
433{ 432{
434} 433}
435 434
436void TextEdit::zoomIn() 435void TextEdit::zoomIn()
437{ 436{
438 setFontSize(editor->font().pointSize()+1,FALSE); 437 setFontSize(editor->font().pointSize()+1,FALSE);
439} 438}
440 439
441void TextEdit::zoomOut() 440void TextEdit::zoomOut()
442{ 441{
443 setFontSize(editor->font().pointSize()-1,TRUE); 442 setFontSize(editor->font().pointSize()-1,TRUE);
444} 443}
445 444
446 445
447void TextEdit::setFontSize(int sz, bool round_down_not_up) 446void TextEdit::setFontSize(int sz, bool round_down_not_up)
448{ 447{
449 int s=10; 448 int s=10;
450 for (int i=0; i<nfontsizes; i++) { 449 for (int i=0; i<nfontsizes; i++) {
451 if ( fontsize[i] == sz ) { 450 if ( fontsize[i] == sz ) {
452 s = sz; 451 s = sz;
453 break; 452 break;
454 } else if ( round_down_not_up ) { 453 } else if ( round_down_not_up ) {
455 if ( fontsize[i] < sz ) 454 if ( fontsize[i] < sz )
456 s = fontsize[i]; 455 s = fontsize[i];
457 } else { 456 } else {
458 if ( fontsize[i] > sz ) { 457 if ( fontsize[i] > sz ) {
459 s = fontsize[i]; 458 s = fontsize[i];
460 break; 459 break;
461 } 460 }
462 } 461 }
463 } 462 }
464 463
465 QFont f = editor->font(); 464 QFont f = editor->font();
466 f.setPointSize(s); 465 f.setPointSize(s);
467 editor->setFont(f); 466 editor->setFont(f);
468 467
469 zin->setEnabled(s != fontsize[nfontsizes-1]); 468 zin->setEnabled(s != fontsize[nfontsizes-1]);
470 zout->setEnabled(s != fontsize[0]); 469 zout->setEnabled(s != fontsize[0]);
471} 470}
472 471
473void TextEdit::setBold(bool y) 472void TextEdit::setBold(bool y)
474{ 473{
475 QFont f = editor->font(); 474 QFont f = editor->font();
476 f.setBold(y); 475 f.setBold(y);
477 editor->setFont(f); 476 editor->setFont(f);
478} 477}
479 478
480void TextEdit::setItalic(bool y) 479void TextEdit::setItalic(bool y)
481{ 480{
482 QFont f = editor->font(); 481 QFont f = editor->font();
483 f.setItalic(y); 482 f.setItalic(y);
484 editor->setFont(f); 483 editor->setFont(f);
485} 484}
486 485
487void TextEdit::setWordWrap(bool y) 486void TextEdit::setWordWrap(bool y)
488{ 487{
489 bool state = editor->edited(); 488 bool state = editor->edited();
490 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 489 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
491 editor->setEdited( state ); 490 editor->setEdited( state );
492} 491}
493 492
494void TextEdit::fileNew() 493void TextEdit::fileNew()
495{ 494{
496// if( !bFromDocView ) { 495// if( !bFromDocView ) {
497// saveAs(); 496// saveAs();
498// } 497// }
499 newFile(DocLnk()); 498 newFile(DocLnk());
500} 499}
501 500
502void TextEdit::fileOpen() 501void TextEdit::fileOpen()
503{ 502{
504 Config cfg("TextEdit"); 503 Config cfg("TextEdit");
505 cfg.setGroup("View"); 504 cfg.setGroup("View");
506 bool b=FALSE; 505 bool b=FALSE;
507 506
508 QMap<QString, QStringList> map; 507 QMap<QString, QStringList> map;
509 map.insert(tr("All"), QStringList() ); 508 map.insert(tr("All"), QStringList() );
510 QStringList text; 509 QStringList text;
511 text << "text/*"; 510 text << "text/*";
512 map.insert(tr("Text"), text ); 511 map.insert(tr("Text"), text );
513 text << "*"; 512 text << "*";
514 map.insert(tr("All"), text ); 513 map.insert(tr("All"), text );
515 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map); 514 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);
516 if(!str.isEmpty() ) 515 if(!str.isEmpty() )
517 openFile( str ); 516 openFile( str );
518 517
519} 518}
520 519
521void TextEdit::doSearchBar() 520void TextEdit::doSearchBar()
522{ 521{
523 Config cfg("TextEdit"); 522 Config cfg("TextEdit");
524 cfg.setGroup("View"); 523 cfg.setGroup("View");
525 if(cfg.readEntry("SearchBar","Closed") != "Opened") 524 if(cfg.readEntry("SearchBar","Closed") != "Opened")
526 searchBar->hide(); 525 searchBar->hide();
527} 526}
528 527
529#if 0 528#if 0
530void TextEdit::slotFind() 529void TextEdit::slotFind()
531{ 530{
532 FindDialog frmFind( tr("Text Editor"), this ); 531 FindDialog frmFind( tr("Text Editor"), this );
533 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 532 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
534 editor, SLOT(slotDoFind( const QString&,bool,bool))); 533 editor, SLOT(slotDoFind( const QString&,bool,bool)));
535 534
536 //case sensitive, backwards, [category] 535 //case sensitive, backwards, [category]
537 536
538 connect( editor, SIGNAL(notFound()), 537 connect( editor, SIGNAL(notFound()),
539 &frmFind, SLOT(slotNotFound()) ); 538 &frmFind, SLOT(slotNotFound()) );
540 connect( editor, SIGNAL(searchWrapped()), 539 connect( editor, SIGNAL(searchWrapped()),
541 &frmFind, SLOT(slotWrapAround()) ); 540 &frmFind, SLOT(slotWrapAround()) );
542 541
543 frmFind.exec(); 542 frmFind.exec();
544 543
545 544
546} 545}
547#endif 546#endif
548 547
549void TextEdit::fileRevert() 548void TextEdit::fileRevert()
550{ 549{
551 clear(); 550 clear();
552 fileOpen(); 551 fileOpen();
553} 552}
554 553
555void TextEdit::editCut() 554void TextEdit::editCut()
556{ 555{
557#ifndef QT_NO_CLIPBOARD 556#ifndef QT_NO_CLIPBOARD
558 editor->cut(); 557 editor->cut();
559#endif 558#endif
560} 559}
561 560
562void TextEdit::editCopy() 561void TextEdit::editCopy()
563{ 562{
564#ifndef QT_NO_CLIPBOARD 563#ifndef QT_NO_CLIPBOARD
565 editor->copy(); 564 editor->copy();
566#endif 565#endif
567} 566}
568 567
569void TextEdit::editPaste() 568void TextEdit::editPaste()
570{ 569{
571#ifndef QT_NO_CLIPBOARD 570#ifndef QT_NO_CLIPBOARD
572 editor->paste(); 571 editor->paste();
573#endif 572#endif
574} 573}
575 574
576void TextEdit::editFind() 575void TextEdit::editFind()
577{ 576{
578 searchBar->show(); 577 searchBar->show();
579 searchVisible = TRUE; 578 searchVisible = TRUE;
580 searchEdit->setFocus(); 579 searchEdit->setFocus();
581 Config cfg("TextEdit"); 580 Config cfg("TextEdit");
582 cfg.setGroup("View"); 581 cfg.setGroup("View");
583 cfg.writeEntry("SearchBar","Opened"); 582 cfg.writeEntry("SearchBar","Opened");
584 583
585} 584}
586 585
587void TextEdit::findNext() 586void TextEdit::findNext()
588{ 587{
589 editor->find( searchEdit->text(), FALSE, FALSE ); 588 editor->find( searchEdit->text(), FALSE, FALSE );
590 589
591} 590}
592 591
593void TextEdit::findClose() 592void TextEdit::findClose()
594{ 593{
595 searchVisible = FALSE; 594 searchVisible = FALSE;
596 searchBar->hide(); 595 searchBar->hide();
597 Config cfg("TextEdit"); 596 Config cfg("TextEdit");
598 cfg.setGroup("View"); 597 cfg.setGroup("View");
599 cfg.writeEntry("SearchBar","Closed"); 598 cfg.writeEntry("SearchBar","Closed");
600 cfg.write(); 599 cfg.write();
601} 600}
602 601
603void TextEdit::search() 602void TextEdit::search()
604{ 603{
605 editor->find( searchEdit->text(), FALSE, FALSE ); 604 editor->find( searchEdit->text(), FALSE, FALSE );
606} 605}
607 606
608void TextEdit::newFile( const DocLnk &f ) 607void TextEdit::newFile( const DocLnk &f )
609{ 608{
610 DocLnk nf = f; 609 DocLnk nf = f;
611 nf.setType("text/plain"); 610 nf.setType("text/plain");
612 clear(); 611 clear();
613 setWState (WState_Reserved1 ); 612 setWState (WState_Reserved1 );
614 editor->setFocus(); 613 editor->setFocus();
615 doc = new DocLnk(nf); 614 doc = new DocLnk(nf);
616 currentFileName = "Unnamed"; 615 currentFileName = "Unnamed";
617 qDebug("newFile "+currentFileName); 616 qDebug("newFile "+currentFileName);
618 updateCaption( currentFileName); 617 updateCaption( currentFileName);
619// editor->setEdited( FALSE); 618// editor->setEdited( FALSE);
620} 619}
621 620
622void TextEdit::openFile( const QString &f ) 621void TextEdit::openFile( const QString &f )
623{ 622{
624 qDebug("filename is "+ f); 623 qDebug("filename is "+ f);
625 QString filer; 624 QString filer;
626// bFromDocView = TRUE; 625// bFromDocView = TRUE;
627 if(f.find(".desktop",0,TRUE) != -1) { 626 if(f.find(".desktop",0,TRUE) != -1) {
628 switch ( QMessageBox::warning(this,tr("Text Editor"), 627 switch ( QMessageBox::warning(this,tr("Text Editor"),
629 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), 628 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"),
630 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 629 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
631 case 0: 630 case 0:
632 filer = f; 631 filer = f;
633 break; 632 break;
634 case 1: 633 case 1:
635 DocLnk sf(f); 634 DocLnk sf(f);
636 filer = sf.file(); 635 filer = sf.file();
637 break; 636 break;
638 } 637 }
639 } else { 638 } else {
640 filer = f; 639 filer = f;
641 fileIs = TRUE; 640 fileIs = TRUE;
642 } 641 }
643 642
644 DocLnk nf; 643 DocLnk nf;
645 nf.setType("text/plain"); 644 nf.setType("text/plain");
646 nf.setFile(filer); 645 nf.setFile(filer);
647 currentFileName=filer; 646 currentFileName=filer;
648 QFileInfo fi( currentFileName); 647 QFileInfo fi( currentFileName);
649 nf.setName(fi.baseName()); 648 nf.setName(fi.baseName());
650 qDebug("openFile string "+currentFileName); 649 qDebug("openFile string "+currentFileName);
651 650
652 openFile(nf); 651 openFile(nf);
653 showEditTools(); 652 showEditTools();
654 // Show filename in caption 653 // Show filename in caption
655 QString name = filer; 654 QString name = filer;
656 int sep = name.findRev( '/' ); 655 int sep = name.findRev( '/' );
657 if ( sep > 0 ) 656 if ( sep > 0 )
658 name = name.mid( sep+1 ); 657 name = name.mid( sep+1 );
659 updateCaption( name ); 658 updateCaption( name );
660} 659}
661 660
662void TextEdit::openFile( const DocLnk &f ) 661void TextEdit::openFile( const DocLnk &f )
663{ 662{
664// clear(); 663// clear();
665// bFromDocView = TRUE; 664// bFromDocView = TRUE;
666 FileManager fm; 665 FileManager fm;
667 QString txt; 666 QString txt;
668 currentFileName=f.file(); 667 currentFileName=f.file();
669 qDebug("openFile doclnk " + currentFileName); 668 qDebug("openFile doclnk " + currentFileName);
670 if ( !fm.loadFile( f, txt ) ) { 669 if ( !fm.loadFile( f, txt ) ) {
671 // ####### could be a new file 670 // ####### could be a new file
672 qDebug( "Cannot open file" ); 671 qDebug( "Cannot open file" );
673 } 672 }
674// fileNew(); 673// fileNew();
675 if ( doc ) 674 if ( doc )
676 delete doc; 675 delete doc;
677 doc = new DocLnk(f); 676 doc = new DocLnk(f);
678 editor->setText(txt); 677 editor->setText(txt);
679 editor->setEdited( FALSE); 678 editor->setEdited( FALSE);
680 edited1=FALSE; 679 edited1=FALSE;
681 edited=FALSE; 680 edited=FALSE;
682 681
683 doc->setName(currentFileName); 682 doc->setName(currentFileName);
684 updateCaption(); 683 updateCaption();
685} 684}
686 685
687void TextEdit::showEditTools() 686void TextEdit::showEditTools()
688{ 687{
689// if ( !doc ) 688// if ( !doc )
690// close(); 689// close();
691// clear(); 690// clear();
692 menu->show(); 691 menu->show();
693 editBar->show(); 692 editBar->show();
694 if ( searchVisible ) 693 if ( searchVisible )
695 searchBar->show(); 694 searchBar->show();
696// updateCaption(); 695// updateCaption();
697 setWState (WState_Reserved1 ); 696 setWState (WState_Reserved1 );
698} 697}
699 698
700/*! 699/*!
701 unprompted save */ 700 unprompted save */
702bool TextEdit::save() 701bool TextEdit::save()
703{ 702{
704 QString file = doc->file(); 703 QString file = doc->file();
705 qDebug("saver file "+file); 704 qDebug("saver file "+file);
706 QString name= doc->name(); 705 QString name= doc->name();
707 qDebug("File named "+name); 706 qDebug("File named "+name);
708 QString rt = editor->text(); 707 QString rt = editor->text();
709 if( !rt.isEmpty() ) { 708 if( !rt.isEmpty() ) {
710 if(name.isEmpty()) { 709 if(name.isEmpty()) {
711 saveAs(); 710 saveAs();
712 } else { 711 } else {
713 currentFileName= name ; 712 currentFileName= name ;
714 qDebug("saveFile "+currentFileName); 713 qDebug("saveFile "+currentFileName);
715 714
716 struct stat buf; 715 struct stat buf;
717 mode_t mode; 716 mode_t mode;
718 stat(file.latin1(), &buf); 717 stat(file.latin1(), &buf);
719 mode = buf.st_mode; 718 mode = buf.st_mode;
720 719
721 if(!fileIs) { 720 if(!fileIs) {
722 doc->setName( name); 721 doc->setName( name);
723 FileManager fm; 722 FileManager fm;
724 if ( !fm.saveFile( *doc, rt ) ) { 723 if ( !fm.saveFile( *doc, rt ) ) {
725 return false; 724 return false;
726 } 725 }
727 } else { 726 } else {
728 qDebug("regular save file"); 727 qDebug("regular save file");
729 QFile f(file); 728 QFile f(file);
730 if( f.open(IO_WriteOnly)) { 729 if( f.open(IO_WriteOnly)) {
731 QCString crt = rt.utf8(); 730 QCString crt = rt.utf8();
732 f.writeBlock(crt,crt.length()); 731 f.writeBlock(crt,crt.length());
733 } else { 732 } else {
734 QMessageBox::message("Text Edit","Write Failed"); 733 QMessageBox::message("Text Edit","Write Failed");
735 return false; 734 return false;
736 } 735 }
737 736
738 } 737 }
739 editor->setEdited( FALSE); 738 editor->setEdited( FALSE);
740 edited1=FALSE; 739 edited1=FALSE;
741 edited=FALSE; 740 edited=FALSE;
742 if(caption().left(1)=="*") 741 if(caption().left(1)=="*")
743 setCaption(caption().right(caption().length()-1)); 742 setCaption(caption().right(caption().length()-1));
744 743
745 744
746 chmod( file.latin1(), mode); 745 chmod( file.latin1(), mode);
747 } 746 }
748 return true; 747 return true;
749 } 748 }
750 return false; 749 return false;
751} 750}
752 751
753/*! 752/*!
754 prompted save */ 753 prompted save */
755bool TextEdit::saveAs() 754bool TextEdit::saveAs()
756{ 755{
757// qDebug("saveAsFile "+currentFileName); 756// qDebug("saveAsFile "+currentFileName);
758 // case of nothing to save... 757 // case of nothing to save...
759 if ( !doc )//|| !bFromDocView) 758 if ( !doc )//|| !bFromDocView)
760 { 759 {
761 qDebug("no doc"); 760 qDebug("no doc");
762 return true; 761 return true;
763 } 762 }
764 if ( !editor->edited() ) { 763 if ( !editor->edited() ) {
765 delete doc; 764 delete doc;
766 doc = 0; 765 doc = 0;
767 return true; 766 return true;
768 } 767 }
769 768
770 QString rt = editor->text(); 769 QString rt = editor->text();
771 qDebug(currentFileName); 770 qDebug(currentFileName);
772 771
773 if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { 772 if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) {
774 qDebug("do silly TT filename thing"); 773 qDebug("do silly TT filename thing");
775 if ( doc->name().isEmpty() ) { 774 if ( doc->name().isEmpty() ) {
776 QString pt = rt.simplifyWhiteSpace(); 775 QString pt = rt.simplifyWhiteSpace();
777 int i = pt.find( ' ' ); 776 int i = pt.find( ' ' );
778 QString docname = pt; 777 QString docname = pt;
779 if ( i > 0 ) 778 if ( i > 0 )
780 docname = pt.left( i ); 779 docname = pt.left( i );
781 // remove "." at the beginning 780 // remove "." at the beginning
782 while( docname.startsWith( "." ) ) 781 while( docname.startsWith( "." ) )
783 docname = docname.mid( 1 ); 782 docname = docname.mid( 1 );
784 docname.replace( QRegExp("/"), "_" ); 783 docname.replace( QRegExp("/"), "_" );
785 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 784 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
786 if ( docname.length() > 40 ) 785 if ( docname.length() > 40 )
787 docname = docname.left(40); 786 docname = docname.left(40);
788 if ( docname.isEmpty() ) 787 if ( docname.isEmpty() )
789 docname = tr("Unnamed"); 788 docname = tr("Unnamed");
790 doc->setName(docname); 789 doc->setName(docname);
791 currentFileName=docname; 790 currentFileName=docname;
792 } 791 }
793 } 792 }
794 793
795/*
796 QMap<QString, QStringList> map; 794 QMap<QString, QStringList> map;
797 map.insert(tr("All"), QStringList() ); 795 map.insert(tr("All"), QStringList() );
798 QStringList text; 796 QStringList text;
799 text << "text/*"; 797 text << "text/*";
800 map.insert(tr("Text"), text ); 798 map.insert(tr("Text"), text );
801 text << "*"; 799 text << "*";
802 map.insert(tr("All"), text ); 800 map.insert(tr("All"), text );
803 QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); 801 QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map);
804 if(!str.isEmpty() ) { 802 if(!str.isEmpty() ) {
805 QString fileNm=str; 803 QString fileNm=str;
806*/
807
808 fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName);
809 qDebug("wanna save filename "+currentFileName);
810 fileSaveDlg->exec();
811 if( fileSaveDlg->result() == 1 ) {
812 QString fileNm=fileSaveDlg->selectedFileName;
813
814 804
815 qDebug("saving filename "+fileNm); 805 qDebug("saving filename "+fileNm);
816 QFileInfo fi(fileNm); 806 QFileInfo fi(fileNm);
817 currentFileName=fi.fileName(); 807 currentFileName=fi.fileName();
818 if(doc) { 808 if(doc) {
819// QString file = doc->file(); 809// QString file = doc->file();
820// doc->removeFiles(); 810// doc->removeFiles();
821 delete doc; 811 delete doc;
822 DocLnk nf; 812 DocLnk nf;
823 nf.setType("text/plain"); 813 nf.setType("text/plain");
824 nf.setFile( fileNm); 814 nf.setFile( fileNm);
825 doc = new DocLnk(nf); 815 doc = new DocLnk(nf);
826// editor->setText(rt); 816// editor->setText(rt);
827// qDebug("openFile doclnk "+currentFileName); 817// qDebug("openFile doclnk "+currentFileName);
828 doc->setName( currentFileName); 818 doc->setName( currentFileName);
829 updateCaption( currentFileName); 819 updateCaption( currentFileName);
830 820
831 FileManager fm; 821 FileManager fm;
832 if ( !fm.saveFile( *doc, rt ) ) { 822 if ( !fm.saveFile( *doc, rt ) ) {
833 return false; 823 return false;
834 } 824 }
835 if( fileSaveDlg->filePermCheck->isChecked() ) { 825
826// if( fileSaveDlg->filePermCheck->isChecked() ) {
836 filePermissions *filePerm; 827 filePermissions *filePerm;
837 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); 828 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm);
838 filePerm->exec(); 829 filePerm->exec();
839 830
840 if( filePerm) 831 if( filePerm)
841 delete filePerm; 832 delete filePerm;
842 } 833// }
843 } 834 }
844 } 835 }
845 editor->setEdited(TRUE); 836 editor->setEdited(TRUE);
846 edited1=FALSE; 837 edited1=FALSE;
847 edited=TRUE; 838 edited=TRUE;
848 if(caption().left(1)=="*") 839 if(caption().left(1)=="*")
849 setCaption(caption().right(caption().length()-1)); 840 setCaption(caption().right(caption().length()-1));
850 841
851 if(fileSaveDlg)
852 delete fileSaveDlg;
853 return true; 842 return true;
854} //end saveAs 843} //end saveAs
855 844
856void TextEdit::clear() 845void TextEdit::clear()
857{ 846{
858 delete doc; 847 delete doc;
859 doc = 0; 848 doc = 0;
860 editor->clear(); 849 editor->clear();
861} 850}
862 851
863void TextEdit::updateCaption( const QString &name ) 852void TextEdit::updateCaption( const QString &name )
864{ 853{
865 if ( !doc ) 854 if ( !doc )
866 setCaption( tr("Text Editor") ); 855 setCaption( tr("Text Editor") );
867 else { 856 else {
868 QString s = name; 857 QString s = name;
869 if ( s.isNull() ) 858 if ( s.isNull() )
870 s = doc->name(); 859 s = doc->name();
871 if ( s.isEmpty() ) { 860 if ( s.isEmpty() ) {
872 s = tr( "Unnamed" ); 861 s = tr( "Unnamed" );
873 currentFileName=s; 862 currentFileName=s;
874 } 863 }
875 if(s.left(1) == "/") 864 if(s.left(1) == "/")
876 s = s.right(s.length()-1); 865 s = s.right(s.length()-1);
877 setCaption( s + " - " + tr("Text Editor") ); 866 setCaption( s + " - " + tr("Text Editor") );
878 } 867 }
879} 868}
880 869
881void TextEdit::setDocument(const QString& fileref) 870void TextEdit::setDocument(const QString& fileref)
882{ 871{
883 bFromDocView = TRUE; 872 bFromDocView = TRUE;
884 openFile(fileref); 873 openFile(fileref);
885 editor->setEdited(TRUE); 874 editor->setEdited(TRUE);
886 edited1=FALSE; 875 edited1=FALSE;
887 edited=TRUE; 876 edited=TRUE;
888 doSearchBar(); 877 doSearchBar();
889} 878}
890 879
891void TextEdit::closeEvent( QCloseEvent *e ) 880void TextEdit::closeEvent( QCloseEvent *e )
892{ 881{
893 bFromDocView = FALSE; 882 bFromDocView = FALSE;
894 e->accept(); 883 e->accept();
895} 884}
896 885
897void TextEdit::accept() 886void TextEdit::accept()
898 { 887 {
899 //if(caption() !="Unnamed") 888 //if(caption() !="Unnamed")
900 if(edited1) 889 if(edited1)
901 saveAs(); 890 saveAs();
902 exit(0); 891 exit(0);
903 892
904} 893}
905 894
906void TextEdit::changeFont() { 895void TextEdit::changeFont() {
907 FontDatabase fdb; 896 FontDatabase fdb;
908 QFont defaultFont=editor->font(); 897 QFont defaultFont=editor->font();
909 QFontInfo fontInfo(defaultFont); 898 QFontInfo fontInfo(defaultFont);
910 Config cfg("TextEdit"); 899 Config cfg("TextEdit");
911 cfg.setGroup("Font"); 900 cfg.setGroup("Font");
912 QString family = cfg.readEntry("Family", fontInfo.family()); 901 QString family = cfg.readEntry("Family", fontInfo.family());
913 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 902 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
914 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 903 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
915 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 904 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
916 905
917 defaultFont = fdb.font(family,style,i_size,charSet); 906 defaultFont = fdb.font(family,style,i_size,charSet);
918 907
919 FontDialog *fontDlg; 908 FontDialog *fontDlg;
920 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); 909 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE);
921 910
922 fontDlg->exec(); 911 fontDlg->exec();
923 912
924 QFont myFont=fontDlg->selectedFont; 913 QFont myFont=fontDlg->selectedFont;
925 editor->setFont( myFont); 914 editor->setFont( myFont);
926 delete fontDlg; 915 delete fontDlg;
927 916
928} 917}
929 918
930void TextEdit::editDelete() 919void TextEdit::editDelete()
931{ 920{
932 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { 921 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) {
933 case 0: 922 case 0:
934 if(doc) { 923 if(doc) {
935 doc->removeFiles(); 924 doc->removeFiles();
936 clear(); 925 clear();
937 setCaption( tr("Text Editor") ); 926 setCaption( tr("Text Editor") );
938 } 927 }
939 break; 928 break;
940 case 1: 929 case 1:
941 // exit 930 // exit
942 break; 931 break;
943 }; 932 };
944} 933}
945 934
946void TextEdit::changeStartConfig( bool b ) { 935void TextEdit::changeStartConfig( bool b ) {
947 936
948 Config cfg("TextEdit"); 937 Config cfg("TextEdit");
949 cfg.setGroup("View"); 938 cfg.setGroup("View");
950 if(b) { 939 if(b) {
951 qDebug("bool"); 940 qDebug("bool");
952 cfg.writeEntry("startNew","TRUE"); 941 cfg.writeEntry("startNew","TRUE");
953 } else { 942 } else {
954 cfg.writeEntry("startNew","FALSE"); 943 cfg.writeEntry("startNew","FALSE");
955 } 944 }
956 update(); 945 update();
957} 946}
958 947
959void TextEdit::editorChanged() { 948void TextEdit::editorChanged() {
960 if(editor->edited() && edited && !edited1) { 949 if(editor->edited() && edited && !edited1) {
961 setCaption( "*"+caption()); 950 setCaption( "*"+caption());
962 edited1=TRUE; 951 edited1=TRUE;
963 } 952 }
964 edited=TRUE; 953 edited=TRUE;
965} 954}
966 955
967void TextEdit::receive(const QCString&msg, const QByteArray&) { 956void TextEdit::receive(const QCString&msg, const QByteArray&) {
968 qDebug("QCop "+msg); 957 qDebug("QCop "+msg);
969 if ( msg == "setDocument(QString)" ) { 958 if ( msg == "setDocument(QString)" ) {
970 qDebug("bugger all"); 959 qDebug("bugger all");
971 } 960 }
972 961
973} 962}
974void TextEdit::doAbout() { 963void TextEdit::doAbout() {
975 QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" 964 QMessageBox::about(0,"Text Edit","Text Edit is copyright\n"
976 "2000 Trolltech AS, and\n" 965 "2000 Trolltech AS, and\n"
977 "2002 by L.J.Potter \nljp@llornkcor.com\n" 966 "2002 by L.J.Potter \nljp@llornkcor.com\n"
978 "and is licensed under the GPL"); 967 "and is licensed under the GPL");
979} 968}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index d8208b1..764d852 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -1,126 +1,126 @@
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// additions made by L.J. Potter Sun 02-17-2002 22:27:46 20// additions made by L.J. Potter Sun 02-17-2002 22:27:46
21 21
22#ifndef TEXTEDIT_H 22#ifndef TEXTEDIT_H
23#define TEXTEDIT_H 23#define TEXTEDIT_H
24 24
25#define QTEXTEDIT_OPEN_API 25#define QTEXTEDIT_OPEN_API
26 26
27//#include "fileBrowser.h" 27//#include "fileBrowser.h"
28#include "fileSaver.h" 28//#include "fileSaver.h"
29 29
30#include <qpe/filemanager.h> 30#include <qpe/filemanager.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include <opie/ofileselector.h> 33#include <opie/ofileselector.h>
34 34
35#include <qmainwindow.h> 35#include <qmainwindow.h>
36#include <qmultilineedit.h> 36#include <qmultilineedit.h>
37#include <qlist.h> 37#include <qlist.h>
38#include <qmap.h> 38#include <qmap.h>
39 39
40class QAction; 40class QAction;
41class QWidgetStack; 41class QWidgetStack;
42class QToolButton; 42class QToolButton;
43class QPopupMenu; 43class QPopupMenu;
44class QToolBar; 44class QToolBar;
45class QLineEdit; 45class QLineEdit;
46class QAction; 46class QAction;
47class FileSelector; 47class FileSelector;
48class QpeEditor; 48class QpeEditor;
49class QPopupMenu; 49class QPopupMenu;
50 50
51class TextEdit : public QMainWindow 51class TextEdit : public QMainWindow
52{ 52{
53 Q_OBJECT 53 Q_OBJECT
54 54
55public: 55public:
56 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 56 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
57 ~TextEdit(); 57 ~TextEdit();
58 58
59 QPopupMenu *font; 59 QPopupMenu *font;
60 QAction *nStart, *nFileDlgOpt; 60 QAction *nStart, *nFileDlgOpt;
61 bool edited, edited1; 61 bool edited, edited1;
62 void openFile( const QString & ); 62 void openFile( const QString & );
63 QCopChannel * channel; 63 QCopChannel * channel;
64public slots: 64public slots:
65 void editorChanged(); 65 void editorChanged();
66void receive(const QCString&, const QByteArray&); 66void receive(const QCString&, const QByteArray&);
67protected: 67protected:
68 bool fileIs; 68 bool fileIs;
69 void closeEvent( QCloseEvent *e ); 69 void closeEvent( QCloseEvent *e );
70 void doSearchBar(); 70 void doSearchBar();
71private slots: 71private slots:
72 void doAbout(); 72 void doAbout();
73 void setDocument(const QString&); 73 void setDocument(const QString&);
74 void changeFont(); 74 void changeFont();
75 void fileNew(); 75 void fileNew();
76 void fileRevert(); 76 void fileRevert();
77 void fileOpen(); 77 void fileOpen();
78 void changeStartConfig(bool); 78 void changeStartConfig(bool);
79 bool save(); 79 bool save();
80 bool saveAs(); 80 bool saveAs();
81 void cleanUp(); 81 void cleanUp();
82 82
83 83
84 void editCut(); 84 void editCut();
85 void editCopy(); 85 void editCopy();
86 void editPaste(); 86 void editPaste();
87 void editFind(); 87 void editFind();
88 void editDelete(); 88 void editDelete();
89 89
90 void findNext(); 90 void findNext();
91 void findClose(); 91 void findClose();
92 92
93 void search(); 93 void search();
94 void accept(); 94 void accept();
95 95
96 void newFile( const DocLnk & ); 96 void newFile( const DocLnk & );
97 void openFile( const DocLnk & ); 97 void openFile( const DocLnk & );
98 void showEditTools(); 98 void showEditTools();
99 99
100 void zoomIn(); 100 void zoomIn();
101 void zoomOut(); 101 void zoomOut();
102 void setBold(bool y); 102 void setBold(bool y);
103 void setItalic(bool y); 103 void setItalic(bool y);
104 void setWordWrap(bool y); 104 void setWordWrap(bool y);
105 105
106private: 106private:
107 void colorChanged( const QColor &c ); 107 void colorChanged( const QColor &c );
108 void clear(); 108 void clear();
109 void updateCaption( const QString &name=QString::null ); 109 void updateCaption( const QString &name=QString::null );
110 void setFontSize(int sz, bool round_down_not_up); 110 void setFontSize(int sz, bool round_down_not_up);
111 111
112private: 112private:
113 fileSaver *fileSaveDlg; 113// fileSaver *fileSaveDlg;
114// fileBrowser *browseForFiles; 114// fileBrowser *browseForFiles;
115 QpeEditor* editor; 115 QpeEditor* editor;
116 QToolBar *menu, *editBar, *searchBar; 116 QToolBar *menu, *editBar, *searchBar;
117 QLineEdit *searchEdit; 117 QLineEdit *searchEdit;
118 DocLnk *doc; 118 DocLnk *doc;
119 bool searchVisible; 119 bool searchVisible;
120 bool bFromDocView; 120 bool bFromDocView;
121 int viewSelection; 121 int viewSelection;
122 QAction *zin, *zout; 122 QAction *zin, *zout;
123 QString currentFileName; 123 QString currentFileName;
124}; 124};
125 125
126#endif 126#endif
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro
index 484d0cd..f6e6530 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
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4HEADERS = textedit.h fontDialog.h fileSaver.h filePermissions.h 4HEADERS = textedit.h fontDialog.h filePermissions.h
5SOURCES = main.cpp textedit.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp 5SOURCES = main.cpp textedit.cpp fontDialog.cpp filePermissions.cpp
6INCLUDEPATH += $(OPIEDIR)/include 6INCLUDEPATH += $(OPIEDIR)/include
7DEPENDPATH += $(OPIEDIR)/include 7DEPENDPATH += $(OPIEDIR)/include
8LIBS += -lqpe -lopie 8LIBS += -lqpe -lopie
9TARGET = textedit 9TARGET = textedit
10 10
11TRANSLATIONS = ../../../i18n/de/textedit.ts \ 11TRANSLATIONS = ../../../i18n/de/textedit.ts \
12 ../../../i18n/en/textedit.ts \ 12 ../../../i18n/en/textedit.ts \
13 ../../../i18n/es/textedit.ts \ 13 ../../../i18n/es/textedit.ts \
14 ../../../i18n/fr/textedit.ts \ 14 ../../../i18n/fr/textedit.ts \
15 ../../../i18n/hu/textedit.ts \ 15 ../../../i18n/hu/textedit.ts \
16 ../../../i18n/ja/textedit.ts \ 16 ../../../i18n/ja/textedit.ts \
17 ../../../i18n/ko/textedit.ts \ 17 ../../../i18n/ko/textedit.ts \
18 ../../../i18n/no/textedit.ts \ 18 ../../../i18n/no/textedit.ts \
19 ../../../i18n/pl/textedit.ts \ 19 ../../../i18n/pl/textedit.ts \
20 ../../../i18n/pt/textedit.ts \ 20 ../../../i18n/pt/textedit.ts \
21 ../../../i18n/pt_BR/textedit.ts \ 21 ../../../i18n/pt_BR/textedit.ts \
22 ../../../i18n/sl/textedit.ts \ 22 ../../../i18n/sl/textedit.ts \
23 ../../../i18n/zh_CN/textedit.ts \ 23 ../../../i18n/zh_CN/textedit.ts \
24 ../../../i18n/zh_TW/textedit.ts 24 ../../../i18n/zh_TW/textedit.ts