summaryrefslogtreecommitdiff
Unidiff
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
@@ -1,54 +1,55 @@
1/* 1/*
2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> 2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
3 * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) 3 * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
4 * 4 *
5 * This file is an add-on for the OPIE Palmtop Environment 5 * This file is an add-on for the OPIE Palmtop Environment
6 * 6 *
7 * This file may be distributed and/or modified under the terms of the 7 * This file may be distributed and/or modified under the terms of the
8 * GNU General Public License version 2 as published by the Free Software 8 * GNU General Public License version 2 as published by the Free Software
9 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging 9 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
10 * of this file. 10 * of this file.
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>
35#include <qlineedit.h> 36#include <qlineedit.h>
36#include <qmultilineedit.h> 37#include <qmultilineedit.h>
37#include <qtoolbutton.h> 38#include <qtoolbutton.h>
38#include <qlistbox.h> 39#include <qlistbox.h>
39#include <qmessagebox.h> 40#include <qmessagebox.h>
40#include <qwhatsthis.h> 41#include <qwhatsthis.h>
41 42
42#include <assert.h> 43#include <assert.h>
43 44
44static inline bool containsAlphaNum( const QString &str ); 45static inline bool containsAlphaNum( const QString &str );
45static inline bool constainsWhiteSpace( const QString &str ); 46static inline bool constainsWhiteSpace( const QString &str );
46 47
47// helper functions, convert our comma delimited list to proper 48// helper functions, convert our comma delimited list to proper
48// file format... 49// file format...
49void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 50void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
50 QString &strAll ); 51 QString &strAll );
51 52
52// helper convert from file format to comma delimited... 53// helper convert from file format to comma delimited...
53void parseEmailTo( const QString &strDefaultEmail, 54void parseEmailTo( const QString &strDefaultEmail,
54 const QString &strOtherEmail, QString &strBack ); 55 const QString &strOtherEmail, QString &strBack );
@@ -112,65 +113,65 @@ void ContactEditor::init() {
112 assert( slDynamicEntries.count() == trlDynamicEntries.count() ); 113 assert( slDynamicEntries.count() == trlDynamicEntries.count() );
113 assert( slChooserNames.count() == trlChooserNames.count() ); 114 assert( slChooserNames.count() == trlChooserNames.count() );
114 115
115 for (i = 0; i < slChooserNames.count(); i++) 116 for (i = 0; i < slChooserNames.count(); i++)
116 slChooserValues.append(""); 117 slChooserValues.append("");
117 118
118 119
119 QVBoxLayout *vb = new QVBoxLayout( this ); 120 QVBoxLayout *vb = new QVBoxLayout( this );
120 121
121 tabMain = new QTabWidget( this ); 122 tabMain = new QTabWidget( this );
122 vb->addWidget( tabMain ); 123 vb->addWidget( tabMain );
123 124
124 QWidget *tabViewport = new QWidget ( tabMain ); 125 QWidget *tabViewport = new QWidget ( tabMain );
125 126
126 vb = new QVBoxLayout( tabViewport ); 127 vb = new QVBoxLayout( tabViewport );
127 128
128 svGeneral = new QScrollView( tabViewport ); 129 svGeneral = new QScrollView( tabViewport );
129 vb->addWidget( svGeneral, 0, 0 ); 130 vb->addWidget( svGeneral, 0, 0 );
130 svGeneral->setResizePolicy( QScrollView::AutoOneFit ); 131 svGeneral->setResizePolicy( QScrollView::AutoOneFit );
131 // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); 132 // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff );
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.\".." ) );
157 gl->addWidget( l, 2, 0 ); 158 gl->addWidget( l, 2, 0 );
158 txtSuffix = new QLineEdit( container ); 159 txtSuffix = new QLineEdit( container );
159 QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) ); 160 QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) );
160 gl->addWidget( txtSuffix, 2, 1 ); 161 gl->addWidget( txtSuffix, 2, 1 );
161 162
162 l = new QLabel( tr( "Organization" ), container ); 163 l = new QLabel( tr( "Organization" ), container );
163 QWhatsThis::add( l, tr( "The working place of the contact" ) ); 164 QWhatsThis::add( l, tr( "The working place of the contact" ) );
164 gl->addWidget( l, 3, 0 ); 165 gl->addWidget( l, 3, 0 );
165 txtOrganization = new QLineEdit( container ); 166 txtOrganization = new QLineEdit( container );
166 QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); 167 QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) );
167 gl->addWidget( txtOrganization, 3, 1 ); 168 gl->addWidget( txtOrganization, 3, 1 );
168 169
169 // Chooser 1 170 // Chooser 1
170 cmbChooserField1 = new QComboBox( FALSE, container ); 171 cmbChooserField1 = new QComboBox( FALSE, container );
171 QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); 172 QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) );
172 cmbChooserField1->setMaximumWidth( 90 ); 173 cmbChooserField1->setMaximumWidth( 90 );
173 gl->addWidget( cmbChooserField1, 4, 0 ); 174 gl->addWidget( cmbChooserField1, 4, 0 );
174 // Textfield for chooser 1. 175 // Textfield for chooser 1.
175 // Now use Widgetstack to contain the textfield and the default-email combo ! 176 // Now use Widgetstack to contain the textfield and the default-email combo !
176 m_widgetStack1 = new QWidgetStack( container ); 177 m_widgetStack1 = new QWidgetStack( container );
@@ -584,75 +585,75 @@ void ContactEditor::init() {
584 QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields(); 585 QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields();
585 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { 586 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) {
586 587
587 if (((*it) == "Anniversary") || 588 if (((*it) == "Anniversary") ||
588 ((*it) == "Birthday")|| ((*it) == "Gender")) continue; 589 ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
589 590
590 l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); 591 l = new QLabel( mapIdToStr[mapStrToID[*it]], container );
591 listName.append( l ); 592 listName.append( l );
592 gl->addWidget( l, i, 0 ); 593 gl->addWidget( l, i, 0 );
593 QLineEdit *e = new QLineEdit( container ); 594 QLineEdit *e = new QLineEdit( container );
594 listValue.append( e ); 595 listValue.append( e );
595 gl->addWidget( e, i, 1); 596 gl->addWidget( e, i, 1);
596 } 597 }
597 // Fill labels with names.. 598 // Fill labels with names..
598 //loadFields(); 599 //loadFields();
599 600
600 601
601 tabMain->insertTab( tabViewport, tr( "Details" ) ); 602 tabMain->insertTab( tabViewport, tr( "Details" ) );
602 603
603 dlgNote = new QDialog( this, "Note Dialog", TRUE ); 604 dlgNote = new QDialog( this, "Note Dialog", TRUE );
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 );
639 cmbChooserField2->insertStringList( trlChooserNames ); 640 cmbChooserField2->insertStringList( trlChooserNames );
640 cmbChooserField3->insertStringList( trlChooserNames ); 641 cmbChooserField3->insertStringList( trlChooserNames );
641 cmbChooserField4->insertStringList( trlChooserNames ); 642 cmbChooserField4->insertStringList( trlChooserNames );
642 643
643 cmbChooserField1->setCurrentItem( 0 ); 644 cmbChooserField1->setCurrentItem( 0 );
644 cmbChooserField2->setCurrentItem( 1 ); 645 cmbChooserField2->setCurrentItem( 1 );
645 cmbChooserField3->setCurrentItem( 2 ); 646 cmbChooserField3->setCurrentItem( 2 );
646 647
647 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 648 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
648 649
649 connect( txtFullName, SIGNAL(textChanged(const QString&)), 650 connect( txtFullName, SIGNAL(textChanged(const QString&)),
650 this, SLOT(slotFullNameChange(const QString&)) ); 651 this, SLOT(slotFullNameChange(const QString&)) );
651 connect( txtSuffix, SIGNAL(textChanged(const QString&)), 652 connect( txtSuffix, SIGNAL(textChanged(const QString&)),
652 this, SLOT(slotSuffixChange(const QString&)) ); 653 this, SLOT(slotSuffixChange(const QString&)) );
653 connect( txtOrganization, SIGNAL(textChanged(const QString&)), 654 connect( txtOrganization, SIGNAL(textChanged(const QString&)),
654 this, SLOT(slotOrganizationChange(const QString&)) ); 655 this, SLOT(slotOrganizationChange(const QString&)) );
655 connect( txtChooserField1, SIGNAL(textChanged(const QString&)), 656 connect( txtChooserField1, SIGNAL(textChanged(const QString&)),
656 this, SLOT(slotChooser1Change(const QString&)) ); 657 this, SLOT(slotChooser1Change(const QString&)) );
657 connect( txtChooserField2, SIGNAL(textChanged(const QString&)), 658 connect( txtChooserField2, SIGNAL(textChanged(const QString&)),
658 this, SLOT(slotChooser2Change(const QString&)) ); 659 this, SLOT(slotChooser2Change(const QString&)) );
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