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