summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/namelineedit.cpp37
-rw-r--r--core/pim/addressbook/namelineedit.h3
2 files changed, 32 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 @@
5 5
6#include <qpe/config.h>
6 7
@@ -8,3 +9,4 @@ namespace ABOOK {
8NameLineEdit::NameLineEdit( QWidget* parent, const char* name ) 9NameLineEdit::NameLineEdit( QWidget* parent, const char* name )
9 : QLineEdit( parent, name ), m_prevSpace( true ) { 10 : QLineEdit( parent, name ), m_prevSpace( true ), m_disabled( false ) {
11 configReader();
10} 12}
@@ -13,3 +15,4 @@ NameLineEdit::NameLineEdit( const QString& str, QWidget* par,
13 const char* name ) 15 const char* name )
14 : QLineEdit( str, par, name ),m_prevSpace( true ) { 16 : QLineEdit( str, par, name ),m_prevSpace( true ), m_disabled( false ) {
17 configReader();
15} 18}
@@ -20,2 +23,9 @@ NameLineEdit::~NameLineEdit() {
20void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { 23void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
24
25 // If disabled: Push everything to the mother class..
26 if ( m_disabled ){
27 QLineEdit::keyPressEvent( ev );
28 return;
29 }
30
21 QString t = ev->text(); 31 QString t = ev->text();
@@ -28,3 +38,3 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
28 key != Key_Return && key != Key_Enter ) { 38 key != Key_Return && key != Key_Enter ) {
29 owarn << "str " << ev->text() << " " << m_prevSpace << oendl; 39 odebug << "str " << ev->text() << " " << m_prevSpace << oendl;
30 40
@@ -42,3 +52,3 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
42 if ( !nEv.isAccepted() ) 52 if ( !nEv.isAccepted() )
43 ev->ignore(); 53 ev->ignore();
44 }else { 54 }else {
@@ -50,6 +60,10 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
50 QString te = text(); 60 QString te = text();
51 /* if string is empty capitalize the first letter */ 61 odebug << "Backspace: " << te << oendl;
52 /* else see if we're at the end of the string */ 62 /* Capitalize first letter if a char is removed and:
53 if ( te.isEmpty() || cursorPosition() == te.length() ) 63 * 1. String is empty
54 m_prevSpace = true; 64 * 2. We are at the beginning of the line (pos 0)
65 * 3. The char left from current cursor position is a space !
66 */
67 if ( te.isEmpty() || ( cursorPosition() == 0 ) || ( te[cursorPosition() - 1] == Key_Space ) )
68 m_prevSpace = true;
55 } 69 }
@@ -58,2 +72,9 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
58 72
73void NameLineEdit::configReader() {
74 Config cfg("AddressBook");
75 cfg.setGroup("Editor");
76 m_disabled = cfg.readBoolEntry( "disableAutoCaps", false );
77}
78
79
59} 80}
diff --git a/core/pim/addressbook/namelineedit.h b/core/pim/addressbook/namelineedit.h
index c719579..7f0eda8 100644
--- a/core/pim/addressbook/namelineedit.h
+++ b/core/pim/addressbook/namelineedit.h
@@ -28,3 +28,6 @@ namespace ABOOK {
28 private: 28 private:
29 void configReader();
30
29 bool m_prevSpace : 1; 31 bool m_prevSpace : 1;
32 bool m_disabled : 1;
30 }; 33 };