author | eilers <eilers> | 2004-07-18 13:54:18 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-07-18 13:54:18 (UTC) |
commit | bb9c5344b397796ed424e3daddaf68e6c062c747 (patch) (side-by-side diff) | |
tree | 13d2fc8da9b891c8d63c6d319177b7e8e868aaa3 /core/pim/addressbook/namelineedit.cpp | |
parent | b5e4ae2b7d5dfc371ed621242da4e019ede1b579 (diff) | |
download | opie-bb9c5344b397796ed424e3daddaf68e6c062c747.zip opie-bb9c5344b397796ed424e3daddaf68e6c062c747.tar.gz opie-bb9c5344b397796ed424e3daddaf68e6c062c747.tar.bz2 |
Fixing Bug #1361
Diffstat (limited to 'core/pim/addressbook/namelineedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/namelineedit.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/core/pim/addressbook/namelineedit.cpp b/core/pim/addressbook/namelineedit.cpp index 81b959b..5c6c0b9 100644 --- a/core/pim/addressbook/namelineedit.cpp +++ b/core/pim/addressbook/namelineedit.cpp @@ -5,2 +5,3 @@ +#include <qpe/config.h> @@ -8,3 +9,4 @@ namespace ABOOK { NameLineEdit::NameLineEdit( QWidget* parent, const char* name ) - : QLineEdit( parent, name ), m_prevSpace( true ) { + : QLineEdit( parent, name ), m_prevSpace( true ), m_disabled( false ) { + configReader(); } @@ -13,3 +15,4 @@ NameLineEdit::NameLineEdit( const QString& str, QWidget* par, const char* name ) - : QLineEdit( str, par, name ),m_prevSpace( true ) { + : QLineEdit( str, par, name ),m_prevSpace( true ), m_disabled( false ) { + configReader(); } @@ -20,2 +23,9 @@ NameLineEdit::~NameLineEdit() { void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { + + // If disabled: Push everything to the mother class.. + if ( m_disabled ){ + QLineEdit::keyPressEvent( ev ); + return; + } + QString t = ev->text(); @@ -28,3 +38,3 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { key != Key_Return && key != Key_Enter ) { - owarn << "str " << ev->text() << " " << m_prevSpace << oendl; + odebug << "str " << ev->text() << " " << m_prevSpace << oendl; @@ -42,3 +52,3 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { if ( !nEv.isAccepted() ) - ev->ignore(); + ev->ignore(); }else { @@ -50,6 +60,10 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { QString te = text(); - /* if string is empty capitalize the first letter */ - /* else see if we're at the end of the string */ - if ( te.isEmpty() || cursorPosition() == te.length() ) - m_prevSpace = true; + odebug << "Backspace: " << te << oendl; + /* Capitalize first letter if a char is removed and: + * 1. String is empty + * 2. We are at the beginning of the line (pos 0) + * 3. The char left from current cursor position is a space ! + */ + if ( te.isEmpty() || ( cursorPosition() == 0 ) || ( te[cursorPosition() - 1] == Key_Space ) ) + m_prevSpace = true; } @@ -58,2 +72,9 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { +void NameLineEdit::configReader() { + Config cfg("AddressBook"); + cfg.setGroup("Editor"); + m_disabled = cfg.readBoolEntry( "disableAutoCaps", false ); +} + + } |