kexi

KexiUtils Namespace Reference


Detailed Description

General Utils.


Classes

class  IdentifierValidator
 Validates input for identifier name. More...
class  LongLongValidator
 A validator for longlong data type. More...
class  StyleProxy
 a QStyle proxy allowing to customizing the currently used style More...
class  WaitCursor
class  WaitCursorRemover
class  Validator
 A validator extending QValidator with offline-checking for value's validity. More...
class  MultiValidator
 A validator groupping multiple QValidators. More...

Enumerations

enum  CopyFileResult { CopySuccess = 0, CopyReadError = 1, CopyWriteError = 2 }

Functions

bool isIdentifier (const QString &s)
QString string2FileName (const QString &s)
QString string2Identifier (const QString &s)
QString identifierExpectedMessage (const QString &valueName, const QVariant &v)
void setWaitCursor (bool noDelay)
void removeWaitCursor ()
QString fileDialogFilterString (const KMimeType::Ptr &mime, bool kdeFormat)
QString fileDialogFilterString (const QString &mimeString, bool kdeFormat)
QString fileDialogFilterStrings (const QStringList &mimeStrings, bool kdeFormat)
QColor blendedColors (const QColor &c1, const QColor &c2, int factor1, int factor2)
QColor contrastColor (const QColor &c)
QColor bleachedColor (const QColor &c, int factor)
QIconSet colorizeIconToTextColor (const QPixmap &icon, const QPalette &palette)
QPixmap emptyIcon (KIcon::Group iconGroup)
void serializeMap (const QMap< QString, QString > &map, const QByteArray &array)
void serializeMap (const QMap< QString, QString > &map, QString &string)
QMap< QString, QString > deserializeMap (const QByteArray &array)
QMap< QString, QString > deserializeMap (const QString &string)
QString stringToFileName (const QString &string)
void simpleCrypt (QString &string)
void simpleDecrypt (QString &string)
void drawPixmap (QPainter &p, int lineWidth, const QRect &rect, const QPixmap &pixmap, int alignment, bool scaledContents, bool keepAspectRatio)
QString ptrToStringInternal (void *ptr, uint size)
void * stringToPtrInternal (const QString &str, uint size)
void setFocusWithReason (QWidget *widget, QFocusEvent::Reason reason)
void unsetFocusWithReason (QWidget *widget, QFocusEvent::Reason reason)
CopyFileResult copyFile (const QString &src, const QString &dest)
bool hasParent (QObject *par, QObject *o)
template<class type>
type * findParent (QObject *o, const char *className)
template<class type>
const type * findParentConst (const QObject *const o, const char *className)
template<class type>
type * findFirstChild (QObject *o, const char *className, const char *objName=0)
QDateTime stringToHackedQTime (const QString &s)
template<class type>
QString ptrToString (type *ptr)
template<class type>
type * stringToPtr (const QString &str)

Enumeration Type Documentation

Used by copyFile().

Definition at line 243 of file kexiutils/utils.h.


Function Documentation

KEXIUTILS_EXPORT QColor KexiUtils::bleachedColor ( const QColor &  c,
int  factor 
)

Returns:
a lighter color for a color c and a factor factor. For colors like Qt::red or Qt::green where hue and saturation are near to 255, hue is decreased so the result will be more bleached. For black color the result is dark gray rather than black.

Definition at line 161 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QColor KexiUtils::blendedColors ( const QColor &  c1,
const QColor &  c2,
int  factor1 = 1,
int  factor2 = 1 
)

Returns:
a color being a result of blending c1 with c2 with factor1 and factor1 factors: (c1*factor1+c2*factor2)/(factor1+factor2).

Definition at line 141 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QIconSet KexiUtils::colorizeIconToTextColor ( const QPixmap &  icon,
const QPalette &  palette 
)

Returns:
icon set computed as a result of colorizing icon pixmap with "buttonText" color of palette palette. This function is useful for displaying monochromed icons on the list view or table view header, to avoid bloat, but still have the color compatible with accessibility settings.

Definition at line 176 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QColor KexiUtils::contrastColor ( const QColor &  c  ) 

Returns:
a contrast color for a color c: If c is light color, darker color created using c.dark(200) is returned; otherwise lighter color created using c.light(200) is returned.

Definition at line 149 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT CopyFileResult KexiUtils::copyFile ( const QString &  src,
const QString &  dest 
)

Copies src file to dest file.

Returns:
CopySuccess on success, CopyReadError on source file error, CopyWriteError on destination file error.
Todo:
remove: QFile in Qt4 provides this.

Definition at line 390 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QMap< QString, QString > KexiUtils::deserializeMap ( const QString &  string  ) 

Returns:
a map deserialized from string. string need to contain data previously serialized using KexiUtils::serializeMap().

Definition at line 223 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QMap< QString, QString > KexiUtils::deserializeMap ( const QByteArray &  array  ) 

Returns:
a map deserialized from a byte array array. array need to contain data previously serialized using KexiUtils::serializeMap().

Definition at line 215 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT void KexiUtils::drawPixmap ( QPainter &  p,
int  lineWidth,
const QRect &  rect,
const QPixmap &  pixmap,
int  alignment,
bool  scaledContents,
bool  keepAspectRatio 
)

Draws pixmap on painter p using predefined parameters.

Used in KexiDBImageBox and KexiBlobTableEdit.

Definition at line 256 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QPixmap KexiUtils::emptyIcon ( KIcon::Group  iconGroup  ) 

Returns:
empty (fully transparent) pixmap that can be used as a place for icon of size iconGroup

Definition at line 186 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QString KexiUtils::fileDialogFilterString ( const KMimeType::Ptr &  mime,
bool  kdeFormat = true 
)

Returns:
filter string in QFileDialog format for a mime type pointed by mime If kdeFormat is true, QFileDialog-compatible filter string is generated, eg. "Image files (*.png *.xpm *.jpg)", otherwise KFileDialog -compatible filter string is generated, eg. "*.png *.xpm *.jpg|Image files (*.png *.xpm *.jpg)". "\\n" is appended if kdeFormat is true, otherwise ";;" is appended.

Definition at line 97 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QString KexiUtils::fileDialogFilterStrings ( const QStringList &  mimeStrings,
bool  kdeFormat 
)

Like QString fileDialogFilterString(const KMimeType::Ptr& mime, bool kdeFormat = true) but returns a list of filter strings.

Definition at line 132 of file kexiutils/utils.cpp.

template<class type>
type* KexiUtils::findFirstChild ( QObject *  o,
const char *  className,
const char *  objName = 0 
)

Returns:
first found child of o, inheriting className. If objName is 0 (the default), all object names match. Returned pointer type is casted.

Definition at line 70 of file kexiutils/utils.h.

template<class type>
type* KexiUtils::findParent ( QObject *  o,
const char *  className 
) [inline]

Returns:
parent object of o that inherits className or NULL if no such parent

Definition at line 45 of file kexiutils/utils.h.

template<class type>
const type* KexiUtils::findParentConst ( const QObject *const   o,
const char *  className 
) [inline]

Const version of findParent().

Definition at line 56 of file kexiutils/utils.h.

bool KexiUtils::hasParent ( QObject *  par,
QObject *  o 
) [inline]

Returns:
true if o has parent par.

Definition at line 34 of file kexiutils/utils.h.

KEXIUTILS_EXPORT QString KexiUtils::identifierExpectedMessage ( const QString &  valueName,
const QVariant &  v 
)

Returns:
useful message "Value of "valueName" column must be an identifier. "v" is not a valid identifier.". It is also used by IdentifierValidator.

Definition at line 88 of file identifier.cpp.

KEXIUTILS_EXPORT bool KexiUtils::isIdentifier ( const QString &  s  ) 

Returns:
true if s is a valid identifier, ie. starts with a letter or '_' character and contains only letters, numbers and '_' character.

Definition at line 26 of file identifier.cpp.

template<class type>
QString KexiUtils::ptrToString ( type *  ptr  ) 

Returns:
a pointer ptr safely serialized to string

Definition at line 224 of file kexiutils/utils.h.

KEXIUTILS_EXPORT void KexiUtils::removeWaitCursor (  ) 

Remove "wait" cursor previously set with setWaitCursor(), even if it's not yet visible. Does nothing if the application has no GUI enabled. (see KApplication::guiEnabled())

Definition at line 69 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT void KexiUtils::serializeMap ( const QMap< QString, QString > &  map,
const QByteArray &  array 
)

Serializes map to array. KexiUtils::deserializeMap() can be used to deserialize this array back to map.

Definition at line 195 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT void KexiUtils::setFocusWithReason ( QWidget *  widget,
QFocusEvent::Reason  reason 
)

Sets focus for widget widget with reason reason.

Definition at line 374 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT void KexiUtils::setWaitCursor ( bool  noDelay = false  ) 

Sets "wait" cursor with 1 second delay (or 0 seconds if noDelay is true). Does nothing if the application has no GUI enabled. (see KApplication::guiEnabled())

Definition at line 65 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT void KexiUtils::simpleCrypt ( QString &  string  ) 

Performs a simple string encryption using rot47-like algorithm. Each character's unicode value is increased by 47 + i (where i is index of the character). The resulting string still contains redable characters. Do not use this for data that can be accessed by attackers!

Definition at line 244 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT void KexiUtils::simpleDecrypt ( QString &  string  ) 

Performs a simple string decryption using rot47-like algorithm, using opposite operations to KexiUtils::simpleCrypt().

Definition at line 250 of file kexiutils/utils.cpp.

KEXIUTILS_EXPORT QString KexiUtils::string2FileName ( const QString &  s  ) 

Returns:
Valid filename based on s

Definition at line 37 of file identifier.cpp.

KEXIUTILS_EXPORT QString KexiUtils::string2Identifier ( const QString &  s  ) 

Returns:
valid identifier based on s. Non-alphanumeric characters (or spaces) are replaced with '_'. If a number is at the beginning, '_' is added at start. Empty strings are not changed. Case remains unchanged.

Definition at line 54 of file identifier.cpp.

KEXIUTILS_EXPORT QString KexiUtils::stringToFileName ( const QString &  string  ) 

Returns:
a valid filename converted from string by:
  • replacing \, /, :, *, ?, ", <, >, |,
    \t characters with a space
  • simplifing whitespace by removing redundant space characters using QString::simplifyWhiteSpace() Do not pass full paths here, but only filename strings.

Definition at line 237 of file kexiutils/utils.cpp.

QDateTime KexiUtils::stringToHackedQTime ( const QString &  s  )  [inline]

QDateTime - a hack needed because QVariant(QTime) has broken isNull().

Definition at line 81 of file kexiutils/utils.h.

template<class type>
type* KexiUtils::stringToPtr ( const QString &  str  ) 

Returns:
a pointer of type type safely deserialized from str

Definition at line 231 of file kexiutils/utils.h.

KEXIUTILS_EXPORT void KexiUtils::unsetFocusWithReason ( QWidget *  widget,
QFocusEvent::Reason  reason 
)

Unsets focus for widget widget with reason reason.

Definition at line 382 of file kexiutils/utils.cpp.

KDE Home | KDE Accessibility Home | Description of Access Keys