summaryrefslogtreecommitdiff
authorzecke <zecke>2004-05-01 17:21:57 (UTC)
committer zecke <zecke>2004-05-01 17:21:57 (UTC)
commit8dd2d693000c916346f0bb7d94cbc02b8456c65b (patch) (unidiff)
tree4246b70152d010a8c0e3e7d5268e462f8630be82
parentfd2bbf9a09aa7a13bd8a43db351b9153e5a4b7ab (diff)
downloadopie-8dd2d693000c916346f0bb7d94cbc02b8456c65b.zip
opie-8dd2d693000c916346f0bb7d94cbc02b8456c65b.tar.gz
opie-8dd2d693000c916346f0bb7d94cbc02b8456c65b.tar.bz2
A new LineEdit to assis entering names.
so holger hans peter freyther will get Holger Hans Peter Freyther on the fly but you can also change the letter later...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.pro6
-rw-r--r--core/pim/addressbook/contacteditor.cpp9
-rw-r--r--core/pim/addressbook/namelineedit.cpp55
-rw-r--r--core/pim/addressbook/namelineedit.h33
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
@@ -1,28 +1,30 @@
1 #CONFIG = qt warn_on quick-app 1 #CONFIG = qt warn_on quick-app
2 CONFIG = qt warn_on quick-app 2 CONFIG = qt warn_on quick-app
3 HEADERS= addressbook.h \ 3 HEADERS= addressbook.h \
4 contacteditor.h \ 4 contacteditor.h \
5 ablabel.h \ 5 ablabel.h \
6 abtable.h \ 6 abtable.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
24INCLUDEPATH += $(OPIEDIR)/include 26INCLUDEPATH += $(OPIEDIR)/include
25 DEPENDPATH+= $(OPIEDIR)/include 27 DEPENDPATH+= $(OPIEDIR)/include
26LIBS += -lqpe -lopiecore2 -lopieui2 -lopiepim2 28LIBS += -lqpe -lopiecore2 -lopieui2 -lopiepim2
27 29
28include ( $(OPIEDIR)/include.pro ) 30include ( $(OPIEDIR)/include.pro )
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
@@ -11,24 +11,25 @@
11 * 11 *
12 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 * 14 *
15 * 15 *
16 * This is a rewrite of the abeditor.h file, modified to provide a more 16 * This is a rewrite of the abeditor.h file, modified to provide a more
17 * intuitive interface to TrollTech's original Address Book editor. This 17 * intuitive interface to TrollTech's original Address Book editor. This
18 * is made to operate exactly in interface with the exception of name. 18 * is made to operate exactly in interface with the exception of name.
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
27#include <qpe/categoryselect.h> 28#include <qpe/categoryselect.h>
28#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
29#include <qpe/qpedialog.h> 30#include <qpe/qpedialog.h>
30#include <qpe/resource.h> 31#include <qpe/resource.h>
31 32
32#include <qlabel.h> 33#include <qlabel.h>
33#include <qtabwidget.h> 34#include <qtabwidget.h>
34#include <qlayout.h> 35#include <qlayout.h>
@@ -132,25 +133,25 @@ void ContactEditor::init() {
132 // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); 133 // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff );
133 svGeneral->setFrameStyle( QFrame::NoFrame ); 134 svGeneral->setFrameStyle( QFrame::NoFrame );
134 135
135 QWidget *container = new QWidget( svGeneral->viewport() ); 136 QWidget *container = new QWidget( svGeneral->viewport() );
136 svGeneral->addChild( container ); 137 svGeneral->addChild( container );
137 138
138 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); 139 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 );
139 gl->setResizeMode( QLayout::FreeResize ); 140 gl->setResizeMode( QLayout::FreeResize );
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 );
149 QWhatsThis::add( l, tr( "The jobtitle.." ) ); 150 QWhatsThis::add( l, tr( "The jobtitle.." ) );
150 gl->addWidget( l, 1, 0 ); 151 gl->addWidget( l, 1, 0 );
151 txtJobTitle = new QLineEdit( container ); 152 txtJobTitle = new QLineEdit( container );
152 QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) ); 153 QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) );
153 gl->addWidget( txtJobTitle, 1, 1 ); 154 gl->addWidget( txtJobTitle, 1, 1 );
154 155
155 l = new QLabel( tr("Suffix"), container ); 156 l = new QLabel( tr("Suffix"), container );
156 QWhatsThis::add( l, tr( "Something like \"jr.\".." ) ); 157 QWhatsThis::add( l, tr( "Something like \"jr.\".." ) );
@@ -604,35 +605,35 @@ void ContactEditor::init() {
604 dlgNote->setCaption( tr("Enter Note") ); 605 dlgNote->setCaption( tr("Enter Note") );
605 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); 606 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
606 txtNote = new QMultiLineEdit( dlgNote ); 607 txtNote = new QMultiLineEdit( dlgNote );
607 vbNote->addWidget( txtNote ); 608 vbNote->addWidget( txtNote );
608 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); 609 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
609 610
610 dlgName = new QDialog( this, "Name Dialog", TRUE ); 611 dlgName = new QDialog( this, "Name Dialog", TRUE );
611 dlgName->setCaption( tr("Edit Name") ); 612 dlgName->setCaption( tr("Edit Name") );
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 );
631 // txtSuffix = new QLineEdit( dlgName ); 632 // txtSuffix = new QLineEdit( dlgName );
632 // gl->addWidget( txtSuffix, 3, 1 ); 633 // gl->addWidget( txtSuffix, 3, 1 );
633 space = new QSpacerItem(1,1, 634 space = new QSpacerItem(1,1,
634 QSizePolicy::Maximum, 635 QSizePolicy::Maximum,
635 QSizePolicy::MinimumExpanding ); 636 QSizePolicy::MinimumExpanding );
636 gl->addItem( space, 4, 0 ); 637 gl->addItem( space, 4, 0 );
637 638
638 cmbChooserField1->insertStringList( trlChooserNames ); 639 cmbChooserField1->insertStringList( trlChooserNames );
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
3namespace ABOOK {
4NameLineEdit::NameLineEdit( QWidget* parent, const char* name )
5 : QLineEdit( parent, name ), m_prevSpace( true ) {
6}
7
8NameLineEdit::NameLineEdit( const QString& str, QWidget* par,
9 const char* name )
10 : QLineEdit( str, par, name ),m_prevSpace( true ) {
11}
12
13NameLineEdit::~NameLineEdit() {
14}
15
16void 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
12namespace 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