summaryrefslogtreecommitdiff
path: root/core/pim
authoreilers <eilers>2004-07-18 13:54:18 (UTC)
committer eilers <eilers>2004-07-18 13:54:18 (UTC)
commitbb9c5344b397796ed424e3daddaf68e6c062c747 (patch) (unidiff)
tree13d2fc8da9b891c8d63c6d319177b7e8e868aaa3 /core/pim
parentb5e4ae2b7d5dfc371ed621242da4e019ede1b579 (diff)
downloadopie-bb9c5344b397796ed424e3daddaf68e6c062c747.zip
opie-bb9c5344b397796ed424e3daddaf68e6c062c747.tar.gz
opie-bb9c5344b397796ed424e3daddaf68e6c062c747.tar.bz2
Fixing Bug #1361
Diffstat (limited to 'core/pim') (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
@@ -3,21 +3,31 @@
3/* OPIE */ 3/* OPIE */
4#include <opie2/odebug.h> 4#include <opie2/odebug.h>
5 5
6#include <qpe/config.h>
6 7
7namespace ABOOK { 8namespace 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}
11 13
12NameLineEdit::NameLineEdit( const QString& str, QWidget* par, 14NameLineEdit::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}
16 19
17NameLineEdit::~NameLineEdit() { 20NameLineEdit::~NameLineEdit() {
18} 21}
19 22
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();
22 int key = ev->key(); 32 int key = ev->key();
23 int ascii = ev->ascii(); 33 int ascii = ev->ascii();
@@ -26,7 +36,7 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
26 if ( !t.isEmpty() && ( !ev->ascii() || ev->ascii()>=32 ) && 36 if ( !t.isEmpty() && ( !ev->ascii() || ev->ascii()>=32 ) &&
27 key != Key_Delete && key != Key_Backspace && 37 key != Key_Delete && key != Key_Backspace &&
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
31 if ( m_prevSpace ) { 41 if ( m_prevSpace ) {
32 t = t.upper(); 42 t = t.upper();
@@ -40,7 +50,7 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
40 t, ev->isAutoRepeat(), ev->count() ); 50 t, ev->isAutoRepeat(), ev->count() );
41 QLineEdit::keyPressEvent( &nEv ); 51 QLineEdit::keyPressEvent( &nEv );
42 if ( !nEv.isAccepted() ) 52 if ( !nEv.isAccepted() )
43 ev->ignore(); 53 ev->ignore();
44 }else { 54 }else {
45 QLineEdit::keyPressEvent( ev ); 55 QLineEdit::keyPressEvent( ev );
46 /* if key was a backspace lets see if we should 56 /* if key was a backspace lets see if we should
@@ -48,12 +58,23 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
48 */ 58 */
49 if ( key == Key_Backspace ) { 59 if ( key == Key_Backspace ) {
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 }
56 } 70 }
57} 71}
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
@@ -26,7 +26,10 @@ namespace ABOOK {
26 void keyPressEvent( QKeyEvent* ev ); 26 void keyPressEvent( QKeyEvent* ev );
27 27
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 };
31} 34}
32 35