diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-03-21 16:21:25 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-03-21 16:21:25 -0500 |
commit | f5b03149e8e68e510efe9842d85a058b42a51264 (patch) | |
tree | 49c476a64e7377ecf25a949a9116fc7bf89c4cf5 /src/widgets/qlineedit.cpp | |
parent | 1b0a52a0c1285bf6237aac3fbd99eaebeca5663a (diff) | |
download | tqt3-f5b03149e8e68e510efe9842d85a058b42a51264.tar.gz tqt3-f5b03149e8e68e510efe9842d85a058b42a51264.zip |
Automated update from Qt3
Diffstat (limited to 'src/widgets/qlineedit.cpp')
-rw-r--r-- | src/widgets/qlineedit.cpp | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/widgets/qlineedit.cpp b/src/widgets/qlineedit.cpp index 3ba828c18..2cc64e017 100644 --- a/src/widgets/qlineedit.cpp +++ b/src/widgets/qlineedit.cpp @@ -63,6 +63,9 @@ #include "../kernel/qinternal_p.h" #include "private/qtextlayout_p.h" #include "ntqvaluevector.h" +#if defined(Q_OS_LINUX) +#include <sys/mman.h> +#endif #if defined(QT_ACCESSIBILITY_SUPPORT) #include "ntqaccessible.h" #endif @@ -74,6 +77,11 @@ #define ACCEL_KEY(k) "\t" + TQString("Ctrl+" #k) #endif +#if defined(Q_OS_LINUX) +#define LINUX_MEMLOCK_LIMIT_BYTES 16384 +#define LINUX_MEMLOCK_LIMIT_CHARACTERS LINUX_MEMLOCK_LIMIT_BYTES/sizeof(TQChar) +#endif + #define innerMargin 1 struct TQLineEditPrivate : public TQt @@ -451,6 +459,10 @@ TQLineEdit::TQLineEdit( const TQString& contents, const TQString &inputMask, TQW TQLineEdit::~TQLineEdit() { + if ((d->echoMode == NoEcho) || (d->echoMode == Password) || (d->echoMode == PasswordThreeStars)) { + d->text.fill(TQChar(0)); + munlock(d->text.d->unicode, LINUX_MEMLOCK_LIMIT_BYTES); + } delete [] d->maskData; delete d; } @@ -500,11 +512,16 @@ void TQLineEdit::setText( const TQString& text) TQString TQLineEdit::displayText() const { - if ( d->echoMode == NoEcho ) + if ( d->echoMode == NoEcho ) { return TQString::fromLatin1(""); + } TQString res = d->text; - if ( d->echoMode == Password ) + if ( d->echoMode == Password ) { res.fill( passwordChar() ); + } + else if ( d->echoMode == PasswordThreeStars ) { + res.fill( passwordChar(), res.length()*3 ); + } return ( res.isNull() ? TQString::fromLatin1("") : res ); } @@ -598,11 +615,26 @@ TQLineEdit::EchoMode TQLineEdit::echoMode() const void TQLineEdit::setEchoMode( EchoMode mode ) { - if (mode == (EchoMode)d->echoMode) + if (mode == (EchoMode)d->echoMode) { return; + } +#if defined(Q_OS_LINUX) + if (((mode == NoEcho) || (mode == Password) || (mode == PasswordThreeStars)) && ((EchoMode)d->echoMode == Normal)) { + if ((uint)d->maxLength > (LINUX_MEMLOCK_LIMIT_CHARACTERS-1)) { + d->maxLength = LINUX_MEMLOCK_LIMIT_CHARACTERS-1; + } + d->text.reserve(LINUX_MEMLOCK_LIMIT_CHARACTERS); + mlock(d->text.d->unicode, LINUX_MEMLOCK_LIMIT_BYTES); + d->text.setSecurityUnPaged(true); + } + else { + d->text.setSecurityUnPaged(false); + munlock(d->text.d->unicode, LINUX_MEMLOCK_LIMIT_BYTES); + } +#endif d->echoMode = mode; d->updateTextLayout(); - setInputMethodEnabled( mode == Normal ); + setInputMethodEnabled( ( mode == Normal ) || ( mode == Password) ); update(); } @@ -1688,12 +1720,12 @@ void TQLineEdit::keyPressEvent( TQKeyEvent * e ) case Key_Right: case Key_Left: if ( d->isRightToLeft() == (e->key() == Key_Right) ) { - if ( echoMode() == Normal ) + if (( echoMode() == Normal ) || ( echoMode() == Password )) cursorWordBackward( e->state() & ShiftButton ); else home( e->state() & ShiftButton ); } else { - if ( echoMode() == Normal ) + if (( echoMode() == Normal ) || ( echoMode() == Password )) cursorWordForward( e->state() & ShiftButton ); else end( e->state() & ShiftButton ); @@ -2069,7 +2101,7 @@ void TQLineEdit::drawContents( TQPainter *p ) // Asian users regard IM selection text as cursor on candidate // selection phase of input method, so ordinary cursor should be // invisible if IM selection text exists. - if ( d->cursorVisible && !supressCursor && !d->hasIMSelection() ) { + if ( d->cursorVisible && !supressCursor && !d->hasIMSelection() && (d->echoMode != PasswordThreeStars) ) { TQPoint from( topLeft.x() + cix, lineRect.top() ); TQPoint to = from + TQPoint( 0, lineRect.height() ); p->drawLine( from, to ); |