org.kde.koala

Class KURLDrag

public class KURLDrag extends QUriDrag

This class is to be used instead of QUriDrag when using KURL. The reason is: QUriDrag (and the XDND/W3C standards) expect URLs to be encoded in UTF-8 (unicode), but KURL uses the current locale by default. The other reasons for using this class are:
  • it exports text/plain (for dropping/pasting into lineedits, mails etc.)
  • it has support for metadata, shipped as part of the dragobject This is important, for instance to set a correct HTTP referrer (some websites require it for downloading e.g. an image).
  • To create a drag object, use the KURLDrag constructor. To handle drops, use QUriDrag.canDecode() and KURLDrag.decode()

    UNKNOWN: This class is to be used instead of QUriDrag when using KURL.

    Constructor Summary
    protected KURLDrag(Class dummy)
    KURLDrag(ArrayList urls, QWidget dragSource, String name)
    Constructs an object to drag the list of URLs in urls. The dragSource and name arguments are passed on to QUriDrag, and the list of urls is converted to UTF-8 before being passed to QUriDrag.
    KURLDrag(ArrayList urls, QWidget dragSource)
    KURLDrag(ArrayList urls)
    Method Summary
    static booleandecode(QMimeSourceInterface e, ArrayList urls)
    Convenience method that decodes the contents of e into a list of KURLs.
    voiddispose()
    Delete the wrapped C++ instance ahead of finalize()
    byte[]encodedData(String mime)
    protected voidfinalize()
    Deletes the wrapped C++ instance
    Stringformat(int i)
    Meta-data to associate with those URLs.
    booleanisDisposed()
    Has the wrapped C++ instance been deleted?
    voidsetExportAsText(boolean exp)
    By default, KURLDrag also exports the URLs as plain text, for e.g. dropping onto a text editor.
    static KURLstringToUrl(String s)
    Converts a string used for dragging to a URL.
    static StringurlToString(KURL url)
    Converts a URL to a string representation suitable for dragging.

    Constructor Detail

    KURLDrag

    protected KURLDrag(Class dummy)

    KURLDrag

    public KURLDrag(ArrayList urls, QWidget dragSource, String name)
    Constructs an object to drag the list of URLs in urls. The dragSource and name arguments are passed on to QUriDrag, and the list of urls is converted to UTF-8 before being passed to QUriDrag.

    Parameters: urls the list of URLs dragSource the parent of the QObject. Should be set when doing drag-n-drop, but should be 0 when copying to the clipboard name the name of the QObject

    UNKNOWN: Constructs an object to drag the list of URLs in urls.

    KURLDrag

    public KURLDrag(ArrayList urls, QWidget dragSource)

    KURLDrag

    public KURLDrag(ArrayList urls)

    Method Detail

    decode

    public static boolean decode(QMimeSourceInterface e, ArrayList urls)
    Convenience method that decodes the contents of e into a list of KURLs. Decoding will fail if at least one decoded value is not a valid KURL.

    Parameters: e the mime source urls the list of urls will be written here

    Returns: true if successful, false otherwise

    UNKNOWN: Convenience method that decodes the contents of e into a list of KURLs.

    dispose

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

    encodedData

    public byte[] encodedData(String mime)

    finalize

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

    format

    public String format(int i)
    Meta-data to associate with those URLs. This is an alternative way of setting the metadata: either use the constructor to pass it all at once, or use drag.metaData()["key"] = data;

    See Also: TransferJob

    UNKNOWN: Meta-data to associate with those URLs.

    isDisposed

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

    setExportAsText

    public void setExportAsText(boolean exp)
    By default, KURLDrag also exports the URLs as plain text, for e.g. dropping onto a text editor. But in some cases this might not be wanted, e.g. if using the KURLDrag in a KMultipleDrag and another component of the multiple-drag provides better plain text data. In such a case, setExportAsText( false ) should be called.

    UNKNOWN: By default, KURLDrag also exports the URLs as plain text, for e.

    stringToUrl

    public static KURL stringToUrl(String s)
    Converts a string used for dragging to a URL.

    UNKNOWN: Converts a string used for dragging to a URL.

    urlToString

    public static String urlToString(KURL url)
    Converts a URL to a string representation suitable for dragging.

    UNKNOWN: Converts a URL to a string representation suitable for dragging.