summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -3,21 +3,31 @@
/* OPIE */
#include <opie2/odebug.h>
+#include <qpe/config.h>
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();
}
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();
}
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();
int key = ev->key();
int ascii = ev->ascii();
@@ -26,7 +36,7 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
if ( !t.isEmpty() && ( !ev->ascii() || ev->ascii()>=32 ) &&
key != Key_Delete && key != Key_Backspace &&
key != Key_Return && key != Key_Enter ) {
- owarn << "str " << ev->text() << " " << m_prevSpace << oendl;
+ odebug << "str " << ev->text() << " " << m_prevSpace << oendl;
if ( m_prevSpace ) {
t = t.upper();
@@ -40,7 +50,7 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
t, ev->isAutoRepeat(), ev->count() );
QLineEdit::keyPressEvent( &nEv );
if ( !nEv.isAccepted() )
- ev->ignore();
+ ev->ignore();
}else {
QLineEdit::keyPressEvent( ev );
/* if key was a backspace lets see if we should
@@ -48,12 +58,23 @@ void NameLineEdit::keyPressEvent( QKeyEvent* ev ) {
*/
if ( key == Key_Backspace ) {
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;
}
}
}
+void NameLineEdit::configReader() {
+ Config cfg("AddressBook");
+ cfg.setGroup("Editor");
+ m_disabled = cfg.readBoolEntry( "disableAutoCaps", false );
+}
+
+
}
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 {
void keyPressEvent( QKeyEvent* ev );
private:
+ void configReader();
+
bool m_prevSpace : 1;
+ bool m_disabled : 1;
};
}