summaryrefslogtreecommitdiffstats
path: root/kexi/kexiutils/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kexi/kexiutils/utils.cpp')
-rw-r--r--kexi/kexiutils/utils.cpp210
1 files changed, 105 insertions, 105 deletions
diff --git a/kexi/kexiutils/utils.cpp b/kexi/kexiutils/utils.cpp
index f96465a6..6b3e26dc 100644
--- a/kexi/kexiutils/utils.cpp
+++ b/kexi/kexiutils/utils.cpp
@@ -20,13 +20,13 @@
#include "utils.h"
#include "utils_p.h"
-#include <qregexp.h>
-#include <qpainter.h>
-#include <qimage.h>
-#include <qwmatrix.h>
-#include <qiconset.h>
-#include <qbitmap.h>
-#include <qfile.h>
+#include <tqregexp.h>
+#include <tqpainter.h>
+#include <tqimage.h>
+#include <tqwmatrix.h>
+#include <tqiconset.h>
+#include <tqbitmap.h>
+#include <tqfile.h>
#include <kdebug.h>
#include <kcursor.h>
@@ -36,7 +36,7 @@
#include <kpixmapeffect.h>
#include <kiconloader.h>
-#if defined(Q_WS_WIN)
+#if defined(TQ_WS_WIN)
# include <win32_utils.h>
#endif
@@ -45,7 +45,7 @@ using namespace KexiUtils;
DelayedCursorHandler::DelayedCursorHandler()
: startedOrActive(false)
{
- connect(&timer, SIGNAL(timeout()), this, SLOT(show()));
+ connect(&timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(show()));
}
void DelayedCursorHandler::start(bool noDelay) {
startedOrActive = true;
@@ -54,10 +54,10 @@ void DelayedCursorHandler::start(bool noDelay) {
void DelayedCursorHandler::stop() {
startedOrActive = false;
timer.stop();
- QApplication::restoreOverrideCursor();
+ TQApplication::restoreOverrideCursor();
}
void DelayedCursorHandler::show() {
- QApplication::setOverrideCursor( KCursor::waitCursor() );
+ TQApplication::setOverrideCursor( KCursor::waitCursor() );
}
DelayedCursorHandler _delayedCursorHandler;
@@ -94,12 +94,12 @@ WaitCursorRemover::~WaitCursorRemover()
//--------------------------------------------------------------------------------
-QString KexiUtils::fileDialogFilterString(const KMimeType::Ptr& mime, bool kdeFormat)
+TQString KexiUtils::fileDialogFilterString(const KMimeType::Ptr& mime, bool kdeFormat)
{
if (mime==0)
- return QString::null;
+ return TQString();
- QString str;
+ TQString str;
if (kdeFormat) {
if (mime->patterns().isEmpty())
str = "*";
@@ -123,138 +123,138 @@ QString KexiUtils::fileDialogFilterString(const KMimeType::Ptr& mime, bool kdeFo
return str;
}
-QString KexiUtils::fileDialogFilterString(const QString& mimeString, bool kdeFormat)
+TQString KexiUtils::fileDialogFilterString(const TQString& mimeString, bool kdeFormat)
{
KMimeType::Ptr ptr = KMimeType::mimeType(mimeString);
return fileDialogFilterString( ptr, kdeFormat );
}
-QString KexiUtils::fileDialogFilterStrings(const QStringList& mimeStrings, bool kdeFormat)
+TQString KexiUtils::fileDialogFilterStrings(const TQStringList& mimeStrings, bool kdeFormat)
{
- QString ret;
- QStringList::ConstIterator endIt = mimeStrings.constEnd();
- for(QStringList::ConstIterator it = mimeStrings.constBegin(); it != endIt; ++it)
+ TQString ret;
+ TQStringList::ConstIterator endIt = mimeStrings.constEnd();
+ for(TQStringList::ConstIterator it = mimeStrings.constBegin(); it != endIt; ++it)
ret += fileDialogFilterString(*it, kdeFormat);
return ret;
}
-QColor KexiUtils::blendedColors(const QColor& c1, const QColor& c2, int factor1, int factor2)
+TQColor KexiUtils::blendedColors(const TQColor& c1, const TQColor& c2, int factor1, int factor2)
{
- return QColor(
+ return TQColor(
int( (c1.red()*factor1+c2.red()*factor2)/(factor1+factor2) ),
int( (c1.green()*factor1+c2.green()*factor2)/(factor1+factor2) ),
int( (c1.blue()*factor1+c2.blue()*factor2)/(factor1+factor2) ) );
}
-QColor KexiUtils::contrastColor(const QColor& c)
+TQColor KexiUtils::contrastColor(const TQColor& c)
{
- int g = qGray( c.rgb() );
+ int g = tqGray( c.rgb() );
if (g>110)
return c.dark(200);
else if (g>80)
return c.light(150);
else if (g>20)
return c.light(300);
- return Qt::gray;
+ return TQt::gray;
}
-QColor KexiUtils::bleachedColor(const QColor& c, int factor)
+TQColor KexiUtils::bleachedColor(const TQColor& c, int factor)
{
int h, s, v;
c.getHsv( &h, &s, &v );
- QColor c2;
+ TQColor c2;
if (factor < 100)
factor = 100;
if (s>=250 && v>=250) //for colors like cyan or red, make the result more white
- s = QMAX(0, s - factor - 50);
+ s = TQMAX(0, s - factor - 50);
else if (s<=5 && s<=5)
v += factor-50;
- c2.setHsv(h, s, QMIN(255,v + factor-100));
+ c2.setHsv(h, s, TQMIN(255,v + factor-100));
return c2;
}
-QIconSet KexiUtils::colorizeIconToTextColor(const QPixmap& icon, const QPalette& palette)
+TQIconSet KexiUtils::colorizeIconToTextColor(const TQPixmap& icon, const TQPalette& palette)
{
- QPixmap pm(
+ TQPixmap pm(
KIconEffect().apply( icon, KIconEffect::Colorize, 1.0f, palette.active().buttonText(), false ) );
KPixmap kpm(pm);
- return QIconSet(
+ return TQIconSet(
KPixmapEffect::fade( kpm, 0.33, palette.active().button() ) );
}
-QPixmap KexiUtils::emptyIcon(KIcon::Group iconGroup)
+TQPixmap KexiUtils::emptyIcon(KIcon::Group iconGroup)
{
- QPixmap noIcon( IconSize( iconGroup ), IconSize( iconGroup ) );
- QBitmap bmpNoIcon(noIcon.size());
- bmpNoIcon.fill(Qt::color0);
+ TQPixmap noIcon( IconSize( iconGroup ), IconSize( iconGroup ) );
+ TQBitmap bmpNoIcon(noIcon.size());
+ bmpNoIcon.fill(TQt::color0);
noIcon.setMask(bmpNoIcon);
return noIcon;
}
-void KexiUtils::serializeMap(const QMap<QString,QString>& map, const QByteArray& array)
+void KexiUtils::serializeMap(const TQMap<TQString,TQString>& map, const TQByteArray& array)
{
- QDataStream ds(array, IO_WriteOnly);
+ TQDataStream ds(array, IO_WriteOnly);
ds << map;
}
-void KexiUtils::serializeMap(const QMap<QString,QString>& map, QString& string)
+void KexiUtils::serializeMap(const TQMap<TQString,TQString>& map, TQString& string)
{
- QByteArray array;
- QDataStream ds(array, IO_WriteOnly);
+ TQByteArray array;
+ TQDataStream ds(array, IO_WriteOnly);
ds << map;
kdDebug() << array[3] << " " << array[4] << " " << array[5] << endl;
const uint size = array.size();
- string = QString::null;
+ string = TQString();
string.reserve(size);
for (uint i=0; i<size; i++) {
- string[i]=QChar(ushort(array[i]+1));
+ string[i]=TQChar(ushort(array[i]+1));
}
}
-QMap<QString,QString> KexiUtils::deserializeMap(const QByteArray& array)
+TQMap<TQString,TQString> KexiUtils::deserializeMap(const TQByteArray& array)
{
- QMap<QString,QString> map;
- QDataStream ds(array, IO_ReadOnly);
+ TQMap<TQString,TQString> map;
+ TQDataStream ds(array, IO_ReadOnly);
ds >> map;
return map;
}
-QMap<QString,QString> KexiUtils::deserializeMap(const QString& string)
+TQMap<TQString,TQString> KexiUtils::deserializeMap(const TQString& string)
{
const uint size = string.length();
- QCString cstr(string.latin1());
- QByteArray array( size );
+ TQCString cstr(string.latin1());
+ TQByteArray array( size );
for (uint i=0; i<size; i++) {
- array[i] = char(string[i].unicode()-1);
+ array[i] = char(string[i].tqunicode()-1);
}
- QMap<QString,QString> map;
- QDataStream ds(array, IO_ReadOnly);
+ TQMap<TQString,TQString> map;
+ TQDataStream ds(array, IO_ReadOnly);
ds >> map;
return map;
}
-QString KexiUtils::stringToFileName(const QString& string)
+TQString KexiUtils::stringToFileName(const TQString& string)
{
- QString _string(string);
- _string.replace(QRegExp("[\\\\/:\\*?\"<>|]"), " ");
+ TQString _string(string);
+ _string.tqreplace(TQRegExp("[\\\\/:\\*?\"<>|]"), " ");
return _string.simplifyWhiteSpace();
}
-void KexiUtils::simpleCrypt(QString& string)
+void KexiUtils::simpleCrypt(TQString& string)
{
for (uint i=0; i<string.length(); i++)
- string[i] = QChar( string[i].unicode() + 47 + i );
+ string[i] = TQChar( string[i].tqunicode() + 47 + i );
}
-void KexiUtils::simpleDecrypt(QString& string)
+void KexiUtils::simpleDecrypt(TQString& string)
{
for (uint i=0; i<string.length(); i++)
- string[i] = QChar( string[i].unicode() - 47 - i );
+ string[i] = TQChar( string[i].tqunicode() - 47 - i );
}
-void KexiUtils::drawPixmap( QPainter& p, int lineWidth, const QRect& rect,
- const QPixmap& pixmap, int alignment, bool scaledContents, bool keepAspectRatio)
+void KexiUtils::drawPixmap( TQPainter& p, int lineWidth, const TQRect& rect,
+ const TQPixmap& pixmap, int tqalignment, bool scaledContents, bool keepAspectRatio)
{
if (pixmap.isNull())
return;
@@ -263,69 +263,69 @@ void KexiUtils::drawPixmap( QPainter& p, int lineWidth, const QRect& rect,
const int w = rect.width()-lineWidth-lineWidth;
const int h = rect.height()-lineWidth-lineWidth;
//! @todo we can optimize drawing by drawing rescaled pixmap here
-//! and performing detailed painting later (using QTimer)
- QPixmap pixmapBuffer;
- QPainter p2;
- QPainter *target;
+//! and performing detailed painting later (using TQTimer)
+ TQPixmap pixmapBuffer;
+ TQPainter p2;
+ TQPainter *target;
if (fast) {
target = &p;
}
else {
-//moved pixmapBuffer.resize(rect.size()-QSize(lineWidth, lineWidth));
+//moved pixmapBuffer.resize(rect.size()-TQSize(lineWidth, lineWidth));
//moved p2.begin(&pm, p.device());
target = &p2;
}
//! @todo only create buffered pixmap of the minimum size and then do not fillRect()
// target->fillRect(0,0,rect.width(),rect.height(), backgroundColor);
- QPoint pos;
+ TQPoint pos;
if (scaledContents) {
if (keepAspectRatio) {
- QImage img(pixmap.convertToImage());
- img = img.smoothScale(w, h, QImage::ScaleMin);
+ TQImage img(pixmap.convertToImage());
+ img = img.smoothScale(w, h, TQ_ScaleMin);
pos = rect.topLeft(); //0, 0);
if (img.width() < w) {
- int hAlign = QApplication::horizontalAlignment( alignment );
- if ( hAlign & Qt::AlignRight )
+ int hAlign = TQApplication::horizontalAlignment( tqalignment );
+ if ( hAlign & TQt::AlignRight )
pos.setX(pos.x() + w-img.width());
- else if ( hAlign & Qt::AlignHCenter )
+ else if ( hAlign & TQt::AlignHCenter )
pos.setX(pos.x() + w/2-img.width()/2);
}
else if (img.height() < h) {
- if ( alignment & Qt::AlignBottom )
+ if ( tqalignment & TQt::AlignBottom )
pos.setY(pos.y() + h-img.height());
- else if ( alignment & Qt::AlignVCenter )
+ else if ( tqalignment & TQt::AlignVCenter )
pos.setY(pos.y() + h/2-img.height()/2);
}
pixmapBuffer.convertFromImage(img);
if (!fast) {
- p2.begin(&pixmapBuffer, p.device());
+ p2.tqbegin(TQT_TQPAINTDEVICE(&pixmapBuffer), p.tqdevice());
}
else
target->drawPixmap(pos, pixmapBuffer);
}
else {
if (!fast) {
- pixmapBuffer.resize(rect.size()-QSize(lineWidth, lineWidth));
- p2.begin(&pixmapBuffer, p.device());
- p2.drawPixmap(QRect(rect.x(), rect.y(), w, h), pixmap);
+ pixmapBuffer.resize(rect.size()-TQSize(lineWidth, lineWidth));
+ p2.tqbegin(TQT_TQPAINTDEVICE(&pixmapBuffer), p.tqdevice());
+ p2.drawPixmap(TQRect(rect.x(), rect.y(), w, h), pixmap);
}
else
- target->drawPixmap(QRect(rect.x() + lineWidth, rect.y() + lineWidth, w, h), pixmap);
+ target->drawPixmap(TQRect(rect.x() + lineWidth, rect.y() + lineWidth, w, h), pixmap);
}
}
else {
- int hAlign = QApplication::horizontalAlignment( alignment );
- if ( hAlign & Qt::AlignRight )
+ int hAlign = TQApplication::horizontalAlignment( tqalignment );
+ if ( hAlign & TQt::AlignRight )
pos.setX(pos.x() + w-pixmap.width());
- else if ( hAlign & Qt::AlignHCenter )
+ else if ( hAlign & TQt::AlignHCenter )
pos.setX(pos.x() + w/2-pixmap.width()/2);
else //left, etc.
pos.setX(pos.x());
- if ( alignment & Qt::AlignBottom )
+ if ( tqalignment & TQt::AlignBottom )
pos.setY(pos.y() + h-pixmap.height());
- else if ( alignment & Qt::AlignVCenter )
+ else if ( tqalignment & TQt::AlignVCenter )
pos.setY(pos.y() + h/2-pixmap.height()/2);
else //top, etc.
pos.setY(pos.y());
@@ -339,27 +339,27 @@ void KexiUtils::drawPixmap( QPainter& p, int lineWidth, const QRect& rect,
bitBlt( p.device(),
// pos.x(),
// pos.y(),
- (int)p.worldMatrix().dx() + rect.x() + lineWidth + pos.x(),
- (int)p.worldMatrix().dy() + rect.y() + lineWidth + pos.y(),
+ (int)p.tqworldMatrix().dx() + rect.x() + lineWidth + pos.x(),
+ (int)p.tqworldMatrix().dy() + rect.y() + lineWidth + pos.y(),
&pixmapBuffer);
}
}
-QString KexiUtils::ptrToStringInternal(void* ptr, uint size)
+TQString KexiUtils::ptrToStringInternal(void* ptr, uint size)
{
- QString str;
+ TQString str;
unsigned char* cstr_ptr = (unsigned char*)&ptr;
for (uint i=0; i<size; i++) {
- QString s;
+ TQString s;
s.sprintf("%2.2x", cstr_ptr[i]);
str.append( s );
}
return str;
}
-void* KexiUtils::stringToPtrInternal(const QString& str, uint size)
+void* KexiUtils::stringToPtrInternal(const TQString& str, uint size)
{
- QByteArray array(size);
+ TQByteArray array(size);
if ((str.length()/2)<size)
return 0;
bool ok;
@@ -371,26 +371,26 @@ void* KexiUtils::stringToPtrInternal(const QString& str, uint size)
return *(void**)(array.data());
}
-void KexiUtils::setFocusWithReason(QWidget* widget, QFocusEvent::Reason reason)
+void KexiUtils::setFocusWithReason(TQWidget* widget, TQFocusEvent::Reason reason)
{
- QEvent fe( QEvent::FocusIn );
- QFocusEvent::setReason(reason);
- QApplication::sendEvent( widget, &fe );
- QFocusEvent::resetReason();
+ TQEvent fe( TQEvent::FocusIn );
+ TQT_TQFOCUSEVENT(&fe)->setReason(reason);
+ TQApplication::sendEvent( widget, &fe );
+ TQT_TQFOCUSEVENT(&fe)->resetReason();
}
-void KexiUtils::unsetFocusWithReason(QWidget* widget, QFocusEvent::Reason reason)
+void KexiUtils::unsetFocusWithReason(TQWidget* widget, TQFocusEvent::Reason reason)
{
- QEvent fe( QEvent::FocusOut );
- QFocusEvent::setReason(reason);
- QApplication::sendEvent( widget, &fe );
- QFocusEvent::resetReason();
+ TQEvent fe( TQEvent::FocusOut );
+ TQT_TQFOCUSEVENT(&fe)->setReason(reason);
+ TQApplication::sendEvent( widget, &fe );
+ TQT_TQFOCUSEVENT(&fe)->resetReason();
}
-CopyFileResult KexiUtils::copyFile(const QString& src, const QString& dest)
+CopyFileResult KexiUtils::copyFile(const TQString& src, const TQString& dest)
{
-#ifdef Q_WS_WIN
- int res = fcopy( QFile::encodeName( src ), QFile::encodeName( dest ) );
+#ifdef TQ_WS_WIN
+ int res = fcopy( TQFile::encodeName( src ), TQFile::encodeName( dest ) );
if (res == fcopy_src_err)
return CopyReadError;
else if (res == fcopy_dest_err)
@@ -404,10 +404,10 @@ CopyFileResult KexiUtils::copyFile(const QString& src, const QString& dest)
int c_in=0, c_out=0;
CopyFileResult res=CopySuccess;
- in=fopen(QFile::encodeName( src ), "rb");
+ in=fopen(TQFile::encodeName( src ), "rb");
if (!in)
return CopyReadError;
- out=fopen(QFile::encodeName( dest ), "wb");
+ out=fopen(TQFile::encodeName( dest ), "wb");
if (!out)
return CopyWriteError;
while (!feof(in) && !ferror(in) && !ferror(out)) {