-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 1f6ca05..5528aed 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp @@ -422,285 +422,285 @@ void OFileViewFileListView::reread( bool all ) QDir dir( m_currentDir ); if (!dir.exists() ) return; dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); int filter; if (m_all ) filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; else filter = QDir::Files | QDir::Dirs | QDir::All; dir.setFilter( filter ); // now go through all files const QFileInfoList *list = dir.entryInfoList(); if (!list) { cdUP(); return; } QFileInfoListIterator it( *list ); QFileInfo *fi; while( (fi=it.current() ) ) { if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) { ++it; continue; } /* * It is a symlink we try to resolve it now but don't let us attack by DOS * */ if( fi->isSymLink() ) { QString file = fi->dirPath( true ) + "/" + fi->readLink(); for( int i = 0; i<=4; i++) { // 5 tries to prevent dos QFileInfo info( file ); if( !info.exists() ) { addSymlink( fi, TRUE ); break; } else if( info.isDir() ) { addDir( fi, TRUE ); break; } else if( info.isFile() ) { addFile( fi, TRUE ); break; } else if( info.isSymLink() ) { file = info.dirPath(true ) + "/" + info.readLink() ; break; } else if( i == 4) { // couldn't resolve symlink add it as symlink addSymlink( fi ); } } // off for loop for symlink resolving } else if( fi->isDir() ) addDir( fi ); else if( fi->isFile() ) addFile( fi ); ++it; } // of while loop m_view->sort(); } int OFileViewFileListView::fileCount()const { return m_view->childCount(); } QString OFileViewFileListView::currentDir()const { return m_currentDir; } OFileSelector* OFileViewFileListView::selector() { return m_sel; } bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *k = (QKeyEvent *)e; if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); return true; } } return false; } void OFileViewFileListView::connectSlots() { connect(m_view, SIGNAL(clicked(QListViewItem*) ), this, SLOT(slotCurrentChanged(QListViewItem*) ) ); connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); } void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { if (!item) return; #if 0 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); if (!sel->isDir() ) { selector()->m_lneEdit->setText( sel->text(1) ); // if in fileselector mode we will emit selected if ( selector()->mode() == OFileSelector::FileSelector ) { - owarn << "slot Current Changed" << oendl; + odebug << "slot Current Changed" << oendl; QStringList str = QStringList::split("->", sel->text(1) ); QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->fileSelected( path ); DocLnk lnk( path ); emit selector()->fileSelected( lnk ); } } #endif } void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { if (!item || ( button != Qt::LeftButton) ) return; OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); if (!sel->isLocked() ) { QStringList str = QStringList::split("->", sel->text(1) ); if (sel->isDir() ) { m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } else { // file - owarn << "slot Clicked" << oendl; + odebug << "slot Clicked" << oendl; selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->fileSelected( path ); DocLnk lnk( path ); emit selector()->fileSelected( lnk ); } } // not locked } void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { MimeType type( info->absFilePath() ); if (!compliesMime( type.id() ) ) return; QPixmap pix = type.pixmap(); QString dir, name; bool locked; if ( pix.isNull() ) { QWMatrix matrix; QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); matrix.scale( .4, .4 ); pix = pixer.xForm( matrix ); } dir = info->dirPath( true ); locked = false; if ( symlink ) name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); else { name = info->fileName(); if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { locked = true; pix = Resource::loadPixmap("locked"); } } (void)new OFileSelectorItem( m_view, pix, name, info->lastModified().toString(), QString::number( info->size() ), dir, locked ); } void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { bool locked = false; QString name; QPixmap pix; if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { locked = true; if ( symlink ) pix = Resource::loadPixmap( "opie/symlink" ); else pix = Resource::loadPixmap( "lockedfolder" ); } else pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : info->fileName(); (void)new OFileSelectorItem( m_view, pix, name, info->lastModified().toString(), QString::number( info->size() ), info->dirPath( true ), locked, true ); } void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { } void OFileViewFileListView::cdUP() { QDir dir( m_currentDir ); dir.cdUp(); if (!dir.exists() ) m_currentDir = "/"; else m_currentDir = dir.absPath(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::cdHome() { m_currentDir = QDir::homeDirPath(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::cdDoc() { m_currentDir = QPEApplication::documentDir(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::changeDir( const QString& dir ) { m_currentDir = dir; emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::slotFSActivated( int id ) { changeDir ( m_dev[m_fsPop->text(id)] ); } /* check if the mimetype in mime * complies with the one which is current */ /* * We've the mimetype of the file * We need to get the stringlist of the current mimetype * * mime = image@slashjpeg * QStringList = 'image@slash*' * or QStringList = image/jpeg;image/png;application/x-ogg * or QStringList = application/x-ogg;image@slash*; * with all these mime filters it should get acceptes * to do so we need to look if mime is contained inside * the stringlist * if it's contained return true |