Difference between revisions of "Development/Tutorials/Plasma/JavaScript/API-Misc"

Jump to: navigation, search
m (Text replace - "<code javascript>" to "<syntaxhighlight lang="javascript">")
m (Text replace - "</code>" to "</syntaxhighlight>")
 
Line 2: Line 2:
 
Represents a local or remote address. To create a new Url (or assign to an existing one), use the following syntax:
 
Represents a local or remote address. To create a new Url (or assign to an existing one), use the following syntax:
  
<syntaxhighlight lang="javascript">var url = new Url("http://kde.org")</code>
+
<syntaxhighlight lang="javascript">var url = new Url("http://kde.org")</syntaxhighlight>
  
 
Read-only properties:
 
Read-only properties:

Latest revision as of 21:53, 29 June 2011

Contents

[edit] Url

Represents a local or remote address. To create a new Url (or assign to an existing one), use the following syntax:

var url = new Url("http://kde.org")

Read-only properties:

  • string toString: the URL as a String object

Read-write properties (each representing a portion of the full URL):

  • string protocol
  • string host
  • string path
  • string user
  • string password

[edit] ByteArray

This class provides an array of bytes. This is often used by data centric objects, such as the Job classes returned by getUrl.

Read-only properties:

  • number length: the size of the array (number of bytes)

Functions:

  • chop(number numBytes): chops numBytes from the end of the array
  • bool equals(ByteArray other)
  • ByteArray left(number len): return len bytes from the left of the array
  • ByteArray mid(number pos, number len): returns an array of bytes starting a post and length len (if len is -1, it returns all remaining bytes)
  • ByteArray remove(number pos, number len): removes len bytes starting at index pos from the array and returns it
  • ByteArray right(number len): returns len bytes from the right of the array
  • ByteArray simplified(): returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space
  • ByteArray toBase64(): returns the array encoded in base64
  • ByteArray toLower(): returns a lowercased copy of the array
  • ByteArray toUpper(): returns an uppercased copy of the array
  • ByteArray trimmed(): returns a copy of the array with whitespace remove from the start and end
  • truncate(number pos): truncates the array at index pos
  • String toLatin1String(): returns a Latin1-ized string based on the array
  • String toUtf8(): (API v3) returns a string from the contents of the array using a Utf8 conversation
  • String valueOf(): returns the raw data in the array as a string

[edit] GraphicsItem

This class represents an item on the canvas. Support is only provided so that GraphicsItem objects returned or taken by other objects work. There is no meaningful API provided directly in the JavaScript runtime for these objects and they should not need to be used directly.

[edit] QSizePolicy

The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy. This can be set on any graphics widget that you have using the enums provided for this (QtSizePolicy ), for example:

button = new PushButton(); button.sizePolicy = QSizePolicy(QSizePolicyMaximum, QSizePolicyFixed);

This is useful when your widgets are being laid out by a layout (specially the anchor layout).

  • QtSizePolicy horizontalPolicy: The horizontal component of the size policy.
  • QtSizePolicy verticalPolicy: The vertical component of the size policy.
  • number horizontalStretch: The horizontal stretch factor of the size policy.
  • number verticalStretch: The vertical stretch factor of the size policy.

This page was last modified on 29 June 2011, at 21:53. This page has been accessed 2,250 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal