summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/ofileselector_p.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp
index f85f8f4..e2af32b 100644
--- a/microkde/ofileselector_p.cpp
+++ b/microkde/ofileselector_p.cpp
@@ -147,28 +147,41 @@ QWidget* ODocumentFileView::widget( QWidget* parent ) {
147 147
148/* 148/*
149 * This is the file system view used 149 * This is the file system view used
150 * we use a QListView + QListViewItems for it 150 * we use a QListView + QListViewItems for it
151 */ 151 */
152 152
153OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 153OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
154 const QString& path, const QString& date, 154 const QString& path, const QString& date,
155 const QString& size, const QString& dir, 155 const QString& size, const QString& dir,
156 bool isLocked, bool isDir ) 156 bool isLocked, bool isDir )
157 : QListViewItem( view ) 157 : QListViewItem( view )
158{ 158{
159
160 QString kind;
161 QString _path = path;
162 if ( isDir )
163 kind = "dir";
164 else
165 kind = "file";
159 setPixmap(0, pixmap ); 166 setPixmap(0, pixmap );
160 setText(1, path ); 167 int arrow = path.find( "->" );
168 if (arrow > 0 ) {
169 kind += path.mid( arrow );
170 _path = path.left(arrow);
171 }
172 setText(1, _path );
161 setText(2, size ); 173 setText(2, size );
162 setText(3, date ); 174 setText(3, date );
175 setText(4, kind );
163 m_isDir = isDir; 176 m_isDir = isDir;
164 m_dir = dir; 177 m_dir = dir;
165 m_locked = isLocked; 178 m_locked = isLocked;
166} 179}
167OFileSelectorItem::~OFileSelectorItem() { 180OFileSelectorItem::~OFileSelectorItem() {
168 181
169} 182}
170bool OFileSelectorItem::isLocked()const { 183bool OFileSelectorItem::isLocked()const {
171 return m_locked; 184 return m_locked;
172} 185}
173QString OFileSelectorItem::directory()const { 186QString OFileSelectorItem::directory()const {
174 return m_dir; 187 return m_dir;
@@ -181,25 +194,30 @@ QString OFileSelectorItem::path()const {
181} 194}
182QString OFileSelectorItem::key( int id, bool )const { 195QString OFileSelectorItem::key( int id, bool )const {
183 QString ke; 196 QString ke;
184 if( id == 0 || id == 1 ){ // name 197 if( id == 0 || id == 1 ){ // name
185 if( m_isDir ){ 198 if( m_isDir ){
186 ke.append("0" ); 199 ke.append("0" );
187 ke.append( text(1) ); 200 ke.append( text(1) );
188 }else{ 201 }else{
189 ke.append("1" ); 202 ke.append("1" );
190 ke.append( text(1) ); 203 ke.append( text(1) );
191 } 204 }
192 return ke; 205 return ke;
193 }else 206 } else if ( id == 2 ) {
207 QString sort = "00000000";
208 sort = sort.left( 9-text( 2 ).length()) + text( 2 );
209 return sort;
210
211 } else
194 return text( id ); 212 return text( id );
195 213
196} 214}
197 215
198OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, 216OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir,
199 OFileSelector* sel) 217 OFileSelector* sel)
200 : QWidget( parent ), m_sel( sel ) { 218 : QWidget( parent ), m_sel( sel ) {
201 m_all = false; 219 m_all = false;
202 QVBoxLayout* lay = new QVBoxLayout( this ); 220 QVBoxLayout* lay = new QVBoxLayout( this );
203 m_currentDir = startDir; 221 m_currentDir = startDir;
204 222
205 /* 223 /*
@@ -336,38 +354,40 @@ void OFileViewFileListView::reread( bool all ) {
336 QFileInfo *fi; 354 QFileInfo *fi;
337 while( (fi=it.current() ) ){ 355 while( (fi=it.current() ) ){
338 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ 356 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
339 ++it; 357 ++it;
340 continue; 358 continue;
341 } 359 }
342 360
343 /* 361 /*
344 * It is a symlink we try to resolve it now but don't let us attack by DOS 362 * It is a symlink we try to resolve it now but don't let us attack by DOS
345 * 363 *
346 */ 364 */
347 if( fi->isSymLink() ){ 365 if( fi->isSymLink() ){
348 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 366 qDebug("SYMLINK ");
349 for( int i = 0; i<=4; i++) { // 5 tries to prevent dos 367 QString file = fi->readLink();
368 for( int i = 0; i<=5; i++) { // 5 tries to prevent dos
350 QFileInfo info( file ); 369 QFileInfo info( file );
370 qDebug("FILE %s ", file.latin1());
351 if( !info.exists() ){ 371 if( !info.exists() ){
352 addSymlink( fi, TRUE ); 372 addSymlink( fi, TRUE );
353 break; 373 break;
354 }else if( info.isDir() ){ 374 }else if( info.isDir() ){
355 addDir( fi, TRUE ); 375 addDir( fi, TRUE );
356 break; 376 break;
357 }else if( info.isFile() ){ 377 }else if( info.isFile() ){
358 addFile( fi, TRUE ); 378 addFile( fi, TRUE );
359 break; 379 break;
360 }else if( info.isSymLink() ){ 380 }else if( info.isSymLink() ){
361 file = info.dirPath(true ) + "/" + info.readLink() ; 381 file = info.readLink() ;
362 break; 382 break;
363 }else if( i == 4){ // couldn't resolve symlink add it as symlink 383 }else if( i == 4){ // couldn't resolve symlink add it as symlink
364 addSymlink( fi ); 384 addSymlink( fi );
365 } 385 }
366 } // off for loop for symlink resolving 386 } // off for loop for symlink resolving
367 }else if( fi->isDir() ) 387 }else if( fi->isDir() )
368 addDir( fi ); 388 addDir( fi );
369 else if( fi->isFile() ) 389 else if( fi->isFile() )
370 addFile( fi ); 390 addFile( fi );
371 391
372 ++it; 392 ++it;
373 } // of while loop 393 } // of while loop
@@ -477,25 +497,25 @@ void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) {
477 497
478 QPixmap pix = type.pixmap(); 498 QPixmap pix = type.pixmap();
479 QString dir, name; bool locked; 499 QString dir, name; bool locked;
480 if ( pix.isNull() ) { 500 if ( pix.isNull() ) {
481 QWMatrix matrix; 501 QWMatrix matrix;
482 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 502 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
483 matrix.scale( .4, .4 ); 503 matrix.scale( .4, .4 );
484 pix = pixer.xForm( matrix ); 504 pix = pixer.xForm( matrix );
485 } 505 }
486 dir = info->dirPath( true ); 506 dir = info->dirPath( true );
487 locked = false; 507 locked = false;
488 if ( symlink ) 508 if ( symlink )
489 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 509 name = info->fileName() + " -> " + info->readLink();
490 else{ 510 else{
491 name = info->fileName(); 511 name = info->fileName();
492 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 512 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
493 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { 513 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) {
494 locked = true; pix = Resource::loadPixmap("locked"); 514 locked = true; pix = Resource::loadPixmap("locked");
495 } 515 }
496 } 516 }
497 (void)new OFileSelectorItem( m_view, pix, name, 517 (void)new OFileSelectorItem( m_view, pix, name,
498 KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), 518 KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate),
499 QString::number( info->size() ), 519 QString::number( info->size() ),
500 dir, locked ); 520 dir, locked );
501} 521}
@@ -503,25 +523,25 @@ void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) {
503 bool locked = false; QString name; QPixmap pix; 523 bool locked = false; QString name; QPixmap pix;
504 524
505 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 525 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
506 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { 526 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) {
507 locked = true; 527 locked = true;
508 if ( symlink ) 528 if ( symlink )
509 pix = Resource::loadPixmap( "symlink" ); 529 pix = Resource::loadPixmap( "symlink" );
510 else 530 else
511 pix = Resource::loadPixmap( "lockedfolder" ); 531 pix = Resource::loadPixmap( "lockedfolder" );
512 }else 532 }else
513 pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); 533 pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder");
514 534
515 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : 535 name = symlink ? info->fileName() + " -> " + info->readLink() :
516 info->fileName(); 536 info->fileName();
517 537
518 (void)new OFileSelectorItem( m_view, pix, name, 538 (void)new OFileSelectorItem( m_view, pix, name,
519 KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), 539 KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate),
520 QString::number( info->size() ), 540 QString::number( info->size() ),
521 info->dirPath( true ), locked, true ); 541 info->dirPath( true ), locked, true );
522 542
523 543
524} 544}
525void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { 545void OFileViewFileListView::addSymlink( QFileInfo* , bool ) {
526 546
527} 547}