author | llornkcor <llornkcor> | 2002-06-29 12:39:00 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-29 12:39:00 (UTC) |
commit | 2d3e1d2a51edeebfb6acea960cc4d505b4c72731 (patch) (unidiff) | |
tree | 26ac8e2f81ab8f131f217a01544d811dd6a5e881 | |
parent | d8508c23608ad28e0b37f26807ee35055fcabe38 (diff) | |
download | opie-2d3e1d2a51edeebfb6acea960cc4d505b4c72731.zip opie-2d3e1d2a51edeebfb6acea960cc4d505b4c72731.tar.gz opie-2d3e1d2a51edeebfb6acea960cc4d505b4c72731.tar.bz2 |
convert to ofilesavedialog
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 634 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 120 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 271 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.h | 75 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 21 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 4 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 30 |
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 | |||
41 | static int u_id = 1; | ||
42 | static int get_unique_id() | ||
43 | { | ||
44 | return u_id++; | ||
45 | } | ||
46 | |||
47 | fileBrowser::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() ); | ||
143 | mimeType="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 | |||
176 | fileBrowser::~fileBrowser() | ||
177 | { | ||
178 | } | ||
179 | |||
180 | void fileBrowser::setFileView( int selection ) | ||
181 | { | ||
182 | SelectionCombo->setCurrentItem( selection ); | ||
183 | selectionChanged( SelectionCombo->currentText() ); | ||
184 | } | ||
185 | |||
186 | void 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 | |||
267 | void 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 | ||
280 | void 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 | |||
325 | void 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 | |||
338 | void fileBrowser::homeButtonPushed() { | ||
339 | QString current = QDir::homeDirPath(); | ||
340 | chdir( current.latin1() ); | ||
341 | currentDir.cd( current, TRUE); | ||
342 | populateList(); | ||
343 | update(); | ||
344 | } | ||
345 | |||
346 | void fileBrowser::docButtonPushed() { | ||
347 | QString current = QPEApplication::documentDir(); | ||
348 | chdir( current.latin1() ); | ||
349 | currentDir.cd( current, TRUE); | ||
350 | populateList(); | ||
351 | update(); | ||
352 | |||
353 | } | ||
354 | |||
355 | void 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 | |||
379 | void fileBrowser::docOpen( const DocLnk &doc ) | ||
380 | { | ||
381 | fileList.append( doc.file().latin1() ); | ||
382 | accept(); | ||
383 | } | ||
384 | |||
385 | void 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 | |||
396 | void 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 | |||
415 | void fileBrowser::doCd() { | ||
416 | listClicked( ListView->currentItem()); | ||
417 | } | ||
418 | |||
419 | void 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 | |||
431 | void 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 | |||
446 | void 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 | |||
479 | void 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 | |||
499 | void 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 | |||
544 | QStringList 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 | |||
575 | void 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 | |||
586 | void fileBrowser::dirPathComboActivated( const QString & current) { | ||
587 | chdir( current.latin1() ); | ||
588 | currentDir.cd( current, TRUE); | ||
589 | populateList(); | ||
590 | update(); | ||
591 | } | ||
592 | |||
593 | void fileBrowser::dirPathEditPressed() { | ||
594 | QString current = dirPathCombo->lineEdit()->text(); | ||
595 | chdir( current.latin1() ); | ||
596 | currentDir.cd( current, TRUE); | ||
597 | populateList(); | ||
598 | update(); | ||
599 | } | ||
600 | |||
601 | void fileBrowser::fillCombo(const QString ¤tPath) { | ||
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 | |||
613 | InputDialog::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 | |||
626 | InputDialog::~InputDialog() | ||
627 | { | ||
628 | inputText= LineEdit1->text(); | ||
629 | |||
630 | } | ||
631 | |||
632 | void 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 | ** | ||
13 | copyright 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 | |||
34 | class QLineEdit; | ||
35 | class QVBoxLayout; | ||
36 | class QHBoxLayout; | ||
37 | class QGridLayout; | ||
38 | class QListView; | ||
39 | class QListViewItem; | ||
40 | class QPushButton; | ||
41 | class QComboBox; | ||
42 | class QWidgetStack; | ||
43 | class FileSelector; | ||
44 | class QPoint; | ||
45 | class MenuButton; | ||
46 | |||
47 | |||
48 | class fileBrowser : public QDialog | ||
49 | { | ||
50 | Q_OBJECT | ||
51 | |||
52 | public: | ||
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; | ||
60 | public slots: | ||
61 | void setFileView( int ); | ||
62 | |||
63 | private: | ||
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 | |||
80 | private 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 | |||
101 | protected slots: | ||
102 | |||
103 | protected: | ||
104 | |||
105 | }; | ||
106 | |||
107 | |||
108 | class InputDialog : public QDialog | ||
109 | { | ||
110 | Q_OBJECT | ||
111 | |||
112 | public: | ||
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 | |||
29 | fileSaver::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 | |||
97 | fileSaver::~fileSaver() | ||
98 | { | ||
99 | } | ||
100 | |||
101 | void 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 | |||
172 | void fileSaver::upDir() | ||
173 | { | ||
174 | // qDebug(currentDir.canonicalPath()); | ||
175 | } | ||
176 | |||
177 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) | ||
178 | { | ||
179 | } | ||
180 | |||
181 | void 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 | |||
224 | void fileSaver::closeEvent( QCloseEvent *e ) | ||
225 | { | ||
226 | if(e->isAccepted()) { | ||
227 | e->accept(); | ||
228 | } else { | ||
229 | qDebug("not accepted"); | ||
230 | done(-1); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | void 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 | |||
246 | void fileSaver::homeButtonPushed() { | ||
247 | chdir( QDir::homeDirPath().latin1() ); | ||
248 | currentDir.cd( QDir::homeDirPath(), TRUE); | ||
249 | populateList(); | ||
250 | update(); | ||
251 | } | ||
252 | void fileSaver::docButtonPushed() { | ||
253 | chdir( QString(QPEApplication::documentDir()+"/text").latin1() ); | ||
254 | currentDir.cd( QPEApplication::documentDir()+"/text", TRUE); | ||
255 | populateList(); | ||
256 | update(); | ||
257 | |||
258 | } | ||
259 | |||
260 | void 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 | ** | ||
5 | copyright 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 | |||
27 | class QVBoxLayout; | ||
28 | class QHBoxLayout; | ||
29 | class QGridLayout; | ||
30 | class QListView; | ||
31 | class QListViewItem; | ||
32 | class QPushButton; | ||
33 | class QLineEdit; | ||
34 | class QCheckBox; | ||
35 | |||
36 | class fileSaver : public QDialog | ||
37 | { | ||
38 | Q_OBJECT | ||
39 | |||
40 | public: | ||
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 | |||
55 | QListViewItem * item; | ||
56 | public slots: | ||
57 | void homeButtonPushed(); | ||
58 | void docButtonPushed(); | ||
59 | void hideButtonPushed(bool); | ||
60 | private: | ||
61 | |||
62 | private slots: | ||
63 | void accept(); | ||
64 | void upDir(); | ||
65 | void listDoubleClicked(QListViewItem *); | ||
66 | void listClicked(QListViewItem *); | ||
67 | void closeEvent( QCloseEvent * ); | ||
68 | |||
69 | protected slots: | ||
70 | |||
71 | protected: | ||
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 | |||
@@ -20,7 +20,6 @@ | |||
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 | ||
@@ -792,7 +791,6 @@ bool TextEdit::saveAs() | |||
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; |
@@ -803,14 +801,6 @@ bool TextEdit::saveAs() | |||
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); |
@@ -832,14 +822,15 @@ bool TextEdit::saveAs() | |||
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); |
@@ -848,8 +839,6 @@ bool TextEdit::saveAs() | |||
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 | ||
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 | |||
@@ -25,7 +25,7 @@ | |||
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> |
@@ -110,7 +110,7 @@ private: | |||
110 | void setFontSize(int sz, bool round_down_not_up); | 110 | void setFontSize(int sz, bool round_down_not_up); |
111 | 111 | ||
112 | private: | 112 | private: |
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; |
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 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = textedit.h fontDialog.h fileSaver.h filePermissions.h | 4 | HEADERS = textedit.h fontDialog.h filePermissions.h |
5 | SOURCES = main.cpp textedit.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp | 5 | SOURCES = main.cpp textedit.cpp fontDialog.cpp filePermissions.cpp |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DEPENDPATH += $(OPIEDIR)/include | 7 | DEPENDPATH += $(OPIEDIR)/include |
8 | LIBS += -lqpe -lopie | 8 | LIBS += -lqpe -lopie |
9 | TARGET = textedit | 9 | TARGET = textedit |
10 | 10 | ||
11 | TRANSLATIONS = ../../../i18n/de/textedit.ts \ | 11 | TRANSLATIONS = ../../../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 |