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,47 +1,46 @@
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>
@@ -771,106 +770,96 @@ bool TextEdit::saveAs()
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);
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
@@ -4,49 +4,49 @@
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{
@@ -89,38 +89,38 @@ private slots:
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