dslinux/user/pixil/packages/viewml/viewml/kfile ChangeLog KFile.kdoc Makefile.am Makefile.in NOTES booktoken.cpp booktoken.h config-kfile.h configuration.txt configure.xpm kcombiview.cpp kcombiview.h kdir.cpp kdir.h kdirlistbox.cpp kdirlistbox.h kfilebookmark.cpp kfilebookmark.h kfiledetaillist.cpp kfiledetaillist.h kfiledialog.cpp kfiledialog.h kfiledialogconf.cpp kfiledialogconf.h kfilefilter.cpp kfilefilter.h kfileinfo.cpp kfileinfo.h kfileinfocontents.cpp kfileinfocontents.h kfilepreview.cpp kfilepreview.h kfilesimpleview.cpp kfilesimpleview.h kfstest.cpp kpreview.cpp kpreview.h kremotefile.cpp kremotefile.h xview.cpp xview.h
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:26:38 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/packages/viewml/viewml/kfile
In directory antilope:/tmp/cvs-serv11916/packages/viewml/viewml/kfile
Added Files:
ChangeLog KFile.kdoc Makefile.am Makefile.in NOTES
booktoken.cpp booktoken.h config-kfile.h configuration.txt
configure.xpm kcombiview.cpp kcombiview.h kdir.cpp kdir.h
kdirlistbox.cpp kdirlistbox.h kfilebookmark.cpp
kfilebookmark.h kfiledetaillist.cpp kfiledetaillist.h
kfiledialog.cpp kfiledialog.h kfiledialogconf.cpp
kfiledialogconf.h kfilefilter.cpp kfilefilter.h kfileinfo.cpp
kfileinfo.h kfileinfocontents.cpp kfileinfocontents.h
kfilepreview.cpp kfilepreview.h kfilesimpleview.cpp
kfilesimpleview.h kfstest.cpp kpreview.cpp kpreview.h
kremotefile.cpp kremotefile.h xview.cpp xview.h
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: kremotefile.h ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KREMOTEFILE_H
#define KREMOTEFILE_H
#include <qstring.h>
#include <kurl.h>
/**
* Obtain and keep track of the local copy of a remote file, removes
* the file when it is deleted.
*
* @author rich at kde.org
* @version $Id: kremotefile.h,v 1.1 2006-10-03 11:26:36 dslinux_amadeus Exp $
*/
class KRemoteFile {
public:
/**
* Fetch a remote file.
*/
KRemoteFile(const char *url);
/**
* Clean up the remote file object and delete the temporary file.
*/
virtual ~KRemoteFile();
/**
* Get the name of the local copy.
*/
const char *tempName();
/**
* Get the url it came from.
*/
const char *url();
private:
QString myTempName;
KURL myLocation;
};
#endif // KREMOTEFILE_H
--- NEW FILE: kfilefilter.cpp ---
#include "kfilefilter.h"
#include <qstrlist.h>
#include <kapp.h>
KFileFilter::KFileFilter( QWidget *parent, const char *name)
: QComboBox(true, parent, name), filters(0)
{
setInsertionPolicy(NoInsertion);
connect(this, SIGNAL(activated(const char*)), SLOT(changed(const char*)));
}
KFileFilter::~KFileFilter()
{
delete filters;
}
void KFileFilter::changed( const char * )
{
emit filterChanged();
}
void KFileFilter::setFilter(const char *filter)
{
delete filters;
filters = new QStrList( true );
if (filter) {
QString tmp = filter; // deep copy
char *g = strtok(tmp.data(), "\n");
while (g) {
filters->append(g);
g = strtok(0, "\n");
}
} else
filters->append(i18n("*|All Files"));
clear();
QString name;
for (const char *item = filters->first(); item;
item = filters->next()) {
name = item;
int tab = name.find('|');
insertItem((tab < 0) ? name :
name.mid(tab + 1, name.length() - tab));
}
}
QString KFileFilter::currentFilter()
{
QString filter = currentText();
if (filter == text(currentItem()))
filter = filters->at(currentItem());
int tab = filter.find('|');
if (tab < 0)
return filter;
else
return filter.left(tab);
}
#include "kfilefilter.moc"
--- NEW FILE: booktoken.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones at kde.org)
(C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
//
// Modified HTMLTokenizer from khtmlw
//
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "booktoken.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <kcharsets.h>
#include <kapp.h>
//-----------------------------------------------------------------------------
BookmarkTokenizer::BookmarkTokenizer()
{
head = tail = curr = 0;
buffer = 0;
}
void BookmarkTokenizer::reset()
{
while ( head )
{
curr = head->next();
delete head;
head = curr;
}
head = tail = curr = 0;
if ( buffer )
delete [] buffer;
buffer = 0;
}
void BookmarkTokenizer::begin()
{
reset();
size = 1000;
buffer = new char[ 1024 ];
dest = buffer;
tag = false;
space = false;
discardCR = false;
comment = false;
tquote = false;
}
void BookmarkTokenizer::write( const char *str )
{
KCharsets *charsets=KApplication::getKApplication()->getCharsets();
if ( str == 0L )
return;
const char *src = str;
while ( *src != 0 )
{
// do we need to enlarge the buffer?
if ( dest - buffer > size )
{
char *newbuf = new char [ size + 1024 ];
memcpy( newbuf, buffer, dest - buffer + 1 );
dest = newbuf + ( dest - buffer );
delete [] buffer;
buffer = newbuf;
size += 1024;
}
if ( comment )
{
if ( !strncmp( src, "->", 2 ) )
{
src += 2;
comment = false;
}
else
src++;
}
else if ( *src == '&' )
{
space = false;
// Is the string long enough?
if ( *(src+1) != '\0' && *(src+2) != '\0' )
{
// Special character by number?
if ( *(src + 1) == '#' )
{
char *endptr;
int z = (int) strtol( src+2, &endptr, 10 );
// parse only ascii characters unless in quotes
if (z<128 || tquote){
*dest++ = z;
}
else{
*dest=0;
// add currend token
appendToken(buffer,dest-buffer);
// add token with the amp-sequence for further conversion
memcpy(buffer,src,endptr-src);
buffer[endptr-src]=0;
appendToken(buffer,endptr-src);
dest=buffer;
}
src = endptr;
// Skip a trailing ';' ?
if ( *src == ';' )
src++;
}
// Special character ?
else if ( isalpha( *(src + 1) ) )
{
if (!tag){
// add currend token
*dest=0;
appendToken(buffer,dest-buffer);
dest=buffer;
const char *endptr=src+1;
while(*endptr && isalpha(*endptr)) endptr++;
if (*endptr==';') endptr++;
// add token with the amp-sequence for further conversion
memcpy(buffer,src,endptr-src);
buffer[endptr-src]=0;
appendToken(buffer,endptr-src);
src=endptr;
*dest=0;
}
else{
// There is no need for font switching
// when we are in tag quotes, so amp-sequences can be
// translated here. I hope noone uses non iso-8859-1
// characters here.
int len=0;
const QString res=charsets->convertTag(src,len).copy();
if ( len > 0 )
{
memcpy(dest,(const char *)res,res.length());
dest+=res.length();
src+=len;
}
else
{
*dest++ = *src++;
}
}
}
else
*dest++ = *src++;
}
else
*dest++ = *src++;
}
else if ( *src == '<' && !tquote )
{
src++;
if ( strncmp( src, "!-", 2 ) == 0 )
{
src += 2;
comment = true;
continue;
}
space = true; // skip leading spaces
discardCR = true; // skip leading CR
tquote = false;
if ( dest > buffer )
{
*dest = 0;
appendToken( buffer, dest-buffer );
dest = buffer;
}
*dest = TAG_ESCAPE;
dest++;
*dest = '<';
dest++;
tag = true;
}
else if ( *src == '>' && tag && !tquote )
{
space = false;
discardCR = false;
*dest = '>';
*(dest+1) = 0;
// make the tag lower case
char *ptr = buffer+2;
while ( *ptr && *ptr != ' ' )
{
*ptr = tolower( *ptr );
ptr++;
}
appendToken( buffer, dest-buffer+1 );
dest = buffer;
tag = false;
src++;
}
else if ( *src == '\n' )
{
if ( !discardCR )
{
if ( tag )
{
if ( !space )
{
*dest = ' ';
dest++;
space = true;
}
}
else if ( !space )
{
*dest = 0;
appendToken( buffer, dest-buffer );
dest = buffer;
*dest = ' ';
*(dest+1) = 0;
appendToken( buffer, 1 );
dest = buffer;
space = true;
}
}
src++;
}
else if ( *src == ' ' )
{
if ( tag )
{
if ( !space )
{
*dest = ' ';
dest++;
space = true;
}
}
else if ( !space )
{
*dest = 0;
appendToken( buffer, dest-buffer );
dest = buffer;
*dest = ' ';
*(dest+1) = 0;
appendToken( buffer, 1 );
dest = buffer;
space = true;
}
src++;
}
else if ( *src == '\t' )
{
if ( tag )
{
if ( !space )
{
*dest = ' ';
dest++;
space = true;
}
}
else if ( !space )
{
*dest = 0;
appendToken( buffer, dest-buffer );
dest = buffer;
*dest = ' ';
*(dest+1) = 0;
appendToken( buffer, 1 );
dest = buffer;
space = true;
}
src++;
}
else if ( *src == 13 )
{
// discard
src++;
}
else if ( *src == '\"' || *src == '\'')
{ // we treat " & ' the same in tags
if ( tag )
{
src++;
if ( *(dest-1) == '=' )
{
tquote = true;
*dest = '\"';
dest++;
space = false;
discardCR = false;
}
else if ( tquote )
{
tquote = false;
*dest = '\"';
dest++;
*dest = ' ';
dest++;
space = true;
discardCR = true;
}
else
continue; // stray '\"'
}
else
{
space = false;
discardCR = false;
*dest = *src++;
dest++;
}
}
else if ( *src == '=' )
{
src++;
if ( tag )
{
if ( tquote )
{
space = false;
discardCR = false;
*dest = '=';
dest++;
}
else
{
// discard space before '='
if ( *(dest-1) == ' ' )
dest--;
*dest = '=';
dest++;
space = true;
discardCR = true;
}
}
else
{
space = false;
discardCR = false;
*dest = '=';
dest++;
}
}
else
{
space = false;
discardCR = false;
*dest = *src++;
dest++;
}
}
}
void BookmarkTokenizer::end()
{
if ( buffer == 0 )
return;
if ( dest > buffer )
{
*dest = 0;
appendToken( buffer, dest-buffer );
}
delete [] buffer;
buffer = 0;
}
char* BookmarkTokenizer::nextToken()
{
char *t = curr->token();
curr = curr->next();
return t;
}
bool BookmarkTokenizer::hasMoreTokens()
{
return ( curr != 0 );
}
BookmarkTokenizer::~BookmarkTokenizer()
{
reset();
}
//-----------------------------------------------------------------------------
--- NEW FILE: kdir.h ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// $Id: kdir.h,v 1.1 2006-10-03 11:26:34 dslinux_amadeus Exp $
#ifndef KDIR_H
#define KDIR_H
#include "kfileinfo.h"
#include <sys/types.h> // To be safe
#include <dirent.h>
#include <qdir.h>
#include <qobject.h>
#include <qstrlist.h>
#include <kurl.h>
class KFM;
/*
** KDir - URL aware directory interface
**
*/
/**
* @short A URL aware directory object.
*/
class KDir : public QObject
{
Q_OBJECT
public:
KDir();
KDir (const KDir &);
KDir(const char *path,
const char *nameFilter= 0,
QDir::SortSpec sortSpec =
static_cast<QDir::SortSpec>(QDir::Name | QDir::IgnoreCase),
QDir::FilterSpec filterSpec= QDir::All);
KDir(const QDir &);
virtual ~KDir();
KDir &operator= (const KDir &);
KDir &operator= (const QDir &);
/**
* @param path or url.
*/
KDir &operator= (const char *);
/**
* Set the current path (accepts normal paths or urls)
*/
virtual void setPath(const char *);
/**
* Change to the parent directory
*/
void cdUp();
/**
* Returns the current host.
*/
const char *host() const { return myLocation.host(); }
/**
* Returns the current protocol.
*/
const char *protocol() const { return myLocation.protocol(); }
/**
* Returns the current path (or the path part of the url).
*/
const char *path() const { return myLocation.path(); }
/**
* Set the current url (accepts normal paths or urls).
*/
void setURL(const char *);
/**
* Returns the current url.
*/
QString url() const { return myLocation.url(); }
/**
* Returns the current name filter.
*/
const char *nameFilter() const { return myNameFilter; }
/**
* Set the current name filter.
*/
void setNameFilter(const char *);
/**
* Returns the current filter.
*/
QDir::FilterSpec filter() const { return myFilterSpec; }
/**
* Set the current filter.
*/
void setFilter(int);
/**
* Returns the current sort order.
*/
QDir::SortSpec sorting() const { return mySortSpec; }
/**
* Set the current sort order.
*/
void setSorting(int);
/**
* Returns the number of directory entries read.
*/
uint count();
/**
* Returns true if KFM has finished the operation.
*/
bool isFinished() const { return (myKfm == 0); }
/**
* Return a list of KFileInfo objects matching the specified filter.
* This call returns immediately, but may provide only partial
* information. If isFinished() returns true then you will receive
* complete information. If this is the contents of the directory are
* not cached then this method will call startLoading().
*
* In blocking I/O mode, it will only return the first maxReturn
* (default 100) entries. The rest will be send through signals
*/
const KFileInfoList *entryInfoList(int filterSpec = QDir::DefaultFilter,
int sortSpec = QDir::DefaultSort);
/**
* Returns true if the name matches the filter. Unlike the match() method
* provided by QDir, KDir allows you to specify more than one glob in the
* pattern. For example the pattern '*.cpp *.h' is valid.
*/
static bool match(const char *filter, const char *name);
/**
* sets, if the class should get the data via blocking I/O.
* This is just useful, if you want to override the internal logic
*/
void setBlocking(bool _block);
/**
* returns, if the class gets its data via blocking I/O
*/
bool blocking() { return isBlocking; }
static void setMaxReturns(uint max);
/**
* indicates, if the path is empty
**/
bool isRoot() { return root; }
/**
* indicates, if the path is readable. That means, if there are
* entries to expect
**/
bool isReadable() { return readable; }
signals:
/**
* Emitted when the url is changed
*/
void urlChanged(const char *);
/**
* Emitted when a directory entry that matches the filter is received.
*/
void dirEntry(KFileInfo *);
/**
* Emitted when the directory has been completely loaded.
*/
void finished();
/**
* Emitted if a network transfer goes wrong.
*/
void error(int, const char *);
/**
* Emitted, if new files are queued
**/
void newFilesArrived(const KFileInfoList *);
protected slots:
/**
* Called when a directory entry is received.
*/
void slotDirEntry(KDirEntry &);
/**
* Called when kfm has finished the current network operation.
*/
void slotKfmFinished();
void slotKfmError(int, const char *);
void timerEvent();
bool matchAllDirs() const { return myMatchDirs; }
void setMatchAllDirs( bool f ) { myMatchDirs = f; }
protected:
void updateFiltered();
bool filterEntry(KFileInfo *);
void initLists();
virtual void getEntries();
/**
* Start listing the directory in the background (returns immeditately).
* @return true if KFM was started successfully.
*/
virtual bool startLoading();
private:
KURL myLocation;
QString myNameFilter;
QDir::SortSpec mySortSpec;
QDir::FilterSpec myFilterSpec;
KFM *myKfm;
// Raw entries (we cache these for performance)
KFileInfoList myEntries;
bool myDirtyFlag;
// Filtered entries (what you actually get)
KFileInfoList myFilteredEntries;
// contains up to maxReturn entries (queueing)
KFileInfoList myTmpEntries;
QStrList myFilteredNames;
bool myFilteredDirtyFlag;
bool isBlocking;
bool root;
static uint maxReturns;
// if the directory is to big, we must divide it
DIR *myOpendir;
uint readFiles;
bool readable, myMatchDirs;
};
#endif // KDIR_H
--- NEW FILE: kfileinfocontents.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kfileinfocontents.h"
#include <qpixmap.h>
#include <qsignal.h>
#include <kapp.h>
#include "config-kfile.h"
#include <stdlib.h>
#ifdef Unsorted // the "I hate X.h" modus
#undef Unsorted
#endif
QPixmap *KFileInfoContents::folder_pixmap = 0;
QPixmap *KFileInfoContents::locked_folder = 0;
QPixmap *KFileInfoContents::file_pixmap = 0;
QPixmap *KFileInfoContents::locked_file = 0;
KFileInfoContents::KFileInfoContents( bool use, QDir::SortSpec sorting )
{
sorted_max = 10000;
sortedArray = new KFileInfo*[sorted_max];
sorted_length = 0;
reversed = false; // defaults
mySortMode = Increasing;
mySorting = sorting;
keepDirsFirst = true;
useSingleClick = use;
nameList = 0;
// don't use IconLoader to always get the same icon,
// it looks very strange, if the icons differ from application
// to application.
if (!folder_pixmap)
folder_pixmap = new QPixmap(KApplication::kde_icondir() +
"/mini/folder.xpm");
if (!locked_folder)
locked_folder = new QPixmap(KApplication::kde_icondir() +
"/mini/lockedfolder.xpm");
if (!file_pixmap)
file_pixmap = new QPixmap(KApplication::kde_icondir() +
"/mini/unknown.xpm");
if (!locked_file)
locked_file = new QPixmap(KApplication::kde_icondir() +
"/mini/locked.xpm");
sig = new KFileInfoContentsSignaler();
filesNumber = 0;
dirsNumber = 0;
}
KFileInfoContents::~KFileInfoContents()
{
delete [] sortedArray;
delete nameList;
delete sig;
}
bool KFileInfoContents::addItem(const KFileInfo *i)
{
if (!acceptsFiles() && i->isFile())
return false;
if (!acceptsDirs() && i->isDir())
return false;
if (i->isDir())
dirsNumber++;
else
filesNumber++;
return addItemInternal(i);
}
void KFileInfoContents::addItemList(const KFileInfoList *list)
{
setAutoUpdate(false);
bool repaint_needed = false;
KFileInfoListIterator it(*list);
for (; it.current(); ++it) {
debugC("insert %s", it.current()->fileName());
repaint_needed |= addItem(it.current());
}
setAutoUpdate(true);
if (repaint_needed)
repaint(true);
}
void KFileInfoContents::setSorting(QDir::SortSpec new_sort)
{
QDir::SortSpec old_sort =
static_cast<QDir::SortSpec>(sorting() & QDir::SortByMask);
QDir::SortSpec sortflags =
static_cast<QDir::SortSpec>(sorting() & (~QDir::SortByMask));
if (mySortMode == Switching) {
if (new_sort == old_sort)
reversed = !reversed;
else
reversed = false;
} else
reversed = (mySortMode == Decreasing);
mySorting = static_cast<QDir::SortSpec>(new_sort | sortflags);
if (count() <= 1) // nothing to do in this case
return;
if ( mySorting & QDir::DirsFirst )
keepDirsFirst = true;
else
keepDirsFirst = false;
setAutoUpdate(false);
clearView();
debugC("qsort %ld", time(0));
QuickSort(sortedArray, 0, sorted_length - 1);
debugC("qsort %ld", time(0));
for (uint i = 0; i < sorted_length; i++)
insertItem(sortedArray[i], -1);
debugC("qsort %ld", time(0));
setAutoUpdate(true);
repaint(true);
}
void KFileInfoContents::clear()
{
sorted_length = 0;
delete nameList;
nameList = 0;
clearView();
filesNumber = 0;
dirsNumber = 0;
}
void KFileInfoContents::connectDirSelected( QObject *receiver,
const char *member)
{
sig->connect(sig, SIGNAL(dirActivated(KFileInfo*)), receiver, member);
}
void KFileInfoContents::connectFileHighlighted( QObject *receiver,
const char *member)
{
sig->connect(sig, SIGNAL(fileHighlighted(KFileInfo*)), receiver, member);
}
void KFileInfoContents::connectFileSelected( QObject *receiver,
const char *member)
{
sig->connect(sig, SIGNAL(fileSelected(KFileInfo*)), receiver, member);
}
// this implementation is from the jdk demo Sorting
void KFileInfoContents::QuickSort(KFileInfo* a[], int lo0, int hi0)
{
int lo = lo0;
int hi = hi0;
const KFileInfo *mid;
if ( hi0 > lo0)
{
/* Arbitrarily establishing partition element as the midpoint of
* the array.
*/
mid = a[ ( lo0 + hi0 ) / 2 ];
// loop through the array until indices cross
while( lo <= hi )
{
/* find the first element that is greater than or equal to
* the partition element starting from the left Index.
*/
while( ( lo < hi0 ) && ( compareItems(a[lo], mid) < 0 ) )
++lo;
/* find an element that is smaller than or equal to
* the partition element starting from the right Index.
*/
while( ( hi > lo0 ) && ( compareItems(a[hi], mid) > 0) )
--hi;
// if the indexes have not crossed, swap
if( lo <= hi )
{
if (lo != hi) {
const KFileInfo *T = a[lo];
a[lo] = a[hi];
a[hi] = const_cast<KFileInfo*>(T);
}
++lo;
--hi;
}
}
/* If the right index has not reached the left side of array
* must now sort the left partition.
*/
if( lo0 < hi )
QuickSort( a, lo0, hi );
/* If the left index has not reached the right side of array
* must now sort the right partition.
*/
if( lo < hi0 )
QuickSort( a, lo, hi0 );
}
}
int KFileInfoContents::compareItems(const KFileInfo *fi1, const KFileInfo *fi2)
{
static int counter = 0;
counter++;
if (counter % 1000 == 0)
debugC("compare %d", counter);
bool bigger = true;
if (keepDirsFirst && (fi1->isDir() != fi2->isDir()))
bigger = !fi1->isDir();
else {
QDir::SortSpec sort = static_cast<QDir::SortSpec>(mySorting & QDir::SortByMask);
if (fi1->isDir())
sort = QDir::Name;
switch (sort) {
case QDir::Unsorted:
bigger = true; // nothing
break;
case QDir::Size:
bigger = (fi1->size() > fi2->size());
break;
case QDir::Name:
default:
bigger = (stricmp(fi1->fileName(),
fi2->fileName()) > 0);
}
}
if (reversed)
bigger = !bigger;
// debugC("compare %s against %s: %s", fi1->fileName(), fi2->fileName(), bigger ? "bigger" : "smaller");
return (bigger ? 1 : -1);
}
int KFileInfoContents::findPosition(const KFileInfo *i, int left)
{
int pos = left;
int right = sorted_length - 1;
while (left < right-1) {
pos = (left + right) / 2;
if (compareItems(i, sortedArray[pos]) < 0)
right = pos;
else
left = pos;
}
// if pos is the left side (rounded), it may be, that we haven't
// compared to the right side and gave up too early
if (pos == left && compareItems(i, sortedArray[right]) > 0)
pos = right+1;
else
pos = right;
if (pos == -1)
pos = sorted_length;
// debugC("findPosition %s %d", i->fileName(), pos);
return pos;
}
bool KFileInfoContents::addItemInternal(const KFileInfo *i)
{
int pos = -1;
if ( sorted_length > 1 && mySorting != QDir::Unsorted) {
// insertation using log(n)
pos = findPosition(i, 0);
} else {
if (sorted_length == 1 && compareItems(i, sortedArray[0]) < 0)
pos = 0;
else
pos = sorted_length;
}
// if the namelist already exist, we can use inSort. In general
// this is too slow
if (nameList)
nameList->inSort(i->fileName());
insertSortedItem(i, pos);
return insertItem(i, pos);
}
const char *KFileInfoContents::text(uint index) const
{
if (index < sorted_length)
return sortedArray[index]->fileName();
else
return "";
}
void KFileInfoContents::select( int index )
{
select(sortedArray[index]);
}
void KFileInfoContents::select( KFileInfo *entry)
{
if ( entry->isDir() ) {
debugC("selectDir %s",entry->fileName());
sig->activateDir(entry);
} else {
sig->activateFile(entry);
}
}
void KFileInfoContents::highlight( KFileInfo *entry )
{
sig->highlightFile(entry);
}
void KFileInfoContents::highlight( int index )
{
highlight(sortedArray[index]);
}
void KFileInfoContents::repaint(bool f)
{
widget()->repaint(f);
}
void KFileInfoContents::setCurrentItem(const char *item,
const KFileInfo *entry)
{
uint i;
if (item != 0) {
for (i = 0; i < sorted_length; i++)
if (!strcmp(sortedArray[i]->fileName(),item)) {
highlightItem(i);
highlight(i);
return;
}
} else
for (i = 0; i < sorted_length; i++)
if (sortedArray[i] == entry) {
highlightItem(i);
return;
}
warning("setCurrentItem: no match found.");
}
QString KFileInfoContents::findCompletion( const char *base,
bool activateFound )
{
if (!nameList) {
uint i;
nameList = new QStrIList();
// prepare an array for quicksort. This is much faster than
// calling n times inSort
const char **nameArray = new const char*[sorted_length];
// fill it
for (i = 0; i < sorted_length; i++)
nameArray[i] = sortedArray[i]->fileName();
qsort(nameArray, sorted_length, sizeof(const char*), (int (*)(const void *, const void *)) stricmp);
// insert into list. Keeps deep copies
for (i = 0; i < sorted_length; i++)
nameList->append(nameArray[i]);
delete [] nameArray;
}
if ( strlen(base) == 0 ) return 0;
QString remainder = base;
const char *name;
for ( name = nameList->first(); name; name = nameList->next() ) {
if ( strlen(name) < remainder.length())
continue;
if (strncmp(name, remainder, remainder.length()) == 0)
break;
}
if (name) {
QString body = name;
QString backup = name;
// get the possible text completions and store the smallest
// common denominator in QString body
unsigned int counter = strlen(base);
for ( const char *extra = nameList->next(); extra;
extra = nameList->next() ) {
counter = strlen(base);
// case insensitive comparison needed because items are stored insensitively
// so next instruction stop loop when first letter does no longer match
if ( strnicmp( extra, remainder, 1 ) != 0 )
break;
// this is case sensitive again!
// goto next item if no completion possible with current item (->extra)
if ( strncmp(extra, remainder, remainder.length()) != 0 )
continue;
// get smallest common denominator
for ( ; counter <= strlen(extra) ; counter++ ) {
if (strncmp( extra, body, counter) != 0)
break;
}
// truncate body, we have the smalles common denominator so far
if ( counter == 1 )
body.truncate(counter);
else
body.truncate(counter-1);
// this is needed because we want to highlight the first item in list
// so we separately keep the "smallest" item separate,
// we need the biggest in case the list is reversed
if ( extra && ( reversed ? (strcmp( extra, backup ) > 0) : (strcmp( extra, backup ) < 0) ) )
backup = extra;
}
name = backup;
debugC("completion base (%s) name (%s) body (%s)", base, name, body.data());
bool matchExactly = (name == body);
if (matchExactly && (activateFound || useSingleClick))
{
for (uint j = 0; j < sorted_length; j++)
{
KFileInfo *i = sortedArray[j];
if (i->fileName() == name) {
if (sortedArray[j]->isDir())
body += "/";
highlightItem(j);
if (activateFound)
select(j);
else
highlight(j);
break;
}
}
} else
setCurrentItem(name); // the first matching name
return body;
} else {
debugC("no completion for %s", base);
return 0;
}
}
void KFileInfoContents::insertSortedItem(const KFileInfo *item, uint pos)
{
// debug("insert %s %d", item->fileName(), pos);
if (sorted_length == sorted_max) {
sorted_max *= 2;
KFileInfo **newArray = new KFileInfo*[sorted_max];
int found = 0;
for (uint j = 0; j < sorted_length; j++) {
if (j == pos) {
found = 1;
newArray[j] = const_cast<KFileInfo*>(item);
}
newArray[j+found] = sortedArray[j];
}
if (!found)
newArray[pos] = const_cast<KFileInfo*>(item);
delete [] sortedArray;
sortedArray = newArray;
sorted_length++;
return;
}
// faster repositioning (very fast :)
memmove(sortedArray + pos+1,
sortedArray + pos,
(sorted_max - 1 - pos) * sizeof(KFileInfo*));
sortedArray[pos] = const_cast<KFileInfo*>(item);
sorted_length++;
}
#include "kfileinfocontents.moc" // for the signaler
--- NEW FILE: kfilebookmark.h ---
/* This file is part of the KDE libraries
Copyright (C) 1996, 1997, 1998 Martin R. Jones <mjones at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
//
// KDE HTML Bookmarks
//
// (c) Martin R. Jones 1996
//
#ifndef __BOOKMARK_H__
#define __BOOKMARK_H__
#include <qobject.h>
#include <qtextstream.h>
#include "booktoken.h"
class KFileBookmark
{
public:
enum { URL, Folder };
KFileBookmark();
KFileBookmark( const char *_text, const char *_url );
void clear();
void setText( const char *_text ) { text = _text; }
void setURL( const char *_url ) { url = _url; }
void setType( int _type ) { type = _type; }
const char *getText() { return text; }
const char *getURL() { return url; }
int getType() { return type; }
QList<KFileBookmark> &getChildren() { return children; }
private:
QString text;
QString url;
int type;
QList<KFileBookmark> children;
};
class KFileBookmarkManager : public QObject
{
Q_OBJECT
public:
KFileBookmarkManager();
void setTitle( const char *t )
{ title = t; }
void read( const char *filename );
void write( const char *filename );
void add( const char *_text, const char *_url );
// rich
bool remove(int);
bool moveUp(int);
bool moveDown(int);
void reread();
void rename(int, const char *);
/**
* Overloaded to reread the last file loaded
*/
void write();
KFileBookmark *getBookmark( int id );
KFileBookmark *getRoot() { return &root; }
private:
const char *parse( BookmarkTokenizer *ht, KFileBookmark *parent, const char *_end);
void writeFolder( QTextStream &stream, KFileBookmark *parent );
KFileBookmark *findBookmark( KFileBookmark *parent, int id, int &currId );
signals:
void changed();
private:
KFileBookmark root;
QString title;
// rich
QString myFilename;
};
#endif // __BOOKMARK_H__
--- NEW FILE: NOTES ---
Rewrite
=======
To Add
======
Mime Mappings?
Filter= ( Mime Type | shell glob list )
Mime Type -> shell glob list
--- NEW FILE: config-kfile.h ---
// #define COOLOS 1
#if defined(COOLOS)
#define debugC debug
#else
inline void debugC(const char *,...) {};
#endif
#define DefaultViewStyle "SimpleView"
#define DefaultSingleClick false
#define DefaultShowListLabels true
#define DefaultShowFilter true
#define DefaultPannerPosition 40
#define DefaultMixDirsAndFiles true
#define DefaultShowStatusLine false
#define DefaultShowHidden true
#define DefaultKeepDirsFirst true
#define DefaultFindCommand "kfind"
#define DefaultShowDirsLeft true
--- NEW FILE: kfiledialog.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __KFILEDIALOG_H__
#define __KFILEDIALOG_H__
#include <qdialog.h>
#include <qstring.h>
#include <qstack.h>
#include <qstrlist.h>
#include <qpixmap.h>
#include "kfileinfo.h"
class KToolBar;
class KDirListBox;
class KFileInfoContents;
class QPopupMenu;
class QCheckBox;
class QComboBox;
class KCombo;
class KFileBookmarkManager;
class KFileBookmark;
class QStrIList;
class QLineEdit;
class KDir;
class QLabel;
class QVBoxLayout;
class QGridLayout;
class QHBoxLayout;
class KFileFilter;
/**
* The KFileDialog widget provides a user (and developer) friendly way to
* select files. The widget can be used as a drop in replacement for the
* QFileDialog widget, but has greater functionality and a nicer GUI.
*
* You will usually want to use one of the two static methods
* KFileDialog::getOpenFileName or KFileDialog::getSaveFileName.
*
* The dialog has been designed to allow applications to customise it
* by subclassing. It uses geometry management to ensure that subclasses
* can easily add children which will be incorperated into the layout.
*
* @short A file selection dialog
*
* @author Richard J. Moore rich at kde.org
*/
class KFileBaseDialog : public QDialog
{
Q_OBJECT
public:
/**
* Construct a KFileBaseDialog
*
* @param dirName The name of the directory to start in.
* @param filter A shell glob that specifies which files to display.
* see setFilter for details on how to use this argument
* @param acceptURLs If set to false, kfiledialog will just accept
* files on the local filesystem.
*/
KFileBaseDialog(const char *dirName, const char *filter= 0,
QWidget *parent= 0, const char *name= 0,
bool modal = false, bool acceptURLs = true);
/**
* Cleans up
*/
~KFileBaseDialog();
/**
* Returns the fully qualified filename.
*/
QString selectedFile();
/**
* Return the path of the selected directory.
*/
QString dirPath();
/**
* Rereads the currently selected directory.
*/
void rereadDir();
/**
* Go back to the previous directory if this is not the first.
*/
void back();
/**
* Go forward to the next directory if this is not the last.
*/
void forward();
/**
* Go home.
*/
void home();
/**
* Go to parent.
*/
void cdUp();
/**
* Returns true for local files, false for remote files.
*/
bool dirIsLocal() const { return !acceptUrls; }
/**
* Returns the url of the selected filename
*/
QString selectedFileURL();
/**
* Returns the URLs of the selected files.
*/
QStrList selectedFileURLList();
/**
* If the argument is true the dialog will accept multiple selections.
*/
void setMultiSelection(bool multi= true);
/**
* Returns true if multiple selections are enabled.
*/
bool isMultiSelection() const { return false; }
/**
* This method creates a modal directory dialog and returns the selected
* directory or an empty string if none was chosen. Note that with
* this method the user must select an existing directory.
*
* @param url This specifies the path the dialog will start in.
* @param parent The widget the dialog will be centered on initially.
* @param name The name of the dialog widget.
*/
static QString getDirectory(const char *url, QWidget *parent = 0,
const char *name = 0);
/**
* This a multiple selection version of getOpenFileURL().
*/
QStrList getOpenFileURLList(const char *url= 0,
const char *filter= 0,
QWidget *parent= 0,
const char *name= 0);
/**
* This a multiple selection version of getSaveFileURL().
*/
QStrList getSaveFileURLList(const char *url= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
/**
* Sets the directory to view
* @param name URL to show
* @param clearforward indicate, if the forward queue
* should be cleared
*/
void setDir(const char *name, bool clearforward = true);
/**
* Sets the filename to preselect.
* It takes absolute and relative file names
*/
void setSelection(const char *name);
/**
* Sets the filter to be used to filter. You can set more
* filters for the user to select seperated by \n. Every
* filter entry is defined through namefilter|text to diplay.
* If no | is found in the expression, just the namefilter is
* shown. Examples:
*
* <pre>
* kfile->setFilter("*.cpp|C++ Source Files\n*.h|Header files");
* kfile->setFilter("*.cpp");
* kfile->setFilter("*.cpp|Sources (*.cpp");
* </pre>
*
* Note: the text to display is not parsed in any way. So, if you
* want to show the suffix to select by a specific filter, you must
* repeat it.
*/
void setFilter(const char *filter);
signals:
/**
* Emitted when the user selects a file.
*/
void fileSelected(const char *);
/**
* Emitted when the user highlights a file.
*/
void fileHighlighted(const char *);
/**
* Emitted when a new directory is entered.
*/
void dirEntered(const char *);
/**
* Emitted when the allowable history operations change.
*/
void historyUpdate(bool, bool);
protected:
KToolBar *toolbar;
KFileInfoContents *fileList;
QStrIList *visitedDirs; // to fill the combo box
static QString *lastDirectory;
QPopupMenu *bookmarksMenu;
QCheckBox *hiddenToggle;
KCombo *locationEdit;
KFileFilter *filterWidget;
KFileBookmarkManager *bookmarks;
QStrList history;
KDir *dir;
QLabel *myStatusLine;
// the last selected filename
QString filename_;
// the name of the filename set by setSelection
QString selection;
// represents the check box. Initialized by "ShowHidden"
bool showHidden;
/*
* indicates, if the status bar should be shown.
* Initialized by "ShowStatusLine"
*/
bool showStatusLine;
bool showFilter;
bool acceptUrls;
/**
* Contains all URLs you can reach with the back button.
*/
QStack<QString> backStack;
/**
* Contains all URLs you can reach with the forward button.
*/
QStack<QString> forwardStack;
/**
* Lock @ref #backStack and @ref #forwardStack .
*/
bool stackLock;
void resizeEvent(QResizeEvent *);
/**
* Subclasses should reimplement this method to swallow the main
* layout. This allows the addition of children that are outside
* the existing layout. The function should return the widget that
* should be the parent of the main layout.
*/
virtual QWidget *swallower() { return this; }
/**
* Subclasses, that want another view should override this
* function to provide another file view.
* It will be used to display files.
**/
virtual KFileInfoContents *initFileList( QWidget *parent ) = 0;
/**
* Overload this function, if you want the filter shown/unshown
*/
virtual bool getShowFilter() = 0;
/**
* adds a entry of the current directory. If disableUpdating is set
* to true, it will care about clever updating
**/
void addDirEntry(KFileInfo *entry, bool disableUpdating);
/**
* rebuild geometry managment.
*
*/
void initGUI();
/**
* Makes a new directory in current directory after asking user
* for a name
*/
void mkdir();
/**
* takes action on the new location. If it's a directory, change
* into it, if it's a file, correct the name, etc.
* @param takeFiles if set to true, if will close the dialog, if
* txt is a file name
*/
void checkPath(const char *txt, bool takeFiles = false);
/**
* this functions must be called by the constructor of a derived
* class.
**/
void init();
protected slots:
void pathChanged();
void comboActivated(int);
void toolbarCallback(int);
void toolbarPressedCallback(int);
void dirActivated(KFileInfo*);
void fileActivated(KFileInfo*);
void fileHighlighted(KFileInfo*);
void updateHistory(bool, bool);
void filterChanged();
void locationChanged(const char*);
void setHiddenToggle(bool);
void slotDirEntry(KFileInfo *);
void slotFinished();
void slotKfmError(int, const char *);
void insertNewFiles(const KFileInfoList *newone);
void completion();
virtual void updateStatusLine();
virtual void okPressed();
/**
* You should override this method if you change the user interface of
* this dialog in a subclass in order to invoke your updated user help.
*/
virtual void help();
/**
* Add the current location to the global bookmarks list
*/
void addToBookmarks();
void bookmarksChanged();
void fillBookmarkMenu( KFileBookmark *parent, QPopupMenu *menu, int &id );
private:
//
// the father of the widget. By default itself, but
// to make it customable, this can be overriden by
// overriding swallower()
//
QWidget *wrapper;
// flag for perfomance hype ;)
bool repaint_files;
// for the handling of the cursor
bool finished;
// indicates, if the file selector accepts just existing
// files or not. If set to true, it will check for local
// files, if they exist
bool acceptOnlyExisting;
// now following all kind of widgets, that I need to rebuild
// the geometry managment
QVBoxLayout *boxLayout;
QGridLayout *lafBox;
QHBoxLayout *btngroup;
QPushButton *bOk, *bCancel, *bHelp;
QLabel *locationLabel, *filterLabel;
QString filterString;
};
/**
* The KDirDialog widget provides a user (and developer) friendly way to
* select directories. It is a specalised KFileDialog.
*
* You will usually want to use one of the two static methods
* KFileDialog::getDirectory.
*
* Being a subclass of KFileKFileBaseDialog, it can therefore be easily
* customised.
*
* @short A directory selection dialog
*
*/
class KDirDialog : public KFileBaseDialog
{
public:
KDirDialog(const char *url, QWidget *parent, const char *name);
protected:
virtual KFileInfoContents *initFileList( QWidget *parent );
virtual bool getShowFilter() { return false; }
virtual void updateStatusLine();
};
class KFileDialog : public KFileBaseDialog
{
public:
KFileDialog(const char *dirName, const char *filter= 0,
QWidget *parent= 0, const char *name= 0,
bool modal = false, bool acceptURLs = true);
/**
* This method creates a modal file dialog and returns the selected
* filename or an empty string if none was chosen. Note that with
* this method the user must select an existing filename.
*
* @param dir This specifies the path the dialog will start in.
* @param filter This is a space seperated list of shell globs.
* @param parent The widget the dialog will be centered on initially.
* @param name The name of the dialog widget.
*/
static QString getOpenFileName(const char *dir= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
/**
* This method creates a modal file dialog and returns the selected
* filename or an empty string if none was chosen. Note that with this
* method the user need not select an existing filename.
*
* @param dir This specifies the path the dialog will start in.
* @param filter This is a space seperated list of shell globs.
* @param parent The widget the dialog will be centered on initially.
* @param name The name of the dialog widget.
*/
static QString getSaveFileName(const char *dir= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
/**
* This function is similar to getOpenFileName() but allows the
* user to select a local file or a remote file.
*/
static QString getOpenFileURL(const char *url= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
/**
* This function is similar to getSaveFileName() but allows the
* user to select a local file or a remote file.
*/
static QString getSaveFileURL(const char *url= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
protected:
virtual KFileInfoContents *initFileList( QWidget *parent);
virtual bool getShowFilter();
};
typedef bool (*PreviewHandler)( const KFileInfo *, const QString fileName,
QString &, QPixmap & );
/**
* Preview modules are of one of these types, which means their preview is either
* text or an pixmap (image).
*/
enum PreviewType { PreviewText = 0x001,
PreviewPixmap = 0x002 };
/**
* The KFilePreviewDialog widget provides a user (and developer) friendly way to
* select files while showing a preview.
*
* You will usually want to use one of the static methods
* KFilePreviewDialog::get[Open|Save][Name|URL](...) which are the same
* as the KFileDialog ones.
*
* Being a subclass of KFileKFileBaseDialog, it can therefore be easily
* customised.
*
* @short A file selection dialog with preview
*
*/
class KFilePreviewDialog : public KFileBaseDialog
{
public:
KFilePreviewDialog(const char *dirName, const char *filter= 0,
QWidget *parent= 0, const char *name= 0,
bool modal = false, bool acceptURLs = true);
~KFilePreviewDialog() {}
static QString getOpenFileName(const char *dir= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
static QString getSaveFileName(const char *dir= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
static QString getOpenFileURL(const char *url= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
static QString getSaveFileURL(const char *url= 0, const char *filter= 0,
QWidget *parent= 0, const char *name= 0);
/**
* This is a static method which allow a user to define a new preview dialog module.
*
* @param format This identifies the module e.g. "JPG" or "PNG".
* @param readPreview This is the function which generates the preview
* @param type This is the type of the preview module
* @see PreviewType
*/
static void registerPreviewModule( const char * format, PreviewHandler readPreview,
PreviewType type);
protected:
virtual KFileInfoContents *initFileList( QWidget *parent );
virtual bool getShowFilter();
};
#endif
--- NEW FILE: kdir.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qdir.h>
#include <qfileinfo.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include "kdir.h"
#include <time.h>
#include <qtimer.h>
#include <kfm.h>
#include "kfileinfo.h"
/*
** KDir - URL aware directory interface
**
*/
uint KDir::maxReturns = 100;
KDir::KDir()
: QObject(0, "KDir")
{
initLists();
myNameFilter= "*";
myFilterSpec= QDir::DefaultFilter;
mySortSpec = QDir::DefaultSort;
setPath(QDir::currentDirPath());
}
KDir::KDir(const char *url, const char *nameFilter,
QDir::SortSpec sortSpec,
QDir::FilterSpec filterSpec)
: QObject(0, "KDir")
{
initLists();
myNameFilter = (nameFilter == 0) ? "*" : nameFilter;
mySortSpec= sortSpec;
myFilterSpec= filterSpec;
myFilteredDirtyFlag= true;
setPath(url);
}
KDir::KDir(const KDir &d)
: QObject(0, "KDir")
{
initLists();
myNameFilter= d.nameFilter();
setPath(d.url());
mySortSpec= d.sorting();
myFilterSpec= d.filter();
myFilteredDirtyFlag= true;
}
KDir::KDir(const QDir &d)
: QObject(0, "KDir")
{
initLists();
myNameFilter= d.nameFilter();
setPath(d.path());
mySortSpec= d.sorting();
myFilterSpec= d.filter();
myFilteredDirtyFlag= true;
}
void KDir::initLists()
{
myOpendir = 0;
readFiles = 0;
setMatchAllDirs(true);
myTmpEntries.setAutoDelete(false);
myDirtyFlag= true;
myFilteredDirtyFlag= true;
myKfm= 0;
myEntries.setAutoDelete(true);
myFilteredEntries.setAutoDelete(true);
myFilteredNames.setAutoDelete(true);
}
KDir::~KDir()
{
delete myKfm;
}
KDir &KDir::operator= (const KDir &d)
{
setPath(d.path());
return *this;
}
KDir &KDir::operator= (const QDir &d)
{
setPath(d.path());
return *this;
}
KDir &KDir::operator= (const char *url)
{
setPath(url);
return *this;
}
void KDir::cdUp()
{
KURL u = myLocation.url().data();
u.cd("..");
setPath(u.url());
}
void KDir::setPath(const char *url)
{
QString ts = url;
if (ts.right(1) != "/")
ts += "/";
KURL tmp = ts.data();
isBlocking = true;
if (tmp.isLocalFile()) { // we can check, if the file is there
struct stat buf;
QString ts = tmp.path();
int ret = stat(ts.data(), &buf);
readable = (ret == 0);
if (readable) { // further checks
DIR *test;
test = opendir(ts); // we do it just to test here
readable = (test != 0);
if (test)
closedir(test);
}
} else {
readable = true; // what else can we say?
isBlocking = false;
}
if (!tmp.isMalformed())
myLocation= tmp.url();
else
warning("Malformed url %s\n", url);
root = (strcmp(myLocation.path(),"/") == 0);
if (!readable)
return; // nothing more we can do here
if (myOpendir) {
closedir(myOpendir);
myOpendir = 0;
}
myDirtyFlag= true;
myFilteredDirtyFlag= true;
}
void KDir::setURL(const char *url)
{
setPath(url);
}
void KDir::setNameFilter(const char *nameFilter)
{
myFilteredDirtyFlag |= (myNameFilter != nameFilter);
myNameFilter= nameFilter;
}
void KDir::setFilter(int f)
{
myFilteredDirtyFlag |= (myFilterSpec != f);
myFilterSpec= static_cast<QDir::FilterSpec>(f);
}
void KDir::setSorting(int s)
{
myFilteredDirtyFlag |= (mySortSpec != s);
mySortSpec= static_cast<QDir::SortSpec>(s);
}
uint KDir::count()
{
if (myFilteredDirtyFlag)
updateFiltered();
return myFilteredNames.count();
}
void KDir::updateFiltered()
{
myFilteredNames.clear();
myFilteredEntries.clear();
if (myDirtyFlag) {
myTmpEntries.clear();
myEntries.clear();
if (isBlocking)
getEntries();
else
startLoading();
} else {
for (KFileInfo *i= myEntries.first(); i; i=myEntries.next()) {
if (filterEntry(i)) {
KFileInfo *fi= new KFileInfo(*i);
CHECK_PTR(fi);
myFilteredEntries.append(fi);
myFilteredNames.append(fi->fileName());
}
}
}
}
void KDir::timerEvent() {
myTmpEntries.clear();
if (myOpendir)
getEntries();
readFiles = 0;
if (myTmpEntries.count())
emit newFilesArrived(&myTmpEntries);
}
void KDir::getEntries() {
struct dirent *dp;
if (!myOpendir) {
QString ts = myLocation.path();
myOpendir = opendir(ts);
if (!myOpendir)
return;
dp = readdir(myOpendir); // take out the "."
}
if (myOpendir) {
KFileInfo *i;
QString path = myLocation.path();
path += "/";
do {
dp = readdir(myOpendir);
if (!dp)
break;
i = new KFileInfo(path, dp->d_name);
CHECK_PTR(i);
if (!i->fileName() || !i->fileName()[0]) {
delete i;
continue;
}
myEntries.append(i);
/* if we just increase readFiles, if we found a file, it may
* be, that we die on the wrong filter */
readFiles++;
if (filterEntry(i)) {
KFileInfo *fi= new KFileInfo(*i);
CHECK_PTR(fi);
myFilteredEntries.append(fi);
myFilteredNames.append(fi->fileName());
myTmpEntries.append(fi);
}
} while (dp && readFiles < maxReturns);
if (dp) { // there are still files left
QTimer::singleShot(40, this, SLOT(timerEvent()));
} else {
closedir(myOpendir);
myOpendir = 0;
emit finished();
}
}
myDirtyFlag= false;
myFilteredDirtyFlag= false;
}
const KFileInfoList *KDir::entryInfoList(int filterSpec,
int sortSpec)
{
setSorting(sortSpec);
setFilter(filterSpec);
if (myFilteredDirtyFlag)
updateFiltered();
if (isBlocking && !myOpendir)
emit finished(); // the using class must know, that there are no more
return &myFilteredEntries;
}
bool KDir::match(const char *filter, const char *name)
{
// Split on white space
QString s = filter;
char *g = strtok(s.data(), " ");
bool matched = false;
while (g) {
if (QDir::match(g, name)) {
matched = true;
break;
}
g = strtok(0, " ");
}
return matched;
}
bool KDir::filterEntry(KFileInfo *i)
{
if (!strcmp(i->fileName(), ".."))
return !root;
if (!(myFilterSpec & QDir::Hidden) && i->fileName()[0] == '.')
return false;
if (myNameFilter.isEmpty())
return true;
if ( !(myFilterSpec & QDir::Dirs) && i->isDir())
return false;
if (matchAllDirs() && i->isDir())
return true;
if (match(myNameFilter, i->fileName()))
return true;
return false;
}
bool KDir::startLoading()
{
// If kfm is not busy
if (myKfm == 0) {
// Create a connection to kfm
myKfm = new KFM;
CHECK_PTR(myKfm);
// Check connection was made
if ( !myKfm->isOK() ) {
delete myKfm;
myKfm = 0;
readable = false;
emit finished(); // what else can I say? ;)
} else { // If all is well
connect(myKfm, SIGNAL(finished()), SLOT(slotKfmFinished()));
connect(myKfm, SIGNAL(error(int, const char *)),
SLOT(slotKfmError(int, const char *)));
connect(myKfm, SIGNAL(dirEntry(KDirEntry&)),
SLOT(slotDirEntry(KDirEntry&)));
myKfm->list(myLocation.url());
return true;
}
}
return false;
}
void KDir::slotDirEntry(KDirEntry& entry) // SLOT
{
KFileInfo *i= new KFileInfo(entry);
CHECK_PTR(i);
myEntries.append(i);
if (filterEntry(i)) {
KFileInfo *fi= new KFileInfo(entry);
CHECK_PTR(fi);
myFilteredEntries.append(fi);
myFilteredNames.append(fi->fileName());
emit dirEntry(fi);
}
}
void KDir::setBlocking(bool _block)
{
isBlocking = _block;
}
void KDir::slotKfmFinished() // SLOT
{
delete myKfm;
myKfm= 0;
emit finished();
}
void KDir::slotKfmError(int kerror, const char *text) // SLOT
{
delete myKfm;
myKfm= 0;
emit error(kerror, text);
}
void KDir::setMaxReturns(uint max) {
maxReturns = max;
}
#include "kdir.moc"
--- NEW FILE: kfiledialogconf.h ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KFILEDIALOGCONF_H
#define KFILEDIALOGCONF_H
#include <qcheckbox.h>
#include <qtabdialog.h>
#include <qradiobutton.h>
#include <qlabel.h>
#include <qslider.h>
/**
* KFileDialog configuration widget.
*
* @short This widget allows users to configure KFileDialog
* @author Richard Moore (rich at kde.org)
* @version $Id: kfiledialogconf.h,v 1.1 2006-10-03 11:26:35 dslinux_amadeus Exp $
*/
class KFileDialogConfigure : public QWidget
{
Q_OBJECT
public:
KFileDialogConfigure(QWidget *parent= 0, const char *name= 0);
enum ViewStyle { ShortView, DetailView };
public slots:
void saveConfiguration();
protected:
QRadioButton *myDetailView;
QRadioButton *myShortView;
QCheckBox *myShowFilter;
QCheckBox *myShowHidden;
QCheckBox *myShowStatusLine;
QCheckBox *useSingleClick;
QCheckBox *myShowListLabels;
QCheckBox *myMixDirsAndFiles;
QCheckBox *myKeepDirsFirst;
};
class KFileDialogConfigureDlg : public QTabDialog
{
Q_OBJECT
public:
KFileDialogConfigureDlg(QWidget *parent,
const char *name);
};
#endif // KFILEDIALOGCONF_H
--- NEW FILE: kcombiview.h ---
/* This file is part of the KDE libraries
Copyright (C) 1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _KCOMBIVIEW_H
#define _KCOMBIVIEW_H
#include "kfileinfocontents.h"
#include "knewpanner.h"
class KCombiView: protected KNewPanner, public KFileInfoContents
{
Q_OBJECT
public:
typedef enum { SimpleView, DetailView, DirList, Custom } FileView;
KCombiView( FileView dirs, FileView files,
bool s, QDir::SortSpec sorting,
QWidget * parent=0, const char * name=0 );
~KCombiView();
virtual QWidget *widget() { return this; }
virtual void setAutoUpdate(bool);
virtual void setCurrentItem(const char *filename, const KFileInfo *i);
virtual void repaint(bool f = true);
virtual QString findCompletion( const char *base, bool activateFound );
virtual bool acceptsFiles() { return true; }
virtual bool acceptsDirs() { return true; }
protected slots:
void dirActivated(KFileInfo*);
void fileActivated(KFileInfo*);
void fileHighlighted(KFileInfo*);
protected:
virtual KFileInfoContents *getDirList() { return 0; }
virtual KFileInfoContents *getFileList() { return 0; }
virtual void highlightItem(unsigned int item);
virtual void clearView();
virtual bool insertItem(const KFileInfo *i, int index);
private:
KFileInfoContents *dirList;
KFileInfoContents *fileList;
};
#endif
--- NEW FILE: kfilesimpleview.h ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997 Stephan Kulow <coolo at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KFILESIMPLEVIEW_H
#define KFILESIMPLEVIEW_H
class KFileInfo;
class QWidget;
#include <qtableview.h>
#include <qpixmap.h>
#include "kfileinfocontents.h"
class KFileSimpleView : public QTableView, public KFileInfoContents {
Q_OBJECT
public:
KFileSimpleView(bool s, QDir::SortSpec sorting, QWidget *parent, const char *name);
virtual ~KFileSimpleView();
virtual QWidget *widget() { return this; }
virtual void setAutoUpdate(bool);
virtual void clearView();
virtual bool acceptsFiles() { return true; }
virtual bool acceptsDirs() { return true; }
protected:
virtual void highlightItem(unsigned int item);
virtual bool insertItem(const KFileInfo *i, int index);
virtual void paintCell( QPainter *, int, int);
virtual void resizeEvent ( QResizeEvent *e );
virtual void keyPressEvent( QKeyEvent* e );
virtual int cellWidth ( int col );
virtual void mousePressEvent( QMouseEvent* e );
virtual void mouseDoubleClickEvent ( QMouseEvent *e );
virtual void focusInEvent ( QFocusEvent * );
virtual void focusOutEvent ( QFocusEvent * );
void highlightItem(int row, int col);
bool isColCompletelyVisible( int col );
/* own function, which calls QTableView::setNumCols */
void setNumCols(int i);
int rowsVisible;
int curCol, curRow;
int *cellWidths;
QList<QPixmap> pixmaps;
// this flag is used for speed up, when autoUpdate is false
bool touched;
uint *width_array;
uint width_length;
uint width_max;
void insertArray(uint item, uint pos);
};
#endif // KFILESIMPLEVIEW_H
--- NEW FILE: kcombiview.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// $Id: kcombiview.cpp,v 1.1 2006-10-03 11:26:34 dslinux_amadeus Exp $
#include "kcombiview.h"
#include "kdirlistbox.h"
#include "kfiledetaillist.h"
#include "kfileinfo.h"
#include "kfilesimpleview.h"
#include "config-kfile.h"
#include <qpainter.h>
#include <qlistbox.h>
#include <qdir.h>
#include <kapp.h>
#ifdef Unsorted // the "I hate X.h" modus
#undef Unsorted
#endif
KCombiView::KCombiView( FileView dirs, FileView files,
bool s, QDir::SortSpec sorting,
QWidget * parent, const char * name )
: KNewPanner(parent, name, KNewPanner::Vertical) ,
KFileInfoContents(s,sorting)
{
setSorting( QDir::Unsorted ); // we sort in the part views
switch (dirs) {
case DirList:
dirList = new KDirListBox(s, sorting, this, "_dirs");
break;
case Custom:
dirList = getDirList();
break;
default:
fatal("this view for dirs not support");
}
switch (files) {
case DetailView:
fileList = new KFileDetailList(false, sorting, this, "_detail");
break;
case SimpleView:
fileList = new KFileSimpleView(false, sorting, this, "_simple");
break;
case DirList: // who ever wants this
fileList = new KDirListBox(false, sorting, this, "_dirs");
break;
case Custom:
fileList = getFileList();
}
bool showListLabels =
kapp->getConfig()->readBoolEntry("ShowListLabels",
DefaultShowListLabels);
if (showListLabels) {
setLabels(i18n("Folders:"),
i18n("Contents:"));
showLabels(showListLabels);
}
bool dirsLeft = kapp->getConfig()->readBoolEntry("ShowDirsLeft",
DefaultShowDirsLeft);
if (dirsLeft)
activate(dirList->widget(), fileList->widget());
else
activate(fileList->widget(), dirList->widget());
int pan = kapp->getConfig()->readNumEntry("PannerPosition",
DefaultPannerPosition);
setSeparatorPos(pan);
dirList->connectDirSelected(this, SLOT(dirActivated(KFileInfo*)));
fileList->connectFileSelected(this, SLOT(fileActivated(KFileInfo*)));
fileList->connectFileHighlighted(this, SLOT(fileHighlighted(KFileInfo*)));
}
KCombiView::~KCombiView()
{
KConfig *c = kapp->getConfig();
QString oldgroup = c->group();
c->writeEntry("PannerPosition", separatorPos(), true, true);
c->setGroup(oldgroup);
}
void KCombiView::setAutoUpdate(bool f)
{
fileList->setAutoUpdate(f);
dirList->setAutoUpdate(f);
}
bool KCombiView::insertItem(const KFileInfo *i, int)
{
if (i->isDir()) // for dirs the index is correct
dirList->addItem(i);
else
fileList->addItem(i);
return true;
}
void KCombiView::clearView()
{
dirList->clear();
fileList->clear();
}
void KCombiView::highlightItem(unsigned int)
{
warning("KCombiView::highlightItem: does nothing");
}
void KCombiView::setCurrentItem(const char *item, const KFileInfo *i)
{
if (item != 0) {
i = 0;
debugC("setCurrentItem %s",item);
for (uint j = 0; j < count(); j++)
if (at(j)->fileName() == item)
i = at(j);
}
if (!i) {
warning("setCurrentItem: no match found.");
return;
}
if (i->isDir())
dirList->setCurrentItem(0, i);
else
fileList->setCurrentItem(0, i);
}
void KCombiView::repaint(bool f)
{
dirList->repaint(f);
fileList->repaint(f);
}
QString KCombiView::findCompletion( const char *base, bool )
{
// first try the files.
QString found = fileList->findCompletion(base);
// if no file completion possible, try the dirs
if (!found) {
found = dirList->findCompletion(base, true);
} else {
// complete in dirList so possible directories are highlighted
QString foundDir = dirList->findCompletion(base, false);
// if we find anything -> highlight it and least common denominator
// is the last result
if ( foundDir ) {
unsigned int i;
for ( i=1; (i<=found.length()) && (i<=foundDir.length()) ; i++) {
if ( strncmp( found, foundDir, i) != 0 )
break;
}
if ( i==1 ) i++;
found.truncate(i-1);
}
}
return found;
}
void KCombiView::dirActivated(KFileInfo *i)
{
select(i);
}
void KCombiView::fileActivated(KFileInfo *i)
{
select(i);
}
void KCombiView::fileHighlighted(KFileInfo *i)
{
highlight(i);
}
#include "kcombiview.moc"
--- NEW FILE: kfileinfo.cpp ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// $Id: kfileinfo.cpp,v 1.1 2006-10-03 11:26:35 dslinux_amadeus Exp $
#include "kfileinfo.h"
#include <sys/types.h>
#include <dirent.h>
#include <grp.h>
#include <sys/stat.h>
#include <pwd.h>
#include <unistd.h>
#include <time.h>
#include <qfileinfo.h>
#include <qregexp.h>
#include <kapp.h>
#include <kfm.h>
KFileInfo::KFileInfo(const KDirEntry &e)
{
myName= e.name;
myName.replace( QRegExp("/$"), "" );
mySize= e.size;
myBaseURL= "";
myDate= e.date;
myOwner= e.owner;
myGroup= e.group;
myAccess= e.access;
parsePermissions(e.access);
myIsSymLink = false;
}
KFileInfo::KFileInfo(const QFileInfo &e)
{
myName = e.fileName();
mySize = e.size();
myBaseURL = "";
myDate= (e.lastModified()).toString();
myOwner = e.owner();
myGroup = e.group();
myIsDir = e.isDir();
myIsFile = e.isFile();
myIsSymLink = e.isSymLink();
myPermissions = 755;
}
KFileInfo::KFileInfo(const char *dir, const char *name)
{
myName = name;
myBaseURL = dir;
struct stat buf;
myIsSymLink = false;
if (lstat((dir + myName).data(), &buf) == 0) {
myIsDir = (buf.st_mode & S_IFDIR) != 0;
// check if this is a symlink to a directory
if (S_ISLNK(buf.st_mode)) {
myIsSymLink = true;
struct stat st;
if (stat((dir + myName).data(), &st) == 0)
myIsDir = S_ISDIR(st.st_mode) != 0;
else
myName = ""; // indicate, that the link is broken
} else
myIsSymLink = false;
myDate = dateTime(buf.st_mtime);
mySize = buf.st_size;
myIsFile = !myIsDir;
struct passwd *pw = getpwuid(buf.st_uid);
struct group * ge = getgrgid( buf.st_gid );
if (pw)
myOwner = pw->pw_name;
else
myOwner = i18n("unknown");
if (ge)
myGroup = ge->gr_name;
else
myGroup = i18n("unknown");
myPermissions = buf.st_mode;
parsePermissions(myPermissions);
// myDate = buf.st_mtime;
} else {
// default
debug("the file does not exist %s%s",dir, name);
myName.insert(0, "?");
mySize = 0;
myIsFile = false;
myIsDir = false;
myPermissions = 0;
parsePermissions(myPermissions);
}
}
// KFileInfo::~KFileInfo()
// {
// debug("~KFileInfo");
// }
KFileInfo &KFileInfo::operator=(const KFileInfo &i)
{
myName= i.myName;
mySize= i.mySize;
myBaseURL= i.myBaseURL;
myDate= i.myDate;
myOwner= i.myOwner;
myGroup= i.myGroup;
myIsDir= i.myIsDir;
myPermissions= i.myPermissions;
return *this;
}
bool KFileInfo::isReadable() const
{
return (::access(myBaseURL + myName, R_OK | (myIsDir ? X_OK : 0)) == 0) ;
}
void KFileInfo::parsePermissions(const char *perms)
{
myPermissions = 0;
char p[11] = {0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0};
strncpy(p, perms, sizeof(p));
myIsDir = (bool)(p[0] == 'd');
myIsSymLink = (bool)(p[0] == 'l');
myIsFile = !myIsDir;
if(p[1] == 'r')
myPermissions |= QFileInfo::ReadUser;
if(p[2] == 'w')
myPermissions |= QFileInfo::WriteUser;
if(p[3] == 'x')
myPermissions |= QFileInfo::ExeUser;
if(p[4] == 'r')
myPermissions |= QFileInfo::ReadGroup;
if(p[5] == 'w')
myPermissions |= QFileInfo::WriteGroup;
if(p[6] == 'x')
myPermissions |= QFileInfo::ExeGroup;
if(p[7] == 'r')
myPermissions |= QFileInfo::ReadOther;
if(p[8] == 'w')
myPermissions |= QFileInfo::WriteOther;
if(p[9] == 'x')
myPermissions |= QFileInfo::ExeOther;
}
void KFileInfo::parsePermissions(uint perm)
{
char p[] = "----------";
if (myIsDir)
p[0]='d';
else if (myIsSymLink)
p[0]='l';
if (perm & QFileInfo::ReadUser)
p[1]='r';
if (perm & QFileInfo::WriteUser)
p[2]='w';
if (perm & QFileInfo::ExeUser)
p[3]='x';
if (perm & QFileInfo::ReadGroup)
p[4]='r';
if (perm & QFileInfo::WriteGroup)
p[5]='w';
if (perm & QFileInfo::ExeGroup)
p[6]='x';
if (perm & QFileInfo::ReadOther)
p[7]='r';
if (perm & QFileInfo::WriteOther)
p[8]='w';
if (perm & QFileInfo::ExeOther)
p[9]='x';
myAccess = p;
}
/* the following will go into KLocale after Beta4!!! */
static const char *months[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
QString KFileInfo::dateTime(time_t _time) {
if (!months[0]) {
months[ 0] = i18n("Jan");
months[ 1] = i18n("Feb");
months[ 2] = i18n("Mar");
months[ 3] = i18n("Apr");
months[ 4] = i18n("May");
months[ 5] = i18n("Jun");
months[ 6] = i18n("Jul");
months[ 7] = i18n("Aug");
months[ 8] = i18n("Sep");
months[ 9] = i18n("Oct");
months[10] = i18n("Nov");
months[11] = i18n("Dec");
}
QDateTime t;
time_t now = time(0);
t.setTime_t(_time);
QString sTime;
if (_time > now || now - _time >= 365 * 24 * 60 * 60)
sTime.sprintf(" %04d", t.date().year());
else
sTime.sprintf("%02d:%02d", t.time().hour(), t.time().minute());
QString text;
text.sprintf("%-3s %2d %s",
QString(months[t.date().month() - 1]).left(3).data(),
t.date().day(),
sTime.data());
return text;
}
--- NEW FILE: kfilefilter.h ---
#ifndef _KFILEFILTER_H
#define _KFILEFILTER_H
#include <qcombobox.h>
class QStrList;
class KFileFilter : public QComboBox
{
Q_OBJECT
public:
KFileFilter(QWidget *parent= 0, const char *name= 0);
~KFileFilter();
void setFilter(const char *filter);
QString currentFilter();
protected:
QStrList *filters;
protected slots:
void changed(const char*);
signals:
void filterChanged();
};
#endif
--- NEW FILE: kremotefile.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kremotefile.h"
KRemoteFile::KRemoteFile(const char *url)
{
myLocation= url;
// Copy the remote file
}
KRemoteFile::~KRemoteFile()
{
// delete the local copy
}
const char *KRemoteFile::tempName()
{
// get the name of the temp
return 0;
}
const char *KRemoteFile::url()
{
// get the url of the remote file
return 0;
}
--- NEW FILE: kfileinfocontents.h ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997 Stephan Kulow <coolo at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KFILEINFOLISTWIDGET_H
#define KFILEINFOLISTWIDGET_H
class KFileInfo;
class QPixmap;
class QSignal;
#include <qwidget.h>
#include "kdir.h"
/**
* internal class to make easier to use signals possible
* @internal
**/
class KFileInfoContentsSignaler : public QObject {
Q_OBJECT
public:
void activateDir(KFileInfo *i) { emit dirActivated(i); }
void highlightFile(KFileInfo *i) { emit fileHighlighted(i); }
void activateFile(KFileInfo *i) { emit fileSelected(i); }
signals:
void dirActivated(KFileInfo*);
void fileHighlighted(KFileInfo*);
void fileSelected(KFileInfo*);
};
/**
* A base class for views of the KDE file selector
*
* This class defines an interface to all file views. It's intent is
* to allow to switch the view of the files in the selector very easily.
* It defines some pure virtual functions, that must be implemented to
* make a file view working.
*
* Since this class is not a widget, but it's meant to be added to other
* widgets, its most important function is @code widget. This should return
* a pointer to the implemented widget.
*
* @short A base class for views of the KDE file selector
* @author Stephan Kulow <coolo at kde.org>
* @version $Id: kfileinfocontents.h,v 1.1 2006-10-03 11:26:35 dslinux_amadeus Exp $
**/
class KFileInfoContents {
public:
/**
* @short Constructor. Defines some used flags and lists
* It loads the icons used to indicate files and folders in
* all views, initializes some used lists and variables
*
* @param useSingleClick defines, if the view should react on
* single click or double click
* @param sorting defines, how the list should be sorted.
* Currently Name, Size and Date are supported.
**/
KFileInfoContents( bool useSingleClick, QDir::SortSpec sorting );
/** Destructor */
virtual ~KFileInfoContents();
/**
* Insert an item into the file view. The view will just maintain
* the pointer. It doesn't free the object.
*
* This functions inserts the file at the correct place in the
* sorted list
* @return true, if a repaint is necessary
* @param item the file to be inserted
**/
virtual bool addItem(const KFileInfo *item);
/**
* inserts a list of items. This is an speed optimized version of
* function above.
* @see addItem
**/
virtual void addItemList(const KFileInfoList *list);
/**
* @return the name of the file at position index.
*
* the meaning of index depends on the sorting and the other files
* in the view. So use this function with care.
**/
virtual const char *text(uint index) const;
/**
* a pure virtual function to get a QWidget, that can be added to
* other widgets. This function is needed to make it possible for
* derived classes to derive from other widgets.
**/
virtual QWidget *widget() = 0;
/**
* set the current item in the view.
*
* the normal use of this function is to use the parameter filename to
* set the highlight on this file.
*
* the extend use of this function is to set filename to 0. In this
* case the @see KFileInfo is used to find out the position of the
* file. Since this is faster, this way is used in case a view has
* other child views.
**/
virtual void setCurrentItem(const char *filename,
const KFileInfo * entry = 0);
/**
* set the autoUpdate flag for the specific widget.
* if set to false, no repaints should be done automaticly unless
* repaint is called.
*
* this function is pure virtual, so it must be implemented
**/
virtual void setAutoUpdate(bool f) = 0;
/**
* clears all lists and calls clearView
*/
void clear();
/**
* does a repaint of the view.
*
* The default implementation calls
* <code>widget()->repaint(f)</code>
**/
virtual void repaint(bool f = true);
/**
* specifies the sorting of the internal list. Newly added files
* are added through this sorting.
*
**/
QDir::SortSpec sorting() { return mySorting; }
/**
* set the sorting of the view. If the sorting is the same as
* the current value and sortMode is Switching, it switches the
* order in the list.
*
* Default is QDir::Name
**/
void setSorting(QDir::SortSpec sort); // a little bit complexer
/**
* returns the number of added files
**/
uint count() const { return sorted_length; }
/**
* to connect a slot to the internal signal, that is emited, if
* the user selects a directory.
*
* the connected slot must have the form
* <pre>member(KFileInfo*)</pre>
**/
void connectDirSelected( QObject *receiver, const char *member);
/**
* to connect a slot to the internal signal, that is emited, if
* the user highlights a file.
*
* the connected slot must have the form
* <pre>member(KFileInfo*)</pre>
**/
void connectFileHighlighted( QObject *receiver, const char *member);
/**
* to connect a slot to the internal signal, that is emited, if
* the user selects a file.
*
* the connected slot must have the form
* <pre>member(KFileInfo*)</pre>
**/
void connectFileSelected( QObject *receiver, const char *member);
/**
* the number of files.
**/
uint numFiles() const { return filesNumber; }
/**
* the number of directories
**/
uint numDirs() const { return dirsNumber; }
/**
* tries to find a completed filename, that starts with base
*
* if it fails, it returns a null string.
* @param activateFound if true, the file should select the
* found file (or directory)
**/
virtual QString findCompletion( const char *base,
bool activateFound = false );
/**
* a pure virtual function to indicate, if the view should list
* files.
**/
virtual bool acceptsFiles() = 0;
/**
* a pure virtual function to indicate, if the view should list
* directories.
**/
virtual bool acceptsDirs() = 0;
protected:
/**
* this function is called after the class found out the correct
* index. The derived view must implement this function to add
* the file in the widget.
*
* it's important, that the view keeps it's contents consistent
* with the indicies in the sorted list of the base class
* @return true, if a repaint is necessary
**/
virtual bool insertItem(const KFileInfo *i, int index) = 0;
/**
* this function does the actual sorting. It is called by
* addItem and calls itself insertItem
**/
bool addItemInternal(const KFileInfo *);
/**
* Increasing means greater indicies means bigger values
*
* Decrease means greater indicies means smaller values
*
* Switching means, that it should switch between Increasing and
* Decreasing
**/
enum SortMode { Increasing, Decreasing, Switching };
/**
* set the sorting mode. Default mode is Increasing
**/
void setSortMode(SortMode mode) { mySortMode = mode; }
/**
* pure virtual function, that should be implemented to clear
* the view. At this moment the list is already empty
**/
virtual void clearView() = 0;
/**
* set the highlighted item to index. This function must be implemented
* by the view
**/
virtual void highlightItem(unsigned int index) = 0;
/** the pixmap for normal files */
static QPixmap *file_pixmap;
/** the pixmap for locked files */
static QPixmap *locked_file;
/** the pixmap for normal folders */
static QPixmap *folder_pixmap;
/** the pixmap for locked folders */
static QPixmap *locked_folder;
/**
* sets the value for the selected file and emits the correct
* signal (depending on the type of the entry)
**/
void select( KFileInfo *entry);
/**
* gets the entry at index and calls the other select function
* with it
**/
void select( int index );
void highlight( int index );
void highlight( KFileInfo *);
/**
* returns, if the view is using single click to activate directories
* Note, that some views do not work completly with single click
**/
bool useSingle() const { return useSingleClick; }
/**
* returns true, if the file at the specific position is a directory
**/
bool isDir( uint index) const { return sortedArray[index]->isDir(); }
/**
* returns the complete file information for the file at the position
* index
**/
const KFileInfo *at( uint index ) const { return sortedArray[index]; }
/**
* compares two items in the current context (sortMode and others)
* returns -1, if i1 is before i2 and 1, if the other case is true
* in case, both are equal (in current context), the behaviour is
* undefined!
**/
int compareItems(const KFileInfo *fi1, const KFileInfo *fi2);
/**
* this is a help function for sorting, since I can't use the libc
* version (because I have a variable sort function)
*
* I heard, STL has a qsort function too, but I don't want to use
* STL now
*/
void QuickSort(KFileInfo* a[], int lo0, int hi0);
private:
bool useSingleClick;
bool reversed;
bool keepDirsFirst;
QDir::SortSpec mySorting;
enum SortMode mySortMode;
KFileInfo **sortedArray;
uint sorted_length;
uint sorted_max;
/**
* filled for completion
**/
QStrIList *nameList;
/**
* counters
**/
uint filesNumber, dirsNumber;
/**
* @internal
* class to distribute the signals
**/
KFileInfoContentsSignaler *sig;
/**
* @internal
* adds an item to sortedArray
**/
void insertSortedItem(const KFileInfo *item, uint pos);
/**
* @internal
* finds the correct position in sortedArray
* @returns the found index
**/
int findPosition(const KFileInfo *item, int left);
};
#endif // KFILEINFOLISTWIDGET_H
--- NEW FILE: KFile.kdoc ---
KBookmark::=KBookmark.html#
KBookmark::KBookmark=KBookmark.html#KBookmark
KBookmark::KBookmark=KBookmark.html#KBookmark
KBookmark::clear=KBookmark.html#clear
KBookmark::setText=KBookmark.html#setText
KBookmark::setURL=KBookmark.html#setURL
KBookmark::setType=KBookmark.html#setType
KBookmark::getText=KBookmark.html#getText
KBookmark::getURL=KBookmark.html#getURL
KBookmark::getType=KBookmark.html#getType
KBookmark::getChildren=KBookmark.html#getChildren
KBookmark::text=KBookmark.html#text
KBookmark::url=KBookmark.html#url
KBookmark::type=KBookmark.html#type
KBookmark=KBookmark.html
KBookmarkManager::KBookmarkManager=KBookmarkManager.html#KBookmarkManager
KBookmarkManager::setTitle=KBookmarkManager.html#setTitle
KBookmarkManager::read=KBookmarkManager.html#read
KBookmarkManager::write=KBookmarkManager.html#write
KBookmarkManager::add=KBookmarkManager.html#add
KBookmarkManager::remove=KBookmarkManager.html#remove
KBookmarkManager::moveUp=KBookmarkManager.html#moveUp
KBookmarkManager::moveDown=KBookmarkManager.html#moveDown
KBookmarkManager::reread=KBookmarkManager.html#reread
KBookmarkManager::rename=KBookmarkManager.html#rename
KBookmarkManager::write=KBookmarkManager.html#write
KBookmarkManager::getBookmark=KBookmarkManager.html#getBookmark
KBookmarkManager::getRoot=KBookmarkManager.html#getRoot
KBookmarkManager::parse=KBookmarkManager.html#parse
KBookmarkManager::writeFolder=KBookmarkManager.html#writeFolder
KBookmarkManager::findBookmark=KBookmarkManager.html#findBookmark
KBookmarkManager::changed=KBookmarkManager.html#changed
KBookmarkManager::root=KBookmarkManager.html#root
KBookmarkManager::title=KBookmarkManager.html#title
KBookmarkManager::myFilename=KBookmarkManager.html#myFilename
KBookmarkManager=KBookmarkManager.html
BMToken::BMToken=BMToken.html#BMToken
BMToken::~BMToken=BMToken.html#~BMToken
BMToken::token=BMToken.html#token
BMToken::next=BMToken.html#next
BMToken::setNext=BMToken.html#setNext
BMToken::tok=BMToken.html#tok
BMToken::nextToken=BMToken.html#nextToken
BMToken=BMToken.html
BookmarkTokenizer::BookmarkTokenizer=BookmarkTokenizer.html#BookmarkTokenizer
BookmarkTokenizer::~BookmarkTokenizer=BookmarkTokenizer.html#~BookmarkTokenizer
BookmarkTokenizer::begin=BookmarkTokenizer.html#begin
BookmarkTokenizer::write=BookmarkTokenizer.html#write
BookmarkTokenizer::end=BookmarkTokenizer.html#end
BookmarkTokenizer::nextToken=BookmarkTokenizer.html#nextToken
BookmarkTokenizer::hasMoreTokens=BookmarkTokenizer.html#hasMoreTokens
BookmarkTokenizer::first=BookmarkTokenizer.html#first
BookmarkTokenizer::reset=BookmarkTokenizer.html#reset
BookmarkTokenizer::appendToken=BookmarkTokenizer.html#appendToken
BookmarkTokenizer::buffer=BookmarkTokenizer.html#buffer
BookmarkTokenizer::dest=BookmarkTokenizer.html#dest
BookmarkTokenizer::head=BookmarkTokenizer.html#head
BookmarkTokenizer::tail=BookmarkTokenizer.html#tail
BookmarkTokenizer::curr=BookmarkTokenizer.html#curr
BookmarkTokenizer::size=BookmarkTokenizer.html#size
BookmarkTokenizer::tag=BookmarkTokenizer.html#tag
BookmarkTokenizer::tquote=BookmarkTokenizer.html#tquote
BookmarkTokenizer::space=BookmarkTokenizer.html#space
BookmarkTokenizer::discardCR=BookmarkTokenizer.html#discardCR
BookmarkTokenizer::comment=BookmarkTokenizer.html#comment
BookmarkTokenizer=BookmarkTokenizer.html
KCombiView::FileView=KCombiView.html#FileView
KCombiView::KCombiView=KCombiView.html#KCombiView
KCombiView::~KCombiView=KCombiView.html#~KCombiView
KCombiView::widget=KCombiView.html#widget
KCombiView::setAutoUpdate=KCombiView.html#setAutoUpdate
KCombiView::setCurrentItem=KCombiView.html#setCurrentItem
KCombiView::repaint=KCombiView.html#repaint
KCombiView::findCompletion=KCombiView.html#findCompletion
KCombiView::acceptsFiles=KCombiView.html#acceptsFiles
KCombiView::acceptsDirs=KCombiView.html#acceptsDirs
KCombiView::dirActivated=KCombiView.html#dirActivated
KCombiView::fileActivated=KCombiView.html#fileActivated
KCombiView::fileHighlighted=KCombiView.html#fileHighlighted
KCombiView::getDirList=KCombiView.html#getDirList
KCombiView::getFileList=KCombiView.html#getFileList
KCombiView::highlightItem=KCombiView.html#highlightItem
KCombiView::clearView=KCombiView.html#clearView
KCombiView::insertItem=KCombiView.html#insertItem
KCombiView::dirList=KCombiView.html#dirList
KCombiView::fileList=KCombiView.html#fileList
KCombiView=KCombiView.html
KDir::KDir=KDir.html#KDir
KDir::KDir=KDir.html#KDir
KDir::KDir=KDir.html#KDir
KDir::KDir=KDir.html#KDir
KDir::~KDir=KDir.html#~KDir
KDir::operator==KDir.html#operator=
KDir::operator==KDir.html#operator=
KDir::operator==KDir.html#operator=
KDir::setPath=KDir.html#setPath
KDir::cdUp=KDir.html#cdUp
KDir::host=KDir.html#host
KDir::protocol=KDir.html#protocol
KDir::path=KDir.html#path
KDir::setURL=KDir.html#setURL
KDir::url=KDir.html#url
KDir::nameFilter=KDir.html#nameFilter
KDir::setNameFilter=KDir.html#setNameFilter
KDir::filter=KDir.html#filter
KDir::setFilter=KDir.html#setFilter
KDir::sorting=KDir.html#sorting
KDir::setSorting=KDir.html#setSorting
KDir::count=KDir.html#count
KDir::isFinished=KDir.html#isFinished
KDir::entryInfoList=KDir.html#entryInfoList
KDir::match=KDir.html#match
KDir::setBlocking=KDir.html#setBlocking
KDir::blocking=KDir.html#blocking
KDir::setMaxReturns=KDir.html#setMaxReturns
KDir::isRoot=KDir.html#isRoot
KDir::isReadable=KDir.html#isReadable
KDir::urlChanged=KDir.html#urlChanged
KDir::dirEntry=KDir.html#dirEntry
KDir::finished=KDir.html#finished
KDir::error=KDir.html#error
KDir::newFilesArrived=KDir.html#newFilesArrived
KDir::slotDirEntry=KDir.html#slotDirEntry
KDir::slotKfmFinished=KDir.html#slotKfmFinished
KDir::slotKfmError=KDir.html#slotKfmError
KDir::timerEvent=KDir.html#timerEvent
KDir::matchAllDirs=KDir.html#matchAllDirs
KDir::setMatchAllDirs=KDir.html#setMatchAllDirs
KDir::updateFiltered=KDir.html#updateFiltered
KDir::filterEntry=KDir.html#filterEntry
KDir::initLists=KDir.html#initLists
KDir::getEntries=KDir.html#getEntries
KDir::startLoading=KDir.html#startLoading
KDir::myLocation=KDir.html#myLocation
KDir::myNameFilter=KDir.html#myNameFilter
KDir::mySortSpec=KDir.html#mySortSpec
KDir::myFilterSpec=KDir.html#myFilterSpec
KDir::myKfm=KDir.html#myKfm
KDir::myEntries=KDir.html#myEntries
KDir::myDirtyFlag=KDir.html#myDirtyFlag
KDir::myFilteredEntries=KDir.html#myFilteredEntries
KDir::myTmpEntries=KDir.html#myTmpEntries
KDir::myFilteredNames=KDir.html#myFilteredNames
KDir::myFilteredDirtyFlag=KDir.html#myFilteredDirtyFlag
KDir::isBlocking=KDir.html#isBlocking
KDir::root=KDir.html#root
KDir::maxReturns=KDir.html#maxReturns
KDir::myOpendir=KDir.html#myOpendir
KDir::readFiles=KDir.html#readFiles
KDir=KDir.html
KDirListBox::KDirListBox=KDirListBox.html#KDirListBox
KDirListBox::KDirListBox=KDirListBox.html#KDirListBox
KDirListBox::~KDirListBox=KDirListBox.html#~KDirListBox
KDirListBox::widget=KDirListBox.html#widget
KDirListBox::setAutoUpdate=KDirListBox.html#setAutoUpdate
KDirListBox::acceptsFiles=KDirListBox.html#acceptsFiles
KDirListBox::acceptsDirs=KDirListBox.html#acceptsDirs
KDirListBox::highlightItem=KDirListBox.html#highlightItem
KDirListBox::mousePressEvent=KDirListBox.html#mousePressEvent
KDirListBox::mouseDoubleClickEvent=KDirListBox.html#mouseDoubleClickEvent
KDirListBox::clearView=KDirListBox.html#clearView
KDirListBox::insertItem=KDirListBox.html#insertItem
KDirListBox::_acceptFiles=KDirListBox.html#_acceptFiles
KDirListBox=KDirListBox.html
KFileDetailList::KFileDetailList=KFileDetailList.html#KFileDetailList
KFileDetailList::~KFileDetailList=KFileDetailList.html#~KFileDetailList
KFileDetailList::widget=KFileDetailList.html#widget
KFileDetailList::setAutoUpdate=KFileDetailList.html#setAutoUpdate
KFileDetailList::clearView=KFileDetailList.html#clearView
KFileDetailList::repaint=KFileDetailList.html#repaint
KFileDetailList::acceptsFiles=KFileDetailList.html#acceptsFiles
KFileDetailList::acceptsDirs=KFileDetailList.html#acceptsDirs
KFileDetailList::highlightItem=KFileDetailList.html#highlightItem
KFileDetailList::insertItem=KFileDetailList.html#insertItem
KFileDetailList::keyPressEvent=KFileDetailList.html#keyPressEvent
KFileDetailList::focusInEvent=KFileDetailList.html#focusInEvent
KFileDetailList::reorderFiles=KFileDetailList.html#reorderFiles
KFileDetailList::selected=KFileDetailList.html#selected
KFileDetailList::highlighted=KFileDetailList.html#highlighted
KFileDetailList=KFileDetailList.html
KFileBaseDialog::KFileBaseDialog=KFileBaseDialog.html#KFileBaseDialog
KFileBaseDialog::~KFileBaseDialog=KFileBaseDialog.html#~KFileBaseDialog
KFileBaseDialog::selectedFile=KFileBaseDialog.html#selectedFile
KFileBaseDialog::dirPath=KFileBaseDialog.html#dirPath
KFileBaseDialog::rereadDir=KFileBaseDialog.html#rereadDir
KFileBaseDialog::back=KFileBaseDialog.html#back
KFileBaseDialog::forward=KFileBaseDialog.html#forward
KFileBaseDialog::home=KFileBaseDialog.html#home
KFileBaseDialog::cdUp=KFileBaseDialog.html#cdUp
KFileBaseDialog::dirIsLocal=KFileBaseDialog.html#dirIsLocal
KFileBaseDialog::selectedFileURL=KFileBaseDialog.html#selectedFileURL
KFileBaseDialog::selectedFileURLList=KFileBaseDialog.html#selectedFileURLList
KFileBaseDialog::setMultiSelection=KFileBaseDialog.html#setMultiSelection
KFileBaseDialog::isMultiSelection=KFileBaseDialog.html#isMultiSelection
KFileBaseDialog::getDirectory=KFileBaseDialog.html#getDirectory
KFileBaseDialog::getOpenFileURLList=KFileBaseDialog.html#getOpenFileURLList
KFileBaseDialog::getSaveFileURLList=KFileBaseDialog.html#getSaveFileURLList
KFileBaseDialog::setDir=KFileBaseDialog.html#setDir
KFileBaseDialog::fileSelected=KFileBaseDialog.html#fileSelected
KFileBaseDialog::fileHighlighted=KFileBaseDialog.html#fileHighlighted
KFileBaseDialog::dirEntered=KFileBaseDialog.html#dirEntered
KFileBaseDialog::historyUpdate=KFileBaseDialog.html#historyUpdate
KFileBaseDialog::toolbar=KFileBaseDialog.html#toolbar
KFileBaseDialog::fileList=KFileBaseDialog.html#fileList
KFileBaseDialog::visitedDirs=KFileBaseDialog.html#visitedDirs
KFileBaseDialog::bookmarksMenu=KFileBaseDialog.html#bookmarksMenu
KFileBaseDialog::hiddenToggle=KFileBaseDialog.html#hiddenToggle
KFileBaseDialog::locationEdit=KFileBaseDialog.html#locationEdit
KFileBaseDialog::filterEdit=KFileBaseDialog.html#filterEdit
KFileBaseDialog::filterCombo=KFileBaseDialog.html#filterCombo
KFileBaseDialog::bookmarks=KFileBaseDialog.html#bookmarks
KFileBaseDialog::history=KFileBaseDialog.html#history
KFileBaseDialog::dir=KFileBaseDialog.html#dir
KFileBaseDialog::myStatusLine=KFileBaseDialog.html#myStatusLine
KFileBaseDialog::filename_=KFileBaseDialog.html#filename_
KFileBaseDialog::showHidden=KFileBaseDialog.html#showHidden
KFileBaseDialog::showStatusLine=KFileBaseDialog.html#showStatusLine
KFileBaseDialog::showFilter=KFileBaseDialog.html#showFilter
KFileBaseDialog::acceptUrls=KFileBaseDialog.html#acceptUrls
KFileBaseDialog::stackLock=KFileBaseDialog.html#stackLock
KFileBaseDialog::resizeEvent=KFileBaseDialog.html#resizeEvent
KFileBaseDialog::swallower=KFileBaseDialog.html#swallower
KFileBaseDialog::initFileList=KFileBaseDialog.html#initFileList
KFileBaseDialog::getShowFilter=KFileBaseDialog.html#getShowFilter
KFileBaseDialog::setDir=KFileBaseDialog.html#setDir
KFileBaseDialog::addDirEntry=KFileBaseDialog.html#addDirEntry
KFileBaseDialog::initGUI=KFileBaseDialog.html#initGUI
KFileBaseDialog::mkdir=KFileBaseDialog.html#mkdir
KFileBaseDialog::checkPath=KFileBaseDialog.html#checkPath
KFileBaseDialog::init=KFileBaseDialog.html#init
KFileBaseDialog::pathChanged=KFileBaseDialog.html#pathChanged
KFileBaseDialog::comboActivated=KFileBaseDialog.html#comboActivated
KFileBaseDialog::toolbarCallback=KFileBaseDialog.html#toolbarCallback
KFileBaseDialog::toolbarPressedCallback=KFileBaseDialog.html#toolbarPressedCallback
KFileBaseDialog::dirActivated=KFileBaseDialog.html#dirActivated
KFileBaseDialog::fileActivated=KFileBaseDialog.html#fileActivated
KFileBaseDialog::fileHighlighted=KFileBaseDialog.html#fileHighlighted
KFileBaseDialog::updateHistory=KFileBaseDialog.html#updateHistory
KFileBaseDialog::filterChanged=KFileBaseDialog.html#filterChanged
KFileBaseDialog::locationChanged=KFileBaseDialog.html#locationChanged
KFileBaseDialog::setHiddenToggle=KFileBaseDialog.html#setHiddenToggle
KFileBaseDialog::slotDirEntry=KFileBaseDialog.html#slotDirEntry
KFileBaseDialog::insertFile=KFileBaseDialog.html#insertFile
KFileBaseDialog::slotFinished=KFileBaseDialog.html#slotFinished
KFileBaseDialog::slotKfmError=KFileBaseDialog.html#slotKfmError
KFileBaseDialog::insertNewFiles=KFileBaseDialog.html#insertNewFiles
KFileBaseDialog::completion=KFileBaseDialog.html#completion
KFileBaseDialog::updateStatusLine=KFileBaseDialog.html#updateStatusLine
KFileBaseDialog::okPressed=KFileBaseDialog.html#okPressed
KFileBaseDialog::help=KFileBaseDialog.html#help
KFileBaseDialog::addToBookmarks=KFileBaseDialog.html#addToBookmarks
KFileBaseDialog::bookmarksChanged=KFileBaseDialog.html#bookmarksChanged
KFileBaseDialog::fillBookmarkMenu=KFileBaseDialog.html#fillBookmarkMenu
KFileBaseDialog::wrapper=KFileBaseDialog.html#wrapper
KFileBaseDialog::filters=KFileBaseDialog.html#filters
KFileBaseDialog::repaint_files=KFileBaseDialog.html#repaint_files
KFileBaseDialog::finished=KFileBaseDialog.html#finished
KFileBaseDialog::acceptOnlyExisting=KFileBaseDialog.html#acceptOnlyExisting
KFileBaseDialog::boxLayout=KFileBaseDialog.html#boxLayout
KFileBaseDialog::lafBox=KFileBaseDialog.html#lafBox
KFileBaseDialog::btngroup=KFileBaseDialog.html#btngroup
KFileBaseDialog=KFileBaseDialog.html
KDirDialog::KDirDialog=KDirDialog.html#KDirDialog
KDirDialog::initFileList=KDirDialog.html#initFileList
KDirDialog::getShowFilter=KDirDialog.html#getShowFilter
KDirDialog::updateStatusLine=KDirDialog.html#updateStatusLine
KDirDialog=KDirDialog.html
KFileDialog::KFileDialog=KFileDialog.html#KFileDialog
KFileDialog::getOpenFileName=KFileDialog.html#getOpenFileName
KFileDialog::getSaveFileName=KFileDialog.html#getSaveFileName
KFileDialog::getOpenFileURL=KFileDialog.html#getOpenFileURL
KFileDialog::getSaveFileURL=KFileDialog.html#getSaveFileURL
KFileDialog::initFileList=KFileDialog.html#initFileList
KFileDialog::getShowFilter=KFileDialog.html#getShowFilter
KFileDialog=KFileDialog.html
KFilePreviewDialog::KFilePreviewDialog=KFilePreviewDialog.html#KFilePreviewDialog
KFilePreviewDialog::~KFilePreviewDialog=KFilePreviewDialog.html#~KFilePreviewDialog
KFilePreviewDialog::getOpenFileName=KFilePreviewDialog.html#getOpenFileName
KFilePreviewDialog::getSaveFileName=KFilePreviewDialog.html#getSaveFileName
KFilePreviewDialog::getOpenFileURL=KFilePreviewDialog.html#getOpenFileURL
KFilePreviewDialog::getSaveFileURL=KFilePreviewDialog.html#getSaveFileURL
KFilePreviewDialog::registerPreviewModule=KFilePreviewDialog.html#registerPreviewModule
KFilePreviewDialog::initFileList=KFilePreviewDialog.html#initFileList
KFilePreviewDialog::getShowFilter=KFilePreviewDialog.html#getShowFilter
KFilePreviewDialog=KFilePreviewDialog.html
KFileDialogConfigure::KFileDialogConfigure=KFileDialogConfigure.html#KFileDialogConfigure
KFileDialogConfigure::ViewStyle=KFileDialogConfigure.html#ViewStyle
KFileDialogConfigure::saveConfiguration=KFileDialogConfigure.html#saveConfiguration
KFileDialogConfigure::myDetailView=KFileDialogConfigure.html#myDetailView
KFileDialogConfigure::myShortView=KFileDialogConfigure.html#myShortView
KFileDialogConfigure::myShowFilter=KFileDialogConfigure.html#myShowFilter
KFileDialogConfigure::myShowHidden=KFileDialogConfigure.html#myShowHidden
KFileDialogConfigure::myShowStatusLine=KFileDialogConfigure.html#myShowStatusLine
KFileDialogConfigure::useSingleClick=KFileDialogConfigure.html#useSingleClick
KFileDialogConfigure::myShowListLabels=KFileDialogConfigure.html#myShowListLabels
KFileDialogConfigure::myMixDirsAndFiles=KFileDialogConfigure.html#myMixDirsAndFiles
KFileDialogConfigure::myKeepDirsFirst=KFileDialogConfigure.html#myKeepDirsFirst
KFileDialogConfigure=KFileDialogConfigure.html
KFileDialogConfigureDlg::KFileDialogConfigureDlg=KFileDialogConfigureDlg.html#KFileDialogConfigureDlg
KFileDialogConfigureDlg=KFileDialogConfigureDlg.html
KFileInfo::KFileInfo=KFileInfo.html#KFileInfo
KFileInfo::KFileInfo=KFileInfo.html#KFileInfo
KFileInfo::KFileInfo=KFileInfo.html#KFileInfo
KFileInfo::~KFileInfo=KFileInfo.html#~KFileInfo
KFileInfo::operator==KFileInfo.html#operator=
KFileInfo::isDir=KFileInfo.html#isDir
KFileInfo::isFile=KFileInfo.html#isFile
KFileInfo::isSymLink=KFileInfo.html#isSymLink
KFileInfo::absURL=KFileInfo.html#absURL
KFileInfo::baseURL=KFileInfo.html#baseURL
KFileInfo::extension=KFileInfo.html#extension
KFileInfo::fileName=KFileInfo.html#fileName
KFileInfo::filePath=KFileInfo.html#filePath
KFileInfo::date=KFileInfo.html#date
KFileInfo::access=KFileInfo.html#access
KFileInfo::owner=KFileInfo.html#owner
KFileInfo::group=KFileInfo.html#group
KFileInfo::size=KFileInfo.html#size
KFileInfo::permission=KFileInfo.html#permission
KFileInfo::isReadable=KFileInfo.html#isReadable
KFileInfo::dateTime=KFileInfo.html#dateTime
KFileInfo::parsePermissions=KFileInfo.html#parsePermissions
KFileInfo::parsePermissions=KFileInfo.html#parsePermissions
KFileInfo::myName=KFileInfo.html#myName
KFileInfo::myBaseURL=KFileInfo.html#myBaseURL
KFileInfo::myAccess=KFileInfo.html#myAccess
KFileInfo::myDate=KFileInfo.html#myDate
KFileInfo::myOwner=KFileInfo.html#myOwner
KFileInfo::myGroup=KFileInfo.html#myGroup
KFileInfo::myIsDir=KFileInfo.html#myIsDir
KFileInfo::myIsFile=KFileInfo.html#myIsFile
KFileInfo::myIsSymLink=KFileInfo.html#myIsSymLink
KFileInfo::myPermissions=KFileInfo.html#myPermissions
KFileInfo::mySize=KFileInfo.html#mySize
KFileInfo::myIsReadable=KFileInfo.html#myIsReadable
KFileInfo=KFileInfo.html
KFileInfoContentsSignaler::activateDir=KFileInfoContentsSignaler.html#activateDir
KFileInfoContentsSignaler::highlightFile=KFileInfoContentsSignaler.html#highlightFile
KFileInfoContentsSignaler::activateFile=KFileInfoContentsSignaler.html#activateFile
KFileInfoContentsSignaler::dirActivated=KFileInfoContentsSignaler.html#dirActivated
KFileInfoContentsSignaler::fileHighlighted=KFileInfoContentsSignaler.html#fileHighlighted
KFileInfoContentsSignaler::fileSelected=KFileInfoContentsSignaler.html#fileSelected
KFileInfoContents::KFileInfoContents=KFileInfoContents.html#KFileInfoContents
KFileInfoContents::~KFileInfoContents=KFileInfoContents.html#~KFileInfoContents
KFileInfoContents::addItem=KFileInfoContents.html#addItem
KFileInfoContents::addItemList=KFileInfoContents.html#addItemList
KFileInfoContents::text=KFileInfoContents.html#text
KFileInfoContents::widget=KFileInfoContents.html#widget
KFileInfoContents::setCurrentItem=KFileInfoContents.html#setCurrentItem
KFileInfoContents::setAutoUpdate=KFileInfoContents.html#setAutoUpdate
KFileInfoContents::clear=KFileInfoContents.html#clear
KFileInfoContents::repaint=KFileInfoContents.html#repaint
KFileInfoContents::sorting=KFileInfoContents.html#sorting
KFileInfoContents::setSorting=KFileInfoContents.html#setSorting
KFileInfoContents::count=KFileInfoContents.html#count
KFileInfoContents::connectDirSelected=KFileInfoContents.html#connectDirSelected
KFileInfoContents::connectFileHighlighted=KFileInfoContents.html#connectFileHighlighted
KFileInfoContents::connectFileSelected=KFileInfoContents.html#connectFileSelected
KFileInfoContents::numFiles=KFileInfoContents.html#numFiles
KFileInfoContents::numDirs=KFileInfoContents.html#numDirs
KFileInfoContents::findCompletion=KFileInfoContents.html#findCompletion
KFileInfoContents::acceptsFiles=KFileInfoContents.html#acceptsFiles
KFileInfoContents::acceptsDirs=KFileInfoContents.html#acceptsDirs
KFileInfoContents::insertItem=KFileInfoContents.html#insertItem
KFileInfoContents::addItemInternal=KFileInfoContents.html#addItemInternal
KFileInfoContents::SortMode=KFileInfoContents.html#SortMode
KFileInfoContents::setSortMode=KFileInfoContents.html#setSortMode
KFileInfoContents::clearView=KFileInfoContents.html#clearView
KFileInfoContents::highlightItem=KFileInfoContents.html#highlightItem
KFileInfoContents::file_pixmap=KFileInfoContents.html#file_pixmap
KFileInfoContents::locked_file=KFileInfoContents.html#locked_file
KFileInfoContents::folder_pixmap=KFileInfoContents.html#folder_pixmap
KFileInfoContents::locked_folder=KFileInfoContents.html#locked_folder
KFileInfoContents::select=KFileInfoContents.html#select
KFileInfoContents::select=KFileInfoContents.html#select
KFileInfoContents::highlight=KFileInfoContents.html#highlight
KFileInfoContents::highlight=KFileInfoContents.html#highlight
KFileInfoContents::useSingle=KFileInfoContents.html#useSingle
KFileInfoContents::isDir=KFileInfoContents.html#isDir
KFileInfoContents::at=KFileInfoContents.html#at
KFileInfoContents::compareItems=KFileInfoContents.html#compareItems
KFileInfoContents::useSingleClick=KFileInfoContents.html#useSingleClick
KFileInfoContents::reversed=KFileInfoContents.html#reversed
KFileInfoContents::keepDirsFirst=KFileInfoContents.html#keepDirsFirst
KFileInfoContents::mySorting=KFileInfoContents.html#mySorting
KFileInfoContents::mySortMode=KFileInfoContents.html#mySortMode
KFileInfoContents::sortedArray=KFileInfoContents.html#sortedArray
KFileInfoContents::sorted_length=KFileInfoContents.html#sorted_length
KFileInfoContents::sorted_max=KFileInfoContents.html#sorted_max
KFileInfoContents::itemsList=KFileInfoContents.html#itemsList
KFileInfoContents::nameList=KFileInfoContents.html#nameList
KFileInfoContents::sig=KFileInfoContents.html#sig
KFileInfoContents=KFileInfoContents.html
KFilePreview::KFilePreview=KFilePreview.html#KFilePreview
KFilePreview::~KFilePreview=KFilePreview.html#~KFilePreview
KFilePreview::widget=KFilePreview.html#widget
KFilePreview::setAutoUpdate=KFilePreview.html#setAutoUpdate
KFilePreview::setCurrentItem=KFilePreview.html#setCurrentItem
KFilePreview::repaint=KFilePreview.html#repaint
KFilePreview::findCompletion=KFilePreview.html#findCompletion
KFilePreview::acceptsFiles=KFilePreview.html#acceptsFiles
KFilePreview::acceptsDirs=KFilePreview.html#acceptsDirs
KFilePreview::registerPreviewModule=KFilePreview.html#registerPreviewModule
KFilePreview::dirActivated=KFilePreview.html#dirActivated
KFilePreview::fileActivated=KFilePreview.html#fileActivated
KFilePreview::fileHighlighted=KFilePreview.html#fileHighlighted
KFilePreview::getDirList=KFilePreview.html#getDirList
KFilePreview::getFileList=KFilePreview.html#getFileList
KFilePreview::highlightItem=KFilePreview.html#highlightItem
KFilePreview::clearView=KFilePreview.html#clearView
KFilePreview::insertItem=KFilePreview.html#insertItem
KFilePreview::fileList=KFilePreview.html#fileList
KFilePreview::myPreview=KFilePreview.html#myPreview
KFilePreview=KFilePreview.html
KFileSimpleView::KFileSimpleView=KFileSimpleView.html#KFileSimpleView
KFileSimpleView::~KFileSimpleView=KFileSimpleView.html#~KFileSimpleView
KFileSimpleView::widget=KFileSimpleView.html#widget
KFileSimpleView::setAutoUpdate=KFileSimpleView.html#setAutoUpdate
KFileSimpleView::clearView=KFileSimpleView.html#clearView
KFileSimpleView::acceptsFiles=KFileSimpleView.html#acceptsFiles
KFileSimpleView::acceptsDirs=KFileSimpleView.html#acceptsDirs
KFileSimpleView::highlightItem=KFileSimpleView.html#highlightItem
KFileSimpleView::insertItem=KFileSimpleView.html#insertItem
KFileSimpleView::paintCell=KFileSimpleView.html#paintCell
KFileSimpleView::resizeEvent=KFileSimpleView.html#resizeEvent
KFileSimpleView::keyPressEvent=KFileSimpleView.html#keyPressEvent
KFileSimpleView::cellWidth=KFileSimpleView.html#cellWidth
KFileSimpleView::mousePressEvent=KFileSimpleView.html#mousePressEvent
KFileSimpleView::mouseDoubleClickEvent=KFileSimpleView.html#mouseDoubleClickEvent
KFileSimpleView::focusInEvent=KFileSimpleView.html#focusInEvent
KFileSimpleView::focusOutEvent=KFileSimpleView.html#focusOutEvent
KFileSimpleView::highlightItem=KFileSimpleView.html#highlightItem
KFileSimpleView::setNumCols=KFileSimpleView.html#setNumCols
KFileSimpleView::rowsVisible=KFileSimpleView.html#rowsVisible
KFileSimpleView::cellWidths=KFileSimpleView.html#cellWidths
KFileSimpleView::touched=KFileSimpleView.html#touched
KFileSimpleView=KFileSimpleView.html
KPreview::KPreview=KPreview.html#KPreview
KPreview::~KPreview=KPreview.html#~KPreview
KPreview::registerPreviewModule=KPreview.html#registerPreviewModule
KPreview::previewFile=KPreview.html#previewFile
KPreview::myName=KPreview.html#myName
KPreview::mySize=KPreview.html#mySize
KPreview::myDate=KPreview.html#myDate
KPreview::myOwner=KPreview.html#myOwner
KPreview::myGroup=KPreview.html#myGroup
KPreview::myType=KPreview.html#myType
KPreview::myPreviewPicture=KPreview.html#myPreviewPicture
KPreview::myPreviewText=KPreview.html#myPreviewText
KPreview::myBox=KPreview.html#myBox
KPreview::myDir=KPreview.html#myDir
KPreview::showedText=KPreview.html#showedText
KPreview::_myKPreview=KPreview.html#_myKPreview
KPreview=KPreview.html
KRemoteFile::KRemoteFile=KRemoteFile.html#KRemoteFile
KRemoteFile::~KRemoteFile=KRemoteFile.html#~KRemoteFile
KRemoteFile::tempName=KRemoteFile.html#tempName
KRemoteFile::url=KRemoteFile.html#url
KRemoteFile::myTempName=KRemoteFile.html#myTempName
KRemoteFile::myLocation=KRemoteFile.html#myLocation
KRemoteFile=KRemoteFile.html
--- NEW FILE: xview.h ---
#ifndef XVIEW_H
#define XVIEW_H
#include <qimage.h>
#include <qpixmap.h>
void read_xv_file( QImageIO* );
void write_xv_file( const char *_filename, QPixmap &_pixmap );
#endif
--- NEW FILE: configuration.txt ---
All file dialog settings are stored in the 'KFileDialog Settings' group.
HelpCommandPath Path to kdehelp binary
HelpFilePath Path to kfiledialog help
(use KConfig i18n features to handle the paths for
different languages)
FindCommandPath Path to kfind binary
ShowListLabels Should the list boxes have labels?
UseTreeView Tree/Finder view if tree, list view if false
only the list view is currently implemented
IncludeDirsInContentsList What it says. (boolean)
--- NEW FILE: kdirlistbox.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Mario Weilguni <mweilguni at sime.com>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kdirlistbox.h"
#include "kfileinfo.h"
#include <kapp.h>
#include <qkeycode.h>
#include <qpainter.h>
#include <qlistbox.h>
class QPixmap;
class QPainter;
class KFileInfo;
/**
* Class to allow pixmaps and text in QListBox.
* Taken from the Qt library documentation.
*/
class KDirListBoxItem : public QListBoxItem
{
public:
KDirListBoxItem( const KFileInfo *i);
void setItalic(bool);
bool isItalic() const;
protected:
virtual void paint( QPainter * );
virtual int height( const QListBox * ) const;
virtual int width( const QListBox * ) const;
virtual const QPixmap *pixmap() { return pm; }
private:
static QPixmap *folder_pixmap;
static QPixmap *locked_folder;
static QPixmap *file_pixmap;
static QPixmap *locked_file;
QPixmap *pm;
bool italic;
};
QPixmap *KDirListBoxItem::folder_pixmap = 0;
QPixmap *KDirListBoxItem::locked_folder = 0;
QPixmap *KDirListBoxItem::file_pixmap = 0;
QPixmap *KDirListBoxItem::locked_file = 0;
KDirListBoxItem::KDirListBoxItem(const KFileInfo *i)
: QListBoxItem()
{
if (!folder_pixmap) // don't use IconLoader to always get the same icon
folder_pixmap = new QPixmap(KApplication::kde_icondir() +
"/mini/folder.xpm");
if (!locked_folder)
locked_folder = new QPixmap(KApplication::kde_icondir() +
"/mini/lockedfolder.xpm");
if (!file_pixmap)
file_pixmap = new QPixmap(KApplication::kde_icondir() +
"/mini/unknown.xpm");
if (!locked_file)
locked_file = new QPixmap(KApplication::kde_icondir() +
"/mini/locked.xpm");
if (i->isDir())
pm = (i->isReadable()) ? folder_pixmap : locked_folder;
else
pm = (i->isReadable()) ? file_pixmap : locked_file;
italic = FALSE;
setText(i->fileName());
}
void KDirListBoxItem::paint( QPainter *p )
{
if(italic) {
p->save();
QFont f = p->font();
f.setItalic(true);
p->setFont(f);
}
p->drawPixmap( 3, 2, *pm );
QFontMetrics fm = p->fontMetrics();
int yPos; // vertical text position
if ( (pm->height()) < fm.height() )
yPos = fm.ascent() + fm.leading()/2;
else
yPos = pm->height()/2 - fm.height()/2 + fm.ascent();
yPos= yPos+2;
p->drawText( pm->width() + 5, yPos, text() );
if(italic)
p->restore();
}
int KDirListBoxItem::height(const QListBox *lb ) const
{
int retval;
retval= QMAX( pm->height(), lb->fontMetrics().lineSpacing() + 1);
retval= retval+2;
return retval;
}
int KDirListBoxItem::width(const QListBox *lb ) const
{
return pm->width() + lb->fontMetrics().width( text() ) + 6;
}
void KDirListBoxItem::setItalic(bool b) {
italic = b;
}
bool KDirListBoxItem::isItalic() const {
return italic;
}
void KDirListBox::mousePressEvent ( QMouseEvent *inEvent )
{
int index = this->findItem(inEvent->pos().y());
if (index == -1 || inEvent->button() != LeftButton)
return;
if ( useSingle() && isDir(index))
select( index );
else
highlight( index );
}
void KDirListBox::keyPressEvent( QKeyEvent *e )
{
int index = 0;
switch ( e->key() ) {
case Key_Return: // fall through
case Key_Enter:
index = currentItem();
if ( index == -1 )
return;
if ( isDir( index ) )
select( index );
break;
case Key_Home:
highlightItem( 0 );
setTopCell( 0 ); // somehow highlightItem() does NOT scroll!?
break;
case Key_End:
index = QListBox::count() -1;
if ( index >= 0 ) {
highlightItem( index ); // somehow highlightItem() does NOT scroll!?
setBottomItem( index );
}
break;
default:
QListBox::keyPressEvent( e );
}
}
KDirListBox::KDirListBox( bool accepts, bool s, QDir::SortSpec sorting,
QWidget * parent , const char * name )
: QListBox(parent, name) , KFileInfoContents(s,sorting)
{
_acceptFiles = accepts;
setSortMode(Increasing);
setSorting(QDir::Name);
}
KDirListBox::KDirListBox( bool s, QDir::SortSpec sorting,
QWidget * parent , const char * name )
: QListBox(parent, name) , KFileInfoContents(s,sorting)
{
_acceptFiles = false;
setSortMode(Increasing);
setSorting(QDir::Name);
}
void KDirListBox::mouseDoubleClickEvent ( QMouseEvent *inEvent )
{
if ( !useSingle() && inEvent->button() == LeftButton ) {
int newItem = this->findItem(inEvent->pos().y());
if ( newItem != -1 )
select(newItem);
}
}
void KDirListBox::setAutoUpdate(bool f)
{
QListBox::setAutoUpdate(f);
}
bool KDirListBox::insertItem(const KFileInfo *i, int index)
{
KDirListBoxItem *li = new KDirListBoxItem(i);
li->setItalic(i->isSymLink());
QListBox::insertItem(li, index);
return true;
}
void KDirListBox::clearView()
{
QListBox::clear();
}
void KDirListBox::highlightItem(unsigned int i)
{
QListBox::setCurrentItem(i);
}
#include "kdirlistbox.moc"
--- NEW FILE: kfilesimpleview.cpp ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997 Stephan Kulow <coolo at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kdir.h"
#include <qpixmap.h>
#include "kfilesimpleview.h"
#include "qkeycode.h"
#include <qpainter.h>
#include <kapp.h>
#include "config-kfile.h"
KFileSimpleView::KFileSimpleView(bool s, QDir::SortSpec sorting,
QWidget *parent, const char *name)
: QTableView(parent, name), KFileInfoContents(s,sorting), cellWidths(0)
{
QWidget::setFocusPolicy(QWidget::StrongFocus);
width_max = 100;
width_length = 0;
width_array = new uint[width_max];
setLineWidth( 2 );
setFrameStyle( Panel | Sunken );
cellWidths = new int[1];
cellWidths[0] = -1;
rowsVisible = 1;
setCellHeight( fontMetrics().lineSpacing() + 5);
setCellWidth(0);
setTableFlags(Tbl_autoHScrollBar | Tbl_cutCellsV |
Tbl_smoothHScrolling | Tbl_snapToGrid );
curCol = curRow = 0;
// QTableView::setNumCols(0);
QTableView::setNumRows(1);
setBackgroundMode( PaletteBase );
touched = false;
}
KFileSimpleView::~KFileSimpleView()
{
delete [] cellWidths;
delete [] width_array;
}
void KFileSimpleView::setNumCols(int count)
{
debugC("setNumCols %d", count);
delete [] cellWidths;
cellWidths = new int[count];
for (int i = 0; i < count; i++)
cellWidths[i] = -1;
QTableView::setNumCols(count);
}
void KFileSimpleView::setAutoUpdate(bool f)
{
QTableView::setAutoUpdate(f);
}
void KFileSimpleView::highlightItem(unsigned int i)
{
debugC("highlightItem %d", i);
int col = i / rowsVisible;
highlightItem( i - rowsVisible * col, col );
}
void KFileSimpleView::highlightItem(int row, int col)
{
debugC("highlightItem %d %d", row, col);
if ( row < 0 || col < 0 )
return;
if (col * rowsVisible + row >= static_cast<int>(count()))
return;
bool oneColOnly = leftCell() == lastColVisible();
int cx;
if (!colXPos ( col , &cx ))
cx = 0;
int edge = leftCell(); // find left edge
if ( col < edge || cx < 0) {
edge = edge - curCol + col;
if (edge < 0)
edge = 0;
setLeftCell( edge );
}
edge = lastColVisible();
if ( col > edge ) {
if ( !oneColOnly )
setLeftCell( leftCell() + col - edge + 1 );
else setLeftCell( col );
}
edge = topCell();
if ( row < edge ) {
setTopCell( edge - 1 );
}
edge = lastRowVisible();
if ( row >= edge ) {
if ( !oneColOnly )
setTopCell( topCell() + 1 );
}
// make sure, selected column is completely visible
while ( col > leftCell() && !isColCompletelyVisible( col ) ) {
setLeftCell( leftCell()+1 );
}
if (curCol != static_cast<int>(col) ||
curRow != static_cast<int>(row))
{
int oldRow = curRow;
int oldCol = curCol;
curCol = col; curRow = row;
updateCell( oldRow, oldCol);
updateCell( row, col );
}
}
bool KFileSimpleView::isColCompletelyVisible( int col )
{
if ( !colIsVisible(col) ) // out of visible area
return false;
else if ( col < lastColVisible() ) // visible and not last column
return true;
else { // last column, may be clipped
int tableWidth = 0;
for ( int i = leftCell(); i <= lastColVisible(); i++ ) {
tableWidth += cellWidth( i );
}
return ( viewWidth() >= tableWidth );
}
}
void KFileSimpleView::clearView()
{
setNumCols(1);
pixmaps.clear();
curCol = curRow = hasFocus() ? 0 : -1;
width_length = 0;
}
void KFileSimpleView::paintCell( QPainter *p, int row, int col)
{
uint index = col * rowsVisible + row;
int w = cellWidth( col ); // width of cell in pixels
int h = cellHeight( row ); // height of cell in pixels
int x2 = w - 1;
int y2 = h - 1;
if ( (row == curRow) && (col == curCol) ) { // if we are on current cell,
if ( hasFocus() ) {
p->fillRect(0, 0, x2, y2, kapp->selectColor);
p->setPen( kapp->selectTextColor );
}
else { // no focus => draw only a dashed line around current item
p->setPen( DotLine ); // used dashed line to
p->drawRect( 0, 0, x2, y2 ); // draw rect along cell edges
p->setPen( SolidLine ); // restore to normal
p->setPen( kapp->windowTextColor );
}
} else // not on current cell, use the normal color
p->setPen( kapp->windowTextColor );
if (index < count()) {
p->drawPixmap(0, 1, *pixmaps.at(index));
p->drawText(3 + pixmaps.at(index)->width(), 15, text(index));
}
}
void KFileSimpleView::keyPressEvent( QKeyEvent* e )
{
int newRow = curRow; // store previous current cell
int newCol = curCol;
int oldRow = curRow;
int oldCol = curCol;
int lastItem = 0;
int jump = 0;
bool oneColOnly = leftCell() == lastColVisible();
// do nothing, when there are no entries
if ( count() == 0 )
return;
// if user scrolled current item out of view via scrollbar and then
// tries to scroll via keyboard, make item visible before going on
if ( !colIsVisible( curCol ) ) {
setLeftCell( curCol );
}
switch( e->key() ) { // Look at the key code
case Key_Left:
if( newCol > 0 )
newCol--;
else newRow = 0;
break;
case Key_Right: // Correspondingly...
if( newCol < numCols()-1 )
newCol++;
else newRow = (count() % numRows()) - 1;
if (newCol * rowsVisible + oldRow >= static_cast<int>(count()))
newRow = count() - rowsVisible * newCol - 1;
break;
case Key_Up:
if( newRow >= 0 ) {
newRow--;
if (newRow == -1)
if (newCol == 0)
newRow = 0;
else {
newRow = rowsVisible - 1;
newCol--;
}
}
break;
case Key_Down:
if( newRow <= numRows()-1 ) {
newRow++;
if (newRow >= numRows() && curCol < numCols()-1) {
newRow = 0;
newCol++;
}
}
break;
case Key_Home:
newRow = 0;
newCol = 0;
break;
case Key_End:
newRow = count() % numRows() - 1; // calc last item in last col
newCol = numCols() - 1;
break;
case Key_PageUp:
if ( oneColOnly )
jump = 1;
else
jump = lastColVisible() - leftCell(); // num of cols we want to jump
if ( curCol - jump < 0 ) {
newRow = 0;
newCol = 0;
}
else newCol = curCol - jump;
if ( curCol == newCol ) newRow = 0;
break;
case Key_PageDown:
if ( oneColOnly )
jump = 1;
else
jump = lastColVisible() - leftCell();
lastItem = count() % numRows() - 1; // last item in last col
if ( curCol + jump >= numCols() ) { // too far, just go to last col
newCol = numCols() - 1;
newRow = lastItem;
} else {
newCol += jump;
if ( newCol == numCols()-1 && curRow > lastItem )
newRow = lastItem;
else if ( curCol == newCol ) newRow = lastItem;
else
newRow = curRow;
}
break;
case Key_Enter:
case Key_Return:
select( curCol * rowsVisible + curRow );
return;
break;
default:
{
if ((e->ascii() >= 'a' && e->ascii() <= 'z') ||
(e->ascii() >= 'A' && e->ascii() <= 'Z')) {
char tmp[2] = " ";
tmp[0] = e->ascii();
QString res = findCompletion(tmp);
if (!res.isNull())
debugC("found %s",res.data());
} else
e->ignore();
}
return;
}
// newRow may be -1 when the last column is completely filled with entries
// and the user tries to go rightwards (End, RightArrow, PageDown)
// the last entry shall be selected, then (numRows()-1)
if ( newRow < 0 ) newRow = numRows() - 1;
if ( newCol >= numCols() ) newCol = numCols() -1;
highlightItem( newRow, newCol );
if ( curRow != oldRow || curCol != oldCol )
highlight( curRow + curCol * rowsVisible );
}
bool KFileSimpleView::insertItem(const KFileInfo *i, int index)
{
if (index == -1) // -1 = append to the end
index = pixmaps.count();
if (numCols() * rowsVisible < static_cast<int>(count()))
setNumCols(numCols() + 1);
if (i->isDir()) {
if (i->isReadable())
pixmaps.insert(index, folder_pixmap);
else
pixmaps.insert(index, locked_folder);
} else {
if (i->isReadable())
pixmaps.insert(index, file_pixmap);
else
pixmaps.insert(index, locked_file);
}
int curCol = index / rowsVisible;
for (int j = curCol; j < numCols(); j++)
cellWidths[ j ] = -1; // reset values
uint size = fontMetrics().width( i->fileName() );
insertArray(size, index);
return colIsVisible(curCol) || curCol < leftCell() ;
}
int KFileSimpleView::cellWidth ( int col )
{
if (cellWidths[col] == -1) {
// debugC("not cached %d", col);
int offset = col * rowsVisible;
int width = 100;
for (int j = 0; offset + j < static_cast<int>(width_length)
&& j < rowsVisible; j++)
{
int w = width_array[offset + j];
if (width < w)
width = w;
}
cellWidths[col] = width + file_pixmap->width() + 9;
}
// debugC("cellWidth %d %d", col, cellWidths[col]);
return cellWidths[col];
}
void KFileSimpleView::resizeEvent ( QResizeEvent *e )
{
int index = curCol * rowsVisible + curRow;
if ( index < 0 ) index = 0;
QTableView::resizeEvent(e);
rowsVisible = viewHeight() / cellHeight();
if (!rowIsVisible(rowsVisible))
rowsVisible--;
int cols;
if (rowsVisible <= 0)
rowsVisible = 1;
setNumRows(rowsVisible);
cols = count() / rowsVisible + 1;
if ( static_cast<int>(count()) <= rowsVisible * (cols-1) && cols >= 1)
cols--; // if last col is completely filled, we calc'ed 1 col too much
setNumCols(cols);
QTableView::repaint(true);
highlightItem( index );
}
void KFileSimpleView::mousePressEvent( QMouseEvent* e )
{
int oldRow = curRow; // store previous current cell
int oldCol = curCol;
QPoint clickedPos = e->pos(); // extract pointer position
curRow = findRow( clickedPos.y() ); // map to row; set current cell
if (curRow > static_cast<int>(rowsVisible))
curRow = rowsVisible;
curCol = findCol( clickedPos.x() ); // map to col; set current cell
uint index = curCol * rowsVisible + curRow;
if ( index >= count()) {
curCol = oldCol;
curRow = oldRow;
return;
}
if ( (curRow != oldRow) // if current cell has moved,
|| (curCol != oldCol) ) {
updateCell( oldRow, oldCol ); // erase previous marking
updateCell( curRow, curCol ); // show new current cell
}
if ( useSingle() && isDir(index))
select( index );
else
highlight( index );
}
void KFileSimpleView::mouseDoubleClickEvent ( QMouseEvent *e )
{
int oldRow = curRow;
int oldCol = curCol;
QPoint clickedPos = e->pos();
curRow = findRow( clickedPos.y() );
if (curRow > static_cast<int>(rowsVisible))
curRow = rowsVisible;
curCol = findCol( clickedPos.x() );
uint index = curCol * rowsVisible + curRow;
if ( index >= count()) {
curCol = oldCol;
curRow = oldRow;
return;
}
if ( (curRow != oldRow)
|| (curCol != oldCol) ) {
updateCell( oldRow, oldCol );
updateCell( curRow, curCol );
}
select( index );
}
void KFileSimpleView::focusInEvent ( QFocusEvent * )
{
if (curRow < 0 || curCol < 0)
curRow = curCol = 0;
updateCell( curRow, curCol );
}
void KFileSimpleView::focusOutEvent ( QFocusEvent * )
{
updateCell( curRow, curCol );
}
void KFileSimpleView::insertArray(uint item, uint pos)
{
// debug("insert %s %d", item->fileName(), pos);
if (width_length == width_max) {
width_max *= 2;
uint *newArray = new uint[width_max];
int found = 0;
for (uint j = 0; j < width_length; j++) {
if (j == pos) {
found = 1;
newArray[j] = item;
}
newArray[j+found] = width_array[j];
}
if (!found)
newArray[pos] = item;
delete [] width_array;
width_array = newArray;
width_length++;
return;
}
// faster repositioning (very fast :)
memmove(width_array + pos+1,
width_array + pos,
(width_max - 1 - pos) * sizeof(uint));
width_array[pos] = item;
width_length++;
}
#include "kfilesimpleview.moc"
--- NEW FILE: configure.xpm ---
/* XPM */
static char*wheel[]={
"22 22 6 1",
"d c #808080",
"b c #a0a0a4",
"c c #c0c0c0",
"# c #000000",
". c None",
"a c #ffffff",
"......................",
"......................",
"..........##..........",
".........#ab#.........",
".....##..#ab#..##.....",
"....#ba##accd##ab#....",
"....#dcaaccccaacd#....",
".....#bccccccccd#.....",
".....#accbdbcccb#.....",
"...##accbd##acccb##...",
"..#aacccd#..#acccab#..",
"..#ddcccb#..#acccdd#..",
"...##bbcca##acccd##...",
".....#bcccaacccd#.....",
".....#accccccccd#.....",
"....#acdbcccccacd#....",
"....#bd##accb##bd#....",
".....##..#ad#..##.....",
".........#ad#.........",
"..........##..........",
"......................",
"......................"};
--- NEW FILE: ChangeLog ---
Tue Apr 20 18:10:58 1999 Carsten Pfeiffer <pfeiffer at kde.org>
* kfilesimpleview.cpp (insertItem): QList::insert() seems to have
changed: valid range for index is only from 0 to count(). Passing -1
as index results in an error - and a segfault in kfile.
=> changed KFileSimpleView::insertItem() to set index to count() if
it is set to -1 (coming from KFileInfoContents::setSorting()).
Sat Apr 17 15:50:41 1999 Carsten Pfeiffer <pfeiffer at kde.org>
* kfiledetaillist.{cpp,h}, kdirview.{cpp,h}:
those views didn't have proper keyboard bindings (HOME, END, RETURN)
* kfiledialog.cpp: fixed some geometry management problems with
large toolbar (noticed because of icon+text in toolbar)
1999-01-14 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: fixed some GUI problems and moved all default
configurations into config-kfile.h.
Changed some default values, so that users that never looked into
the config dialog gets a nice suprise with 1.1 ;-)
* kfiledialog.cpp: changed selectedFile to return decoded path instead
of encoded one
Thu Jan 7 23:14:39 1999 Carsten Pfeiffer <pfeiffer at kde.org>
* kfilesimpleview.cpp (keyPressEvent): fixed segfault on keypress,
when there were no files at all in the list
1998-12-19 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: fixing an ugly bug when "." is used as argument
Mon Dec 14 23:00:41 1998 Carsten Pfeiffer <pfeiffer at kde.org>
* kfilebookmark.cpp: renamed class KBookmark to KFileBookmark to
avoid problems with KFM's KBookmark class. Renamed bookmark.* to
kfilebookmark.*, too and changed all occurrences of bookmark.* to
kfilebookmark.* (especially all the .po-files)
Wed Dec 2 15:59:13 1998 Carsten Pfeiffer <pfeiffer at kde.org>
* kfilesimpleview.cpp: Fixed some more keyboard navigation bugs.
Added method isColCompletelyVisible( int col ), now you can scroll
perfectly to make items completely visible.
Moreover, in resizeEvent() the number of columns was not calculated
correctly in a special case.
And the currently selected item is rehighlighted correctly after
resizing, now.
1998-10-12 Jochen Küpper <jochen at uni-duesseldorf.de>
* kfiledialog.cpp (okPressed): Changed okPressed to store the correct
filename before leaving the dialog.
1998-06-07 Stephan Kulow <coolo at kde.org>
* kfilesimpleview.cpp: added some checks to prevent division with
zero using the latest qt snapshots
* kfilesimpleview.cpp: added a repaint call after a resize
* kfiledialog.cpp: new experimental button order
* kfiledialog.cpp: added lastDirectory to remember the last visited
directory for next open
1998-05-24 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: use setSelection also for the initial filename
given
* kfiledialog.cpp: introduced KFileFilter to make an abstraction
for the used filter widget. Currently only QComboBox is supported,
but this may change in the future
1998-05-20 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: changed the accelerator for completion
to CTRL-T
* kfiledialog.cpp: fixed the setSelection() feature
1998-05-19 Stephan Kulow <coolo at kde.org>
* kfiledialog.h: added setSelection
1998-05-18 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: bugfixes
1998-05-15 Stephan Kulow <coolo at kde.org>
* kfileinfocontents.cpp: some more changes and speed ups
(caching and some other little things)
1998-05-14 Stephan Kulow <coolo at kde.org>
* kfileinfocontents.cpp: added addItemList
* kfileinfocontents.h: introduced KFileInfoContentsSignaler
* kfileinfocontents.cpp: some more speed improvment
1998-05-10 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: tried to speed up the refresh
1998-04-17 Stephan Kulow <coolo at kde.org>
* kfiledetaillist.cpp: implemented the date field
* kfiledetaillist.cpp: made the columns wider
* kfileinfocontents.cpp: use the new icons by Mark
Thu Apr 16 10:51:24 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* kfiledialog.*: some small fixes concerning preview
* kfileinfocontents.cpp: fixed sorting bug in preview
* kfilepreview.*: small bug fixes
* kpreview.*: small bug fixes
* added some documentation
1998-04-15 Stephan Kulow <coolo at kde.org>
* kfilepreview.cpp: use a list box instead of simple view
* kfiledialog.cpp: fixed an ugly bug
1998-04-14 Stephan Kulow <coolo at kde.org>
* kfiledialogconf.cpp: removed the width/height sliders
* kfiledialog.cpp: save the width and height on exit
* kfiledialogconf.cpp: added more guys to the about box
* kfiledialog.h: removed init*Children. They were useless
* kfiledialog.cpp: set the default size to a useful value
Mon Apr 6 17:30:18 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* kfilepreview.*: restructured previewing, one can now easily
use custom previewers, dynamically
* kpreview.*: changes for allowing custom previewers, two previewers
are hardcoded so far
* kfiledialog.*: changes changes for allowing custom previewers
* kfstest.cpp: changes to preview mode
* xview.*: QimageIO module allowing the visual-schnauzer generated
images to be loaded
1998-04-06 Stephan Kulow <coolo at kde.org>
* debug.h: added debugC. An empty macro to hide debug output
Thu Apr 2 19:39:37 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* kpreview.*: widget which for now shows some info about a
file/folder along with the first 20-30 lines of it
* kfilepreview.*: added a new view which has a preview of any text
file in the right part
* kfstest.cpp: added the new mode "preview" which shows the above
view
1998-03-30 Stephan Kulow <coolo at kde.org>
* kfilesimpleview.cpp: fixed highlightning
* kfiledialog.cpp: some fixes for the dir selection
* kfiledialog.h: Moved KFileDialog into KFileBaseDialog and made
KFileDialog and KDirDialog a derived class of KFileBaseDialog to
make this virtual functions work
Mon Mar 30 17:53:20 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* kcombiview.cpp: bug fixes for completion & corresponding
highlighting
* kfiledialog.cpp: small bug fix, too much copying into location
* kfileinfocontents.cpp: completion slightly remodeled, should
work in all views now
* kfileinfocontents.h: changed nameList to case insensitive
list
1998-03-28 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: changed the filter seperator to \n.
This looks nicer in the source code of the call
Sat Mar 28 14:49:00 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: changed the meaning of the dirName argument
* kfiledialog.h: added getShowFilter
Thu Mar 26 12:47:42 1998 Stephan Kulow <coolo at kde.org>
* kfilesimpleview.cpp: improved scrolling in simple view
* kfileinfocontents.cpp: add a / after a found dir
* kfiledialog.cpp: fixed bug for !showFilter
Wed Mar 25 18:39:09 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* kfileinfocontents.cpp: completion now working
* kcombiview.cpp: changed behaviour for completion, it
now highlights completed directory and file
Tue Mar 24 16:08:46 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* kfileinfocontents.cpp: sorting now fully working
* kfiledialog.cpp: modifications for sorting in the on the
fly reconfiguration
* kfileinfocontents.*: modification to the constructor
to pass along the sorting
* kfiledetaillist.*: modification to the constructor
to pass along the sorting
* kcombiview.*: modification to the constructor
to pass along the sorting
* kfilesimpleview.*: modification to the constructor
to pass along the sorting
Tue Mar 24 10:45:15 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* kfileinfocontents.cpp: sorting fixed, the feature of keeping
directories grouped is still missing though
Mon Mar 23 22:59:18 1998 Stephan Kulow <coolo at kde.org>
* kfiledetaillist.h: added acceptsFiles() and acceptsDirs() to
make dirs-only views useful
* kfileinfocontents.cpp: OK, completion is back again, but
currently not working, because the code is missing ;-)
Mon Mar 23 00:08:02 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: moved all GM related things into initGUI() to
make recreation possible
Sun Mar 22 00:22:46 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: use KShellProcess now
* kfiledialog.h: added virtual function initFileList to made
KFileDialog customable
* kfiledialog.cpp: show a combo box, in case more filters are given
* kfiledialog.cpp: some bug fixes. I can't get the sorting to work
* Makefile.am: install some toolbar pixmaps
* kfiledetailview.cpp: added pixmaps to the detail view
* Kfiledialog.cpp: made KComboView customable through virtual
functions
* kcombiview.cpp: took out the completion for now, added
kcombiview and some little changes in setCurrentItem
* kdirlistbox.cpp: fixed the use of single click
* kdir.h: moved the header files a little bit to remove
some dependencies
* kdirlistbox.cpp: KDirListBox is now a KFileInfoContents too
* kfiledialog.cpp: another change in the API. It uses now QSignal.
I didn't liked the old way
1998-03-21 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: implemented mixDirsAndFiles. Need some work and currently
only supported by the simple view
Sat Mar 21 01:00:48 1998 Stephan Kulow <coolo at kde.org>
* kfilesimpleview.cpp: added pixmaps to indicate access on the file
* kfilesimpleview.cpp: improved keyboard navigation
* kfilesimpleview.cpp: first almost working simple view
* kfilesimpleview.cpp: started implementing a simple view. Needs
still some work
Fri Mar 20 22:42:31 1998 Stephan Kulow <coolo at kde.org>
* kfileinfocontents.h: bugfixes
* kfileinfo.cpp: KFileInfo is no longer a derived class of
QFileInfo. This should reduce memory use too
* kfileinfocontents.h: moved the actual sorting in
KFileInfoContents. Derived classes are for viewing only
* kfiledialog.h: fixed some header files locations
1998-03-20 Stephan Kulow <coolo at kde.org>
* kfileinfo.cpp: show lockedfolder.xpm for folders, that are not
allowed to enter or read
* kfiledialog.cpp: bug fixes
Fri Mar 20 13:10:11 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* kfilgdialog.*, remodeled the configuration dialog to reflect the
current possible settings
* kfiledetailList.cpp: added the PageUp PageDown navigation
1998-03-19 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: fixed the forward/back back reported by
Stefan Tafener
1998-03-18 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: set the initial focus to the line edit
* kfiledialog.cpp: use kapp->invokeHTMLHelp now
* kfiledialog.h: removed treeList, since it's not implemented
Wed Mar 18 02:56:32 1998 Stephan Kulow <coolo at kde.org>
* kfiledetaillist.cpp: fixed sorting again
1998-03-17 Stephan Kulow <coolo at kde.org>
* added a virtual class KInfoListContent to make an abstraction
for the file contents. Currently there is just one implementation
KFileDetailList
1998-03-16 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: don't accept the first entry of the combo
box as a file name
* kfiledialog.cpp: added an accelerator for completion, since
KCombo no longer emits such a thing (currently CTRL-A)
* kdir.cpp: disable parent button in /
* kfiledialog.cpp: fixed layout of mkdir dialog
* kdir.cpp: use currentDir instead of homeDir as default
* kfiledialog.cpp: added member acceptOnlyExisting and set it
for now to always false. I guess, we need an extra parameter for this
* kfiledialog.cpp: changed dirList and fileList to fix the
focus handling
* kfileinfolistwidget.cpp: added focus handling
* kfileinfolistwidget.cpp: added keyevent handling to handle
cursor and enter
* kfiledialog.cpp: changed the filter edit to a QLineEdit, since
we don't need the completion, but the tabing for focus changes
Mon Mar 16 11:36:07 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* added create directory, pops up a modal dialog, should add
a mkdir method to kdir in near future
Mon Mar 16 20:04:00 1998 Martin Jones <mjones at kde.org>
* Added booktoken.* to remove dependancy on khtmlw and jscript
Thu Mar 12 09:32:06 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
* worked on the dir and file completion, should do both now,
text in the location box will be added as much as possible
(right now it's the lowest denominator of dir&file&location-text)
* added sorting for the detailed list, so far only name and size
sorting implemented
* added single click selection for directories
* added a status line, which shows the number of directories and
files showed
Thu Mar 12 00:36:05 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: made a library out of the file selector
* kfiledialog.cpp: added an extra parameter acceptURLs to seperate
between getOpenFileName and getOpenFileURL
Sun Feb 15 23:13:47 1998 Richard Moore <rich at kde.org>
* More work on the bookmarks - they should work properly now, you
must create the directory ~/.kde/share/apps/kdeui to store the
bookmarks in.
* Regenerated docs
Thu Feb 12 17:27:51 1998 Stephan Kulow <coolo at kde.org>
* kfileinfo.cpp: added determination of group and other things to
be display the correct values in the kfileinfolistwidget
Thu Feb 12 16:01:44 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: removed the #ifdef code. Now the combo box for
the path is the only option
Tue Feb 10 01:09:16 1998 Richard Moore <rich at kde.org>
* Added details widget - this is currently selected by a config
file entry, but it there should be a toolbar button. Many changes
to kfiledialog to allow the switch (need an abstract fileview class).
Fri Feb 6 18:08:14 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: replaced the location lineedit with an combo
box. Currently configurable with a compiler define.
Fri Feb 6 17:07:26 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: fixed the en- and decoding of URLs. Now it's
possible to move into directories called "sdasd#sdsd" for example
Sat Jan 24 17:18:10 1998 Mario Weilguni <mweilguni at sime.com>
* fixed a bug in kdir.cpp/parsePermissions()
* implemented error handling for KFM URL errors
Tue Jan 20 00:51:55 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: some fixes to make kfm support more robust
Mon Jan 19 01:10:11 1998 Stephan Kulow <coolo at kde.org>
* kdir.cpp: re-added ftp support
* kfiledialog.cpp: take care of the case, when the user enters a
complete filename
* kdir.cpp: added isReadable() to indicate, that the dir is not
correct
* kfiledialog.cpp: played a little bit with the geometry managment
Sun Jan 18 15:00:06 1998 Stephan Kulow <coolo at kde.org>
* kfiledialog.cpp: - back/forward work now as expected
- show the correct filter
- the combo box works now as expected
* kdir.cpp: check if the directory is correct (for local
files). If not, go back to the old value
* kfiledialog.cpp: - disable parent button, when in root
- treat the case, that the URL ends with "/"
- strip white spaces out of the location text
* kfileinfo.cpp: don't insert broken links
* kfiledialog.cpp: just set the dir, if it's different
from the already set one
Sun Jan 18 11:53:32 1998 Mario Weilguni <mweilguni at sime.com>
* symbolic links to subdirectories are now correctly reported as
directories
* symbolic links are show as italic text
* The toolbar button "Home" works now as expected
--- NEW FILE: kfiledialogconf.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qlayout.h>
#include <qlineedit.h>
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qcheckbox.h>
#include "kfiledialogconf.h"
#include "config-kfile.h"
#include <kapp.h>
enum Buttons { B_STATUSLINE=10, B_FILTER, B_SINGLECLICK, B_HIDDEN,
B_LISTLABELS, B_SHORTVIEW, B_DETAILVIEW, B_MIX, B_KEEPDIR };
KFileDialogConfigureDlg::KFileDialogConfigureDlg(QWidget *parent,
const char *name)
: QTabDialog(parent, name, true)
{
KFileDialogConfigure *kfdc= new KFileDialogConfigure(this);
resize(kfdc->size());
addTab(kfdc, i18n("Look and Feel"));
QLabel *label= new QLabel(i18n("KDE File Selector by:\n"
"\n"
"Richard Moore <rich at kde.org>\n"
"Stephan Kulow <coolo at kde.org>\n"
"and Daniel Grana <grana at ie.iwi.unibe.ch>\n"
"\n"
"with contributions by\n"
"\n"
"Mario Weilguni <mweilguni at sime.com>\n"
"and Martin Jones <mjones at kde.org>"),
this);
label->setAlignment(AlignCenter);
label->adjustSize();
addTab(label, i18n("About"));
setCancelButton(i18n("Cancel"));
// setApplyButton(i18n("Apply"));
setOKButton(i18n("OK"));
connect( this, SIGNAL(applyButtonPressed()), kfdc, SLOT(saveConfiguration()) );
};
KFileDialogConfigure::KFileDialogConfigure(QWidget *parent,
const char *name)
: QWidget(parent, name)
{
QVBoxLayout *choices = new QVBoxLayout(this, 5);
QButtonGroup *group= new QButtonGroup( i18n("View style"), this);
group->setExclusive(true);
QVBoxLayout *l1 = new QVBoxLayout(group, 5);
l1->addSpacing(10);
myShortView= new QRadioButton( i18n("Show Short View"), group);
group->insert( myShortView, B_SHORTVIEW );
myShortView->adjustSize();
myShortView->setMinimumSize( myShortView->sizeHint() );
l1->addWidget( myShortView, 0 );
l1->addSpacing(10);
myDetailView= new QRadioButton( i18n("Show Detail View"), group);
group->insert( myDetailView, B_DETAILVIEW );
myDetailView->adjustSize();
myDetailView->setMinimumSize( myDetailView->sizeHint() );
l1->addWidget( myDetailView, 0 );
choices->addWidget(group, 2);
//
//
QButtonGroup *group2= new QButtonGroup(i18n("Misc"), this);
choices->addSpacing(15);
choices->addWidget( group2, 5 );
QVBoxLayout *l2 = new QVBoxLayout(group2, 5);
l2->addSpacing(10);
myShowFilter= new QCheckBox(i18n("Show Filter"), group2);
group2->insert( myShowFilter, B_FILTER );
myShowFilter->adjustSize();
myShowFilter->setMinimumSize( myShowFilter->sizeHint() );
l2->addWidget( myShowFilter, 0 );
l2->addSpacing(10);
myShowListLabels= new QCheckBox(i18n("Show List Labels"), group2);
group2->insert( myShowListLabels, B_LISTLABELS );
myShowListLabels->adjustSize();
myShowListLabels->setMinimumSize( myShowListLabels->sizeHint() );
l2->addWidget( myShowListLabels, 0 );
l2->addSpacing(10);
myShowHidden= new QCheckBox( i18n("Show Hidden"), group2);
group2->insert( myShowHidden, B_HIDDEN );
myShowHidden->adjustSize();
myShowHidden->setMinimumSize( myShowHidden->sizeHint() );
l2->addWidget( myShowHidden, 0 );
l2->addSpacing(10);
myShowStatusLine= new QCheckBox( i18n("Show Status Line"), group2);
group2->insert( myShowStatusLine, B_STATUSLINE );
myShowStatusLine->adjustSize();
myShowStatusLine->setMinimumSize( myShowStatusLine->sizeHint() );
l2->addWidget( myShowStatusLine, 0 );
l2->addSpacing(10);
useSingleClick= new QCheckBox( i18n("Use single Click"), group2);
group2->insert( useSingleClick, B_SINGLECLICK );
useSingleClick->adjustSize();
useSingleClick->setMinimumSize( useSingleClick->sizeHint() );
l2->addWidget( useSingleClick, 0 );
l2->addSpacing(10);
myMixDirsAndFiles = new QCheckBox( i18n("Mix dirs and files"), group2);
group2->insert( myMixDirsAndFiles, B_MIX );
myMixDirsAndFiles->adjustSize();
myMixDirsAndFiles->setMinimumSize( myMixDirsAndFiles->sizeHint() );
l2->addWidget( myMixDirsAndFiles, 0 );
l2->addSpacing(10);
myKeepDirsFirst = new QCheckBox( i18n("Keep dirs first"), group2);
group2->insert( myKeepDirsFirst, B_KEEPDIR );
myKeepDirsFirst->adjustSize();
myKeepDirsFirst->setMinimumSize( myKeepDirsFirst->sizeHint() );
l2->addWidget( myKeepDirsFirst, 0 );
group2->setMinimumSize( group2->childrenRect().size() );
l2->activate();
group->setMinimumSize( group->childrenRect().size() );
l1->activate();
choices->activate();
this->adjustSize();
/*
horizontal->addSpacing( 10 );
horizontal->addWidget( group2, 5 );
QBoxLayout *horizontalx= new QBoxLayout(QBoxLayout::LeftToRight);
QLineEdit *findPathEdit;
findPathEdit= new QLineEdit(this, "findpathedit");
QLabel *tmpLabel;
tmpLabel= new QLabel(findPathEdit, i18n("&Find command:"), this);
tmpLabel->adjustSize();
tmpLabel->setAlignment(AlignCenter);
tmpLabel->setMinimumSize(tmpLabel->size());
tmpLabel->setMaximumHeight(tmpLabel->height());
findPathEdit->setMinimumHeight(tmpLabel->size().height()+8);
findPathEdit->setMaximumHeight(tmpLabel->size().height()+8);
vertical->addLayout(horizontalx);
horizontal->addWidget(tmpLabel, 1);
horizontal->addWidget(findPathEdit, 10);
vertical->activate();
*/
// Now read the current settings
KConfig *c;
QString oldgroup;
QString dirview;
c= kapp->getConfig();
oldgroup= c->group();
c->setGroup("KFileDialog Settings");
QString currentViewStyle = c->readEntry("ViewStyle", DefaultViewStyle);
if ( currentViewStyle == "DetailView" )
myDetailView->setChecked(true);
else
myShortView->setChecked(true);
myShowHidden->setChecked(c->readBoolEntry("ShowHidden", DefaultShowHidden));
myShowFilter->setChecked(c->readBoolEntry("ShowFilter", DefaultShowFilter));
myShowListLabels->setChecked(c->readBoolEntry("ShowListLabels",
DefaultShowListLabels));
useSingleClick->setChecked(c->readBoolEntry("SingleClick",
DefaultSingleClick));
myShowStatusLine->setChecked(c->readBoolEntry("ShowStatusLine",
DefaultShowStatusLine));
myMixDirsAndFiles->setChecked(c->readBoolEntry("MixDirsAndFiles",
DefaultMixDirsAndFiles));
myKeepDirsFirst->setChecked(c->readBoolEntry("KeepDirsFirst",
DefaultKeepDirsFirst));
// Restore the old config group
c->setGroup(oldgroup);
}
void
KFileDialogConfigure::saveConfiguration()
{
// Now read the current settings
KConfig *c;
QString oldgroup;
QString dirview;
c= kapp->getConfig();
oldgroup= c->group();
c->setGroup("KFileDialog Settings");
c->writeEntry("ViewStyle",
myDetailView->isChecked() ? "DetailView" : "ShortView",
true, true);
c->writeEntry("ShowHidden", myShowHidden->isChecked(), true, true);
c->writeEntry("ShowFilter", myShowFilter->isChecked(), true, true);
c->writeEntry("ShowListLabels",myShowListLabels->isChecked(), true, true );
c->writeEntry("SingleClick", useSingleClick->isChecked(), true, true);
c->writeEntry("ShowStatusLine", myShowStatusLine->isChecked(), true, true);
c->writeEntry("MixDirsAndFiles",myMixDirsAndFiles->isChecked(), true, true);
c->writeEntry("KeepDirsFirst", myKeepDirsFirst->isChecked(), true, true);
c->sync();
// Restore the old config group
c->setGroup(oldgroup);
}
#include "kfiledialogconf.moc"
--- NEW FILE: kfiledialog.cpp ---
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <qtimer.h>
#include <qtabdialog.h>
#include <qstrlist.h>
#include <qstring.h>
#include <qstack.h>
#include <qpushbutton.h>
#include <qpopupmenu.h>
#include <qpixmap.h>
#include <qobjcoll.h>
#include <qmessagebox.h>
#include <qlistbox.h>
#include <qlist.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <qcolor.h>
[...1418 lines suppressed...]
delete dlg;
return retval;
}
bool KFilePreviewDialog::getShowFilter()
{
return kapp->getConfig()->readBoolEntry("ShowFilter", DefaultShowFilter);
}
void KFilePreviewDialog::registerPreviewModule( const char * format,
PreviewHandler readPreview,
PreviewType inType)
{
KPreview::registerPreviewModule( format, readPreview, inType );
}
#include "kfiledialog.moc"
--- NEW FILE: kfiledetaillist.cpp ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kdir.h"
#include "kfiledetaillist.h"
#include "qkeycode.h"
#include <kapp.h>
KFileDetailList::KFileDetailList(bool s, QDir::SortSpec sorting,
QWidget *parent, const char *name)
: KTabListBox(parent, name, 7), KFileInfoContents(s,sorting)
{
QWidget::setFocusPolicy(QWidget::StrongFocus);
setSeparator('\t');
setColumn(0, "", file_pixmap->width() + 10, KTabListBox::PixmapColumn);
QFontMetrics fm = fontMetrics();
QString text = i18n("Name");
setColumn(1, text, QMAX(fm.width(text + "_"), 150));
text = i18n("Size");
setColumn(2, text, QMAX(fm.width(text + "_"), 50));
text = i18n("Permissions");
setColumn(3, text, QMAX(fm.width(text + "_"), 80));
text = i18n("Date");
int _width = QMAX(fm.width(text + "_"), 50);
setColumn(4, text, QMAX(_width, fm.width(KFileInfo::dateTime(0) + "_")));
text = i18n("Owner");
setColumn(5, text, QMAX(fm.width(text + "_"), 70));
text = i18n("Group");
setColumn(6, text, QMAX(fm.width(text + "_"), 70));
dict().insert("file", file_pixmap);
dict().insert("l_file", locked_file);
dict().insert("folder", folder_pixmap);
dict().insert("l_folder", locked_folder);
setSortMode(Switching);
//setSorting(QDir::Name);
connect(this,SIGNAL(selected(int,int )), SLOT(selected(int)));
connect(this, SIGNAL(highlighted(int,int)), SLOT(highlighted(int)));
connect(this, SIGNAL(headerClicked(int)), SLOT(reorderFiles(int)));
}
void KFileDetailList::repaint(bool)
{
KTabListBox::repaint();
}
void KFileDetailList::keyPressEvent( QKeyEvent *e)
{
int oldRow = currentItem();
int edge;
int numVisible = lastRowVisible() - topCell();
switch( e->key() ) {
case Key_Up:
if( oldRow > 0 ) {
KTabListBox::setCurrentItem(oldRow-1);
edge = topItem();
if ( currentItem() < edge )
setTopItem( edge - 1 );
}
break;
case Key_Down:
if( oldRow < numRows()-1 ) {
KTabListBox::setCurrentItem(oldRow+1);
edge = lastRowVisible();
if ( currentItem() >= edge )
setTopItem( topCell() + 1 );
}
break;
case Key_Home:
highlightItem( 0 );
break;
case Key_End:
edge = KTabListBox::count() -1;
if ( edge >= 0 )
highlightItem( edge );
break;
case Key_Enter:
case Key_Return:
select( currentItem() );
break;
case Key_PageUp:
if ( oldRow > 0 ) {
if ( oldRow >= numVisible ) {
KTabListBox::setCurrentItem(oldRow - numVisible);
edge = topCell() - numVisible;
if ( currentItem() - edge >= numVisible )
edge++;
if ( edge >= 0)
setTopItem(edge);
else
setTopItem(0);
} else {
KTabListBox::setCurrentItem(0);
setTopItem(0);
}
}
break;
case Key_PageDown:
if ( oldRow < numRows()-1 ) {
if ( oldRow < numRows()-numVisible-1 ) {
KTabListBox::setCurrentItem(oldRow + numVisible);
edge = lastRowVisible();
if ( currentItem()+numVisible-1 >= edge )
setTopItem( topCell() + numVisible );
else
setTopItem( numRows() - numVisible );
} else {
KTabListBox::setCurrentItem(numRows()-1);
setTopItem( numRows() - numVisible );
}
}
break;
default:
e->ignore();
return;
}
}
void KFileDetailList::focusInEvent ( QFocusEvent *)
{
if (currentItem() < 0) {
KTabListBox::setCurrentItem(topItem());
}
else {
markItem( currentItem() );
}
}
KFileDetailList::~KFileDetailList()
{
}
void KFileDetailList::setAutoUpdate(bool f)
{
KTabListBox::setAutoUpdate(f);
}
void KFileDetailList::highlightItem(unsigned int i)
{
KTabListBox::setCurrentItem(i);
unsigned j = (KTabListBox::lastRowVisible()-KTabListBox::topItem())/2;
j = (j>i) ? 0 : (i-j);
KTabListBox::setTopItem( j );
}
void KFileDetailList::clearView()
{
KTabListBox::clear();
}
void KFileDetailList::reorderFiles(int inColumn)
{
QDir::SortSpec new_sort;
// QDir::SortSpec oldFlags = sorting() & (~QDir::SortByMask);
switch ( inColumn ) {
case 1:
new_sort = QDir::Name;
break;
case 2:
new_sort = QDir::Size;
break;
case 4:
new_sort = QDir::Time;
break;
default:
return;
}
setSorting(new_sort);
}
bool KFileDetailList::insertItem(const KFileInfo *i, int index)
{
const char *type;
if (i->isDir())
if (i->isReadable())
type = "folder";
else
type = "l_folder";
else
if (i->isReadable())
type = "file";
else
type = "l_file";
QString item;
item.sprintf("%s\t%s\t%u\t%s\t%s\t%s\t%s",
type,
i->fileName(),
i->size(),
i->access(),
i->date(),
i->owner(),
i->group());
KTabListBox::insertItem(item, index);
// TODO: find out, if a repaint is really necessary
return true;
}
void KFileDetailList::selected(int row)
{
select(row);
}
void KFileDetailList::highlighted(int row)
{
highlight(row);
}
#include "kfiledetaillist.moc"
--- NEW FILE: xview.cpp ---
#include <stdio.h>
#include <string.h>
#include <qiodevice.h>
#include <qcolor.h>
#include <qfile.h>
#include <qwmatrix.h>
#include "xview.h"
// #include "config-kfm.h"
void read_xv_file( QImageIO *_imageio )
{
int x=-1;
int y=-1;
int maxval=-1;
char str[ 1024 ];
// magic number must be "P7 332"
_imageio->ioDevice()->readLine( str, 1024 );
if (strncmp(str,"P7 332",6)) return;
// next line #XVVERSION
_imageio->ioDevice()->readLine( str, 1024 );
if (strncmp(str, "#XVVERSION", 10))
return;
// now it gets interesting, #BUILTIN means we are out.
// if IMGINFO comes, we are happy!
_imageio->ioDevice()->readLine( str, 1024 );
if (strncmp(str, "#IMGINFO:", 9))
return;
// after this an #END_OF_COMMENTS signals everything to be ok!
_imageio->ioDevice()->readLine( str, 1024 );
if (strncmp(str, "#END_OF", 7))
return;
// now a last line with width, height, maxval which is supposed to be 255
_imageio->ioDevice()->readLine( str, 1024 );
sscanf(str, "%d %d %d", &x, &y, &maxval);
if (maxval != 255) return;
// now follows a binary block of x*y bytes.
// debugT("Loading XView file %d %d %d\n",x,y,maxval);
char *block = new char[x*y];
if (_imageio->ioDevice()->readBlock(block, x*y) != x*y)
{
// debugT("kpixmap::readXVPICS could not read datablock of %d bytes\n", x*y);
return;
}
// debugT("Loaded data\n");
// Create the image
QImage image( x, y, 8, maxval + 1, QImage::BigEndian );
// debugT("Created image\n");
// how do the color handling? they are absolute 24bpp
// or at least can be calculated as such.
int r,g,b;
// char *p;
for ( int j = 0; j < 256; j++ )
{
r = ((int) ((j >> 5) & 0x07)) << 5;
g = ((int) ((j >> 2) & 0x07)) << 5;
b = ((int) ((j >> 0) & 0x03)) << 6;
image.setColor( j, qRgb( r, g, b ) );
}
// debugT("Created colors\n");
for ( int py = 0; py < y; py++ )
{
uchar *data = image.scanLine( py );
memcpy( data, block + py * x, x );
}
_imageio->setImage( image );
_imageio->setStatus( 0 );
// debugT("Loaded image\n");
delete [] block;
return;
}
void write_xv_file( const char *_filename, QPixmap &_pixmap )
{
// debugT("Saving to '%s'\n",_filename);
QFile f( _filename );
if ( !f.open( IO_WriteOnly ) )
return;
if ( _pixmap.isNull() )
{
f.close();
return;
}
int w, h;
if ( _pixmap.width() > _pixmap.height() )
{
if ( _pixmap.width() < 80 )
w = _pixmap.width();
else
w = 80;
h = (int)( (float)_pixmap.height() * ( (float)w / (float)_pixmap.width() ) );
}
else
{
if ( _pixmap.height() < 60 )
h = _pixmap.height();
else
h = 60;
w = (int)( (float)_pixmap.width() * ( (float)h / (float)_pixmap.height() ) );
}
QWMatrix matrix;
matrix.scale( (float)w/_pixmap.width(), (float)h/_pixmap.height() );
QPixmap tp = _pixmap.xForm( matrix );
char str[ 1024 ];
// magic number must be "P7 332"
f.writeBlock( "P7 332\n", 7 );
// next line #XVVERSION
f.writeBlock( "#XVVERSION:\n", 12 );
// now it gets interesting, #BUILTIN means we are out.
// if IMGINFO comes, we are happy!
f.writeBlock( "#IMGINFO:\n", 10 );
// after this an #END_OF_COMMENTS signals everything to be ok!
f.writeBlock( "#END_OF_COMMENTS:\n", 18 );
// now a last line with width, height, maxval which is supposed to be 255
sprintf( str, "%i %i 255\n", w, h );
f.writeBlock( str, strlen( str ) );
QImage image = tp.convertToImage();
if ( image.depth() == 1 )
{
// debugT("Converted image\n");
image = image.convertDepth( 8 );
}
uchar buffer[ 128 ];
// debugT("Image of depth %i\n",image.depth());
for ( int py = 0; py < h; py++ )
{
uchar *data = image.scanLine( py );
for ( int px = 0; px < w; px++ )
{
int r, g, b;
if ( image.depth() == 32 )
{
QRgb *data32 = (QRgb*) data;
r = qRed( *data32 ) >> 5;
g = qGreen( *data32 ) >> 5;
b = qBlue( *data32 ) >> 6;
data += sizeof( QRgb );
}
else
{
QRgb color = image.color( *data );
r = qRed( color ) >> 5;
g = qGreen( color ) >> 5;
b = qBlue( color ) >> 6;
data++;
}
buffer[ px ] = ( r << 5 ) | ( g << 2 ) | b;
}
f.writeBlock( (const char*)buffer, w );
}
f.close();
}
--- NEW FILE: kpreview.cpp ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
1998 Stephan Kulow <coolo at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qlayout.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qpixmap.h>
#include <qwmatrix.h>
#include <qstring.h>
#include "kpreview.h"
#include "xview.h"
#include "kdir.h"
#include <kapp.h>
static void cleanUpHandlers();
static void initHandlers();
static const int cMaxLines = 20;
static const int cMaxColumns = 79;
bool previewTextFile( const KFileInfo *, const QString inFilename,
QString &outText, QPixmap & )
{
bool loaded = false;
QFile lFile( inFilename );
if ( lFile.open(IO_ReadOnly) ) {
QTextStream t( &lFile );
QString line;
int n = 1;
while ( !t.eof() && (n<cMaxLines) ) {
line = t.readLine();
outText.append(line.mid(0,cMaxColumns));
if (line.mid(cMaxColumns,1) != "\n") outText.append("\n");
n++;
}
lFile.close();
loaded = true;
}
return loaded;
}
bool previewXVPicFile( const KFileInfo *i, const QString inFilename,
QString &, QPixmap &outPixmap )
{
bool loaded = false;
QString iconName(inFilename);
iconName.detach();
int index = iconName.find( i->fileName() );
iconName.insert(index,".xvpics/");
QFile miniPic( iconName );
if ( miniPic.exists() ) {
outPixmap = QPixmap( iconName );
QWMatrix m;
m.scale ( 2.0, 2.0 );
outPixmap = outPixmap.xForm( m ); // scale it to double size
loaded = true;
}
return loaded;
}
/*
*
*/
class KPreviewObject {
public:
KPreviewObject ( const char *inFormat,
PreviewHandler inPreviewModule );
QString format;
PreviewHandler preview;
};
KPreviewObject::KPreviewObject ( const char *inFormat,
PreviewHandler inPreviewModule )
: format(inFormat)
{
preview = inPreviewModule;
}
/*
*
*/
static QDict<KPreviewObject> *myTextPreviewerStorage = 0;
static QDict<KPreviewObject> *myPicturePreviewerStorage = 0;
static void cleanUpHandlers()
{
delete myTextPreviewerStorage;
delete myPicturePreviewerStorage;
myTextPreviewerStorage = 0L;
myPicturePreviewerStorage = 0L;
}
static void initHandlers()
{
if ( myTextPreviewerStorage )
return;
myTextPreviewerStorage = new QDict<KPreviewObject>;
myPicturePreviewerStorage = new QDict<KPreviewObject>;
myTextPreviewerStorage->setAutoDelete( true );
myPicturePreviewerStorage->setAutoDelete( true );
qAddPostRoutine(cleanUpHandlers);
KPreview::registerPreviewModule( "TEXT", previewTextFile, PreviewText);
KPreview::registerPreviewModule( "XVPIC", previewXVPicFile, PreviewPixmap);
}
//
// NOTE: was static, not sure if it has t be static or not ...
// commented it out for now
//
//KPreview *KPreview::_myKPreview = 0;
/*
KPreview *KPreview::getKPreview(KDir *inDir, QWidget *parent, const char *name)
{
if ( _myKPreview == 0 ) {
_myKPreview = new KPreview( inDir, parent, name );
}
return _myKPreview;
}
KPreview *KPreview::getKPreview()
{
if ( _myKPreview == 0 )
debug("oops");
return _myKPreview;
}
*/
KPreview::~KPreview()
{}
KPreview::KPreview( const KDir *inDir, QWidget *parent, const char *name)
: QWidget(parent,name), myDir(inDir), showedText(false)
{
QImageIO::defineIOHandler( "XV", "^P7 332", 0, read_xv_file, 0L );
if ( !myTextPreviewerStorage )
initHandlers();
QHBoxLayout *top = new QHBoxLayout( this, 0, 5, "_top" );
myBox = new QGroupBox(this,"_previewbox");
top->addSpacing(5);
top->addWidget( myBox, 10 );
QGridLayout *vertical = new QGridLayout( myBox,
10, // rows
8, // columns
10, // border
5, // autoborder
"_vertical" );
for (int i=0; i<4; i++)
vertical->setRowStretch ( i, 0 );
for (int i=4; i<10; i++)
vertical->setRowStretch ( i, 5 );
QLabel *myNameLabel = new QLabel( i18n("Name:"), myBox, "_namelabel");
myNameLabel->adjustSize();
myNameLabel->setMinimumHeight( myNameLabel->sizeHint().height() );
myNameLabel->setAlignment( AlignVCenter | AlignLeft );
vertical->addWidget( myNameLabel, 0, 0 );
myName = new QLabel( myBox, "_name" );
myName->setAlignment( AlignVCenter | AlignLeft );
vertical->addMultiCellWidget( myName, 0, 0, 1, 7 );
QLabel *mySizeLabel = new QLabel( i18n("Size:"), myBox, "_sizelabel");
mySizeLabel->setAlignment( AlignVCenter | AlignLeft );
mySizeLabel->adjustSize();
mySizeLabel->setMinimumHeight( mySizeLabel->sizeHint().height() );
vertical->addWidget( mySizeLabel, 1, 0 );
mySize = new QLabel( myBox, "_size" );
mySize->setAlignment( AlignVCenter | AlignLeft );
vertical->addMultiCellWidget( mySize, 1, 1, 1, 3 );
QLabel *myDateLabel = new QLabel( i18n("Date:"), myBox, "_datelabel");
myDateLabel->setAlignment( AlignVCenter | AlignLeft );
myDateLabel->adjustSize();
myDateLabel->setMinimumHeight( myDateLabel->sizeHint().height() );
vertical->addWidget( myDateLabel, 1, 4 );
myDate = new QLabel( myBox, "_date" );
myDate->setAlignment( AlignVCenter | AlignLeft );
vertical->addMultiCellWidget( myDate, 1, 1, 5, 7 );
QLabel *myOwnerLabel = new QLabel( i18n("Owner:"), myBox, "_ownerlabel");
myOwnerLabel->setAlignment( AlignVCenter | AlignLeft );
myOwnerLabel->adjustSize();
myOwnerLabel->setMinimumHeight( myOwnerLabel->sizeHint().height() );
vertical->addWidget( myOwnerLabel, 2, 0 );
myOwner = new QLabel( myBox, "_owner" );
myOwner->setAlignment( AlignVCenter | AlignLeft );
vertical->addMultiCellWidget( myOwner, 2, 2, 1, 3 );
QLabel *myGroupLabel = new QLabel( i18n("Group:"), myBox, "_grouplabel");
myGroupLabel->setAlignment( AlignVCenter | AlignLeft );
myGroupLabel->adjustSize();
myGroupLabel->setMinimumHeight( myGroupLabel->sizeHint().height() );
vertical->addWidget( myGroupLabel, 2, 4 );
myGroup = new QLabel( myBox, "_owner" );
myGroup->setAlignment( AlignVCenter | AlignLeft );
vertical->addMultiCellWidget( myGroup, 2, 2, 5, 7 );
QLabel *myTypeLabel = new QLabel( i18n("Type:"), myBox, "_typelabel");
myTypeLabel->setAlignment( AlignVCenter | AlignLeft );
myTypeLabel->adjustSize();
myTypeLabel->setMinimumHeight( myTypeLabel->sizeHint().height() );
vertical->addWidget( myTypeLabel, 3, 0 );
myType = new QLabel( myBox, "_name" );
myType->setAlignment( AlignVCenter | AlignLeft );
vertical->addMultiCellWidget( myType, 3, 3, 1, 7 );
myPreviewText = new QMultiLineEdit( myBox, "_previewpart" );
myPreviewText->setReadOnly(true);
vertical->addMultiCellWidget( myPreviewText, 4, 9, 0, 7 );
myPreviewPicture = new QLabel( myBox, "_previewpart" );
// myPreviewText->setBackgroundColor( white );
myPreviewPicture->setAlignment( AlignCenter );
myPreviewPicture->setFrameStyle( QFrame::Panel | QFrame::Sunken );
myPreviewPicture->setLineWidth( 2 );
myPreviewPicture->setMinimumHeight( 80 ); // this is the size of the mini pictures
vertical->addMultiCellWidget( myPreviewPicture, 4, 9, 0, 7 );
}
void KPreview::registerPreviewModule(const char * format, PreviewHandler readPreview,
PreviewType inType)
{
//debug("registering preview module (%s)",format);
if ( !myTextPreviewerStorage ) {
initHandlers();
}
KPreviewObject *po;
switch ( inType ) {
case (PreviewText) : po = new KPreviewObject( format, readPreview );
myTextPreviewerStorage->insert( format, po );
break;
case (PreviewPixmap) : po = new KPreviewObject( format, readPreview );
myPicturePreviewerStorage->insert( format, po );
break;
default : break;
}
}
void KPreview::previewFile(const KFileInfo *i)
{
if ( !myTextPreviewerStorage )
initHandlers();
// upper text part
//
bool isRegularFile = !i->isDir();
bool canOpen = i->isReadable() && isRegularFile;
QString lType = "";
if ( !i->isReadable() )
lType += i18n("locked");
myName->setText(i->fileName());
mySize->setNum((int)i->size());
myDate->setText(i->date());
myOwner->setText(i->owner());
myGroup->setText(i->group());
// preview part
//
QString fullPath;
QString lTextOutput;
QPixmap lPictOutput;
QDictIterator<KPreviewObject> lTextIterator( *myTextPreviewerStorage );
QDictIterator<KPreviewObject> lPictIterator( *myPicturePreviewerStorage );
bool found = false;
if ( canOpen ) {
fullPath = myDir->path();
fullPath += i->fileName();
lPictIterator.toFirst();
while ( lPictIterator.current() && (!found) ) {
if ( lPictIterator.current()->preview( i, fullPath, lTextOutput, lPictOutput ) ) {
myPreviewPicture->setPixmap( lPictOutput );
lType += i18n("picture");
found = true;
if ( showedText ) {
showedText = false;
// myPreviewPicture->raise();
myPreviewText->hide();
myPreviewPicture->show();
}
}
++lPictIterator;
}
lTextIterator.toFirst();
while ( !found && lTextIterator.current() ) {
if ( lTextIterator.current()->preview( i, fullPath, lTextOutput, lPictOutput ) ) {
myPreviewText->setText( lTextOutput );
lType += i18n("file");
found = true;
if ( !showedText ) {
showedText = true;
// myPreviewText->raise();
myPreviewPicture->hide();
myPreviewText->show();
}
}
++lTextIterator;
}
} else {
myPreviewText->clear();
myPreviewPicture->setText("");
}
if ( i->isDir() )
lType += i18n("folder");
myType->setText(lType);
}
#include "kpreview.moc"
--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# This file is part of the KDE libraries
# Copyright (C) 1997 Stephan Kulow (coolo at kde.org)
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this library; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
GLINC = @GLINC@
GLLIB = @GLLIB@
GMSGFMT = @GMSGFMT@
IDL = @IDL@
KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@
KDE_INCLUDES = @KDE_INCLUDES@
KDE_LDFLAGS = @KDE_LDFLAGS@
KDE_RPATH = @KDE_RPATH@
LD = @LD@
LIBCOMPAT = @LIBCOMPAT@
LIBCRYPT = @LIBCRYPT@
LIBDL = @LIBDL@
LIBJPEG = @LIBJPEG@
LIBMICO = @LIBMICO@
LIBOBJS = @LIBOBJS@
LIBPNG = @LIBPNG@
LIBPTHREAD = @LIBPTHREAD@
LIBPYTHON = @LIBPYTHON@
LIBQIMGIO = @LIBQIMGIO@
LIBSOCKET = @LIBSOCKET@
LIBTIFF = @LIBTIFF@
LIBTOOL = @LIBTOOL@
LIBUCB = @LIBUCB@
LIBZ = @LIBZ@
LIB_KAB = @LIB_KAB@
LIB_KDECORE = @LIB_KDECORE@
LIB_KDEUI = @LIB_KDEUI@
LIB_KDEUTIL = @LIB_KDEUTIL@
LIB_KFILE = @LIB_KFILE@
LIB_KFM = @LIB_KFM@
LIB_KHTML = @LIB_KHTML@
LIB_KHTMLW = @LIB_KHTMLW@
LIB_KIMGIO = @LIB_KIMGIO@
LIB_KIO = @LIB_KIO@
LIB_MEDIATOOL = @LIB_MEDIATOOL@
LIB_QT = @LIB_QT@
LIB_X11 = @LIB_X11@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
MICO_INCLUDES = @MICO_INCLUDES@
MICO_LDFLAGS = @MICO_LDFLAGS@
MOC = @MOC@
MSGFMT = @MSGFMT@
NM = @NM@
PACKAGE = @PACKAGE@
PAMINC = @PAMINC@
PAMLIBPATHS = @PAMLIBPATHS@
PAMLIBS = @PAMLIBS@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
QKEYCODE_H = @QKEYCODE_H@
QT_INCLUDES = @QT_INCLUDES@
QT_LDFLAGS = @QT_LDFLAGS@
RANLIB = @RANLIB@
TOPSUBDIRS = @TOPSUBDIRS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XPMINC = @XPMINC@
XPMLIB = @XPMLIB@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_INCLUDES = @X_INCLUDES@
X_LDFLAGS = @X_LDFLAGS@
all_includes = @all_includes@
all_libraries = @all_libraries@
install_root = @install_root@
kde_appsdir = @kde_appsdir@
kde_bindir = @kde_bindir@
kde_cgidir = @kde_cgidir@
kde_confdir = @kde_confdir@
kde_datadir = @kde_datadir@
kde_htmldir = @kde_htmldir@
kde_icondir = @kde_icondir@
kde_includes = @kde_includes@
kde_libraries = @kde_libraries@
kde_locale = @kde_locale@
kde_mimedir = @kde_mimedir@
kde_minidir = @kde_minidir@
kde_partsdir = @kde_partsdir@
kde_sounddir = @kde_sounddir@
kde_toolbardir = @kde_toolbardir@
kde_wallpaperdir = @kde_wallpaperdir@
qt_includes = @qt_includes@
qt_libraries = @qt_libraries@
topdir = @topdir@
x_includes = @x_includes@
x_libraries = @x_libraries@
INCLUDES = -I$(top_srcdir)/kdecore -I$(top_srcdir)/kdeui -I$(top_srcdir)/kfmlib $(QT_INCLUDES) $(X_INCLUDES)
lib_LTLIBRARIES = libkfile.la
libkfile_la_METASOURCES = kcombiview.moc kdir.moc kdirlistbox.moc kfilebookmark.moc kfiledetaillist.moc kfiledialog.moc kfiledialogconf.moc kfilefilter.moc kfileinfocontents.moc kfilepreview.moc kfilesimpleview.moc kpreview.moc
include_HEADERS = kfiledialog.h kfileinfo.h kfilebookmark.h kremotefile.h kdir.h kdirlistbox.h kfileinfocontents.h booktoken.h kfiledetaillist.h kcombiview.h kpreview.h kfilepreview.h xview.h kfilesimpleview.h kfilefilter.h
noinst_HEADERS = kfiledialogconf.h kfilefilter.h config-kfile.h
kfstest_SOURCES = kfstest.cpp
libkfile_la_SOURCES = kfilebookmark.cpp kfiledialogconf.cpp kcombiview.cpp kdir.cpp kfileinfo.cpp kremotefile.cpp kdirlistbox.cpp kfiledetaillist.cpp kfiledialog.cpp booktoken.cpp kfileinfocontents.cpp kfilesimpleview.cpp kpreview.cpp kfilepreview.cpp xview.cpp kfilefilter.cpp
toolbar_DATA = configure.xpm
EXTRA_DIST = configure.xpm KFile.kdoc NOTES configuration.txt
# I'm not sure, if they really should go there
toolbardir = $(kde_toolbardir)
LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS)
libkfile_la_LDFLAGS = -version-info 2:0 $(LDFLAGS)
libkfile_la_LIBADD = -lXext $(LIB_QT)
check_PROGRAMS = kfstest
kfstest_LDFLAGS = $(LDFLAGS) $(KDE_RPATH)
kfstest_LDADD = libkfile.la ../kfmlib/libkfm.la ../kdeui/libkdeui.la ../kdecore/libkdecore.la -lXext $(LIB_QT)
mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
libkfile_la_DEPENDENCIES =
libkfile_la_OBJECTS = kfilebookmark.lo kfiledialogconf.lo kcombiview.lo \
kdir.lo kfileinfo.lo kremotefile.lo kdirlistbox.lo kfiledetaillist.lo \
kfiledialog.lo booktoken.lo kfileinfocontents.lo kfilesimpleview.lo \
kpreview.lo kfilepreview.lo xview.lo kfilefilter.lo
kfstest_OBJECTS = kfstest.o
kfstest_DEPENDENCIES = libkfile.la ../kfmlib/libkfm.la \
../kdeui/libkdeui.la ../kdecore/libkdecore.la
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
DATA = $(toolbar_DATA)
HEADERS = $(include_HEADERS) $(noinst_HEADERS)
DIST_COMMON = ChangeLog Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
SOURCES = $(libkfile_la_SOURCES) $(kfstest_SOURCES)
OBJECTS = $(libkfile_la_OBJECTS) $(kfstest_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cpp .lo .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps kfile/Makefile
cd $(top_srcdir) && perl admin/automoc kfile/Makefile.in
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
done
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
libkfile.la: $(libkfile_la_OBJECTS) $(libkfile_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libkfile_la_LDFLAGS) $(libkfile_la_OBJECTS) $(libkfile_la_LIBADD) $(LIBS)
mostlyclean-checkPROGRAMS:
clean-checkPROGRAMS:
-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
distclean-checkPROGRAMS:
maintainer-clean-checkPROGRAMS:
kfstest: $(kfstest_OBJECTS) $(kfstest_DEPENDENCIES)
@rm -f kfstest
$(CXXLINK) $(kfstest_LDFLAGS) $(kfstest_OBJECTS) $(kfstest_LDADD) $(LIBS)
.cpp.o:
$(CXXCOMPILE) -c $<
.cpp.lo:
$(LTCXXCOMPILE) -c $<
install-toolbarDATA: $(toolbar_DATA)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(toolbardir)
@list='$(toolbar_DATA)'; for p in $$list; do \
if test -f $(srcdir)/$$p; then \
echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(toolbardir)/$$p"; \
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(toolbardir)/$$p; \
else if test -f $$p; then \
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(toolbardir)/$$p"; \
$(INSTALL_DATA) $$p $(DESTDIR)$(toolbardir)/$$p; \
fi; fi; \
done
uninstall-toolbarDATA:
@$(NORMAL_UNINSTALL)
list='$(toolbar_DATA)'; for p in $$list; do \
rm -f $(DESTDIR)$(toolbardir)/$$p; \
done
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
list='$(include_HEADERS)'; for p in $$list; do \
rm -f $(DESTDIR)$(includedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = kfile
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES
install-exec: install-exec-am
install-data-am: install-toolbarDATA install-includeHEADERS
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES uninstall-toolbarDATA \
uninstall-includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(toolbardir) \
$(DESTDIR)$(includedir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-checkPROGRAMS \
mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool \
clean-checkPROGRAMS clean-tags clean-generic \
mostlyclean-am
clean: clean-am
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-checkPROGRAMS \
distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-metasources distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-checkPROGRAMS maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
mostlyclean-libtool distclean-libtool clean-libtool \
maintainer-clean-libtool mostlyclean-checkPROGRAMS \
distclean-checkPROGRAMS clean-checkPROGRAMS \
maintainer-clean-checkPROGRAMS uninstall-toolbarDATA \
install-toolbarDATA uninstall-includeHEADERS install-includeHEADERS \
tags mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
distdir info-am info dvi-am dvi check check-am installcheck-am \
installcheck install-exec-am install-exec install-data-am install-data \
install-am install uninstall-am uninstall all-redirect all-am all \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
$(srcdir)/kcombiview.cpp: kcombiview.moc
kcombiview.moc: $(srcdir)/kcombiview.h
$(MOC) $(srcdir)/kcombiview.h -o kcombiview.moc
$(srcdir)/kdir.cpp: kdir.moc
kdir.moc: $(srcdir)/kdir.h
$(MOC) $(srcdir)/kdir.h -o kdir.moc
$(srcdir)/kdirlistbox.cpp: kdirlistbox.moc
kdirlistbox.moc: $(srcdir)/kdirlistbox.h
$(MOC) $(srcdir)/kdirlistbox.h -o kdirlistbox.moc
$(srcdir)/kfilebookmark.cpp: kfilebookmark.moc
kfilebookmark.moc: $(srcdir)/kfilebookmark.h
$(MOC) $(srcdir)/kfilebookmark.h -o kfilebookmark.moc
$(srcdir)/kfiledetaillist.cpp: kfiledetaillist.moc
kfiledetaillist.moc: $(srcdir)/kfiledetaillist.h
$(MOC) $(srcdir)/kfiledetaillist.h -o kfiledetaillist.moc
$(srcdir)/kfiledialog.cpp: kfiledialog.moc
kfiledialog.moc: $(srcdir)/kfiledialog.h
$(MOC) $(srcdir)/kfiledialog.h -o kfiledialog.moc
$(srcdir)/kfiledialogconf.cpp: kfiledialogconf.moc
kfiledialogconf.moc: $(srcdir)/kfiledialogconf.h
$(MOC) $(srcdir)/kfiledialogconf.h -o kfiledialogconf.moc
$(srcdir)/kfilefilter.cpp: kfilefilter.moc
kfilefilter.moc: $(srcdir)/kfilefilter.h
$(MOC) $(srcdir)/kfilefilter.h -o kfilefilter.moc
$(srcdir)/kfileinfocontents.cpp: kfileinfocontents.moc
kfileinfocontents.moc: $(srcdir)/kfileinfocontents.h
$(MOC) $(srcdir)/kfileinfocontents.h -o kfileinfocontents.moc
$(srcdir)/kfilepreview.cpp: kfilepreview.moc
kfilepreview.moc: $(srcdir)/kfilepreview.h
$(MOC) $(srcdir)/kfilepreview.h -o kfilepreview.moc
$(srcdir)/kfilesimpleview.cpp: kfilesimpleview.moc
kfilesimpleview.moc: $(srcdir)/kfilesimpleview.h
$(MOC) $(srcdir)/kfilesimpleview.h -o kfilesimpleview.moc
$(srcdir)/kpreview.cpp: kpreview.moc
kpreview.moc: $(srcdir)/kpreview.h
$(MOC) $(srcdir)/kpreview.h -o kpreview.moc
distclean-metasources:
-rm -f kcombiview.moc kdir.moc kdirlistbox.moc kfilebookmark.moc kfiledetaillist.moc kfiledialog.moc kfiledialogconf.moc kfilefilter.moc kfileinfocontents.moc kfilepreview.moc kfilesimpleview.moc kpreview.moc
# DO_NOT_USE_AUTOMOC
--- NEW FILE: Makefile.am ---
# This file is part of the KDE libraries
# Copyright (C) 1997 Stephan Kulow (coolo at kde.org)
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this library; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
INCLUDES= -I$(top_srcdir)/kdecore -I$(top_srcdir)/kdeui -I$(top_srcdir)/kfmlib $(QT_INCLUDES) $(X_INCLUDES)
lib_LTLIBRARIES = libkfile.la
libkfile_la_METASOURCES = kcombiview.moc kdir.moc kdirlistbox.moc \
kfilebookmark.moc kfiledetaillist.moc kfiledialog.moc \
kfiledialogconf.moc kfilefilter.moc kfileinfocontents.moc \
kfilepreview.moc kfilesimpleview.moc kpreview.moc
include_HEADERS = kfiledialog.h kfileinfo.h kfilebookmark.h \
kremotefile.h kdir.h kdirlistbox.h kfileinfocontents.h \
booktoken.h kfiledetaillist.h kcombiview.h kpreview.h kfilepreview.h \
xview.h kfilesimpleview.h kfilefilter.h
noinst_HEADERS = kfiledialogconf.h kfilefilter.h config-kfile.h
kfstest_SOURCES = kfstest.cpp
libkfile_la_SOURCES = kfilebookmark.cpp kfiledialogconf.cpp kcombiview.cpp \
kdir.cpp kfileinfo.cpp kremotefile.cpp kdirlistbox.cpp \
kfiledetaillist.cpp kfiledialog.cpp booktoken.cpp \
kfileinfocontents.cpp kfilesimpleview.cpp kpreview.cpp \
kfilepreview.cpp xview.cpp kfilefilter.cpp
toolbar_DATA = configure.xpm
EXTRA_DIST = configure.xpm KFile.kdoc NOTES configuration.txt
# I'm not sure, if they really should go there
toolbardir = $(kde_toolbardir)
LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS)
libkfile_la_LDFLAGS = -version-info 2:0 $(LDFLAGS)
libkfile_la_LIBADD = -lXext $(LIB_QT)
check_PROGRAMS = kfstest
kfstest_LDFLAGS = $(LDFLAGS) $(KDE_RPATH)
kfstest_LDADD = libkfile.la ../kfmlib/libkfm.la ../kdeui/libkdeui.la ../kdecore/libkdecore.la -lXext $(LIB_QT)
--- NEW FILE: kfileinfo.h ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KFILEINFO_H
#define KFILEINFO_H
#include <qstring.h>
#include <qdatetime.h>
#include <qlist.h>
#include <time.h>
class QFileInfo;
class KDirEntry;
/**
* Provides information about a file that has been examined
* with KDir.
*
* @author rich at kde.org
* @version $Id: kfileinfo.h,v 1.1 2006-10-03 11:26:35 dslinux_amadeus Exp $
*/
class KFileInfo {
public:
/**
* Construct a KFileInfo object from a KDirEntry.
*/
KFileInfo(const KDirEntry &);
/**
* Constructs a KFileInfo object from a QFileInfo.
* This is only useful for local files
*/
KFileInfo(const QFileInfo &);
/**
* Constructs a "little" KFileInfo (just for local files)
**/
KFileInfo(const char *dir, const char *name = "");
/**
* Destroy the KFileInfo object.
*/
~KFileInfo(){};
/**
* Copy a KFileInfo.
*/
KFileInfo &operator=(const KFileInfo &);
/**
* Returns true if this file is a directory.
*/
bool isDir() const { return myIsDir; }
bool isFile() const { return myIsFile; }
bool isSymLink() const { return myIsSymLink; }
QString absURL() const { return myBaseURL; }
QString baseURL();
QString extension();
/**
* Returns the name of the file
*
* Note: If this object does not refer to a real file
* (broken symlink), it will return 0
**/
const char *fileName() const { return myName; }
QString filePath();
/**
* Returns the group of the file.
*/
const char *date() const { return myDate; }
/**
* Returns the access permissions for the file as a string.
*/
const char *access() const { return myAccess; }
/**
* Returns the owner of the file.
*/
const char *owner() const { return myOwner; }
/**
* Returns the group of the file.
*/
const char *group() const { return myGroup; }
/**
* Returns the size of the file.
*/
uint size() const { return mySize; }
/**
* Returns true if the specified permission flag is set.
*/
bool permission(uint permissionSpec);
// overriding QFileInfo's function
bool isReadable() const ;
static QString dateTime(time_t secsSince1Jan1970UTC);
protected:
void parsePermissions(const char *perms);
void parsePermissions(uint perm);
private:
QString myName;
QString myBaseURL;
QString myAccess;
QString myDate;
QString myOwner;
QString myGroup;
bool myIsDir;
bool myIsFile;
bool myIsSymLink;
uint myPermissions;
int mySize;
bool myIsReadable;
};
typedef QList<KFileInfo> KFileInfoList;
typedef QListIterator<KFileInfo> KFileInfoListIterator;
inline bool KFileInfo::permission(uint permissionSpec)
{
return ((myPermissions & permissionSpec) != 0);
}
#endif // KFILEINFO_H
--- NEW FILE: kfilebookmark.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1996, 1997, 1998 Martin R. Jones <mjones at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
//
// KDE HTML Bookmarks
//
// (c) Martin R. Jones 1996
//
#include <qfile.h>
#include "kfilebookmark.h"
#include "kfilebookmark.h"
#include <klocale.h>
#include <kapp.h>
//-----------------------------------------------------------------------------
KFileBookmark::KFileBookmark()
{
children.setAutoDelete( true );
type = URL;
}
KFileBookmark::KFileBookmark( const char *_text, const char *_url )
{
children.setAutoDelete( true );
text = _text;
url = _url;
type = URL;
}
void KFileBookmark::clear()
{
KFileBookmark *bm;
for ( bm = getChildren().first(); bm != NULL; bm = getChildren().next() )
{
bm->clear();
}
children.clear();
}
//-----------------------------------------------------------------------------
KFileBookmarkManager::KFileBookmarkManager()
{
}
void KFileBookmarkManager::read( const char *filename )
{
QFile file( filename );
// rich
myFilename= filename;
if ( !file.open( IO_ReadOnly ) )
return;
root.clear();
QString text;
char buffer[256];
do
{
file.readLine( buffer, 256 );
text += buffer;
}
while ( !file.atEnd() );
BookmarkTokenizer *ht = new BookmarkTokenizer();
ht->begin();
ht->write( text );
ht->end();
const char *str;
while ( ht->hasMoreTokens() )
{
str = ht->nextToken();
// Every tag starts with an escape character
if ( str[0] == TAG_ESCAPE )
{
str++;
if ( strncasecmp( str, "<title>", 7 ) == 0 )
{
QString t = "";
bool bend = false;
do
{
if ( !ht->hasMoreTokens() )
bend = true;
else
{
str = ht->nextToken();
if ( str[0] == TAG_ESCAPE &&
strncasecmp( str + 1, "</title>", 8 ) == 0 )
bend = true;
else
t += str;
}
}
while ( !bend );
title = t;
}
else if ( strncasecmp( str, "<DL>", 4 ) == 0 )
{
parse( ht, &root, "" );
}
}
}
delete ht;
emit changed();
}
// parser based on HTML widget parser
//
const char *KFileBookmarkManager::parse( BookmarkTokenizer *ht, KFileBookmark *parent,
const char *_end )
{
KFileBookmark *bm = parent;
QString text;
const char *str;
parent->setType( KFileBookmark::Folder );
while ( ht->hasMoreTokens() )
{
str = ht->nextToken();
if (str[0] == TAG_ESCAPE )
{
str++;
if ( _end[0] != 0 && strcasecmp( str, _end ) == 0 )
{
return str;
}
else if ( strncasecmp( str, "<dl>", 4 ) == 0 )
{
parse( ht, bm, "</dl>" );
}
else if ( strncasecmp( str, "<dt>", 4 ) == 0 )
{
bm = new KFileBookmark;
parent->getChildren().append( bm );
}
else if ( strncasecmp( str, "<a ", 3 ) == 0 )
{
const char *p = str + 3;
while ( *p != '>' )
{
if ( strncasecmp( p, "href=", 5 ) == 0 )
{
p += 5;
text = "";
bool quoted = false;
while ( ( *p != ' ' && *p != '>' ) || quoted )
{
if ( *p == '\"' )
quoted = !quoted;
else
text += *p;
p++;
}
bm->setURL( text );
if ( *p == ' ' )
p++;
}
else
{
char *p2 = strchr( p, ' ' );
if ( p2 == 0L )
p2 = strchr( p, '>');
else
p2++;
p = p2;
}
}
text = "";
}
else if ( strncasecmp( str, "<H3", 3 ) == 0 )
{
text = "";
}
else if ( strncasecmp( str, "</H3>", 5 ) == 0 ||
strncasecmp( str, "</a>", 4 ) == 0 )
{
bm->setText( text );
}
}
else if ( str[0] )
{
text += str;
}
}
return NULL;
}
// write bookmarks file
//
void KFileBookmarkManager::write( const char *filename )
{
QFile file( filename );
if ( !file.open( IO_WriteOnly ) )
return;
// rich
myFilename= filename;
QTextStream stream( &file );
stream << "<!DOCTYPE KDEHELP-Bookmark-file>" << endl;
stream << klocale->translate("<!-- Do not edit this file -->") << endl;
stream << "<TITLE>" << title << "</TITLE>" << endl;
stream << "<H1>" << title << "</H1>" << endl;
stream << "<DL><p>" << endl;
writeFolder( stream, &root );
stream << "</DL><P>" << endl;
}
// write the contents of a folder (recursive)
//
void KFileBookmarkManager::writeFolder( QTextStream &stream, KFileBookmark *parent )
{
KFileBookmark *bm;
for ( bm = parent->getChildren().first(); bm != NULL;
bm = parent->getChildren().next() )
{
if ( bm->getType() == KFileBookmark::URL )
{
stream << "<DT><A HREF=\"" << bm->getURL() << "\">"
<< bm->getText() << "</A>" << endl;
}
else
{
stream << "<DT><H3>" << bm->getText() << "</H3>" << endl;
stream << "<DL><P>" << endl;
writeFolder( stream, bm );
stream << "</DL><P>" << endl;
}
}
}
KFileBookmark *KFileBookmarkManager::getBookmark( int id )
{
int currId = 0;
return findBookmark( &root, id, currId );
}
KFileBookmark *KFileBookmarkManager::findBookmark( KFileBookmark *parent, int id,
int &currId )
{
KFileBookmark *bm;
for ( bm = parent->getChildren().first(); bm != NULL;
bm = parent->getChildren().next() )
{
if ( bm->getType() == KFileBookmark::URL )
{
if ( currId == id )
return bm;
currId++;
}
else
{
KFileBookmark *retbm;
if ( ( retbm = findBookmark( bm, id, currId ) ) != NULL )
return retbm;
}
}
return NULL;
}
void KFileBookmarkManager::add( const char *_text, const char *_url )
{
root.getChildren().append( new KFileBookmark( _text, _url ) );
emit changed();
}
// rich
bool KFileBookmarkManager::remove(int i)
{
bool result= false;
if (i >= 0) {
root.getChildren().remove(i);
emit changed();
result= true;
}
return result;
}
// rich
void KFileBookmarkManager::rename(int i, const char *s)
{
KFileBookmark *b;
if (i > 0) {
b= root.getChildren().at(i);
b->setText(s);
emit changed();
}
}
// rich
bool KFileBookmarkManager::moveUp(int i)
{
KFileBookmark *b;
bool result= false;
if (i > 0) {
b= root.getChildren().take(i);
root.getChildren().insert(i-1, b);
emit changed();
result= true;
}
return result;
}
// rich
bool KFileBookmarkManager::moveDown(int i)
{
KFileBookmark *b;
uint j= i;
bool result= false;
if (j < (root.getChildren().count() -1)) {
b= root.getChildren().take(i);
root.getChildren().insert(i+1, b);
emit changed();
result= true;
}
return result;
}
// rich
void KFileBookmarkManager::reread()
{
read(myFilename);
}
// rich
void KFileBookmarkManager::write()
{
write(myFilename);
}
#include "kfilebookmark.moc"
--- NEW FILE: booktoken.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones at kde.org)
(C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
//
// This is a modified HTMLTokenizer from khtmlw.
//
#ifndef BOOKTOKEN_H
#define BOOKTOKEN_H
#include <qlist.h>
#include <qstrlist.h>
#include <qarray.h>
// Every tag as deliverd by HTMLTokenizer starts with TAG_ESCAPE. This way
// you can devide between tags and words.
#define TAG_ESCAPE 13
// The count of spaces used for each tab.
#define TAB_SIZE 8
//-----------------------------------------------------------------------------
class BMToken
{
public:
BMToken( const char *t, int len )
{
tok = new char [ len + 1 ];
memcpy( tok, t, len+1 );
nextToken = 0;
}
~BMToken()
{
delete [] tok;
}
char *token()
{ return tok; }
BMToken *next()
{ return nextToken; }
void setNext( BMToken *n )
{ nextToken = n; }
private:
char *tok;
BMToken *nextToken;
};
//-----------------------------------------------------------------------------
class BookmarkTokenizer
{
public:
BookmarkTokenizer();
~BookmarkTokenizer();
void begin();
void write( const char * );
void end();
char* nextToken();
bool hasMoreTokens();
void first()
{ curr = head; }
protected:
void reset();
void appendToken( const char *t, int len )
{
if ( len < 1 )
return;
BMToken *tok = new BMToken( t, len );
if ( head )
{
tail->setNext( tok );
tail = tok;
}
else
{
head = tail = tok;
}
if ( !curr )
curr = tok;
}
protected:
char *buffer;
char *dest;
BMToken *head;
BMToken *tail;
BMToken *curr;
// the size of buffer
int size;
// are we in a html tag
bool tag;
// are we in quotes within a html tag
bool tquote;
// To avoid multiple spaces
bool space;
// Discard line breaks immediately after tags
bool discardCR;
// Area we in a <!-- comment --> block
bool comment;
};
//-----------------------------------------------------------------------------
#endif
--- NEW FILE: kdirlistbox.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KDE_KDIRLISTBOX_H
#define KDE_KDIRLISTBOX_H
#include <qlistbox.h>
#include "kfileinfocontents.h"
class KDirListBox : protected QListBox, public KFileInfoContents
{
Q_OBJECT
public:
KDirListBox( bool acceptFiles, bool s, QDir::SortSpec sorting,
QWidget * parent=0, const char * name=0 );
KDirListBox( bool s, QDir::SortSpec sorting,
QWidget * parent=0, const char * name=0 );
~KDirListBox() {};
virtual QWidget *widget() { return this; }
virtual void setAutoUpdate(bool);
virtual bool acceptsFiles() { return _acceptFiles; }
virtual bool acceptsDirs() { return true; }
protected:
virtual void highlightItem(unsigned int item);
virtual void keyPressEvent( QKeyEvent * );
virtual void mousePressEvent ( QMouseEvent * );
virtual void mouseDoubleClickEvent ( QMouseEvent * );
virtual void clearView();
virtual bool insertItem(const KFileInfo *i, int index);
bool _acceptFiles;
};
#endif
--- NEW FILE: kfstest.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <unistd.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <qdir.h>
#include <qfiledlg.h>
#include "kfiledialog.h"
#include <qmsgbox.h>
#include <kconfig.h>
#include <kapp.h>
#include <kurl.h>
/*
* just an example of how to make a new preview module
*
bool previewTestFile( const KFileInfo *i, const QString inFilename,
QString &, QPixmap &outPixmap )
{
bool loaded = false;
QString iconName(inFilename);
iconName.detach();
int index = iconName.find( i->fileName() );
iconName.insert(index,".xvpics/");
QFile miniPic( iconName );
if ( miniPic.exists() ) {
outPixmap = QPixmap( iconName );
loaded = true;
}
return loaded;
}
*/
int main(int argc, char **argv)
{
KApplication a(argc, argv, "kfstest");
QString name1;
if (argc != 2) {
warning("usage: %s {dirs, filter, preselect, normal, preview}", argv[0]);
exit(0);
}
enum { Dirs, Filter, Preselect, Normal, Preview } mode;
if (QString(argv[1]) == "dirs")
mode = Dirs;
else if (QString(argv[1]) == "filter")
mode = Filter;
else if (QString(argv[1]) == "preselect")
mode = Preselect;
else if (QString(argv[1]) == "preview")
mode = Preview;
else mode = Normal;
switch (mode) {
case Dirs:
name1 = KFileDialog::getDirectory(0);
break;
case Filter:
name1 = KFileDialog::getOpenFileURL(0,
"*.cpp|C++-Files (*.cpp)\n"
"*.h|Header-Files (*.h)\n"
"*.o *.a *.lo *.la|Object-Files");
break;
case Preselect:
name1 = KFileDialog::getOpenFileURL("/etc/inetd/inetd.conf");
break;
case Normal: {
KFileDialog dlg(0, 0, 0, 0, true);
dlg.setSelection("../hello");
dlg.setFilter("*|All files");
dlg.exec();
name1 = dlg.selectedFile();
}
break;
case Preview:
// this is how you activate the new preview module
//
// KFilePreviewDialog::registerPreviewModule( "TEST", previewTestFile, PreviewPixmap );
KFilePreviewDialog::getOpenFileURL(0,"*.cpp|C++-Files (*.cpp)\n""*|All Files");
break;
}
if (!(name1.isNull()))
QMessageBox::message("Your Choice",
"You selected the file "+ name1);
return 0;
}
--- NEW FILE: kfilepreview.h ---
/* This file is part of the KDE libraries
Copyright (C) 1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _KFILEPREVIEW_H
#define _KFILEPREVIEW_H
#include "kpreview.h"
#include "kfileinfocontents.h"
#include "knewpanner.h"
#include "kdir.h"
class KFilePreview: protected KNewPanner, public KFileInfoContents
{
Q_OBJECT
public:
KFilePreview( KDir *inDir, bool s, QDir::SortSpec sorting,
QWidget * parent=0, const char * name=0 );
~KFilePreview();
virtual QWidget *widget() { return this; }
virtual void setAutoUpdate(bool);
virtual void setCurrentItem(const char *filename, const KFileInfo *i);
virtual void repaint(bool f = true);
virtual QString findCompletion( const char *base, bool activateFound );
virtual bool acceptsFiles() { return true; }
virtual bool acceptsDirs() { return true; }
void registerPreviewModule( const char * format, PreviewHandler readPreview,
PreviewType inType);
protected slots:
void dirActivated(KFileInfo *);
void fileActivated(KFileInfo *);
void fileHighlighted(KFileInfo *);
protected:
virtual KFileInfoContents *getDirList() { return 0; }
virtual KFileInfoContents *getFileList() { return 0; }
virtual void highlightItem(unsigned int item);
virtual void clearView();
virtual bool insertItem(const KFileInfo *i, int index);
private:
KFileInfoContents *fileList;
KPreview *myPreview;
};
#endif
--- NEW FILE: kpreview.h ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Daniel Grana <grana at ie.iwi.unibe.ch>
1998 Stephan Kulow <coolo at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __KPREVIEW_H__
#define __KPREVIEW_H__
#include <qpixmap.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qmultilinedit.h>
#include <qdict.h>
#include "kfileinfo.h"
#include "kdir.h"
#include "kfiledialog.h"
class KPreviewObject;
/**
* The KPreview widget displays previews of a file. Two possible previews
* are possible, either some text or a pixmap.
*
* The widget has been designed to allow the uses to easily add new
* custom preview modules. For that use the static method
* KPreview::registerPreviewModule.
*
* @short A file preview widget
*
* @author Daniel Grana grana at ie.iwi.unibe.ch
*
* @version $Id: kpreview.h,v 1.1 2006-10-03 11:26:35 dslinux_amadeus Exp $
*/
class KPreview : public QWidget {
Q_OBJECT
public:
KPreview( const KDir *inDir= 0, QWidget *parent= 0, const char *name= 0);
//static KPreview *getKPreview(KDir *inDir, QWidget *parent= 0, const char *name= 0);
//static KPreview *getKPreview();
virtual ~KPreview();
public:
static void registerPreviewModule( const char * format, PreviewHandler readPreview,
PreviewType inType);
public slots:
virtual void previewFile(const KFileInfo *i);
private:
QLabel *myName;
QLabel *mySize;
QLabel *myDate;
QLabel *myOwner;
QLabel *myGroup;
QLabel *myType;
QLabel *myPreviewPicture;
QMultiLineEdit *myPreviewText;
QGroupBox *myBox;
const KDir *myDir;
bool showedText;
KPreview *_myKPreview;
};
#endif
--- NEW FILE: kfilepreview.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// $Id: kfilepreview.cpp,v 1.1 2006-10-03 11:26:35 dslinux_amadeus Exp $
#include "kfilepreview.h"
#include "kdirlistbox.h"
#include "kfiledetaillist.h"
#include "kfileinfo.h"
#include "kfilesimpleview.h"
#include "kpreview.h"
#include "kfilepreview.h"
#include "config-kfile.h"
#include <qpainter.h>
#include <qlistbox.h>
#include <qdir.h>
#include <kapp.h>
#ifdef Unsorted // the "I hate X.h" modus
#undef Unsorted
#endif
KFilePreview::KFilePreview(
KDir *inDir, bool s, QDir::SortSpec sorting,
QWidget * parent, const char * name )
: KNewPanner(parent, name, KNewPanner::Vertical) ,
KFileInfoContents(s,sorting)
{
fileList = new KDirListBox(true, s, sorting, this, "_dirs");
myPreview = new KPreview( inDir, this, "_preview" );
activate(fileList->widget(), myPreview);
int pan = kapp->getConfig()->readNumEntry("PannerPosition",
DefaultPannerPosition);
setSeparatorPos(pan);
fileList->connectDirSelected(this, SLOT(dirActivated(KFileInfo *)));
fileList->connectFileSelected(this, SLOT(fileActivated(KFileInfo *)));
fileList->connectFileHighlighted(this, SLOT(fileHighlighted(KFileInfo *)));
}
KFilePreview::~KFilePreview()
{
delete fileList;
delete myPreview;
}
void KFilePreview::registerPreviewModule( const char * format, PreviewHandler readPreview,
PreviewType inType)
{
myPreview->registerPreviewModule( format, readPreview, inType );
}
void KFilePreview::setAutoUpdate(bool f)
{
fileList->setAutoUpdate(f);
}
bool KFilePreview::insertItem(const KFileInfo *i, int)
{
fileList->addItem(i);
return true;
}
void KFilePreview::clearView()
{
fileList->clear();
}
void KFilePreview::highlightItem(unsigned int)
{
warning("KCombiView::highlightItem: does nothing");
}
void KFilePreview::setCurrentItem(const char *item, const KFileInfo *i)
{
if (item != 0) {
i = 0;
debugC("setCurrentItem %s",item);
for (uint j = 0; j < count(); j++)
if (at(j)->fileName() == item)
i = at(j);
}
if (!i) {
warning("setCurrentItem: no match found.");
return;
}
fileList->setCurrentItem(0, i);
}
void KFilePreview::repaint(bool f)
{
fileList->repaint(f);
}
QString KFilePreview::findCompletion( const char *base, bool )
{
// try files and directories
QString found = fileList->findCompletion(base);
return found;
}
void KFilePreview::dirActivated(KFileInfo *i)
{
select(i);
}
void KFilePreview::fileActivated(KFileInfo *i)
{
select(i);
}
void KFilePreview::fileHighlighted(KFileInfo *i)
{
highlight(i);
myPreview->previewFile(i);
}
#include "kfilepreview.moc"
--- NEW FILE: kfiledetaillist.h ---
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich at kde.org>
1998 Stephan Kulow <coolo at kde.org>
1998 Daniel Grana <grana at ie.iwi.unibe.ch>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KFILEDETAILLIST_H
#define KFILEDETAILLIST_H
#include <ktablistbox.h>
#include "kfileinfocontents.h"
#include "kfileinfo.h"
#include "kdir.h"
class KFileDetailList : protected KTabListBox, public KFileInfoContents {
Q_OBJECT
public:
/**
* Create a file info list widget.
*/
KFileDetailList(bool s, QDir::SortSpec sorting, QWidget *parent= 0, const char *name= 0);
virtual ~KFileDetailList();
virtual QWidget *widget() { return this; }
virtual void setAutoUpdate(bool);
virtual void clearView();
virtual void repaint(bool f = true);
virtual bool acceptsFiles() { return true; }
virtual bool acceptsDirs() { return true; }
protected:
virtual void highlightItem(unsigned int item);
virtual bool insertItem(const KFileInfo *i, int index);
virtual void keyPressEvent( QKeyEvent *e);
virtual void focusInEvent ( QFocusEvent *e );
protected slots:
void reorderFiles(int inColumn);
void selected(int);
void highlighted(int);
};
#endif // KFILEDETAILLIST_H
More information about the dslinux-commit
mailing list