author | llornkcor <llornkcor> | 2002-03-27 04:33:32 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-27 04:33:32 (UTC) |
commit | 7d6828df281631bce0aaa2aaa229b69b9329e03c (patch) (unidiff) | |
tree | efd928de11a2d7d2ae33bbccf737fae7a51ff36d | |
parent | 524ad1da733675debd5c248b54efc5d58e855485 (diff) | |
download | opie-7d6828df281631bce0aaa2aaa229b69b9329e03c.zip opie-7d6828df281631bce0aaa2aaa229b69b9329e03c.tar.gz opie-7d6828df281631bce0aaa2aaa229b69b9329e03c.tar.bz2 |
fixed something erother.. probably something todo with deleting or somesuch. probably broke something else in the process
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 117 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 2 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 45 |
3 files changed, 104 insertions, 60 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 8c942a1..8ea8067 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -116,17 +116,17 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
116 | 116 | ||
117 | ListView->setColumnWidthMode(0,QListView::Manual); | 117 | ListView->setColumnWidthMode(0,QListView::Manual); |
118 | ListView->setColumnAlignment(1,QListView::AlignRight); | 118 | ListView->setColumnAlignment(1,QListView::AlignRight); |
119 | ListView->setColumnAlignment(2,QListView::AlignRight); | 119 | ListView->setColumnAlignment(2,QListView::AlignRight); |
120 | ListView->setAllColumnsShowFocus( TRUE ); | 120 | ListView->setAllColumnsShowFocus( TRUE ); |
121 | 121 | ||
122 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 122 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
123 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 123 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
124 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 124 | this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
125 | 125 | ||
126 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 126 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
127 | 127 | ||
128 | FileStack->addWidget( ListView, get_unique_id() ); | 128 | FileStack->addWidget( ListView, get_unique_id() ); |
129 | 129 | ||
130 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 130 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
131 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 131 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
132 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 132 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
@@ -166,79 +166,80 @@ void fileBrowser::setFileView( int selection ) | |||
166 | { | 166 | { |
167 | SelectionCombo->setCurrentItem( selection ); | 167 | SelectionCombo->setCurrentItem( selection ); |
168 | selectionChanged( SelectionCombo->currentText() ); | 168 | selectionChanged( SelectionCombo->currentText() ); |
169 | } | 169 | } |
170 | 170 | ||
171 | void fileBrowser::populateList() | 171 | void fileBrowser::populateList() |
172 | { | 172 | { |
173 | ListView->clear(); | 173 | ListView->clear(); |
174 | QListViewItem * item; | ||
174 | bool isDir=FALSE; | 175 | bool isDir=FALSE; |
175 | //qDebug(currentDir.canonicalPath()); | 176 | //qDebug(currentDir.canonicalPath()); |
176 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 177 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
177 | currentDir.setMatchAllDirs(TRUE); | 178 | currentDir.setMatchAllDirs(TRUE); |
178 | 179 | ||
179 | // currentDir.setNameFilter("*.txt;*.etx"); | 180 | // currentDir.setNameFilter("*.txt;*.etx"); |
180 | QString fileL, fileS, fileDate; | 181 | QString fileL, fileS, fileDate; |
181 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 182 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
182 | QFileInfoListIterator it(*list); | 183 | QFileInfoListIterator it(*list); |
183 | QFileInfo *fi; | 184 | QFileInfo *fi; |
184 | while ( (fi=it.current()) ) { | 185 | while ( (fi=it.current()) ) { |
185 | 186 | if (fi->isSymLink() ){ | |
186 | if (fi->isSymLink() ){ | 187 | QString symLink=fi->readLink(); |
187 | QString symLink=fi->readLink(); | ||
188 | // qDebug("Symlink detected "+symLink); | 188 | // qDebug("Symlink detected "+symLink); |
189 | QFileInfo sym( symLink); | 189 | QFileInfo sym( symLink); |
190 | fileS.sprintf( "%10li", sym.size() ); | 190 | fileS.sprintf( "%10li", sym.size() ); |
191 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 191 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
192 | fileDate = sym.lastModified().toString(); | 192 | fileDate = sym.lastModified().toString(); |
193 | } else { | 193 | } else { |
194 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 194 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
195 | fileS.sprintf( "%10li", fi->size() ); | 195 | fileS.sprintf( "%10li", fi->size() ); |
196 | fileL.sprintf( "%s",fi->fileName().data() ); | 196 | fileL.sprintf( "%s",fi->fileName().data() ); |
197 | fileDate= fi->lastModified().toString(); | 197 | fileDate= fi->lastModified().toString(); |
198 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 198 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
199 | fileL+="/"; | 199 | fileL+="/"; |
200 | isDir=TRUE; | 200 | isDir=TRUE; |
201 | // qDebug( fileL); | 201 | // qDebug( fileL); |
202 | } | ||
202 | } | 203 | } |
203 | } | 204 | if(fileL !="./" && fi->exists()) { |
204 | if(fileL !="./") { | 205 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
205 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 206 | QPixmap pm; |
206 | QPixmap pm; | ||
207 | 207 | ||
208 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 208 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
209 | if( !QDir( fi->filePath() ).isReadable()) | 209 | if( !QDir( fi->filePath() ).isReadable()) |
210 | pm = Resource::loadPixmap( "lockedfolder" ); | 210 | pm = Resource::loadPixmap( "lockedfolder" ); |
211 | else | 211 | else |
212 | pm= Resource::loadPixmap( "folder" ); | ||
213 | item->setPixmap( 0,pm ); | ||
214 | } else { | ||
215 | if( !fi->isReadable() ) | ||
216 | pm = Resource::loadPixmap( "locked" ); | ||
217 | else { | ||
218 | MimeType mt(fi->filePath()); | ||
219 | pm=mt.pixmap(); | ||
220 | if(pm.isNull()) | ||
221 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | ||
222 | item->setPixmap( 0,pm); | ||
223 | } | ||
224 | } | ||
225 | if( fileL.find("->",0,TRUE) != -1) { | ||
226 | // overlay link image | ||
212 | pm= Resource::loadPixmap( "folder" ); | 227 | pm= Resource::loadPixmap( "folder" ); |
213 | item->setPixmap( 0,pm ); | 228 | QPixmap lnk = Resource::loadPixmap( "symlink" ); |
214 | } else { | 229 | QPainter painter( &pm ); |
215 | if( !fi->isReadable() ) | 230 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
216 | pm = Resource::loadPixmap( "locked" ); | 231 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
217 | else { | 232 | item->setPixmap( 0, pm); |
218 | MimeType mt(fi->filePath()); | ||
219 | pm=mt.pixmap(); | ||
220 | if(pm.isNull()) | ||
221 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | ||
222 | item->setPixmap( 0,pm); | ||
223 | } | 233 | } |
224 | } | 234 | } |
225 | if( fileL.find("->",0,TRUE) != -1) { | 235 | isDir=FALSE; |
226 | // overlay link image | 236 | ++it; |
227 | pm= Resource::loadPixmap( "folder" ); | 237 | // } |
228 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | ||
229 | QPainter painter( &pm ); | ||
230 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
231 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
232 | item->setPixmap( 0, pm); | ||
233 | } | ||
234 | } | ||
235 | isDir=FALSE; | ||
236 | ++it; | ||
237 | } | 238 | } |
238 | ListView->setSorting( 3, FALSE); | 239 | ListView->setSorting( 3, FALSE); |
239 | QString currentPath = currentDir.canonicalPath(); | 240 | QString currentPath = currentDir.canonicalPath(); |
240 | 241 | ||
241 | fillCombo( (const QString &)currentPath); | 242 | fillCombo( (const QString &)currentPath); |
242 | // dirPathCombo->lineEdit()->setText(currentPath); | 243 | // dirPathCombo->lineEdit()->setText(currentPath); |
243 | 244 | ||
244 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 245 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
@@ -258,16 +259,17 @@ void fileBrowser::upDir() | |||
258 | currentDir.cd( current, TRUE); | 259 | currentDir.cd( current, TRUE); |
259 | populateList(); | 260 | populateList(); |
260 | update(); | 261 | update(); |
261 | } | 262 | } |
262 | 263 | ||
263 | // you may want to switch these 2 functions. I like single clicks | 264 | // you may want to switch these 2 functions. I like single clicks |
264 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 265 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
265 | { | 266 | { |
267 | if(selectedItem) { | ||
266 | QString strItem=selectedItem->text(0); | 268 | QString strItem=selectedItem->text(0); |
267 | QString strSize=selectedItem->text(1); | 269 | QString strSize=selectedItem->text(1); |
268 | // qDebug("strItem is "+strItem); | 270 | // qDebug("strItem is "+strItem); |
269 | strSize.stripWhiteSpace(); | 271 | strSize.stripWhiteSpace(); |
270 | // qDebug(strSize); | 272 | // qDebug(strSize); |
271 | 273 | ||
272 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 274 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
273 | // is symlink | 275 | // is symlink |
@@ -297,16 +299,17 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
297 | if( QFile::exists(strItem ) ) { | 299 | if( QFile::exists(strItem ) ) { |
298 | //currentDir.canonicalPath() | 300 | //currentDir.canonicalPath() |
299 | qDebug("We found our files!!"+strItem); | 301 | qDebug("We found our files!!"+strItem); |
300 | OnOK(); | 302 | OnOK(); |
301 | } | 303 | } |
302 | } //end not symlink | 304 | } //end not symlink |
303 | chdir(strItem.latin1()); | 305 | chdir(strItem.latin1()); |
304 | } | 306 | } |
307 | } | ||
305 | } | 308 | } |
306 | 309 | ||
307 | void fileBrowser::OnOK() | 310 | void fileBrowser::OnOK() |
308 | { | 311 | { |
309 | QListViewItemIterator it1( ListView); | 312 | QListViewItemIterator it1( ListView); |
310 | for ( ; it1.current(); ++it1 ) { | 313 | for ( ; it1.current(); ++it1 ) { |
311 | if ( it1.current()->isSelected() ) { | 314 | if ( it1.current()->isSelected() ) { |
312 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 315 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
@@ -373,38 +376,43 @@ void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &poi | |||
373 | showListMenu(item); | 376 | showListMenu(item); |
374 | break; | 377 | break; |
375 | }; | 378 | }; |
376 | } | 379 | } |
377 | 380 | ||
378 | void fileBrowser::showListMenu(QListViewItem *item) { | 381 | void fileBrowser::showListMenu(QListViewItem *item) { |
379 | 382 | ||
380 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 383 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
381 | if( item->text(0).find("/",0,TRUE)) | 384 | if(item) { |
382 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | 385 | if( item->text(0).find("/",0,TRUE)) |
383 | else | 386 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); |
384 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 387 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
385 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); | 388 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); |
386 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 389 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
387 | m.insertSeparator(); | 390 | m.insertSeparator(); |
388 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 391 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
392 | } else { | ||
393 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | ||
394 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); | ||
395 | |||
396 | } | ||
389 | m.exec( QCursor::pos() ); | 397 | m.exec( QCursor::pos() ); |
390 | |||
391 | } | 398 | } |
392 | 399 | ||
393 | void fileBrowser::doCd() { | 400 | void fileBrowser::doCd() { |
394 | listClicked( ListView->currentItem()); | 401 | listClicked( ListView->currentItem()); |
395 | } | 402 | } |
396 | 403 | ||
397 | void fileBrowser::makDir() { | 404 | void fileBrowser::makDir() { |
398 | InputDialog *fileDlg; | 405 | InputDialog *fileDlg; |
399 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 406 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
400 | fileDlg->exec(); | 407 | fileDlg->exec(); |
401 | if( fileDlg->result() == 1 ) { | 408 | if( fileDlg->result() == 1 ) { |
402 | QString filename = fileDlg->LineEdit1->text(); | 409 | QString filename = fileDlg->LineEdit1->text(); |
410 | qDebug("Make dir"); | ||
403 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 411 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
404 | } | 412 | } |
405 | populateList(); | 413 | populateList(); |
406 | } | 414 | } |
407 | 415 | ||
408 | void fileBrowser::localRename() { | 416 | void fileBrowser::localRename() { |
409 | QString curFile = ListView->currentItem()->text(0); | 417 | QString curFile = ListView->currentItem()->text(0); |
410 | InputDialog *fileDlg; | 418 | InputDialog *fileDlg; |
@@ -431,17 +439,16 @@ void fileBrowser::localDelete() { | |||
431 | system( cmd.latin1()); | 439 | system( cmd.latin1()); |
432 | populateList(); | 440 | populateList(); |
433 | } | 441 | } |
434 | break; | 442 | break; |
435 | case 1: | 443 | case 1: |
436 | // exit | 444 | // exit |
437 | break; | 445 | break; |
438 | }; | 446 | }; |
439 | |||
440 | } else { | 447 | } else { |
441 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 448 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
442 | +" ?","Yes","No",0,0,1) ) { | 449 | +" ?","Yes","No",0,0,1) ) { |
443 | case 0: { | 450 | case 0: { |
444 | f=currentDir.canonicalPath()+"/"+f; | 451 | f=currentDir.canonicalPath()+"/"+f; |
445 | QString cmd="rm "+f; | 452 | QString cmd="rm "+f; |
446 | system( cmd.latin1()); | 453 | system( cmd.latin1()); |
447 | populateList(); | 454 | populateList(); |
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index 339483f..e76c7df 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h | |||
@@ -62,17 +62,17 @@ public slots: | |||
62 | private: | 62 | private: |
63 | // QDict<void> mimes; | 63 | // QDict<void> mimes; |
64 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; | 64 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; |
65 | QListView* ListView; | 65 | QListView* ListView; |
66 | QLabel *dirLabel; | 66 | QLabel *dirLabel; |
67 | QString filterStr, mimeType; | 67 | QString filterStr, mimeType; |
68 | QDir currentDir; | 68 | QDir currentDir; |
69 | QStringList dirPathStringList, mimetypes; | 69 | QStringList dirPathStringList, mimetypes; |
70 | QListViewItem * item; | 70 | /* QListViewItem * item; */ |
71 | QComboBox *dirPathCombo; | 71 | QComboBox *dirPathCombo; |
72 | MenuButton *typemb; | 72 | MenuButton *typemb; |
73 | QWidgetStack *FileStack; | 73 | QWidgetStack *FileStack; |
74 | FileSelector *fileSelector; | 74 | FileSelector *fileSelector; |
75 | QRegExp tf; | 75 | QRegExp tf; |
76 | QStringList getMimeTypes(); | 76 | QStringList getMimeTypes(); |
77 | void fillCombo( const QString&); | 77 | void fillCombo( const QString&); |
78 | 78 | ||
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index 07fb5ba..f2a5355 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -9,16 +9,17 @@ | |||
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 | #include "fileSaver.h" | 14 | #include "fileSaver.h" |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/mimetype.h> | ||
17 | 18 | ||
18 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
19 | #include <qlistview.h> | 20 | #include <qlistview.h> |
20 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
21 | #include <qfile.h> | 22 | #include <qfile.h> |
22 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
23 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
24 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
@@ -42,30 +43,33 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
42 | homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); | 43 | homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); |
43 | homeButton->setGeometry(200,4,25,25); | 44 | homeButton->setGeometry(200,4,25,25); |
44 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 45 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
45 | homeButton->setFlat(TRUE); | 46 | homeButton->setFlat(TRUE); |
46 | 47 | ||
47 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 48 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
48 | docButton->setGeometry(170,4,25,25); | 49 | docButton->setGeometry(170,4,25,25); |
49 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 50 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
51 | |||
50 | docButton->setFlat(TRUE); | 52 | docButton->setFlat(TRUE); |
51 | 53 | ||
52 | hideButton = new QPushButton( Resource::loadIconSet("textedit/s_hidden"),"",this,"hideButton"); | 54 | hideButton = new QPushButton( Resource::loadIconSet("textedit/s_hidden"),"",this,"hideButton"); |
53 | hideButton->setGeometry(140,4,25,25); | 55 | hideButton->setGeometry(140,4,25,25); |
54 | connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) ); | 56 | connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) ); |
55 | hideButton->setToggleButton(TRUE); | 57 | hideButton->setToggleButton(TRUE); |
56 | hideButton->setFlat(TRUE); | 58 | hideButton->setFlat(TRUE); |
57 | 59 | ||
58 | ListView = new QListView( this, "ListView" ); | 60 | ListView = new QListView( this, "ListView" ); |
59 | ListView->addColumn( tr( "Name" ) ); | 61 | ListView->addColumn( tr( "Name" ) ); |
60 | ListView->setColumnWidth(0,140); | 62 | ListView->setColumnWidth(0,120); |
61 | ListView->setSorting( 2, FALSE); | 63 | ListView->setSorting( 2, FALSE); |
62 | ListView->addColumn( tr( "Size" ) ); | 64 | ListView->addColumn( tr( "Size" ) ); |
63 | ListView->setColumnWidth(1,59); | 65 | ListView->setColumnWidth(1,-1); |
66 | ListView->addColumn( "Date",-1); | ||
67 | |||
64 | ListView->setColumnWidthMode(0,QListView::Manual); | 68 | ListView->setColumnWidthMode(0,QListView::Manual); |
65 | ListView->setColumnAlignment(1,QListView::AlignRight); | 69 | ListView->setColumnAlignment(1,QListView::AlignRight); |
66 | // ListView->setMultiSelection(true); | 70 | // ListView->setMultiSelection(true); |
67 | // ListView->setSelectionMode(QListView::Extended); | 71 | // ListView->setSelectionMode(QListView::Extended); |
68 | 72 | ||
69 | ListView->setAllColumnsShowFocus( TRUE ); | 73 | ListView->setAllColumnsShowFocus( TRUE ); |
70 | ListView->setGeometry( QRect( 10,35,220,125)); | 74 | ListView->setGeometry( QRect( 10,35,220,125)); |
71 | 75 | ||
@@ -92,21 +96,22 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
92 | 96 | ||
93 | fileSaver::~fileSaver() | 97 | fileSaver::~fileSaver() |
94 | { | 98 | { |
95 | } | 99 | } |
96 | 100 | ||
97 | void fileSaver::populateList() | 101 | void fileSaver::populateList() |
98 | { | 102 | { |
99 | ListView->clear(); | 103 | ListView->clear(); |
104 | bool isDir=FALSE; | ||
100 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 105 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
101 | currentDir.setMatchAllDirs(TRUE); | 106 | currentDir.setMatchAllDirs(TRUE); |
102 | 107 | ||
103 | currentDir.setNameFilter("*"); | 108 | currentDir.setNameFilter("*"); |
104 | QString fileL, fileS; | 109 | QString fileL, fileS, fileDate; |
105 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 110 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
106 | QFileInfoListIterator it(*list); | 111 | QFileInfoListIterator it(*list); |
107 | QFileInfo *fi; | 112 | QFileInfo *fi; |
108 | while ( (fi=it.current()) ) { | 113 | while ( (fi=it.current()) ) { |
109 | 114 | ||
110 | if (fi->isSymLink() ){ | 115 | if (fi->isSymLink() ){ |
111 | QString symLink=fi->readLink(); | 116 | QString symLink=fi->readLink(); |
112 | // qDebug("Symlink detected "+symLink); | 117 | // qDebug("Symlink detected "+symLink); |
@@ -115,20 +120,52 @@ void fileSaver::populateList() | |||
115 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 120 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
116 | 121 | ||
117 | } else { | 122 | } else { |
118 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 123 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
119 | fileS.sprintf( "%10li", fi->size() ); | 124 | fileS.sprintf( "%10li", fi->size() ); |
120 | fileL.sprintf( "%s",fi->fileName().data() ); | 125 | fileL.sprintf( "%s",fi->fileName().data() ); |
121 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 126 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
122 | fileL+="/"; | 127 | fileL+="/"; |
128 | isDir=TRUE; | ||
123 | // qDebug(currentDir.canonicalPath()+fileL); | 129 | // qDebug(currentDir.canonicalPath()+fileL); |
124 | } | 130 | } |
125 | } | 131 | } |
126 | item= new QListViewItem( ListView,fileL,fileS ); | 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; | ||
127 | ++it; | 164 | ++it; |
128 | } | 165 | } |
129 | ListView->setSorting( 2, FALSE); | 166 | ListView->setSorting( 2, FALSE); |
130 | dirLabel->setText(currentDir.canonicalPath()); | 167 | dirLabel->setText(currentDir.canonicalPath()); |
131 | 168 | ||
132 | 169 | ||
133 | } | 170 | } |
134 | 171 | ||