org.kde.koala

Class KFileItem

public class KFileItem extends Object implements QtSupport

A KFileItem is a generic class to handle a file, local or remote. In particular, it makes it easier to handle the result of KIO.listDir (UDSEntry isn't very friendly to use). It includes many file attributes such as mimetype, icon, text, mode, link...

UNKNOWN: A KFileItem is a generic class to handle a file, local or remote.

Field Summary
static intAccess
static intCreation
static intModification
static intNumFlags
static intUnknown
Constructor Summary
protected KFileItem(Class dummy)
KFileItem(long _mode, long _permissions, KURL _url, boolean _determineMimeTypeOnDemand)
Creates an item representing a file, from all the necessary info for it.
KFileItem(long _mode, long _permissions, KURL _url)
KFileItem(KURL url, String mimeType, long mode)
Creates an item representing a file, for which the mimetype is already known.
KFileItem(KFileItem item)
Copy constructor.
Method Summary
booleanacceptsDrops()
Returns true if files can be dropped over this item.
voidassign(KFileItem item)
Somewhat like an assignment operator, but more explicit.
booleancmp(KFileItem item)
Somewhat like a comparison operator, but more explicit.
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
protected voidfinalize()
Deletes the wrapped C++ instance
StringgetStatusBarInfo()
Returns the string to be displayed in the statusbar, e.g. when the mouse is over this item
StringgetToolTipText(int maxcount)
Returns the string to be displayed in the tool tip when the mouse is over this item.
StringgetToolTipText()
Stringgroup()
Returns the group of the file.
booleanhasExtendedACL()
Tells if the file has extended access level information ( Posix ACL )
StringiconName()
Returns the full path name to the icon that represents this mime type.
protected voidinit(boolean _determineMimeTypeOnDemand)
Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called again later
booleanisDir()
Returns true if this item represents a directory.
booleanisDisposed()
Has the wrapped C++ instance been deleted?
booleanisFile()
Returns true if this item represents a file (and not a a directory)
booleanisHidden()
Checks whether the file is hidden.
booleanisLink()
Returns true if this item represents a link in the UNIX sense of a link.
booleanisLocalFile()
Returns true if the file is a local file.
booleanisMarked()
Used when updating a directory. marked == seen when refreshing.
booleanisMimeTypeKnown()
Returns the currently known mimetype of the file item.
booleanisReadable()
Checks whether the file or directory is readable.
booleanisWritable()
Checks whether the file or directory is writable.
StringlinkDest()
Returns the link destination if isLink() == true.
StringlocalPath()
Returns the local path if isLocalFile() == true or the KIO item has a UDS_LOCAL_PATH atom.
voidmark()
Marks the item.
KFileMetaInfometaInfo(boolean autoget, int what)
Returns the metainfo of this item.
KFileMetaInfometaInfo(boolean autoget)
KFileMetaInfometaInfo()
StringmimeComment()
Returns the descriptive comment for this mime type, or the mime type itself if none is present.
Stringmimetype()
Returns the mimetype of the file item.
longmode()
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
KURLmostLocalURL(boolean local)
Tries to give a local URL for this file item if possible.
Stringname(boolean lowerCase)
Return the name of the file item (without a path).
Stringname()
intoverlays()
Returns the overlays (bitfield of KIcon.Overlay flags) that are used for this item's pixmap.
protected StringparsePermissions(long perm)
Parses the given permission set and provides it for access()
longpermissions()
Returns the permissions of the file (stat.st_mode containing only permissions).
StringpermissionsString()
Returns the access permissions for the file as a string.
QPixmappixmap(int _size, int _state)
Returns a pixmap representing the file.
QPixmappixmap(int _size)
protected voidreadUDSEntry(boolean _urlIsDirectory)
Extracts the data from the UDSEntry member and updates the KFileItem accordingly.
voidrefresh()
Throw away and re-read (for local files) all information about the file.
voidrefreshMimeType()
Re-reads mimetype information.
voidrun()
Let's "KRun" this file !
voidsetFileMode(long m)
Sets the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
voidsetMetaInfo(KFileMetaInfo info)
Sets the metainfo of this item to info.
voidsetMimeType(String mimetype)
Sets new mimetype for item
voidsetName(String name)
Sets the item's name (i.e. the filename).
voidsetURL(KURL url)
Sets the item's URL.
longsize()
Returns the size of the file, if known.
longsize(boolean hasSize)
Returns the size of the file, if known, and sets hasSize to false if not known
Stringtext()
Returns the text of the file item.
inttime(int which)
Requests the modification, access or creation time, depending on which.
inttime(int which, boolean hasTime)
Requests the modification, access or creation time, depending on which.
StringtimeString(int which)
Requests the modification, access or creation time as a string, depending on which.
StringtimeString()
voidunmark()
Unmarks the item.
KURLurl()
Returns the url of the file.
Stringuser()
Returns the owner of the file.

Field Detail

Access

public static final int Access

Creation

public static final int Creation

Modification

public static final int Modification

NumFlags

public static final int NumFlags

Unknown

public static final int Unknown

Constructor Detail

KFileItem

protected KFileItem(Class dummy)

KFileItem

public KFileItem(long _mode, long _permissions, KURL _url, boolean _determineMimeTypeOnDemand)
Creates an item representing a file, from all the necessary info for it.

Parameters: _mode the file mode (according to stat() (e.g. S_IFDIR...) Set to KFileItem.Unknown if unknown. For local files, KFileItem will use stat(). _permissions the access permissions If you set both the mode and the permissions, you save a .stat() for local files. Set to KFileItem.Unknown if you don't know the mode or the permission. _url the file url _determineMimeTypeOnDemand specify if the mimetype of the given URL should be determined immediately or on demand

UNKNOWN: Creates an item representing a file, from all the necessary info for it.

KFileItem

public KFileItem(long _mode, long _permissions, KURL _url)

KFileItem

public KFileItem(KURL url, String mimeType, long mode)
Creates an item representing a file, for which the mimetype is already known.

Parameters: url the file url mimeType the name of the file's mimetype mode the mode (S_IFDIR...)

UNKNOWN: Creates an item representing a file, for which the mimetype is already known.

KFileItem

public KFileItem(KFileItem item)
Copy constructor. Note that extra-data set via setExtraData() is not deeply copied -- just the pointers are copied.

UNKNOWN: Copy constructor.

Method Detail

acceptsDrops

public boolean acceptsDrops()
Returns true if files can be dropped over this item. Contrary to popular belief, not only dirs will return true :) Executables, .desktop files, will do so as well.

Returns: true if you can drop files over the item

UNKNOWN: Returns true if files can be dropped over this item.

assign

public void assign(KFileItem item)
Somewhat like an assignment operator, but more explicit. Note: extra-data set with setExtraData() is not copied, so be careful what you do!

Parameters: item the item to copy

UNKNOWN: Somewhat like an assignment operator, but more explicit.

cmp

public boolean cmp(KFileItem item)
Somewhat like a comparison operator, but more explicit.

Parameters: item the item to compare

Returns: true if all values are equal

UNKNOWN: Somewhat like a comparison operator, but more explicit.

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()

finalize

protected void finalize()
Deletes the wrapped C++ instance

getStatusBarInfo

public String getStatusBarInfo()
Returns the string to be displayed in the statusbar, e.g. when the mouse is over this item

Returns: the status bar information

UNKNOWN: Returns the string to be displayed in the statusbar, e.

getToolTipText

public String getToolTipText(int maxcount)
Returns the string to be displayed in the tool tip when the mouse is over this item. This may load a plugin to determine additional information specific to the mimetype of the file.

Parameters: maxcount the maximum number of entries shown

Returns: the tool tip string

UNKNOWN: Returns the string to be displayed in the tool tip when the mouse is over this item.

getToolTipText

public String getToolTipText()

group

public String group()
Returns the group of the file.

Returns: the file's group

UNKNOWN: Returns the group of the file.

hasExtendedACL

public boolean hasExtendedACL()
Tells if the file has extended access level information ( Posix ACL )

Returns: true if the file has extend ACL information or false if it hasn't

UNKNOWN: Tells if the file has extended access level information ( Posix ACL )

iconName

public String iconName()
Returns the full path name to the icon that represents this mime type.

Returns: iconName the name of the file's icon

UNKNOWN: Returns the full path name to the icon that represents this mime type.

init

protected void init(boolean _determineMimeTypeOnDemand)
Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called again later

UNKNOWN: Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called again later

isDir

public boolean isDir()
Returns true if this item represents a directory.

Returns: true if the item is a directory

UNKNOWN: Returns true if this item represents a directory.

isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?

isFile

public boolean isFile()
Returns true if this item represents a file (and not a a directory)

Returns: true if the item is a file

UNKNOWN: Returns true if this item represents a file (and not a a directory)

isHidden

public boolean isHidden()
Checks whether the file is hidden.

Returns: true if the file is hidden.

UNKNOWN: Checks whether the file is hidden.

isLink

public boolean isLink()
Returns true if this item represents a link in the UNIX sense of a link.

Returns: true if the file is a link

UNKNOWN: Returns true if this item represents a link in the UNIX sense of a link.

isLocalFile

public boolean isLocalFile()
Returns true if the file is a local file.

Returns: true if the file is local, false otherwise

UNKNOWN: Returns true if the file is a local file.

isMarked

public boolean isMarked()
Used when updating a directory. marked == seen when refreshing.

Returns: true if the file item is marked

UNKNOWN: Used when updating a directory.

isMimeTypeKnown

public boolean isMimeTypeKnown()
Returns the currently known mimetype of the file item. This will not try to determine the mimetype if unknown.

Returns: the known mime type

UNKNOWN: Returns the currently known mimetype of the file item.

isReadable

public boolean isReadable()
Checks whether the file or directory is readable. In some cases (remote files), we may return true even though it can't be read.

Returns: true if the file can be read - more precisely, false if we know for sure it can't

UNKNOWN: Checks whether the file or directory is readable.

isWritable

public boolean isWritable()
Checks whether the file or directory is writable. In some cases (remote files), we may return true even though it can't be written to.

Returns: true if the file or directory can be written to - more precisely, false if we know for sure it can't

UNKNOWN: Checks whether the file or directory is writable.

linkDest

public String linkDest()
Returns the link destination if isLink() == true.

Returns: the link destination. null if the item is not a link

UNKNOWN: Returns the link destination if isLink() == true.

localPath

public String localPath()
Returns the local path if isLocalFile() == true or the KIO item has a UDS_LOCAL_PATH atom.

Returns: the item local path, or null if not known

UNKNOWN: Returns the local path if isLocalFile() == true or the KIO item has a UDS_LOCAL_PATH atom.

mark

public void mark()
Marks the item.

See Also: KFileItem

UNKNOWN: Marks the item.

metaInfo

public KFileMetaInfo metaInfo(boolean autoget, int what)
Returns the metainfo of this item.

Parameters: autoget if true, the metainfo will automatically be created what ignored

UNKNOWN: Returns the metainfo of this item.

metaInfo

public KFileMetaInfo metaInfo(boolean autoget)

metaInfo

public KFileMetaInfo metaInfo()

mimeComment

public String mimeComment()
Returns the descriptive comment for this mime type, or the mime type itself if none is present.

Returns: the mime type description, or the mime type itself

UNKNOWN: Returns the descriptive comment for this mime type, or the mime type itself if none is present.

mimetype

public String mimetype()
Returns the mimetype of the file item. If _determineMimeTypeOnDemand was used in the constructor, this will determine the mimetype first. Equivalent to determineMimeType().name()

Returns: the mime type of the file

UNKNOWN: Returns the mimetype of the file item.

mode

public long mode()
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).

Returns: the file type

UNKNOWN: Returns the file type (stat.

mostLocalURL

public KURL mostLocalURL(boolean local)
Tries to give a local URL for this file item if possible. The given booleanean indicates if the returned url is local or not.

UNKNOWN: Tries to give a local URL for this file item if possible.

name

public String name(boolean lowerCase)
Return the name of the file item (without a path). Similar to text(), but unencoded, i.e. the original name.

Parameters: lowerCase if true, the name will be returned in lower case, which is useful to speed up sorting by name, case insensitively.

Returns: the file's name

UNKNOWN: Return the name of the file item (without a path).

name

public String name()

overlays

public int overlays()
Returns the overlays (bitfield of KIcon.Overlay flags) that are used for this item's pixmap. Overlays are used to show for example, whether a file can be modified.

Returns: the overlays of the pixmap

UNKNOWN: Returns the overlays (bitfield of KIcon. Overlay flags) that are used for this item's pixmap.

parsePermissions

protected String parsePermissions(long perm)
Parses the given permission set and provides it for access()

UNKNOWN: Parses the given permission set and provides it for access()

permissions

public long permissions()
Returns the permissions of the file (stat.st_mode containing only permissions).

Returns: the permissions of the file

UNKNOWN: Returns the permissions of the file (stat.

permissionsString

public String permissionsString()
Returns the access permissions for the file as a string.

Returns: the access persmission as string

UNKNOWN: Returns the access permissions for the file as a string.

pixmap

public QPixmap pixmap(int _size, int _state)
Returns a pixmap representing the file.

Parameters: _size Size for the pixmap in pixels. Zero will return the globally configured default size. _state The state of the icon: KIcon.DefaultState, KIcon.ActiveState or KIcon.DisabledState.

Returns: the pixmap

UNKNOWN: Returns a pixmap representing the file.

pixmap

public QPixmap pixmap(int _size)

readUDSEntry

protected void readUDSEntry(boolean _urlIsDirectory)
Extracts the data from the UDSEntry member and updates the KFileItem accordingly.

UNKNOWN: Extracts the data from the UDSEntry member and updates the KFileItem accordingly.

refresh

public void refresh()
Throw away and re-read (for local files) all information about the file. This is called when the _file_ changes.

UNKNOWN: Throw away and re-read (for local files) all information about the file.

refreshMimeType

public void refreshMimeType()
Re-reads mimetype information. This is called when the mimetype database changes.

UNKNOWN: Re-reads mimetype information.

run

public void run()
Let's "KRun" this file ! (e.g. when file is clicked or double-clicked or return is pressed)

UNKNOWN: Let's "KRun" this file ! (e.

setFileMode

public void setFileMode(long m)
Sets the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).

Parameters: m the new file type

UNKNOWN: Sets the file type (stat.

setMetaInfo

public void setMetaInfo(KFileMetaInfo info)
Sets the metainfo of this item to info.

Parameters: info the new meta info

UNKNOWN: Sets the metainfo of this item to info.

setMimeType

public void setMimeType(String mimetype)
Sets new mimetype for item

Parameters: mimetype the new mimetype

UNKNOWN: Sets new mimetype for item

setName

public void setName(String name)
Sets the item's name (i.e. the filename). This is automatically done by setURL, to set the name from the URL's fileName(). This method is provided for some special cases like relative paths as names (KFindPart)

Parameters: name the item's name

UNKNOWN: Sets the item's name (i.

setURL

public void setURL(KURL url)
Sets the item's URL. Do not call unless you know what you are doing! (used for example when an item got renamed).

Parameters: url the item's URL

UNKNOWN: Sets the item's URL.

size

public long size()
Returns the size of the file, if known.

Returns: the file size, or 0 if not known

UNKNOWN: Returns the size of the file, if known.

size

public long size(boolean hasSize)
Returns the size of the file, if known, and sets hasSize to false if not known

Parameters: @hasSize This is set to true if the size is known, and false if not known

Returns: the file size, or 0 if not known

UNKNOWN: Returns the size of the file, if known, and sets hasSize to false if not known @param @hasSize This is set to true if the size is known, and false if not known

text

public String text()
Returns the text of the file item. It's not exactly the filename since some decoding happens ('%2F'.'/').

Returns: the text of the file item

UNKNOWN: Returns the text of the file item.

time

public int time(int which)
Requests the modification, access or creation time, depending on which.

Parameters: which UDS_MODIFICATION_TIME, UDS_ACCESS_TIME or UDS_CREATION_TIME

Returns: the time asked for, (time_t)0 if not available

See Also: KFileItem

UNKNOWN: Requests the modification, access or creation time, depending on which.

time

public int time(int which, boolean hasTime)
Requests the modification, access or creation time, depending on which.

Parameters: which UDS_MODIFICATION_TIME, UDS_ACCESS_TIME or UDS_CREATION_TIME hasTime This is set to true is the time is known, and false if not known

Returns: the time asked for, (time_t)0 if not known/available

See Also: KFileItem

UNKNOWN: Requests the modification, access or creation time, depending on which.

timeString

public String timeString(int which)
Requests the modification, access or creation time as a string, depending on which.

Parameters: which UDS_MODIFICATION_TIME, UDS_ACCESS_TIME or UDS_CREATION_TIME

Returns: a formatted string of the requested time, null if time is not known

See Also: KFileItem

UNKNOWN: Requests the modification, access or creation time as a string, depending on which.

timeString

public String timeString()

unmark

public void unmark()
Unmarks the item.

See Also: KFileItem

UNKNOWN: Unmarks the item.

url

public KURL url()
Returns the url of the file.

Returns: the url of the file

UNKNOWN: Returns the url of the file.

user

public String user()
Returns the owner of the file.

Returns: the file's owner

UNKNOWN: Returns the owner of the file.