summaryrefslogtreecommitdiffabout
path: root/microkde/ofileselector_p.cpp
Side-by-side diff
Diffstat (limited to 'microkde/ofileselector_p.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/ofileselector_p.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp
index fd5f965..f85f8f4 100644
--- a/microkde/ofileselector_p.cpp
+++ b/microkde/ofileselector_p.cpp
@@ -340,147 +340,173 @@ void OFileViewFileListView::reread( bool all ) {
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 0
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;
}
}
+#endif
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 ) ) );
+ connect(m_view, SIGNAL(doubleClicked( QListViewItem* )),
+ this, SLOT(slotDoubleClicked(QListViewItem* ) ) );
+ connect(m_view, SIGNAL(returnPressed( QListViewItem* )),
+ this, SLOT(slotDoubleClicked(QListViewItem* ) ) );
}
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 ) {
qWarning("slot Current Changed");
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::slotDoubleClicked(QListViewItem* item ) {
+ if (!item ) 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
+ //qWarning("slot Clicked");
+ 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 );
+ emit selector()->ok();
+ }
+ } // not locked
+}
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
- qWarning("slot Clicked");
+ //qWarning("slot Clicked");
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,
KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate),
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( "symlink" );
else
pix = Resource::loadPixmap( "lockedfolder" );
}else