author | zecke <zecke> | 2004-05-01 17:21:57 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-05-01 17:21:57 (UTC) |
commit | 8dd2d693000c916346f0bb7d94cbc02b8456c65b (patch) (unidiff) | |
tree | 4246b70152d010a8c0e3e7d5268e462f8630be82 | |
parent | fd2bbf9a09aa7a13bd8a43db351b9153e5a4b7ab (diff) | |
download | opie-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...
-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 | |||
@@ -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 |
24 | INCLUDEPATH += $(OPIEDIR)/include | 26 | INCLUDEPATH += $(OPIEDIR)/include |
25 | DEPENDPATH+= $(OPIEDIR)/include | 27 | DEPENDPATH+= $(OPIEDIR)/include |
26 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopiepim2 | 28 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopiepim2 |
27 | 29 | ||
28 | include ( $(OPIEDIR)/include.pro ) | 30 | include ( $(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,208 +1,209 @@ | |||
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 | ||
44 | static inline bool containsAlphaNum( const QString &str ); | 45 | static inline bool containsAlphaNum( const QString &str ); |
45 | static inline bool constainsWhiteSpace( const QString &str ); | 46 | static 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... |
49 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 50 | void 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... |
53 | void parseEmailTo( const QString &strDefaultEmail, | 54 | void parseEmailTo( const QString &strDefaultEmail, |
54 | const QString &strOtherEmail, QString &strBack ); | 55 | const QString &strOtherEmail, QString &strBack ); |
55 | 56 | ||
56 | ContactEditor::ContactEditor(const Opie::OPimContact &entry, | 57 | ContactEditor::ContactEditor(const Opie::OPimContact &entry, |
57 | QWidget *parent, | 58 | QWidget *parent, |
58 | const char *name, | 59 | const char *name, |
59 | WFlags ) | 60 | WFlags ) |
60 | : QDialog( parent, name, TRUE, WStyle_ContextHelp ), | 61 | : QDialog( parent, name, TRUE, WStyle_ContextHelp ), |
61 | defaultEmailChooserPosition( -1 ), | 62 | defaultEmailChooserPosition( -1 ), |
62 | m_personalView ( false ), | 63 | m_personalView ( false ), |
63 | cmbDefaultEmail( 0 ), | 64 | cmbDefaultEmail( 0 ), |
64 | initializing ( false ) | 65 | initializing ( false ) |
65 | { | 66 | { |
66 | 67 | ||
67 | initializing = true; | 68 | initializing = true; |
68 | 69 | ||
69 | init(); | 70 | init(); |
70 | setEntry( entry ); | 71 | setEntry( entry ); |
71 | // cmbDefaultEmail = 0; | 72 | // cmbDefaultEmail = 0; |
72 | // defaultEmailChooserPosition = -1; | 73 | // defaultEmailChooserPosition = -1; |
73 | 74 | ||
74 | initializing = false; | 75 | initializing = false; |
75 | } | 76 | } |
76 | 77 | ||
77 | ContactEditor::~ContactEditor() { | 78 | ContactEditor::~ContactEditor() { |
78 | } | 79 | } |
79 | 80 | ||
80 | void ContactEditor::init() { | 81 | void ContactEditor::init() { |
81 | owarn << "init() START" << oendl; | 82 | owarn << "init() START" << oendl; |
82 | 83 | ||
83 | uint i = 0; | 84 | uint i = 0; |
84 | 85 | ||
85 | QStringList trlChooserNames; | 86 | QStringList trlChooserNames; |
86 | 87 | ||
87 | for (i = 0; i <= 6; i++) { | 88 | for (i = 0; i <= 6; i++) { |
88 | slHomeAddress.append( "" ); | 89 | slHomeAddress.append( "" ); |
89 | slBusinessAddress.append( "" ); | 90 | slBusinessAddress.append( "" ); |
90 | } | 91 | } |
91 | 92 | ||
92 | trlChooserNames = Opie::OPimContactFields::trphonefields( false ); | 93 | trlChooserNames = Opie::OPimContactFields::trphonefields( false ); |
93 | slChooserNames = Opie::OPimContactFields::untrphonefields( false ); | 94 | slChooserNames = Opie::OPimContactFields::untrphonefields( false ); |
94 | slDynamicEntries = Opie::OPimContactFields::untrdetailsfields( false ); | 95 | slDynamicEntries = Opie::OPimContactFields::untrdetailsfields( false ); |
95 | trlDynamicEntries = Opie::OPimContactFields::trdetailsfields( false ); | 96 | trlDynamicEntries = Opie::OPimContactFields::trdetailsfields( false ); |
96 | 97 | ||
97 | // Ok, we have to remove elements from the list of dynamic entries | 98 | // Ok, we have to remove elements from the list of dynamic entries |
98 | // which are now stored in special (not dynamic) widgets.. | 99 | // which are now stored in special (not dynamic) widgets.. |
99 | // Otherwise we will get problems with field assignments! (se) | 100 | // Otherwise we will get problems with field assignments! (se) |
100 | slDynamicEntries.remove("Anniversary"); | 101 | slDynamicEntries.remove("Anniversary"); |
101 | slDynamicEntries.remove("Birthday"); | 102 | slDynamicEntries.remove("Birthday"); |
102 | slDynamicEntries.remove("Gender"); | 103 | slDynamicEntries.remove("Gender"); |
103 | 104 | ||
104 | // The same with translated fields.. But I will | 105 | // The same with translated fields.. But I will |
105 | // use the translation map to avoid mismatches.. | 106 | // use the translation map to avoid mismatches.. |
106 | QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields(); | 107 | QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields(); |
107 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); | 108 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); |
108 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); | 109 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); |
109 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); | 110 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); |
110 | 111 | ||
111 | // Last Check to be sure.. | 112 | // Last Check to be sure.. |
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 ); |
177 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); | 178 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); |
178 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); | 179 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); |
179 | gl->addWidget( m_widgetStack1, 4, 1 ); | 180 | gl->addWidget( m_widgetStack1, 4, 1 ); |
180 | m_widgetStack1 -> raiseWidget( TextField ); | 181 | m_widgetStack1 -> raiseWidget( TextField ); |
181 | 182 | ||
182 | // Chooser 2 | 183 | // Chooser 2 |
183 | cmbChooserField2 = new QComboBox( FALSE, container ); | 184 | cmbChooserField2 = new QComboBox( FALSE, container ); |
184 | QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); | 185 | QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); |
185 | cmbChooserField2->setMaximumWidth( 90 ); | 186 | cmbChooserField2->setMaximumWidth( 90 ); |
186 | gl->addWidget( cmbChooserField2, 5, 0 ); | 187 | gl->addWidget( cmbChooserField2, 5, 0 ); |
187 | // Textfield for chooser 2 | 188 | // Textfield for chooser 2 |
188 | // Now use WidgetStack to contain the textfield and the default-email combo! | 189 | // Now use WidgetStack to contain the textfield and the default-email combo! |
189 | m_widgetStack2 = new QWidgetStack( container ); | 190 | m_widgetStack2 = new QWidgetStack( container ); |
190 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); | 191 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); |
191 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); | 192 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); |
192 | gl->addWidget( m_widgetStack2, 5, 1 ); | 193 | gl->addWidget( m_widgetStack2, 5, 1 ); |
193 | m_widgetStack2 -> raiseWidget( TextField ); | 194 | m_widgetStack2 -> raiseWidget( TextField ); |
194 | 195 | ||
195 | // Chooser 3 | 196 | // Chooser 3 |
196 | cmbChooserField3 = new QComboBox( FALSE, container ); | 197 | cmbChooserField3 = new QComboBox( FALSE, container ); |
197 | QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); | 198 | QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); |
198 | cmbChooserField3->setMaximumWidth( 90 ); | 199 | cmbChooserField3->setMaximumWidth( 90 ); |
199 | gl->addWidget( cmbChooserField3, 6, 0 ); | 200 | gl->addWidget( cmbChooserField3, 6, 0 ); |
200 | // Textfield for chooser 2 | 201 | // Textfield for chooser 2 |
201 | // Now use WidgetStack to contain the textfield and the default-email combo! | 202 | // Now use WidgetStack to contain the textfield and the default-email combo! |
202 | m_widgetStack3 = new QWidgetStack( container ); | 203 | m_widgetStack3 = new QWidgetStack( container ); |
203 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); | 204 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); |
204 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); | 205 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); |
205 | gl->addWidget( m_widgetStack3, 6, 1 ); | 206 | gl->addWidget( m_widgetStack3, 6, 1 ); |
206 | m_widgetStack3 -> raiseWidget( TextField ); | 207 | m_widgetStack3 -> raiseWidget( TextField ); |
207 | 208 | ||
208 | l = new QLabel( tr( "File As" ), container ); | 209 | l = new QLabel( tr( "File As" ), container ); |
@@ -552,139 +553,139 @@ void ContactEditor::init() { | |||
552 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); | 553 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); |
553 | m1->insertItem( anniversaryPicker ); | 554 | m1->insertItem( anniversaryPicker ); |
554 | 555 | ||
555 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); | 556 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); |
556 | anniversaryButton->setPopup( m1 ); | 557 | anniversaryButton->setPopup( m1 ); |
557 | anniversaryButton->setPopupDelay(0); | 558 | anniversaryButton->setPopupDelay(0); |
558 | 559 | ||
559 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 560 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
560 | tr( "Delete" ), | 561 | tr( "Delete" ), |
561 | hBox, 0 ); | 562 | hBox, 0 ); |
562 | gl->addWidget( hBox, counter , 1 ); | 563 | gl->addWidget( hBox, counter , 1 ); |
563 | 564 | ||
564 | connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), | 565 | connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), |
565 | this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); | 566 | this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); |
566 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); | 567 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); |
567 | 568 | ||
568 | ++counter; | 569 | ++counter; |
569 | 570 | ||
570 | // Gender | 571 | // Gender |
571 | l = new QLabel( tr("Gender"), container ); | 572 | l = new QLabel( tr("Gender"), container ); |
572 | gl->addWidget( l, counter, 0 ); | 573 | gl->addWidget( l, counter, 0 ); |
573 | cmbGender = new QComboBox( container ); | 574 | cmbGender = new QComboBox( container ); |
574 | cmbGender->insertItem( "", 0 ); | 575 | cmbGender->insertItem( "", 0 ); |
575 | cmbGender->insertItem( tr("Male"), 1); | 576 | cmbGender->insertItem( tr("Male"), 1); |
576 | cmbGender->insertItem( tr("Female"), 2); | 577 | cmbGender->insertItem( tr("Female"), 2); |
577 | gl->addWidget( cmbGender, counter, 1 ); | 578 | gl->addWidget( cmbGender, counter, 1 ); |
578 | 579 | ||
579 | ++counter; | 580 | ++counter; |
580 | 581 | ||
581 | // Create Labels and lineedit fields for every dynamic entry | 582 | // Create Labels and lineedit fields for every dynamic entry |
582 | QStringList::ConstIterator it = slDynamicEntries.begin(); | 583 | QStringList::ConstIterator it = slDynamicEntries.begin(); |
583 | QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId(); | 584 | QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId(); |
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&)) ); |
659 | connect( txtChooserField3, SIGNAL(textChanged(const QString&)), | 660 | connect( txtChooserField3, SIGNAL(textChanged(const QString&)), |
660 | this, SLOT(slotChooser3Change(const QString&)) ); | 661 | this, SLOT(slotChooser3Change(const QString&)) ); |
661 | connect( txtChooserField4, SIGNAL(textChanged(const QString&)), | 662 | connect( txtChooserField4, SIGNAL(textChanged(const QString&)), |
662 | this, SLOT(slotChooser4Change(const QString&)) ); | 663 | this, SLOT(slotChooser4Change(const QString&)) ); |
663 | connect( txtAddress, SIGNAL(textChanged(const QString&)), | 664 | connect( txtAddress, SIGNAL(textChanged(const QString&)), |
664 | this, SLOT(slotAddressChange(const QString&)) ); | 665 | this, SLOT(slotAddressChange(const QString&)) ); |
665 | connect( txtCity, SIGNAL(textChanged(const QString&)), | 666 | connect( txtCity, SIGNAL(textChanged(const QString&)), |
666 | this, SLOT(slotCityChange(const QString&)) ); | 667 | this, SLOT(slotCityChange(const QString&)) ); |
667 | connect( txtState, SIGNAL(textChanged(const QString&)), | 668 | connect( txtState, SIGNAL(textChanged(const QString&)), |
668 | this, SLOT(slotStateChange(const QString&)) ); | 669 | this, SLOT(slotStateChange(const QString&)) ); |
669 | connect( txtZip, SIGNAL(textChanged(const QString&)), | 670 | connect( txtZip, SIGNAL(textChanged(const QString&)), |
670 | this, SLOT(slotZipChange(const QString&)) ); | 671 | this, SLOT(slotZipChange(const QString&)) ); |
671 | connect( cmbCountry, SIGNAL(textChanged(const QString&)), | 672 | connect( cmbCountry, SIGNAL(textChanged(const QString&)), |
672 | this, SLOT(slotCountryChange(const QString&)) ); | 673 | this, SLOT(slotCountryChange(const QString&)) ); |
673 | connect( cmbCountry, SIGNAL(activated(const QString&)), | 674 | connect( cmbCountry, SIGNAL(activated(const QString&)), |
674 | this, SLOT(slotCountryChange(const QString&)) ); | 675 | this, SLOT(slotCountryChange(const QString&)) ); |
675 | connect( cmbChooserField1, SIGNAL(activated(int)), | 676 | connect( cmbChooserField1, SIGNAL(activated(int)), |
676 | this, SLOT(slotCmbChooser1Change(int)) ); | 677 | this, SLOT(slotCmbChooser1Change(int)) ); |
677 | connect( cmbChooserField2, SIGNAL(activated(int)), | 678 | connect( cmbChooserField2, SIGNAL(activated(int)), |
678 | this, SLOT(slotCmbChooser2Change(int)) ); | 679 | this, SLOT(slotCmbChooser2Change(int)) ); |
679 | connect( cmbChooserField3, SIGNAL(activated(int)), | 680 | connect( cmbChooserField3, SIGNAL(activated(int)), |
680 | this, SLOT(slotCmbChooser3Change(int)) ); | 681 | this, SLOT(slotCmbChooser3Change(int)) ); |
681 | connect( cmbChooserField4, SIGNAL(activated(int)), | 682 | connect( cmbChooserField4, SIGNAL(activated(int)), |
682 | this, SLOT(slotCmbChooser4Change(int)) ); | 683 | this, SLOT(slotCmbChooser4Change(int)) ); |
683 | connect( cmbAddress, SIGNAL(activated(int)), | 684 | connect( cmbAddress, SIGNAL(activated(int)), |
684 | this, SLOT(slotAddressTypeChange(int)) ); | 685 | this, SLOT(slotAddressTypeChange(int)) ); |
685 | 686 | ||
686 | new QPEDialogListener(this); | 687 | new QPEDialogListener(this); |
687 | 688 | ||
688 | setPersonalView ( m_personalView ); | 689 | setPersonalView ( m_personalView ); |
689 | 690 | ||
690 | owarn << "init() END" << oendl; | 691 | owarn << "init() END" << oendl; |
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 | ||