Diffstat (limited to 'core/apps/textedit/fileBrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 117 |
1 files changed, 62 insertions, 55 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 | |||
@@ -123,3 +123,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
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 | ||
@@ -173,2 +173,3 @@ void fileBrowser::populateList() | |||
173 | ListView->clear(); | 173 | ListView->clear(); |
174 | QListViewItem * item; | ||
174 | bool isDir=FALSE; | 175 | bool isDir=FALSE; |
@@ -184,54 +185,54 @@ void fileBrowser::populateList() | |||
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 | } |
@@ -265,2 +266,3 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
265 | { | 266 | { |
267 | if(selectedItem) { | ||
266 | QString strItem=selectedItem->text(0); | 268 | QString strItem=selectedItem->text(0); |
@@ -304,2 +306,3 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
304 | } | 306 | } |
307 | } | ||
305 | } | 308 | } |
@@ -380,12 +383,16 @@ void fileBrowser::showListMenu(QListViewItem *item) { | |||
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 | } |
@@ -402,2 +409,3 @@ void fileBrowser::makDir() { | |||
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); |
@@ -438,3 +446,2 @@ void fileBrowser::localDelete() { | |||
438 | }; | 446 | }; |
439 | |||
440 | } else { | 447 | } else { |