-rw-r--r-- | core/pim/addressbook/addressbook.pro | 6 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 9 | ||||
-rw-r--r-- | core/pim/addressbook/namelineedit.cpp | 55 | ||||
-rw-r--r-- | core/pim/addressbook/namelineedit.h | 33 |
4 files changed, 97 insertions, 6 deletions
diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro index b27e4b8..bcfdb62 100644 --- a/core/pim/addressbook/addressbook.pro +++ b/core/pim/addressbook/addressbook.pro | |||
@@ -7,18 +7,20 @@ HEADERS = addressbook.h \ | |||
7 | picker.h \ | 7 | picker.h \ |
8 | ofloatbar.h \ | 8 | ofloatbar.h \ |
9 | configdlg.h \ | 9 | configdlg.h \ |
10 | abconfig.h \ | 10 | abconfig.h \ |
11 | abview.h | 11 | abview.h \ |
12 | namelineedit.h | ||
12 | SOURCES= main.cpp \ | 13 | SOURCES= main.cpp \ |
13 | addressbook.cpp \ | 14 | addressbook.cpp \ |
14 | contacteditor.cpp \ | 15 | contacteditor.cpp \ |
15 | ablabel.cpp \ | 16 | ablabel.cpp \ |
16 | abtable.cpp \ | 17 | abtable.cpp \ |
17 | picker.cpp \ | 18 | picker.cpp \ |
18 | configdlg.cpp \ | 19 | configdlg.cpp \ |
19 | abconfig.cpp \ | 20 | abconfig.cpp \ |
20 | abview.cpp | 21 | abview.cpp \ |
22 | namelineedit.cpp | ||
21 | 23 | ||
22 | INTERFACES= configdlg_base.ui | 24 | INTERFACES= configdlg_base.ui |
23 | TARGET = addressbook | 25 | TARGET = addressbook |
24 | INCLUDEPATH += $(OPIEDIR)/include | 26 | INCLUDEPATH += $(OPIEDIR)/include |
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 72c8bd3..9c13017 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -19,8 +19,9 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
23 | #include "namelineedit.h" | ||
23 | 24 | ||
24 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
25 | #include <opie2/opimcontact.h> | 26 | #include <opie2/opimcontact.h> |
26 | 27 | ||
@@ -140,9 +141,9 @@ void ContactEditor::init() { | |||
140 | 141 | ||
141 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); | 142 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); |
142 | QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); | 143 | QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); |
143 | gl->addWidget( btnFullName, 0, 0 ); | 144 | gl->addWidget( btnFullName, 0, 0 ); |
144 | txtFullName = new QLineEdit( container ); | 145 | txtFullName = new ABOOK::NameLineEdit( container ); |
145 | QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) ); | 146 | QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) ); |
146 | gl->addWidget( txtFullName, 0, 1 ); | 147 | gl->addWidget( txtFullName, 0, 1 ); |
147 | 148 | ||
148 | QLabel *l = new QLabel( tr( "Job Title" ), container ); | 149 | QLabel *l = new QLabel( tr( "Job Title" ), container ); |
@@ -612,19 +613,19 @@ void ContactEditor::init() { | |||
612 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); | 613 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); |
613 | 614 | ||
614 | l = new QLabel( tr("First Name"), dlgName ); | 615 | l = new QLabel( tr("First Name"), dlgName ); |
615 | gl->addWidget( l, 0, 0 ); | 616 | gl->addWidget( l, 0, 0 ); |
616 | txtFirstName = new QLineEdit( dlgName ); | 617 | txtFirstName = new ABOOK::NameLineEdit( dlgName ); |
617 | gl->addWidget( txtFirstName, 0, 1 ); | 618 | gl->addWidget( txtFirstName, 0, 1 ); |
618 | 619 | ||
619 | l = new QLabel( tr("Middle Name"), dlgName ); | 620 | l = new QLabel( tr("Middle Name"), dlgName ); |
620 | gl->addWidget( l, 1, 0 ); | 621 | gl->addWidget( l, 1, 0 ); |
621 | txtMiddleName = new QLineEdit( dlgName ); | 622 | txtMiddleName = new ABOOK::NameLineEdit( dlgName ); |
622 | gl->addWidget( txtMiddleName, 1, 1 ); | 623 | gl->addWidget( txtMiddleName, 1, 1 ); |
623 | 624 | ||
624 | l = new QLabel( tr("Last Name"), dlgName ); | 625 | l = new QLabel( tr("Last Name"), dlgName ); |
625 | gl->addWidget( l, 2, 0 ); | 626 | gl->addWidget( l, 2, 0 ); |
626 | txtLastName = new QLineEdit( dlgName ); | 627 | txtLastName = new ABOOK::NameLineEdit( dlgName ); |
627 | gl->addWidget( txtLastName, 2, 1 ); | 628 | gl->addWidget( txtLastName, 2, 1 ); |
628 | 629 | ||
629 | // l = new QLabel( tr("Suffix"), dlgName ); | 630 | // l = new QLabel( tr("Suffix"), dlgName ); |
630 | // gl->addWidget( l, 3, 0 ); | 631 | // gl->addWidget( l, 3, 0 ); |
diff --git a/core/pim/addressbook/namelineedit.cpp b/core/pim/addressbook/namelineedit.cpp new file mode 100644 index 0000000..ba16e2c --- a/dev/null +++ b/core/pim/addressbook/namelineedit.cpp | |||
@@ -0,0 +1,55 @@ | |||
1 | #include "namelineedit.h" | ||
2 | |||
3 | namespace ABOOK { | ||
4 | NameLineEdit::NameLineEdit( QWidget* parent, const char* name ) | ||
5 | : QLineEdit( parent, name ), m_prevSpace( true ) { | ||
6 | } | ||
7 | |||
8 | NameLineEdit::NameLineEdit( const QString& str, QWidget* par, | ||
9 | const char* name ) | ||
10 | : QLineEdit( str, par, name ),m_prevSpace( true ) { | ||
11 | } | ||
12 | |||
13 | NameLineEdit::~NameLineEdit() { | ||
14 | } | ||
15 | |||
16 | void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { | ||
17 | QString t = ev->text(); | ||
18 | int key = ev->key(); | ||
19 | int ascii = ev->ascii(); | ||
20 | |||
21 | // ### FIXME with composed events | ||
22 | if ( !t.isEmpty() && ( !ev->ascii() || ev->ascii()>=32 ) && | ||
23 | key != Key_Delete && key != Key_Backspace && | ||
24 | key != Key_Return && key != Key_Enter ) { | ||
25 | qWarning( "str " + ev->text() + " %d", m_prevSpace ); | ||
26 | |||
27 | if ( m_prevSpace ) { | ||
28 | t = t.upper(); | ||
29 | m_prevSpace = false; | ||
30 | } | ||
31 | if ( key == Key_Space ) | ||
32 | m_prevSpace = true; | ||
33 | |||
34 | |||
35 | QKeyEvent nEv(ev->type(), key, ascii, ev->state(), | ||
36 | t, ev->isAutoRepeat(), ev->count() ); | ||
37 | QLineEdit::keyPressEvent( &nEv ); | ||
38 | if ( !nEv.isAccepted() ) | ||
39 | ev->ignore(); | ||
40 | }else { | ||
41 | QLineEdit::keyPressEvent( ev ); | ||
42 | /* if key was a backspace lets see if we should | ||
43 | * capitalize the next letter | ||
44 | */ | ||
45 | if ( key == Key_Backspace ) { | ||
46 | QString te = text(); | ||
47 | /* if string is empty capitalize the first letter */ | ||
48 | /* else see if we're at the end of the string */ | ||
49 | if ( te.isEmpty() || cursorPosition() == te.length() ) | ||
50 | m_prevSpace = true; | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | |||
55 | } | ||
diff --git a/core/pim/addressbook/namelineedit.h b/core/pim/addressbook/namelineedit.h new file mode 100644 index 0000000..c719579 --- a/dev/null +++ b/core/pim/addressbook/namelineedit.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * (C) 2004 | ||
3 | * GPLv2 zecke@handhelds.org | ||
4 | * | ||
5 | */ | ||
6 | |||
7 | #ifndef ABOOK_NAME_LINE_EDIT | ||
8 | #define ABOOK_NAME_LINE_EDIT | ||
9 | |||
10 | #include <qlineedit.h> | ||
11 | |||
12 | namespace ABOOK { | ||
13 | /** | ||
14 | * small class to ease the input of names to capitalize them | ||
15 | * | ||
16 | */ | ||
17 | class NameLineEdit : public QLineEdit { | ||
18 | Q_OBJECT | ||
19 | public: | ||
20 | NameLineEdit( QWidget* parent, const char* name = 0 ); | ||
21 | NameLineEdit( const QString& str, QWidget* par, | ||
22 | const char *name = 0); | ||
23 | ~NameLineEdit(); | ||
24 | |||
25 | protected: | ||
26 | void keyPressEvent( QKeyEvent* ev ); | ||
27 | |||
28 | private: | ||
29 | bool m_prevSpace : 1; | ||
30 | }; | ||
31 | } | ||
32 | |||
33 | #endif | ||