com.sibvisions.rad.ui.qt.ext
Class QVxUtil

java.lang.Object
  extended by com.sibvisions.rad.ui.qt.ext.QVxUtil

public final class QVxUtil
extends Object

The QVxUtil is a utility class with often used functionality encapsulated in useful methods.


Method Summary
static ICellEditor getDefaultCellEditor(Class pClass)
          Gets the default ICellEditor for the given class.
static String getImageMapping(String pMappingName)
          Gets the image name for the given mapping name.
static String[] getImageMappingNames()
          Gets all used mapping names.
static QPixmap getPixmap(String pImageName)
          Gets a pixmap from the resource bundle.
static QPixmap getPixmap(String pImageName, byte[] pData)
          Gets a pixmap with a specific name and byte data.
static QColor getSystemColor(String pType)
          Gets the system color.
static void setBackground(QWidget pWidget, QColor pColor)
          Sets the background for a widget.
static void setColors(QWidget pWidget, QColor pBackground, QColor pForeground)
          Sets the foreground for a widget.
static void setDefaultCellEditor(Class pClass, ICellEditor pCellEditor)
          Sets the default ICellEditor for the given class.
static void setImageMapping(String pMappingName, String pImageName)
          Gets the image name for the given mapping name.
static void setReadOnly(QWidget pWidget, boolean pReadOnly)
          Sets a text widget readonly.
static void setSystemColor(String pType, QColor pSystemColor)
          Sets the system color.
static QSize sizeHint(QLayoutItemInterface pWidget)
          Gets the sizeHint of a widget.
static QSize sizeHint(QWidget pWidget)
          Gets the sizeHint of a widget.
static Date toDate(QDateTime pDateTime)
          Gets the java date for a QT date time.
static QDateTime toDateTime(Date pDate)
          Gets the QT date time for a java date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sizeHint

public static QSize sizeHint(QLayoutItemInterface pWidget)
Gets the sizeHint of a widget. The size is between the minimum and maximum size.

Parameters:
pWidget - the widget
Returns:
the sizeHint dependent of the minimum and maximum size

sizeHint

public static QSize sizeHint(QWidget pWidget)
Gets the sizeHint of a widget. The size is between the minimum and maximum size.

Parameters:
pWidget - the widget
Returns:
the sizeHint dependent of the minimum and maximum size

getDefaultCellEditor

public static ICellEditor getDefaultCellEditor(Class pClass)
Gets the default ICellEditor for the given class. This function should always return an editor. It should look for best matching editor with Class.isAssignableFrom.

Parameters:
pClass - the class type to be edited.
Returns:
the ICellEditor
See Also:
ICellEditor

setDefaultCellEditor

public static void setDefaultCellEditor(Class pClass,
                                        ICellEditor pCellEditor)
Sets the default ICellEditor for the given class. This function should always return an editor. It should look for best matching editor with Class.isAssignableFrom. If the given ICellEditor is null, it is removed as editor for the given class.

Parameters:
pClass - the class type to be edited.
pCellEditor - the ICellEditor
See Also:
ICellEditor

getSystemColor

public static QColor getSystemColor(String pType)
Gets the system color.

Parameters:
pType - the color type
Returns:
the system color

setSystemColor

public static void setSystemColor(String pType,
                                  QColor pSystemColor)
Sets the system color.

Parameters:
pType - the color type
pSystemColor - the system color

getPixmap

public static QPixmap getPixmap(String pImageName)
Gets a pixmap from the resource bundle.

Parameters:
pImageName - the image resource name
Returns:
the QPixmap or null if the resource is not available

getPixmap

public static QPixmap getPixmap(String pImageName,
                                byte[] pData)
Gets a pixmap with a specific name and byte data.

Parameters:
pImageName - the image name (used for cache mechanism) or null if the image should not be cached
pData - the image byte data
Returns:
the pixmap instance or null if the byData == null

getImageMapping

public static String getImageMapping(String pMappingName)
Gets the image name for the given mapping name.

Parameters:
pMappingName - the mapping name.
Returns:
the image name.

setImageMapping

public static void setImageMapping(String pMappingName,
                                   String pImageName)
Gets the image name for the given mapping name.

Parameters:
pMappingName - the mapping name.
pImageName - the image name.

getImageMappingNames

public static String[] getImageMappingNames()
Gets all used mapping names.

Returns:
the mapping names.

toDateTime

public static QDateTime toDateTime(Date pDate)
Gets the QT date time for a java date.

Parameters:
pDate - the java date
Returns:
the QT date time

toDate

public static Date toDate(QDateTime pDateTime)
Gets the java date for a QT date time.

Parameters:
pDateTime - the QT date time
Returns:
the java date

setReadOnly

public static void setReadOnly(QWidget pWidget,
                               boolean pReadOnly)
Sets a text widget readonly. Readonly means that the user can not edit the text but it is possible to copy the text out of the editor. The background of the editor will be grayed out.

Parameters:
pWidget - a line or text edit widget.
pReadOnly - true to set the widget read only, false otherwise

setBackground

public static void setBackground(QWidget pWidget,
                                 QColor pColor)
Sets the background for a widget.

Parameters:
pWidget - a line or text edit widget.
pColor - the color to set.

setColors

public static void setColors(QWidget pWidget,
                             QColor pBackground,
                             QColor pForeground)
Sets the foreground for a widget.

Parameters:
pWidget - a line or text edit widget.
pBackground - the background to set.
pForeground - the foreground to set.


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.