summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2005-06-18 16:38:24 (UTC)
committer zautrix <zautrix>2005-06-18 16:38:24 (UTC)
commit1919ddd25fb835b0eb03a44cbfbf4713d45266b8 (patch) (side-by-side diff)
treef2ed65d2ad6b204dcb7eeb76da8776aae69aba6c /microkde
parent4ad2d49928757d72657735e088ac1cf587637fca (diff)
downloadkdepimpi-1919ddd25fb835b0eb03a44cbfbf4713d45266b8.zip
kdepimpi-1919ddd25fb835b0eb03a44cbfbf4713d45266b8.tar.gz
kdepimpi-1919ddd25fb835b0eb03a44cbfbf4713d45266b8.tar.bz2
fixed links
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
@@ -135,83 +135,101 @@ QWidget* ODocumentFileView::widget( QWidget* parent ) {
if (!m_selector ) {
m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ),
selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
QObject::connect(m_selector, SIGNAL(closeMe() ),
selector(), SIGNAL(closeMe() ) );
QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ),
selector(), SIGNAL(newSelected(const DocLnk& ) ) );
}
return m_selector;
}
/*
* This is the file system view used
* we use a QListView + QListViewItems for it
*/
OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
const QString& path, const QString& date,
const QString& size, const QString& dir,
bool isLocked, bool isDir )
: QListViewItem( view )
{
+
+ QString kind;
+ QString _path = path;
+ if ( isDir )
+ kind = "dir";
+ else
+ kind = "file";
setPixmap(0, pixmap );
- setText(1, path );
+ int arrow = path.find( "->" );
+ if (arrow > 0 ) {
+ kind += path.mid( arrow );
+ _path = path.left(arrow);
+ }
+ setText(1, _path );
setText(2, size );
setText(3, date );
+ setText(4, kind );
m_isDir = isDir;
m_dir = dir;
m_locked = isLocked;
}
OFileSelectorItem::~OFileSelectorItem() {
}
bool OFileSelectorItem::isLocked()const {
return m_locked;
}
QString OFileSelectorItem::directory()const {
return m_dir;
}
bool OFileSelectorItem::isDir()const {
return m_isDir;
}
QString OFileSelectorItem::path()const {
return text( 1 );
}
QString OFileSelectorItem::key( int id, bool )const {
QString ke;
if( id == 0 || id == 1 ){ // name
if( m_isDir ){
ke.append("0" );
ke.append( text(1) );
}else{
ke.append("1" );
ke.append( text(1) );
}
return ke;
- }else
+ } else if ( id == 2 ) {
+ QString sort = "00000000";
+ sort = sort.left( 9-text( 2 ).length()) + text( 2 );
+ return sort;
+
+ } else
return text( id );
}
OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir,
OFileSelector* sel)
: QWidget( parent ), m_sel( sel ) {
m_all = false;
QVBoxLayout* lay = new QVBoxLayout( this );
m_currentDir = startDir;
/*
* now we add a special bar
* One Button For Up
* Home
* Doc
* And a dropdown menu with FileSystems
* FUTURE: one to change dir with lineedit
* Bookmarks
* Create Dir
*/
QHBox* box = new QHBox(this );
box->setBackgroundMode( PaletteButton );
box->setSpacing( 0 );
@@ -324,62 +342,64 @@ void OFileViewFileListView::reread( bool 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
+ qDebug("SYMLINK ");
+ QString file = fi->readLink();
+ for( int i = 0; i<=5; i++) { // 5 tries to prevent dos
QFileInfo info( file );
+ qDebug("FILE %s ", file.latin1());
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() ;
+ file = 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;
}
@@ -465,75 +485,75 @@ void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const
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();
+ name = info->fileName() + " -> " + 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
pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder");
- name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() :
+ name = symlink ? info->fileName() + " -> " + info->readLink() :
info->fileName();
(void)new OFileSelectorItem( m_view, pix, name,
KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate),
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 );
}