summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abconfig.cpp22
-rw-r--r--core/pim/addressbook/abconfig.h13
-rw-r--r--core/pim/addressbook/addressbook.cpp654
-rw-r--r--core/pim/addressbook/addressbook.h52
-rw-r--r--core/pim/addressbook/contacteditor.cpp62
-rw-r--r--core/pim/addressbook/contacteditor.h6
6 files changed, 310 insertions, 499 deletions
diff --git a/core/pim/addressbook/abconfig.cpp b/core/pim/addressbook/abconfig.cpp
index a3fd222..2583327 100644
--- a/core/pim/addressbook/abconfig.cpp
+++ b/core/pim/addressbook/abconfig.cpp
@@ -1,213 +1,229 @@
1#include "abconfig.h" 1#include "abconfig.h"
2#include "version.h" 2#include "version.h"
3 3
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/recordfields.h> 5#include <qpe/recordfields.h>
6 6
7AbConfig::AbConfig( ): 7AbConfig::AbConfig( ):
8 m_useQtMail( true ), 8 m_useQtMail( true ),
9 m_useOpieMail( false ), 9 m_useOpieMail( false ),
10 m_useRegExp( false ), 10 m_useRegExp( false ),
11 m_beCaseSensitive( false ), 11 m_beCaseSensitive( false ),
12 m_fontSize( 1 ), 12 m_fontSize( 1 ),
13 m_barPos( QMainWindow::Top ), 13 m_barPos( QMainWindow::Top ),
14 m_fixedBars( true ), 14 m_fixedBars( true ),
15 m_lpSearchMode( LastName ), 15 m_lpSearchMode( LastName ),
16 m_changed( false ) 16 m_changed( false )
17{ 17{
18} 18}
19 19
20AbConfig::~AbConfig() 20AbConfig::~AbConfig()
21{ 21{
22} 22}
23 23
24bool AbConfig::useRegExp() const 24bool AbConfig::useRegExp() const
25{ 25{
26 return m_useRegExp; 26 return m_useRegExp;
27} 27}
28bool AbConfig::useWildCards() const 28bool AbConfig::useWildCards() const
29{ 29{
30 return !m_useRegExp; 30 return !m_useRegExp;
31} 31}
32bool AbConfig::useQtMail() const 32bool AbConfig::useQtMail() const
33{ 33{
34 return m_useQtMail; 34 return m_useQtMail;
35} 35}
36bool AbConfig::useOpieMail() const 36bool AbConfig::useOpieMail() const
37{ 37{
38 return m_useOpieMail; 38 return m_useOpieMail;
39} 39}
40bool AbConfig::beCaseSensitive() const 40bool AbConfig::beCaseSensitive() const
41{ 41{
42 return m_beCaseSensitive; 42 return m_beCaseSensitive;
43} 43}
44int AbConfig::fontSize() const 44int AbConfig::fontSize() const
45{ 45{
46 return m_fontSize; 46 return m_fontSize;
47} 47}
48 48
49QValueList<int> AbConfig::orderList() const 49QValueList<int> AbConfig::orderList() const
50{ 50{
51 return m_ordered; 51 return m_ordered;
52} 52}
53 53
54QMainWindow::ToolBarDock AbConfig::getToolBarPos() const 54QMainWindow::ToolBarDock AbConfig::getToolBarPos() const
55{ 55{
56 return (QMainWindow::ToolBarDock) m_barPos; 56 return (QMainWindow::ToolBarDock) m_barPos;
57} 57}
58 58
59bool AbConfig::fixedBars() const 59bool AbConfig::fixedBars() const
60{ 60{
61 return m_fixedBars; 61 return m_fixedBars;
62} 62}
63 63
64AbConfig::LPSearchMode AbConfig::letterPickerSearch() const 64AbConfig::LPSearchMode AbConfig::letterPickerSearch() const
65{ 65{
66 return ( AbConfig::LPSearchMode ) m_lpSearchMode; 66 return ( AbConfig::LPSearchMode ) m_lpSearchMode;
67} 67}
68 68
69const QString &AbConfig::category() const
70{
71 return m_category;
72}
73
69void AbConfig::setUseRegExp( bool v ) 74void AbConfig::setUseRegExp( bool v )
70{ 75{
71 m_useRegExp = v ; 76 m_useRegExp = v ;
72 m_changed = true; 77 m_changed = true;
73} 78}
74void AbConfig::setUseWildCards( bool v ) 79void AbConfig::setUseWildCards( bool v )
75{ 80{
76 m_useRegExp = !v; 81 m_useRegExp = !v;
77 m_changed = true; 82 m_changed = true;
78} 83}
79void AbConfig::setBeCaseSensitive( bool v ) 84void AbConfig::setBeCaseSensitive( bool v )
80{ 85{
81 m_beCaseSensitive = v; 86 m_beCaseSensitive = v;
82 m_changed = true; 87 m_changed = true;
83} 88}
84void AbConfig::setUseQtMail( bool v ) 89void AbConfig::setUseQtMail( bool v )
85{ 90{
86 m_useQtMail = v; 91 m_useQtMail = v;
87 m_changed = true; 92 m_changed = true;
88} 93}
89void AbConfig::setUseOpieMail( bool v ) 94void AbConfig::setUseOpieMail( bool v )
90{ 95{
91 m_useOpieMail = v; 96 m_useOpieMail = v;
92 m_changed = true; 97 m_changed = true;
93} 98}
94void AbConfig::setFontSize( int v ) 99void AbConfig::setFontSize( int v )
95{ 100{
96 m_fontSize = v; 101 m_fontSize = v;
97 m_changed = true; 102 m_changed = true;
98} 103}
99 104
100void AbConfig::setOrderList( const QValueList<int>& list ) 105void AbConfig::setOrderList( const QValueList<int>& list )
101{ 106{
102 m_ordered = list; 107 m_ordered = list;
103 m_changed = true; 108 m_changed = true;
104} 109}
105 110
106void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v ) 111void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v )
107{ 112{
108 m_barPos = v; 113 m_barPos = v;
109 m_changed = true; 114 m_changed = true;
110} 115}
111 116
112void AbConfig::setFixedBars( const bool fixed ) 117void AbConfig::setFixedBars( const bool fixed )
113{ 118{
114 m_fixedBars = fixed; 119 m_fixedBars = fixed;
115 m_changed = true; 120 m_changed = true;
116} 121}
117 122
118void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode ) 123void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode )
119{ 124{
120 m_lpSearchMode = mode; 125 m_lpSearchMode = mode;
121 m_changed = true; 126 m_changed = true;
122} 127}
123 128
129void AbConfig::setCategory( const QString &cat )
130{
131 m_category = cat;
132}
133
124void AbConfig::load() 134void AbConfig::load()
125{ 135{
126 // Read Config settings 136 // Read Config settings
127 Config cfg("AddressBook"); 137 Config cfg("AddressBook");
128 138
139 cfg.setGroup( "View" );
140 m_category = cfg.readEntry( "Category", "All" );
141
129 cfg.setGroup("Font"); 142 cfg.setGroup("Font");
130 m_fontSize = cfg.readNumEntry( "fontSize", 1 ); 143 m_fontSize = cfg.readNumEntry( "fontSize", 1 );
131 144
132 cfg.setGroup("Search"); 145 cfg.setGroup("Search");
133 m_useRegExp = cfg.readBoolEntry( "useRegExp", false ); 146 m_useRegExp = cfg.readBoolEntry( "useRegExp", false );
134 m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive", false ); 147 m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive", false );
135 m_lpSearchMode = cfg.readNumEntry( "lpSearchMode", FileAs ); 148 m_lpSearchMode = cfg.readNumEntry( "lpSearchMode", FileAs );
136 149
137 cfg.setGroup("Mail"); 150 cfg.setGroup("Mail");
138 m_useQtMail = cfg.readBoolEntry( "useQtMail", true ); 151 m_useQtMail = cfg.readBoolEntry( "useQtMail", true );
139 m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); 152 m_useOpieMail=cfg.readBoolEntry( "useOpieMail" );
140 153
141 cfg.setGroup("ContactOrder"); 154 cfg.setGroup("ContactOrder");
142 int ID = 0; 155 int ID = 0;
143 int i = 0; 156 int i = 0;
144 ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); 157 ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 );
145 while ( ID != 0 ){ 158 while ( ID != 0 ){
146 m_ordered.append( ID ); 159 m_ordered.append( ID );
147 ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); 160 ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 );
148 } 161 }
149 162
150 // If no contact order is defined, we set the default 163 // If no contact order is defined, we set the default
151 if ( m_ordered.count() == 0 ) { 164 if ( m_ordered.count() == 0 ) {
152 m_ordered.append( Qtopia::DefaultEmail ); 165 m_ordered.append( Qtopia::DefaultEmail );
153 m_ordered.append( Qtopia::HomePhone); 166 m_ordered.append( Qtopia::HomePhone);
154 m_ordered.append( Qtopia::HomeMobile); 167 m_ordered.append( Qtopia::HomeMobile);
155 m_ordered.append( Qtopia::BusinessPhone); 168 m_ordered.append( Qtopia::BusinessPhone);
156 } 169 }
157 170
158 cfg.setGroup("ToolBar"); 171 cfg.setGroup("ToolBar");
159 m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top ); 172 m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top );
160 m_fixedBars= cfg.readBoolEntry( "fixedBars", true ); 173 m_fixedBars= cfg.readBoolEntry( "fixedBars", true );
161 174
162 m_changed = false; 175 m_changed = false;
163} 176}
164 177
165void AbConfig::save() 178void AbConfig::save()
166{ 179{
167 if ( m_changed ){ 180 if ( m_changed ){
168 Config cfg("AddressBook"); 181 Config cfg("AddressBook");
182 cfg.setGroup( "View" );
183 cfg.writeEntry( "Category", m_category );
184
169 cfg.setGroup("Font"); 185 cfg.setGroup("Font");
170 cfg.writeEntry("fontSize", m_fontSize); 186 cfg.writeEntry("fontSize", m_fontSize);
171 187
172 cfg.setGroup("Search"); 188 cfg.setGroup("Search");
173 cfg.writeEntry("useRegExp", m_useRegExp); 189 cfg.writeEntry("useRegExp", m_useRegExp);
174 cfg.writeEntry("caseSensitive", m_beCaseSensitive); 190 cfg.writeEntry("caseSensitive", m_beCaseSensitive);
175 cfg.writeEntry("lpSearchMode", m_lpSearchMode ); 191 cfg.writeEntry("lpSearchMode", m_lpSearchMode );
176 192
177 cfg.setGroup("Mail"); 193 cfg.setGroup("Mail");
178 cfg.writeEntry( "useQtMail", m_useQtMail ); 194 cfg.writeEntry( "useQtMail", m_useQtMail );
179 cfg.writeEntry( "useOpieMail", m_useOpieMail); 195 cfg.writeEntry( "useOpieMail", m_useOpieMail);
180 196
181 cfg.setGroup("ContactOrder"); 197 cfg.setGroup("ContactOrder");
182 cfg.clearGroup(); 198 cfg.clearGroup();
183 for ( uint i = 0; i < m_ordered.count(); i++ ){ 199 for ( uint i = 0; i < m_ordered.count(); i++ ){
184 cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] ); 200 cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] );
185 } 201 }
186 202
187 cfg.setGroup("ToolBar"); 203 cfg.setGroup("ToolBar");
188 cfg.writeEntry( "Position", m_barPos ); 204 cfg.writeEntry( "Position", m_barPos );
189 cfg.writeEntry( "fixedBars", m_fixedBars ); 205 cfg.writeEntry( "fixedBars", m_fixedBars );
190 206
191 cfg.setGroup("Version"); 207 cfg.setGroup("Version");
192 cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION); 208 cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION);
193 cfg.writeEntry( "Mainversion", MAINVERSION ); 209 cfg.writeEntry( "Mainversion", MAINVERSION );
194 cfg.writeEntry( "SubVersion", SUBVERSION ); 210 cfg.writeEntry( "SubVersion", SUBVERSION );
195 cfg.writeEntry( "PatchVersion", PATCHVERSION ); 211 cfg.writeEntry( "PatchVersion", PATCHVERSION );
196 212
197 } 213 }
198 214
199} 215}
200 216
201void AbConfig::operator= ( const AbConfig& cnf ) 217void AbConfig::operator= ( const AbConfig& cnf )
202{ 218{
203 m_useQtMail = cnf.m_useQtMail; 219 m_useQtMail = cnf.m_useQtMail;
204 m_useOpieMail = cnf.m_useOpieMail; 220 m_useOpieMail = cnf.m_useOpieMail;
205 m_useRegExp = cnf.m_useRegExp; 221 m_useRegExp = cnf.m_useRegExp;
206 m_beCaseSensitive = cnf.m_beCaseSensitive; 222 m_beCaseSensitive = cnf.m_beCaseSensitive;
207 m_fontSize = cnf.m_fontSize; 223 m_fontSize = cnf.m_fontSize;
208 m_ordered = cnf.m_ordered; 224 m_ordered = cnf.m_ordered;
209 m_barPos = cnf.m_barPos; 225 m_barPos = cnf.m_barPos;
210 m_fixedBars = cnf.m_fixedBars; 226 m_fixedBars = cnf.m_fixedBars;
211 m_lpSearchMode = cnf.m_lpSearchMode; 227 m_lpSearchMode = cnf.m_lpSearchMode;
212} 228}
213 229
diff --git a/core/pim/addressbook/abconfig.h b/core/pim/addressbook/abconfig.h
index c312179..68d087c 100644
--- a/core/pim/addressbook/abconfig.h
+++ b/core/pim/addressbook/abconfig.h
@@ -1,69 +1,72 @@
1#ifndef _ABCONFIG_H_ 1#ifndef _ABCONFIG_H_
2#define _ABCONFIG_H_ 2#define _ABCONFIG_H_
3 3
4#include <qstringlist.h> 4#include <qstringlist.h>
5#include <qmainwindow.h> 5#include <qmainwindow.h>
6 6
7class AbConfig 7class AbConfig
8{ 8{
9public: 9public:
10 enum LPSearchMode{ 10 enum LPSearchMode{
11 LastName = 0, 11 LastName = 0,
12 FileAs, 12 FileAs,
13 LASTELEMENT 13 LASTELEMENT
14 }; 14 };
15 15
16 16
17 17
18 AbConfig(); 18 AbConfig();
19 ~AbConfig(); 19 ~AbConfig();
20 20
21 // Search Settings 21 // Search Settings
22 bool useRegExp() const; 22 bool useRegExp() const;
23 bool useWildCards() const; 23 bool useWildCards() const;
24 bool beCaseSensitive() const; 24 bool beCaseSensitive() const;
25 bool useQtMail() const; 25 bool useQtMail() const;
26 bool useOpieMail() const; 26 bool useOpieMail() const;
27 int fontSize() const; 27 int fontSize() const;
28 QValueList<int> orderList() const; 28 QValueList<int> orderList() const;
29 QMainWindow::ToolBarDock getToolBarPos() const; 29 QMainWindow::ToolBarDock getToolBarPos() const;
30 bool fixedBars() const; 30 bool fixedBars() const;
31 LPSearchMode letterPickerSearch() const; 31 LPSearchMode letterPickerSearch() const;
32 32 const QString &category() const;
33
33 void setUseRegExp( bool v ); 34 void setUseRegExp( bool v );
34 void setUseWildCards( bool v ); 35 void setUseWildCards( bool v );
35 void setBeCaseSensitive( bool v ); 36 void setBeCaseSensitive( bool v );
36 void setUseQtMail( bool v ); 37 void setUseQtMail( bool v );
37 void setUseOpieMail( bool v ); 38 void setUseOpieMail( bool v );
38 void setFontSize( int v ); 39 void setFontSize( int v );
39 void setOrderList( const QValueList<int>& list ); 40 void setOrderList( const QValueList<int>& list );
40 void setToolBarDock( const QMainWindow::ToolBarDock v ); 41 void setToolBarDock( const QMainWindow::ToolBarDock v );
41 void setFixedBars( const bool fixed ); 42 void setFixedBars( const bool fixed );
42 void setLetterPickerSearch( const LPSearchMode mode ); 43 void setLetterPickerSearch( const LPSearchMode mode );
44 void setCategory( const QString &cat );
43 45
44 void operator= ( const AbConfig& cnf ); 46 void operator= ( const AbConfig& cnf );
45 47
46 void load(); 48 void load();
47 void save(); 49 void save();
48 50
49protected: 51protected:
50/* virtual void itemUp(); */ 52/* virtual void itemUp(); */
51/* virtual void itemDown(); */ 53/* virtual void itemDown(); */
52 54
53 QStringList contFields; 55 QStringList contFields;
54 56
55 bool m_useQtMail; 57 bool m_useQtMail;
56 bool m_useOpieMail; 58 bool m_useOpieMail;
57 bool m_useRegExp; 59 bool m_useRegExp;
58 bool m_beCaseSensitive; 60 bool m_beCaseSensitive;
59 int m_fontSize; 61 int m_fontSize;
60 QValueList<int> m_ordered; 62 QValueList<int> m_ordered;
61 int m_barPos; 63 int m_barPos;
62 bool m_fixedBars; 64 bool m_fixedBars;
63 int m_lpSearchMode; 65 int m_lpSearchMode;
66 QString m_category;
64 67
65 bool m_changed; 68 bool m_changed;
66}; 69};
67 70
68 71
69#endif 72#endif
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 3f0ac74..a4c2c6e 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -9,1041 +9,835 @@
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging 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** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#define QTOPIA_INTERNAL_FD 20#define QTOPIA_INTERNAL_FD
21 21
22// #include "addresssettings.h" 22// #include "addresssettings.h"
23#include "addressbook.h" 23#include "addressbook.h"
24 24
25#include <opie2/odebug.h> 25#include <opie2/odebug.h>
26#include <opie2/ofileselector.h> 26#include <opie2/ofileselector.h>
27#include <opie2/ofiledialog.h> 27#include <opie2/ofiledialog.h>
28#include <opie2/opimcontact.h> 28#include <opie2/opimcontact.h>
29#include <opie2/ocontactaccessbackend_vcard.h> 29#include <opie2/ocontactaccessbackend_vcard.h>
30 30
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32#include <qpe/ir.h> 32#include <qpe/ir.h>
33#include <qpe/qpemessagebox.h> 33#include <qpe/qpemessagebox.h>
34#include <qmenubar.h> 34#include <qmenubar.h>
35// #include <qtoolbar.h> 35// #include <qtoolbar.h>
36// #include <qmenubar.h> 36// #include <qmenubar.h>
37#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
38 38
39#include <qaction.h> 39#include <qaction.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qmessagebox.h> 41#include <qmessagebox.h>
42#include <qtoolbutton.h> 42#include <qtoolbutton.h>
43 43
44#include <stdlib.h> 44#include <stdlib.h>
45#include <sys/stat.h> 45#include <sys/stat.h>
46#include <sys/types.h> 46#include <sys/types.h>
47#include <fcntl.h> 47#include <fcntl.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50 50
51#include "picker.h" 51#include "picker.h"
52#include "configdlg.h" 52#include "configdlg.h"
53 53
54extern QString addressbookPersonalVCardName(); 54extern QString addressbookPersonalVCardName();
55 55
56AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 56AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
57 WFlags f ) 57 WFlags /*f*/ )
58 : QMainWindow( parent, name, f ), 58 : Opie::OPimMainWindow( "Addressbook", "Contacts", tr( "Contact" ), "AddressBook",
59 catMenu (0l), 59 parent, name, WType_TopLevel | WStyle_ContextHelp ),
60 abEditor(0l), 60 abEditor(0l),
61 syncing(FALSE), 61 syncing(false)
62 m_tableViewButton(0l),
63 m_cardViewButton(0l)
64{ 62{
63 setCaption( tr( "Contacts" ) );
64
65 isLoading = true; 65 isLoading = true;
66 66
67 m_config.load(); 67 m_config.load();
68 68
69 setCaption( tr("Contacts") ); 69 // Create Views
70 setIcon( Resource::loadPixmap( "addressbook/AddressBook" ) ); 70 m_listContainer = new QWidget( this );
71 71 QVBoxLayout *vb = new QVBoxLayout( m_listContainer );
72 // Settings for Main Menu
73 // setToolBarsMovable( false );
74 setToolBarsMovable( !m_config.fixedBars() );
75 setRightJustification( true );
76
77 QToolBar *bar = new QToolBar( this );
78 bar->setHorizontalStretchable( TRUE );
79
80 QMenuBar *mbList = new QMenuBar( bar );
81 mbList->setMargin( 0 );
82
83 QPopupMenu *edit = new QPopupMenu( mbList );
84 mbList->insertItem( tr( "Contact" ), edit );
85
86 // Category Menu
87 catMenu = new QPopupMenu( this );
88 catMenu->setCheckable( TRUE );
89 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
90 mbList->insertItem( tr("View"), catMenu );
91
92 // Create Toolbar
93 listTools = new QToolBar( this, "list operations" );
94 listTools->setHorizontalStretchable( true );
95 addToolBar( listTools );
96 moveToolBar( listTools, m_config.getToolBarPos() );
97
98 // View Icons
99 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ),
100 QString::null, 0, this, 0 );
101 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
102 m_tableViewButton->setToggleAction( true );
103 m_tableViewButton->addTo( listTools );
104 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 );
105 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
106 m_cardViewButton->setToggleAction( true );
107 m_cardViewButton->addTo( listTools );
108
109 listTools->addSeparator();
110
111 // Other Buttons
112 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
113 0, this, 0 );
114 actionNew = a;
115 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
116 a->addTo( edit );
117 a->addTo( listTools );
118
119 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
120 0, this, 0 );
121 actionEdit = a;
122 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
123 a->addTo( edit );
124 a->addTo( listTools );
125
126 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
127 0, this, 0 );
128 actionTrash = a;
129 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
130 a->addTo( edit );
131 a->addTo( listTools );
132
133
134 // make it possible to go directly to businesscard via qcop call
135 //#if defined(Q_WS_QWS) // Why this ? (se)
136#if !defined(QT_NO_COP)
137 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
138 connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)),
139 this, SLOT ( appMessage(const QCString&,const QByteArray&) ) );
140#endif
141 // #endif
142 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
143 QString::null, 0, this, 0 );
144 actionFind = a;
145 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
146 a->addTo( edit );
147 a->addTo( listTools );
148
149 // Much better search widget, taken from QTReader.. (se)
150 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
151 searchBar->setHorizontalStretchable( TRUE );
152 searchBar->hide();
153 searchEdit = new QLineEdit( searchBar, "searchEdit" );
154
155 // QFont f("unifont", 16 /*, QFont::Bold*/);
156 // searchEdit->setFont( f );
157
158 searchBar->setStretchableWidget( searchEdit );
159 connect( searchEdit, SIGNAL( returnPressed() ),
160 this, SLOT( slotFind() ) );
161
162 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
163 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
164 a->addTo( searchBar );
165
166 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
167 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
168 a->addTo( searchBar );
169
170 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ),
171 QString::null, 0, this, 0 );
172 //a->setEnabled( FALSE ); we got support for it now :) zecke
173 actionMail = a;
174 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
175 a->addTo( edit );
176 a->addTo( listTools );
177
178 if ( Ir::supported() ) {
179 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
180 0, this, 0 );
181 actionBeam = a;
182 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
183 a->addTo( edit );
184 a->addTo( listTools );
185 }
186 72
187 edit->insertSeparator(); 73 m_abView = new AbView( m_listContainer, m_config.orderList() );
74 vb->addWidget( m_abView );
75 connect( m_abView, SIGNAL(signalViewSwitched(int)),
76 this, SLOT(slotViewSwitched(int)) );
188 77
189 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, 78 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
190 0, this, 0);
191 actionPersonal = a;
192 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
193 a->addTo( edit );
194 79
195 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, 80 // Letter Picker
196 0, this, 0); 81 pLabel = new LetterPicker( m_listContainer );
197 actionPersonal = a; 82 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
198 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); 83 connect(m_abView, SIGNAL(signalClearLetterPicker()), pLabel, SLOT(clear()) );
199 a->addTo( edit );
200 84
201 edit->insertSeparator(); 85 vb->addWidget( pLabel );
202 86
203 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), 87 // Quick search bar
204 QString::null, 0, this, 0 , TRUE ); 88 m_searchBar = new OFloatBar( "Search", this, QMainWindow::Top, true );
205 actionPersonal = a; 89 m_searchBar->setHorizontalStretchable( true );
206 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 90 m_searchBar->hide();
207 a->addTo( edit ); 91 m_searchEdit = new QLineEdit( m_searchBar, "m_searchEdit" );
208 92
93 m_searchBar->setStretchableWidget( m_searchEdit );
94 connect( m_searchEdit, SIGNAL(returnPressed()), this, SLOT(slotFind()) );
209 95
210#ifdef __DEBUG_RELEASE 96 QAction *a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
211 // Remove this function for public Release ! This is only 97 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
212 // for debug purposes .. 98 a->addTo( m_searchBar );
213 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
214 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
215 a->addTo( edit );
216#endif
217 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null,
218 0, this, 0 );
219 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
220 a->addTo( edit );
221 99
222 // Create Views 100 // Insert Contact menu items
223 listContainer = new QWidget( this ); 101 QActionGroup *items = new QActionGroup( this, QString::null, false );
224 QVBoxLayout *vb = new QVBoxLayout( listContainer );
225 102
226 m_abView = new AbView( listContainer, m_config.orderList() ); 103 m_actionMail = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ),
227 vb->addWidget( m_abView ); 104 QString::null, 0, items, 0 );
228 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 105 connect( m_actionMail, SIGNAL(activated()), this, SLOT(writeMail()) );
229 connect( m_abView, SIGNAL( signalViewSwitched(int) ),
230 this, SLOT( slotViewSwitched(int) ) );
231 106
107 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"),
108 QString::null, 0, items, 0 );
109 connect( a, SIGNAL(activated()), this, SLOT(importvCard()) );
232 110
233 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); 111 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"),
112 QString::null, 0, items, 0 );
113 connect( a, SIGNAL(activated()), this, SLOT(exportvCard()) );
234 114
235 // m_abView->load(); // Already done by c'tor . 115 m_actionPersonal = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ),
116 QString::null, 0, items, 0 , true );
117 connect( m_actionPersonal, SIGNAL(activated()), this, SLOT(slotPersonalView()) );
236 118
237 // Letter Picker 119 insertItemMenuItems( items );
238 pLabel = new LetterPicker( listContainer );
239 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
240 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
241 120
242 vb->addWidget( pLabel ); 121 // Insert View menu items
122 items = new QActionGroup( this, QString::null, false );
123
124 a = new QAction( tr("Show quick search bar"),QString::null, 0, items, 0, true );
125 connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowFind(bool)) );
243 126
244 // All Categories into view-menu.. 127 insertViewMenuItems( items );
245 populateCategories();
246 128
247 // Fontsize 129 // Fontsize
248 defaultFont = new QFont( m_abView->font() ); 130 defaultFont = new QFont( m_abView->font() );
249 slotSetFont(m_config.fontSize()); 131 slotSetFont(m_config.fontSize());
250 m_curFontSize = m_config.fontSize(); 132 m_curFontSize = m_config.fontSize();
251 133
252 setCentralWidget(listContainer); 134 setCentralWidget(m_listContainer);
253 135
254 //odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; 136 //odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl;
255 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 137 connect( qApp, SIGNAL(flush()), this, SLOT(flush()) );
256 connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); 138 connect( qApp, SIGNAL(reload()), this, SLOT(reload()) );
257 connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), 139 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
258 this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); 140 this, SLOT(appMessage(const QCString&,const QByteArray&)) );
259
260 141
261 isLoading = false; 142 isLoading = false;
262}
263 143
264 144 // Handle category selection
265void AddressbookWindow::slotConfig() 145 setViewCategory( m_config.category() );
266{ 146 m_abView->setShowByCategory( m_config.category() );
267 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 147 connect( this, SIGNAL(categorySelected(const QString&)),
268 dlg -> setConfig( m_config ); 148 this, SLOT(slotSetCategory(const QString&)) );
269 if ( QPEApplication::execDialog( dlg ) ) {
270 odebug << "Config Dialog accepted!" << oendl;
271 m_config = dlg -> getConfig();
272 if ( m_curFontSize != m_config.fontSize() ){
273 odebug << "Font was changed!" << oendl;
274 m_curFontSize = m_config.fontSize();
275 emit slotSetFont( m_curFontSize );
276 }
277 m_abView -> setListOrder( m_config.orderList() );
278 }
279
280 delete dlg;
281} 149}
282 150
283
284void AddressbookWindow::slotSetFont( int size ) 151void AddressbookWindow::slotSetFont( int size )
285{ 152{
286 odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl; 153 odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl;
287 154
288 if (size > 2 || size < 0) 155 if (size > 2 || size < 0)
289 size = 1; 156 size = 1;
290 157
291 m_config.setFontSize( size ); 158 m_config.setFontSize( size );
292 159
293 QFont *currentFont; 160 QFont *currentFont;
294 161
295 switch (size) { 162 switch (size) {
296 case 0: 163 case 0:
297 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 164 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
298 currentFont = new QFont (m_abView->font()); 165 currentFont = new QFont (m_abView->font());
299 // abList->resizeRows(currentFont->pixelSize() + 7); :SX 166 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
300 // abList->resizeRows(); 167 // abList->resizeRows();
301 break; 168 break;
302 case 1: 169 case 1:
303 m_abView->setFont( *defaultFont ); 170 m_abView->setFont( *defaultFont );
304 currentFont = new QFont (m_abView->font()); 171 currentFont = new QFont (m_abView->font());
305 // // abList->resizeRows(currentFont->pixelSize() + 7); 172 // // abList->resizeRows(currentFont->pixelSize() + 7);
306 // abList->resizeRows(); 173 // abList->resizeRows();
307 break; 174 break;
308 case 2: 175 case 2:
309 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 176 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
310 currentFont = new QFont (m_abView->font()); 177 currentFont = new QFont (m_abView->font());
311 // //abList->resizeRows(currentFont->pixelSize() + 7); 178 // //abList->resizeRows(currentFont->pixelSize() + 7);
312 // abList->resizeRows(); 179 // abList->resizeRows();
313 break; 180 break;
314 } 181 }
315} 182}
316 183
317 184
318 185
319void AddressbookWindow::importvCard() { 186void AddressbookWindow::importvCard() {
320 QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 187 QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
321 if(!str.isEmpty() ){ 188 if(!str.isEmpty() ){
322 setDocument((const QString&) str ); 189 setDocument((const QString&) str );
323 } 190 }
324 191
325} 192}
326void AddressbookWindow::exportvCard() 193void AddressbookWindow::exportvCard()
327{ 194{
328 odebug << "void AddressbookWindow::exportvCard()" << oendl; 195 odebug << "void AddressbookWindow::exportvCard()" << oendl;
329 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); 196 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this );
330 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ 197 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){
331 odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; 198 odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl;
332 Opie::OPimContact curCont = m_abView->currentEntry(); 199 Opie::OPimContact curCont = m_abView->currentEntry();
333 if ( !curCont.isEmpty() ){ 200 if ( !curCont.isEmpty() ){
334 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 201 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
335 filename ); 202 filename );
336 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); 203 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true );
337 if ( access ){ 204 if ( access ){
338 access->add( curCont ); 205 access->add( curCont );
339 access->save(); 206 access->save();
340 } 207 }
341 delete access; 208 delete access;
342 }else 209 }else
343 QMessageBox::critical( 0, "Export VCard", 210 QMessageBox::critical( 0, "Export VCard",
344 QString( tr( "You have to select a contact !") ) ); 211 QString( tr( "You have to select a contact !") ) );
345 212
346 }else 213 }else
347 QMessageBox::critical( 0, "Export VCard", 214 QMessageBox::critical( 0, "Export VCard",
348 QString( tr( "You have to set a filename !") ) ); 215 QString( tr( "You have to set a filename !") ) );
349} 216}
350 217
351void AddressbookWindow::setDocument( const QString &filename ) 218void AddressbookWindow::setDocument( const QString &filename )
352{ 219{
353 odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; 220 odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl;
354 221
355 // Switch to default backend. This should avoid to import into 222 // Switch to default backend. This should avoid to import into
356 // the personal database accidently. 223 // the personal database accidently.
357 if ( actionPersonal->isOn() ){ 224 if ( m_actionPersonal->isOn() ){
358 actionPersonal->setOn( false ); 225 m_actionPersonal->setOn( false );
359 slotPersonalView(); 226 slotPersonalView();
360 } 227 }
361 228
362 if ( filename.find(".vcf") != int(filename.length()) - 4 ){ 229 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
363 230
364 231
365 232
366 switch( QMessageBox::information( this, tr ( "Right file type ?" ), 233 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
367 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), 234 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ),
368 tr( "&Yes" ), tr( "&No" ), QString::null, 235 tr( "&Yes" ), tr( "&No" ), QString::null,
369 0, // Enter == button 0 236 0, // Enter == button 0
370 2 ) ) { // Escape == button 2 237 2 ) ) { // Escape == button 2
371 case 0: 238 case 0:
372 odebug << "YES clicked" << oendl; 239 odebug << "YES clicked" << oendl;
373 break; 240 break;
374 case 1: 241 case 1:
375 odebug << "NO clicked" << oendl; 242 odebug << "NO clicked" << oendl;
376 return; 243 return;
377 break; 244 break;
378 } 245 }
379 } 246 }
380 247
381 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 248 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
382 filename ); 249 filename );
383 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 250 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
384 Opie::OPimContactAccess::List allList = access->allRecords(); 251 Opie::OPimContactAccess::List allList = access->allRecords();
385 odebug << "Found number of contacts in File: " << allList.count() << oendl; 252 odebug << "Found number of contacts in File: " << allList.count() << oendl;
386 253
387 if ( !allList.count() ) { 254 if ( !allList.count() ) {
388 QMessageBox::information( this, "Import VCard", 255 QMessageBox::information( this, "Import VCard",
389 "It was impossible to import\nthe VCard.\n" 256 "It was impossible to import\nthe VCard.\n"
390 "The VCard may be corrupted!" ); 257 "The VCard may be corrupted!" );
391 } 258 }
392 259
393 bool doAsk = true; 260 bool doAsk = true;
394 Opie::OPimContactAccess::List::Iterator it; 261 Opie::OPimContactAccess::List::Iterator it;
395 for ( it = allList.begin(); it != allList.end(); ++it ){ 262 for ( it = allList.begin(); it != allList.end(); ++it ){
396 odebug << "Adding Contact from: " << (*it).fullName() << oendl; 263 odebug << "Adding Contact from: " << (*it).fullName() << oendl;
397 if ( doAsk ){ 264 if ( doAsk ){
398 switch( QMessageBox::information( this, tr ( "Add Contact?" ), 265 switch( QMessageBox::information( this, tr ( "Add Contact?" ),
399 tr( "Do you really want add contact for \n%1?" ) 266 tr( "Do you really want add contact for \n%1?" )
400 .arg( (*it).fullName().latin1() ), 267 .arg( (*it).fullName().latin1() ),
401 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), 268 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"),
402 0, // Enter == button 0 269 0, // Enter == button 0
403 2 ) ) { // Escape == button 2 270 2 ) ) { // Escape == button 2
404 case 0: 271 case 0:
405 odebug << "YES clicked" << oendl; 272 odebug << "YES clicked" << oendl;
406 m_abView->addEntry( *it ); 273 m_abView->addEntry( *it );
407 break; 274 break;
408 case 1: 275 case 1:
409 odebug << "NO clicked" << oendl; 276 odebug << "NO clicked" << oendl;
410 break; 277 break;
411 case 2: 278 case 2:
412 odebug << "YesAll clicked" << oendl; 279 odebug << "YesAll clicked" << oendl;
413 doAsk = false; 280 doAsk = false;
414 break; 281 break;
415 } 282 }
416 }else 283 }else
417 m_abView->addEntry( *it ); 284 m_abView->addEntry( *it );
418 285
419 } 286 }
420 287
421 delete access; 288 delete access;
422} 289}
423 290
424void AddressbookWindow::resizeEvent( QResizeEvent *e ) 291void AddressbookWindow::resizeEvent( QResizeEvent *e )
425{ 292{
426 QMainWindow::resizeEvent( e ); 293 QMainWindow::resizeEvent( e );
427 294
428 295
429} 296}
430 297
431AddressbookWindow::~AddressbookWindow() 298AddressbookWindow::~AddressbookWindow()
432{ 299{
433 ToolBarDock dock; 300 ToolBarDock dock;
434 int dummy; 301 int dummy;
435 bool bDummy; 302 bool bDummy;
436 getLocation ( listTools, dock, dummy, bDummy, dummy ); 303 getLocation ( listTools, dock, dummy, bDummy, dummy );
437 m_config.setToolBarDock( dock ); 304 m_config.setToolBarDock( dock );
438 m_config.save(); 305 m_config.save();
439} 306}
440 307
441void AddressbookWindow::slotUpdateToolbar() 308int AddressbookWindow::create()
309{
310 return 0;
311}
312
313bool AddressbookWindow::remove( int /*uid*/ )
314{
315 return false;
316}
317
318void AddressbookWindow::beam( int /*uid*/ )
319{
320}
321
322void AddressbookWindow::show( int /*uid*/ )
323{
324}
325
326void AddressbookWindow::edit( int /*uid*/ )
442{ 327{
443 Opie::OPimContact ce = m_abView->currentEntry();
444 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
445} 328}
446 329
447void AddressbookWindow::slotListNew() 330void AddressbookWindow::add( const Opie::OPimRecord& )
331{
332}
333
334void AddressbookWindow::slotItemNew()
448{ 335{
449 Opie::OPimContact cnt; 336 Opie::OPimContact cnt;
450 if( !syncing ) { 337 if( !syncing ) {
451 editEntry( NewEntry ); 338 editEntry( NewEntry );
452 } else { 339 } else {
453 QMessageBox::warning(this, tr("Contacts"), 340 QMessageBox::warning(this, tr("Contacts"),
454 tr("Can not edit data, currently syncing")); 341 tr("Can not edit data, currently syncing"));
455 } 342 }
456} 343}
457 344
458// void AddressbookWindow::slotListView() 345void AddressbookWindow::slotItemEdit()
459// { 346{
460 // m_abView -> init( abList->currentEntry() ); 347 if(!syncing) {
461 // // :SX mView->sync(); 348 if (m_actionPersonal->isOn()) {
462 // //:SXshowView(); 349 editPersonal();
463// } 350 } else {
351 editEntry( EditEntry );
352 }
353 } else {
354 QMessageBox::warning( this, tr("Contacts"),
355 tr("Can not edit data, currently syncing") );
356 }
357}
358
359void AddressbookWindow::slotItemDuplicate()
360{
361}
464 362
465void AddressbookWindow::slotListDelete() 363void AddressbookWindow::slotItemDelete()
466{ 364{
467 if(!syncing) { 365 if(!syncing) {
468 Opie::OPimContact tmpEntry = m_abView ->currentEntry(); 366 Opie::OPimContact tmpEntry = m_abView ->currentEntry();
469 367
470 // get a name, do the best we can... 368 // get a name, do the best we can...
471 QString strName = tmpEntry.fullName(); 369 QString strName = tmpEntry.fullName();
472 if ( strName.isEmpty() ) { 370 if ( strName.isEmpty() ) {
473 strName = tmpEntry.company(); 371 strName = tmpEntry.company();
474 if ( strName.isEmpty() ) 372 if ( strName.isEmpty() )
475 strName = "No Name"; 373 strName = "No Name";
476 } 374 }
477 375
478 376
479 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 377 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
480 strName ) ) { 378 strName ) ) {
481 m_abView->removeEntry( tmpEntry.uid() ); 379 m_abView->removeEntry( tmpEntry.uid() );
482 } 380 }
483 } else { 381 } else {
484 QMessageBox::warning( this, tr("Contacts"), 382 QMessageBox::warning( this, tr("Contacts"),
485 tr("Can not edit data, currently syncing") ); 383 tr("Can not edit data, currently syncing") );
486 } 384 }
487} 385}
488 386
489void AddressbookWindow::slotFindOpen() 387static const char * beamfile = "/tmp/obex/contact.vcf";
388
389void AddressbookWindow::slotItemBeam()
490{ 390{
491 searchBar->show(); 391 QString beamFilename;
492 m_abView -> inSearch(); 392 Opie::OPimContact c;
493 searchEdit->setFocus(); 393 if ( m_actionPersonal->isOn() ) {
394 beamFilename = addressbookPersonalVCardName();
395 if ( !QFile::exists( beamFilename ) )
396 return; // can't beam a non-existent file
397 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
398 beamFilename );
399 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
400 Opie::OPimContactAccess::List allList = access->allRecords();
401 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
402 c = *it;
403
404 delete access;
405 } else {
406 unlink( beamfile ); // delete if exists
407 mkdir("/tmp/obex/", 0755);
408 c = m_abView -> currentEntry();
409 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
410 beamfile );
411 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
412 access->add( c );
413 access->save();
414 delete access;
415
416 beamFilename = beamfile;
417 }
418
419 odebug << "Beaming: " << beamFilename << oendl;
420
421 Ir *ir = new Ir( this );
422 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
423 QString description = c.fullName();
424 ir->send( beamFilename, description, "text/x-vCard" );
494} 425}
495void AddressbookWindow::slotFindClose() 426
427void AddressbookWindow::slotItemFind()
496{ 428{
497 searchBar->hide();
498 m_abView -> offSearch();
499 // m_abView->setFocus();
500} 429}
501 430
431void AddressbookWindow::slotConfigure()
432{
433 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
434 dlg -> setConfig( m_config );
435 if ( QPEApplication::execDialog( dlg ) ) {
436 odebug << "Config Dialog accepted!" << oendl;
437 m_config = dlg -> getConfig();
438 if ( m_curFontSize != m_config.fontSize() ){
439 odebug << "Font was changed!" << oendl;
440 m_curFontSize = m_config.fontSize();
441 emit slotSetFont( m_curFontSize );
442 }
443 m_abView -> setListOrder( m_config.orderList() );
444 }
445
446 delete dlg;
447}
448
449void AddressbookWindow::slotShowFind( bool show )
450{
451 if ( show )
452 {
453 // Display search bar
454 m_searchBar->show();
455 m_abView -> inSearch();
456 m_searchEdit->setFocus();
457 }
458 else
459 {
460 // Hide search bar
461 m_searchBar->hide();
462 m_abView -> offSearch();
463 }
464}
502 465
503void AddressbookWindow::slotFind() 466void AddressbookWindow::slotFind()
504{ 467{
505 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); 468 m_abView->slotDoFind( m_searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
506 469
507 searchEdit->clearFocus(); 470 m_searchEdit->clearFocus();
508 // m_abView->setFocus(); 471 // m_abView->setFocus();
509 472
510} 473}
511 474
512void AddressbookWindow::slotViewBack() 475void AddressbookWindow::slotViewBack()
513{ 476{
514 // :SX showList(); 477 // :SX showList();
515} 478}
516 479
517void AddressbookWindow::slotViewEdit()
518{
519 if(!syncing) {
520 if (actionPersonal->isOn()) {
521 editPersonal();
522 } else {
523 editEntry( EditEntry );
524 }
525 } else {
526 QMessageBox::warning( this, tr("Contacts"),
527 tr("Can not edit data, currently syncing") );
528 }
529}
530
531
532
533void AddressbookWindow::writeMail() 480void AddressbookWindow::writeMail()
534{ 481{
535 Opie::OPimContact c = m_abView -> currentEntry(); 482 Opie::OPimContact c = m_abView -> currentEntry();
536 QString name = c.fileAs(); 483 QString name = c.fileAs();
537 QString email = c.defaultEmail(); 484 QString email = c.defaultEmail();
538 485
539 // I prefer the OPIE-Environment variable before the 486 // I prefer the OPIE-Environment variable before the
540 // QPE-one.. 487 // QPE-one..
541 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 488 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
542 if ( basepath.isEmpty() ) 489 if ( basepath.isEmpty() )
543 basepath = QString::fromLatin1( getenv("QPEDIR") ); 490 basepath = QString::fromLatin1( getenv("QPEDIR") );
544 491
545 // Try to access the preferred. If not possible, try to 492 // Try to access the preferred. If not possible, try to
546 // switch to the other one.. 493 // switch to the other one..
547 if ( m_config.useQtMail() ){ 494 if ( m_config.useQtMail() ){
548 odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl; 495 odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl;
549 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 496 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
550 odebug << "QCop" << oendl; 497 odebug << "QCop" << oendl;
551 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 498 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
552 e << name << email; 499 e << name << email;
553 return; 500 return;
554 } else 501 } else
555 m_config.setUseOpieMail( true ); 502 m_config.setUseOpieMail( true );
556 } 503 }
557 if ( m_config.useOpieMail() ){ 504 if ( m_config.useOpieMail() ){
558 odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl; 505 odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl;
559 if ( QFile::exists( basepath + "/bin/opiemail" ) ){ 506 if ( QFile::exists( basepath + "/bin/opiemail" ) ){
560 odebug << "QCop" << oendl; 507 odebug << "QCop" << oendl;
561 QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); 508 QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)");
562 e << name << email; 509 e << name << email;
563 return; 510 return;
564 } else 511 } else
565 m_config.setUseQtMail( true ); 512 m_config.setUseQtMail( true );
566 } 513 }
567 514
568} 515}
569 516
570static const char * beamfile = "/tmp/obex/contact.vcf";
571
572void AddressbookWindow::slotBeam()
573{
574 QString beamFilename;
575 Opie::OPimContact c;
576 if ( actionPersonal->isOn() ) {
577 beamFilename = addressbookPersonalVCardName();
578 if ( !QFile::exists( beamFilename ) )
579 return; // can't beam a non-existent file
580 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
581 beamFilename );
582 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
583 Opie::OPimContactAccess::List allList = access->allRecords();
584 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
585 c = *it;
586
587 delete access;
588 } else {
589 unlink( beamfile ); // delete if exists
590 mkdir("/tmp/obex/", 0755);
591 c = m_abView -> currentEntry();
592 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
593 beamfile );
594 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
595 access->add( c );
596 access->save();
597 delete access;
598
599 beamFilename = beamfile;
600 }
601
602 odebug << "Beaming: " << beamFilename << oendl;
603
604 Ir *ir = new Ir( this );
605 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
606 QString description = c.fullName();
607 ir->send( beamFilename, description, "text/x-vCard" );
608}
609
610void AddressbookWindow::beamDone( Ir *ir ) 517void AddressbookWindow::beamDone( Ir *ir )
611{ 518{
612 519
613 delete ir; 520 delete ir;
614 unlink( beamfile ); 521 unlink( beamfile );
615} 522}
616 523
617 524
618static void parseName( const QString& name, QString *first, QString *middle, 525static void parseName( const QString& name, QString *first, QString *middle,
619 QString * last ) 526 QString * last )
620{ 527{
621 528
622 int comma = name.find ( "," ); 529 int comma = name.find ( "," );
623 QString rest; 530 QString rest;
624 if ( comma > 0 ) { 531 if ( comma > 0 ) {
625 *last = name.left( comma ); 532 *last = name.left( comma );
626 comma++; 533 comma++;
627 while ( comma < int(name.length()) && name[comma] == ' ' ) 534 while ( comma < int(name.length()) && name[comma] == ' ' )
628 comma++; 535 comma++;
629 rest = name.mid( comma ); 536 rest = name.mid( comma );
630 } else { 537 } else {
631 int space = name.findRev( ' ' ); 538 int space = name.findRev( ' ' );
632 *last = name.mid( space+1 ); 539 *last = name.mid( space+1 );
633 rest = name.left( space ); 540 rest = name.left( space );
634 } 541 }
635 int space = rest.find( ' ' ); 542 int space = rest.find( ' ' );
636 if ( space <= 0 ) { 543 if ( space <= 0 ) {
637 *first = rest; 544 *first = rest;
638 } else { 545 } else {
639 *first = rest.left( space ); 546 *first = rest.left( space );
640 *middle = rest.mid( space+1 ); 547 *middle = rest.mid( space+1 );
641 } 548 }
642 549
643} 550}
644 551
645 552
646void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 553void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
647{ 554{
648 bool needShow = FALSE; 555 bool needShow = false;
649 odebug << "Receiving QCop-Call with message " << msg << oendl; 556 odebug << "Receiving QCop-Call with message " << msg << oendl;
650 557
651 558
652 if (msg == "editPersonal()") { 559 if (msg == "editPersonal()") {
653 editPersonal(); 560 editPersonal();
561
562 // Categories might have changed, so reload
563 reloadCategories();
654 } else if (msg == "editPersonalAndClose()") { 564 } else if (msg == "editPersonalAndClose()") {
655 editPersonal(); 565 editPersonal();
656 close(); 566 close();
657 } else if ( msg == "addContact(QString,QString)" ) { 567 } else if ( msg == "addContact(QString,QString)" ) {
658 QDataStream stream(data,IO_ReadOnly); 568 QDataStream stream(data,IO_ReadOnly);
659 QString name, email; 569 QString name, email;
660 stream >> name >> email; 570 stream >> name >> email;
661 571
662 Opie::OPimContact cnt; 572 Opie::OPimContact cnt;
663 QString fn, mn, ln; 573 QString fn, mn, ln;
664 parseName( name, &fn, &mn, &ln ); 574 parseName( name, &fn, &mn, &ln );
665 //odebug << " " << fn << " - " << mn " - " << ln << oendl; 575 //odebug << " " << fn << " - " << mn " - " << ln << oendl;
666 cnt.setFirstName( fn ); 576 cnt.setFirstName( fn );
667 cnt.setMiddleName( mn ); 577 cnt.setMiddleName( mn );
668 cnt.setLastName( ln ); 578 cnt.setLastName( ln );
669 cnt.insertEmails( email ); 579 cnt.insertEmails( email );
670 cnt.setDefaultEmail( email ); 580 cnt.setDefaultEmail( email );
671 cnt.setFileAs(); 581 cnt.setFileAs();
672 582
673 m_abView -> addEntry( cnt ); 583 m_abView -> addEntry( cnt );
674 584
675 // :SXm_abView()->init( cnt ); 585 // :SXm_abView()->init( cnt );
676 editEntry( EditEntry ); 586 editEntry( EditEntry );
587
588 // Categories might have changed, so reload
589 reloadCategories();
677 } else if ( msg == "beamBusinessCard()" ) { 590 } else if ( msg == "beamBusinessCard()" ) {
678 QString beamFilename = addressbookPersonalVCardName(); 591 QString beamFilename = addressbookPersonalVCardName();
679 if ( !QFile::exists( beamFilename ) ) 592 if ( !QFile::exists( beamFilename ) )
680 return; // can't beam a non-existent file 593 return; // can't beam a non-existent file
681 594
682 Ir *ir = new Ir( this ); 595 Ir *ir = new Ir( this );
683 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 596 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
684 QString description = "mycard.vcf"; 597 QString description = "mycard.vcf";
685 ir->send( beamFilename, description, "text/x-vCard" ); 598 ir->send( beamFilename, description, "text/x-vCard" );
686 } else if ( msg == "show(int)" ) { 599 } else if ( msg == "show(int)" ) {
687 raise(); 600 raise();
688 QDataStream stream(data,IO_ReadOnly); 601 QDataStream stream(data,IO_ReadOnly);
689 int uid; 602 int uid;
690 stream >> uid; 603 stream >> uid;
691 604
692 odebug << "Showing uid: " << uid << oendl; 605 odebug << "Showing uid: " << uid << oendl;
693 606
694 // Deactivate Personal View.. 607 // Deactivate Personal View..
695 if ( actionPersonal->isOn() ){ 608 if ( m_actionPersonal->isOn() ){
696 actionPersonal->setOn( false ); 609 m_actionPersonal->setOn( false );
697 slotPersonalView(); 610 slotPersonalView();
698 } 611 }
699 612
700 // Reset category and show as card.. 613 // Reset category and show as card..
701 m_abView -> setShowByCategory( QString::null ); 614 m_abView -> setShowByCategory( QString::null );
702 m_abView -> setCurrentUid( uid ); 615 m_abView -> setCurrentUid( uid );
703 slotViewSwitched ( AbView::CardView ); 616 slotViewSwitched ( AbView::CardView );
704 617
705 needShow = true; 618 needShow = true;
706 619
707 620
708 } else if ( msg == "edit(int)" ) { 621 } else if ( msg == "edit(int)" ) {
709 QDataStream stream(data,IO_ReadOnly); 622 QDataStream stream(data,IO_ReadOnly);
710 int uid; 623 int uid;
711 stream >> uid; 624 stream >> uid;
712 625
713 // Deactivate Personal View.. 626 // Deactivate Personal View..
714 if ( actionPersonal->isOn() ){ 627 if ( m_actionPersonal->isOn() ){
715 actionPersonal->setOn( false ); 628 m_actionPersonal->setOn( false );
716 slotPersonalView(); 629 slotPersonalView();
717 } 630 }
718 631
719 // Reset category and edit.. 632 // Reset category and edit..
720 m_abView -> setShowByCategory( QString::null ); 633 m_abView -> setShowByCategory( QString::null );
721 m_abView -> setCurrentUid( uid ); 634 m_abView -> setCurrentUid( uid );
722 slotViewEdit(); 635 slotItemEdit();
723 } 636
637 // Categories might have changed, so reload
638 reloadCategories();
639 }
724 640
725 if (needShow) 641 if (needShow)
726 QPEApplication::setKeepRunning(); 642 QPEApplication::setKeepRunning();
727
728} 643}
729 644
730void AddressbookWindow::editEntry( EntryMode entryMode ) 645void AddressbookWindow::editEntry( EntryMode entryMode )
731{ 646{
732 Opie::OPimContact entry; 647 Opie::OPimContact entry;
733 if ( !abEditor ) { 648 if ( !abEditor ) {
734 abEditor = new ContactEditor( entry, this, "editor" ); 649 abEditor = new ContactEditor( entry, this, "editor" );
735 } 650 }
736 if ( entryMode == EditEntry ) 651 if ( entryMode == EditEntry )
737 abEditor->setEntry( m_abView -> currentEntry() ); 652 abEditor->setEntry( m_abView -> currentEntry() );
738 else if ( entryMode == NewEntry ) 653 else if ( entryMode == NewEntry )
739 abEditor->setEntry( entry ); 654 abEditor->setEntry( entry );
740 // other things may change the caption. 655 // other things may change the caption.
741 abEditor->setCaption( tr("Edit Address") ); 656 abEditor->setCaption( tr("Edit Address") );
742 657
743 // fix the foxus... 658 // fix the focus...
744 abEditor->setNameFocus(); 659 abEditor->setNameFocus();
745 if ( QPEApplication::execDialog( abEditor ) ) { 660 if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) {
746 setFocus(); 661 setFocus();
747 if ( entryMode == NewEntry ) { 662 if ( entryMode == NewEntry ) {
748 Opie::OPimContact insertEntry = abEditor->entry(); 663 Opie::OPimContact insertEntry = abEditor->entry();
749 insertEntry.assignUid(); 664 insertEntry.assignUid();
750 m_abView -> addEntry( insertEntry ); 665 m_abView -> addEntry( insertEntry );
751 m_abView -> setCurrentUid( insertEntry.uid() ); 666 m_abView -> setCurrentUid( insertEntry.uid() );
752 } else { 667 } else {
753 Opie::OPimContact replEntry = abEditor->entry(); 668 Opie::OPimContact replEntry = abEditor->entry();
754 669
755 if ( !replEntry.isValidUid() ) 670 if ( !replEntry.isValidUid() )
756 replEntry.assignUid(); 671 replEntry.assignUid();
757 672
758 m_abView -> replaceEntry( replEntry ); 673 m_abView -> replaceEntry( replEntry );
759 } 674 }
760 }
761 // populateCategories();
762 675
676 // Categories might have changed, so reload
677 reloadCategories();
678 }
763} 679}
764 680
765void AddressbookWindow::editPersonal() 681void AddressbookWindow::editPersonal()
766{ 682{
767 Opie::OPimContact entry; 683 Opie::OPimContact entry;
768 684
769 // Switch to personal view if not selected 685 // Switch to personal view if not selected
770 // but take care of the menu, too 686 // but take care of the menu, too
771 if ( ! actionPersonal->isOn() ){ 687 if ( ! m_actionPersonal->isOn() ){
772 odebug << "*** ++++" << oendl; 688 odebug << "*** ++++" << oendl;
773 actionPersonal->setOn( true ); 689 m_actionPersonal->setOn( true );
774 slotPersonalView(); 690 slotPersonalView();
775 } 691 }
776 692
777 if ( !abEditor ) { 693 if ( !abEditor ) {
778 abEditor = new ContactEditor( entry, this, "editor" ); 694 abEditor = new ContactEditor( entry, this, "editor" );
779 } 695 }
780 696
781 abEditor->setCaption(tr("Edit My Personal Details")); 697 abEditor->setCaption(tr("Edit My Personal Details"));
782 abEditor->setPersonalView( true ); 698 abEditor->setPersonalView( true );
783 editEntry( EditEntry ); 699 editEntry( EditEntry );
784 abEditor->setPersonalView( false ); 700 abEditor->setPersonalView( false );
785 701
786} 702}
787 703
788 704
789void AddressbookWindow::slotPersonalView() 705void AddressbookWindow::slotPersonalView()
790{ 706{
791 odebug << "slotPersonalView()" << oendl; 707 odebug << "slotPersonalView()" << oendl;
792 if (!actionPersonal->isOn()) {
793 // we just turned it off
794 odebug << "slotPersonalView()-> OFF" << oendl;
795 setCaption( tr("Contacts") );
796 actionNew->setEnabled(TRUE);
797 actionTrash->setEnabled(TRUE);
798 actionFind->setEnabled(TRUE);
799 actionMail->setEnabled(TRUE);
800 // slotUpdateToolbar();
801
802 m_abView->showPersonal( false );
803 708
804 return; 709 bool personal = m_actionPersonal->isOn();
805 }
806
807 odebug << "slotPersonalView()-> ON" << oendl;
808 // XXX need to disable some QActions.
809 actionNew->setEnabled(FALSE);
810 actionTrash->setEnabled(FALSE);
811 actionFind->setEnabled(FALSE);
812 actionMail->setEnabled(FALSE);
813 710
814 setCaption( tr("Contacts - My Personal Details") ); 711 // Disable certain menu items when showing personal details
712 setItemNewEnabled( !personal );
713 setItemDuplicateEnabled( !personal );
714 setItemDeleteEnabled( !personal );
715 m_actionMail->setEnabled( !personal );
815 716
816 m_abView->showPersonal( true ); 717 // Display appropriate view
718 m_abView->showPersonal( personal );
817 719
818} 720 // Set application caption
819 721 personal ? setCaption( tr( "Contacts - My Personal Details") )
820 722 : setCaption( tr( "Contacts") );
821void AddressbookWindow::listIsEmpty( bool empty )
822{
823 if ( !empty ) {
824 deleteButton->setEnabled( TRUE );
825 }
826} 723}
827 724
828void AddressbookWindow::reload() 725void AddressbookWindow::reload()
829{ 726{
830 syncing = FALSE; 727 syncing = false;
831 m_abView->clear(); 728 m_abView->clear();
832 m_abView->reload(); 729 m_abView->reload();
833} 730}
834 731
835void AddressbookWindow::flush() 732void AddressbookWindow::flush()
836{ 733{
837 syncing = TRUE; 734 syncing = true;
838 m_abView->save(); 735 m_abView->save();
839} 736}
840 737
841 738
842void AddressbookWindow::closeEvent( QCloseEvent *e ) 739void AddressbookWindow::closeEvent( QCloseEvent *e )
843{ 740{
844 if(active_view == AbView::CardView){ 741 if(active_view == AbView::CardView){
845 slotViewSwitched( AbView::TableView ); 742 slotViewSwitched( AbView::TableView );
846 e->ignore(); 743 e->ignore();
847 return; 744 return;
848 } 745 }
849 if(syncing) { 746 if(syncing) {
850 /* shouldn't we save, I hear you say? well its already been set 747 /* shouldn't we save, I hear you say? well its already been set
851 so that an edit can not occur during a sync, and we flushed 748 so that an edit can not occur during a sync, and we flushed
852 at the start of the sync, so there is no need to save 749 at the start of the sync, so there is no need to save
853 Saving however itself would cause problems. */ 750 Saving however itself would cause problems. */
854 e->accept(); 751 e->accept();
855 return; 752 return;
856 } 753 }
857 //################## shouldn't always save 754 //################## shouldn't always save
858 // True, but the database handles this automatically ! (se) 755 // True, but the database handles this automatically ! (se)
859 if ( save() ) 756 if ( save() )
860 e->accept(); 757 e->accept();
861 else 758 else
862 e->ignore(); 759 e->ignore();
863} 760}
864 761
865/* 762/*
866 Returns TRUE if it is OK to exit 763 Returns true if it is OK to exit
867*/ 764*/
868 765
869bool AddressbookWindow::save() 766bool AddressbookWindow::save()
870{ 767{
871 if ( !m_abView->save() ) { 768 if ( !m_abView->save() ) {
872 if ( QMessageBox::critical( 0, tr( "Out of space" ), 769 if ( QMessageBox::critical( 0, tr( "Out of space" ),
873 tr("Unable to save information.\n" 770 tr("Unable to save information.\n"
874 "Free up some space\n" 771 "Free up some space\n"
875 "and try again.\n" 772 "and try again.\n"
876 "\nQuit anyway?"), 773 "\nQuit anyway?"),
877 QMessageBox::Yes|QMessageBox::Escape, 774 QMessageBox::Yes|QMessageBox::Escape,
878 QMessageBox::No|QMessageBox::Default ) 775 QMessageBox::No|QMessageBox::Default )
879 != QMessageBox::No ) 776 != QMessageBox::No )
880 return TRUE; 777 return true;
881 else 778 else
882 return FALSE; 779 return false;
883 } 780 }
884 return TRUE; 781 return true;
885} 782}
886 783
887#ifdef __DEBUG_RELEASE 784#ifdef __DEBUG_RELEASE
888void AddressbookWindow::slotSave() 785void AddressbookWindow::slotSave()
889{ 786{
890 save(); 787 save();
891} 788}
892#endif 789#endif
893 790
894 791
895void AddressbookWindow::slotNotFound() 792void AddressbookWindow::slotNotFound()
896{ 793{
897 odebug << "Got not found signal!" << oendl; 794 odebug << "Got not found signal!" << oendl;
898 QMessageBox::information( this, tr( "Not Found" ), 795 QMessageBox::information( this, tr( "Not Found" ),
899 "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); 796 "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" );
900 797
901 798
902} 799}
903void AddressbookWindow::slotWrapAround() 800void AddressbookWindow::slotWrapAround()
904{ 801{
905 odebug << "Got wrap signal!" << oendl; 802 odebug << "Got wrap signal!" << oendl;
906 // if ( doNotifyWrapAround ) 803 // if ( doNotifyWrapAround )
907 // QMessageBox::information( this, tr( "End of list" ), 804 // QMessageBox::information( this, tr( "End of list" ),
908 // tr( "End of list. Wrap around now...!" ) + "\n" ); 805 // tr( "End of list. Wrap around now...!" ) + "\n" );
909 806
910} 807}
911 808
912void AddressbookWindow::slotSetCategory( int c ) 809void AddressbookWindow::slotSetCategory( const QString &category )
913{ 810{
914 odebug << "void AddressbookWindow::slotSetCategory( " << c << " ) from " 811 odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl;
915 << catMenu->count() << oendl;
916
917 QString cat, book;
918 AbView::Views view = AbView::TableView;
919
920 if ( c <= 0 )
921 return;
922
923 // Switch view
924 if ( c < 3 )
925 for ( unsigned int i = 1; i < 3; i++ ){
926 if ( catMenu )
927 catMenu->setItemChecked( i, c == (int)i );
928 }
929 else
930 // Checkmark Category Menu Item Selected
931 for ( unsigned int i = 3; i < catMenu->count(); i++ )
932 catMenu->setItemChecked( i, c == (int)i );
933
934 // Now switch to the selected category
935 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
936 if (catMenu->isItemChecked( i )) {
937 if ( i == 1 ){ // default List view
938 book = QString::null;
939 view = AbView::TableView;
940 }else if ( i == 2 ){
941 book = tr( "Cards" );
942 view = AbView::CardView;
943 // }else if ( i == 3 ){
944 // book = tr( "Personal" );
945 // view = AbView:: PersonalView;
946 }else if ( i == 3 ){ // default All Categories
947 cat = QString::null;
948 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
949 cat = "Unfiled";
950 odebug << "Unfiled selected!" << oendl;
951 }else{
952 cat = m_abView->categories()[i - 4];
953 }
954 }
955 }
956
957 // Switch to the selected View
958 slotViewSwitched( view );
959 812
960 // Tell the view about the selected category 813 // Tell the view about the selected category
961 m_abView -> setShowByCategory( cat ); 814 m_config.setCategory( category );
962 815 m_abView -> setShowByCategory( category );
963 if ( book.isEmpty() )
964 book = "List";
965 if ( cat.isEmpty() )
966 cat = "All";
967
968 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
969} 816}
970 817
971void AddressbookWindow::slotViewSwitched( int view ) 818void AddressbookWindow::slotViewSwitched( int view )
972{ 819{
973 odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl; 820 odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl;
974 int menu = 0;
975
976 // Switch to selected view
977 switch ( view ){
978 case AbView::TableView:
979 menu = 1;
980 m_tableViewButton->setOn(true);
981 m_cardViewButton->setOn(false);
982 break;
983 case AbView::CardView:
984 menu = 2;
985 m_tableViewButton->setOn(false);
986 m_cardViewButton->setOn(true);
987 break;
988 }
989 for ( unsigned int i = 1; i < 3; i++ ){
990 if ( catMenu )
991 catMenu->setItemChecked( i, menu == (int)i );
992 }
993 821
994 // Tell the view about the selected view 822 // Tell the view about the selected view
995 m_abView -> setShowToView ( (AbView::Views) view ); 823 m_abView -> setShowToView ( (AbView::Views) view );
996 active_view = view; 824 active_view = view;
997} 825}
998 826
999 827
1000void AddressbookWindow::slotListView() 828void AddressbookWindow::slotListView()
1001{ 829{
1002 slotViewSwitched( AbView::TableView ); 830 slotViewSwitched( AbView::TableView );
1003} 831}
1004 832
1005void AddressbookWindow::slotCardView() 833void AddressbookWindow::slotCardView()
1006{ 834{
1007 slotViewSwitched( AbView::CardView ); 835 slotViewSwitched( AbView::CardView );
1008} 836}
1009 837
1010void AddressbookWindow::slotSetLetter( char c ) { 838void AddressbookWindow::slotSetLetter( char c ) {
1011 839
1012 m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); 840 m_abView->setShowByLetter( c, m_config.letterPickerSearch() );
1013 841
1014} 842}
1015 843
1016
1017void AddressbookWindow::populateCategories()
1018{
1019 catMenu->clear();
1020
1021 int id, rememberId;
1022 id = 1;
1023 rememberId = 0;
1024
1025 catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ );
1026 catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ );
1027 // catMenu->insertItem( tr( "Personal" ), id++ );
1028 catMenu->insertSeparator();
1029
1030 catMenu->insertItem( tr( "All" ), id++ );
1031 QStringList categories = m_abView->categories();
1032 categories.append( tr( "Unfiled" ) );
1033 for ( QStringList::Iterator it = categories.begin();
1034 it != categories.end(); ++it ) {
1035 catMenu->insertItem( *it, id );
1036 if ( *it == m_abView -> showCategory() )
1037 rememberId = id;
1038 ++id;
1039 }
1040
1041
1042 if ( m_abView -> showCategory().isEmpty() ) {
1043 slotSetCategory( 3 );
1044 }
1045 else {
1046 slotSetCategory( rememberId );
1047 }
1048}
1049
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 7cc61bf..b04e2cc 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -1,137 +1,137 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef Addressbook_H 20#ifndef Addressbook_H
21#define Addressbook_H 21#define Addressbook_H
22 22
23// Remove this for OPIE releae 1.0 ! 23// Remove this for OPIE releae 1.0 !
24// #define __DEBUG_RELEASE 24// #define __DEBUG_RELEASE
25 25
26#include <qmainwindow.h> 26#include <opie2/opimmainwindow.h>
27
27#include <qvaluelist.h> 28#include <qvaluelist.h>
28#include <qstringlist.h> 29#include <qstringlist.h>
29#include <qlineedit.h> 30#include <qlineedit.h>
30#include "ofloatbar.h" 31#include "ofloatbar.h"
31#include "abview.h" 32#include "abview.h"
32#include "abconfig.h" 33#include "abconfig.h"
33 34
34class ContactEditor; 35class ContactEditor;
35class AbLabel; 36class AbLabel;
36class AbTable; 37class AbTable;
37class QToolBar; 38class QToolBar;
38class QPopupMenu; 39class QPopupMenu;
39class QToolButton; 40class QToolButton;
40class QDialog; 41class QDialog;
41class Ir; 42class Ir;
42class QAction; 43class QAction;
43class LetterPicker; 44class LetterPicker;
45class Opie::OPimRecord;
44 46
45class AddressbookWindow: public QMainWindow 47class AddressbookWindow: public Opie::OPimMainWindow
46{ 48{
47 Q_OBJECT 49 Q_OBJECT
48public: 50public:
49 enum EntryMode { NewEntry=0, EditEntry }; 51 enum EntryMode { NewEntry=0, EditEntry };
50 52
51 static QString appName() { return QString::fromLatin1("addressbook"); } 53 static QString appName() { return QString::fromLatin1("addressbook"); }
52 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 54 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
53 ~AddressbookWindow(); 55 ~AddressbookWindow();
54 56
55protected: 57protected:
56 void resizeEvent( QResizeEvent * e ); 58 void resizeEvent( QResizeEvent * e );
57 59
58 void editPersonal(); 60 void editPersonal();
59 void editEntry( EntryMode ); 61 void editEntry( EntryMode );
60 void closeEvent( QCloseEvent *e ); 62 void closeEvent( QCloseEvent *e );
61 bool save(); 63 bool save();
62 64
63public slots: 65public slots:
64 void flush(); 66 void flush();
65 void reload(); 67 void reload();
66 void appMessage(const QCString &, const QByteArray &); 68 void appMessage(const QCString &, const QByteArray &);
67 void setDocument( const QString & ); // Called by obex receiver and internally! 69 void setDocument( const QString & ); // Called by obex receiver and internally!
68#ifdef __DEBUG_RELEASE 70#ifdef __DEBUG_RELEASE
69 // void slotSave(); 71 // void slotSave();
70#endif 72#endif
71 73
74protected slots:
75 int create();
76 bool remove( int uid );
77 void beam( int uid );
78 void show( int uid );
79 void edit( int uid );
80 void add( const Opie::OPimRecord& );
81
72private slots: 82private slots:
83 void slotItemNew();
84 void slotItemEdit();
85 void slotItemDuplicate();
86 void slotItemDelete();
87 void slotItemBeam();
88 void slotItemFind();
89 void slotConfigure();
90
73 void importvCard(); 91 void importvCard();
74 void exportvCard(); 92 void exportvCard();
75 void slotListNew();
76 /* void slotListView(); */
77 void slotListDelete();
78 void slotViewBack(); 93 void slotViewBack();
79 void slotViewEdit();
80 void slotPersonalView(); 94 void slotPersonalView();
81 void listIsEmpty( bool );
82 /* void slotSettings(); */
83 void writeMail(); 95 void writeMail();
84 void slotBeam();
85 void beamDone( Ir * ); 96 void beamDone( Ir * );
86 void slotSetCategory( int ); 97 void slotSetCategory( const QString &category );
87 void slotSetLetter( char ); 98 void slotSetLetter( char );
88 void slotUpdateToolbar();
89 void slotSetFont(int); 99 void slotSetFont(int);
90 100
91 void slotFindOpen(); 101 void slotShowFind( bool show );
92 void slotFindClose();
93 void slotFind(); 102 void slotFind();
94 void slotNotFound(); 103 void slotNotFound();
95 void slotWrapAround(); 104 void slotWrapAround();
96 105
97 void slotViewSwitched( int ); 106 void slotViewSwitched( int );
98 void slotListView(); 107 void slotListView();
99 void slotCardView(); 108 void slotCardView();
100 109
101 void slotConfig();
102
103private: 110private:
104 void populateCategories();
105
106 QPopupMenu *catMenu;
107 QToolBar *listTools; 111 QToolBar *listTools;
108 QToolButton *deleteButton;
109 enum Panes { paneList=0, paneView, paneEdit }; 112 enum Panes { paneList=0, paneView, paneEdit };
110 ContactEditor *abEditor; 113 ContactEditor *abEditor;
111 LetterPicker *pLabel; 114 LetterPicker *pLabel;
112 AbView* m_abView; 115 AbView* m_abView;
113 QWidget *listContainer; 116 QWidget *m_listContainer;
114 117
115 // Searching stuff 118 // Searching stuff
116 OFloatBar* searchBar; 119 OFloatBar* m_searchBar;
117 QLineEdit* searchEdit; 120 QLineEdit* m_searchEdit;
118 121
119 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; 122 QAction *m_actionPersonal, *m_actionMail;
120 123
121 int viewMargin; 124 int viewMargin;
122 125
123 bool syncing; 126 bool syncing;
124 QFont *defaultFont; 127 QFont *defaultFont;
125 int m_curFontSize; 128 int m_curFontSize;
126 129
127 bool isLoading; 130 bool isLoading;
128 131
129 AbConfig m_config; 132 AbConfig m_config;
130 133
131 QAction* m_tableViewButton;
132 QAction* m_cardViewButton;
133
134 int active_view; 134 int active_view;
135}; 135};
136 136
137#endif 137#endif
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index b078968..dec4c7c 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,316 +1,314 @@
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#include "namelineedit.h"
24 24
25#include <opie2/odebug.h> 25#include <opie2/odebug.h>
26#include <opie2/opimcontact.h> 26#include <opie2/opimcontact.h>
27 27
28#include <qpe/categoryselect.h> 28#include <qpe/categoryselect.h>
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/qpedialog.h> 30#include <qpe/qpedialog.h>
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32 32
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qtabwidget.h>
35#include <qlayout.h> 34#include <qlayout.h>
36#include <qlineedit.h> 35#include <qlineedit.h>
37#include <qmultilineedit.h> 36#include <qmultilineedit.h>
38#include <qtoolbutton.h> 37#include <qtoolbutton.h>
39#include <qlistbox.h> 38#include <qlistbox.h>
40#include <qmessagebox.h> 39#include <qmessagebox.h>
41#include <qwhatsthis.h> 40#include <qwhatsthis.h>
42 41
43#include <assert.h> 42#include <assert.h>
44 43
45static inline bool containsAlphaNum( const QString &str ); 44static inline bool containsAlphaNum( const QString &str );
46static inline bool constainsWhiteSpace( const QString &str ); 45static inline bool constainsWhiteSpace( const QString &str );
47 46
48// helper functions, convert our comma delimited list to proper 47// helper functions, convert our comma delimited list to proper
49// file format... 48// file format...
50void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 49void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
51 QString &strAll ); 50 QString &strAll );
52 51
53// helper convert from file format to comma delimited... 52// helper convert from file format to comma delimited...
54void parseEmailTo( const QString &strDefaultEmail, 53void parseEmailTo( const QString &strDefaultEmail,
55 const QString &strOtherEmail, QString &strBack ); 54 const QString &strOtherEmail, QString &strBack );
56 55
57 ContactEditor::ContactEditor(const Opie::OPimContact &entry, 56 ContactEditor::ContactEditor(const Opie::OPimContact &entry,
58 QWidget *parent, 57 QWidget *parent,
59 const char *name, 58 const char *name,
60 WFlags ) 59 WFlags )
61 : QDialog( parent, name, TRUE, WStyle_ContextHelp ), 60 : QDialog( parent, name, true, WStyle_ContextHelp ),
62 defaultEmailChooserPosition( -1 ), 61 defaultEmailChooserPosition( -1 ),
63 m_personalView ( false ), 62 m_personalView ( false ),
64 cmbDefaultEmail( 0 ), 63 cmbDefaultEmail( 0 ),
65 initializing ( false ) 64 initializing ( false )
66{ 65{
67 66
68 initializing = true; 67 initializing = true;
69 68
70 init(); 69 init();
71 setEntry( entry ); 70 setEntry( entry );
72 // cmbDefaultEmail = 0; 71 // cmbDefaultEmail = 0;
73 // defaultEmailChooserPosition = -1; 72 // defaultEmailChooserPosition = -1;
74 73
75 initializing = false; 74 initializing = false;
76} 75}
77 76
78ContactEditor::~ContactEditor() { 77ContactEditor::~ContactEditor() {
79} 78}
80 79
81void ContactEditor::init() { 80void ContactEditor::init() {
82 odebug << "init() START" << oendl; 81 odebug << "init() START" << oendl;
83 82
84 uint i = 0; 83 uint i = 0;
85 84
86 QStringList trlChooserNames; 85 QStringList trlChooserNames;
87 86
88 for (i = 0; i <= 6; i++) { 87 for (i = 0; i <= 6; i++) {
89 slHomeAddress.append( "" ); 88 slHomeAddress.append( "" );
90 slBusinessAddress.append( "" ); 89 slBusinessAddress.append( "" );
91 } 90 }
92 91
93 trlChooserNames = Opie::OPimContactFields::trphonefields( false ); 92 trlChooserNames = Opie::OPimContactFields::trphonefields( false );
94 slChooserNames = Opie::OPimContactFields::untrphonefields( false ); 93 slChooserNames = Opie::OPimContactFields::untrphonefields( false );
95 slDynamicEntries = Opie::OPimContactFields::untrdetailsfields( false ); 94 slDynamicEntries = Opie::OPimContactFields::untrdetailsfields( false );
96 trlDynamicEntries = Opie::OPimContactFields::trdetailsfields( false ); 95 trlDynamicEntries = Opie::OPimContactFields::trdetailsfields( false );
97 96
98 // Ok, we have to remove elements from the list of dynamic entries 97 // Ok, we have to remove elements from the list of dynamic entries
99 // which are now stored in special (not dynamic) widgets.. 98 // which are now stored in special (not dynamic) widgets..
100 // Otherwise we will get problems with field assignments! (se) 99 // Otherwise we will get problems with field assignments! (se)
101 slDynamicEntries.remove("Anniversary"); 100 slDynamicEntries.remove("Anniversary");
102 slDynamicEntries.remove("Birthday"); 101 slDynamicEntries.remove("Birthday");
103 slDynamicEntries.remove("Gender"); 102 slDynamicEntries.remove("Gender");
104 103
105 // The same with translated fields.. But I will 104 // The same with translated fields.. But I will
106 // use the translation map to avoid mismatches.. 105 // use the translation map to avoid mismatches..
107 QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields(); 106 QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields();
108 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); 107 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] );
109 trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); 108 trlDynamicEntries.remove( translMap[Qtopia::Birthday] );
110 trlDynamicEntries.remove( translMap[Qtopia::Gender] ); 109 trlDynamicEntries.remove( translMap[Qtopia::Gender] );
111 110
112 // Last Check to be sure.. 111 // Last Check to be sure..
113 assert( slDynamicEntries.count() == trlDynamicEntries.count() ); 112 assert( slDynamicEntries.count() == trlDynamicEntries.count() );
114 assert( slChooserNames.count() == trlChooserNames.count() ); 113 assert( slChooserNames.count() == trlChooserNames.count() );
115 114
116 for (i = 0; i < slChooserNames.count(); i++) 115 for (i = 0; i < slChooserNames.count(); i++)
117 slChooserValues.append(""); 116 slChooserValues.append("");
118 117
119 118
120 QVBoxLayout *vb = new QVBoxLayout( this ); 119 QVBoxLayout *vb = new QVBoxLayout( this );
121 120
122 tabMain = new QTabWidget( this ); 121 tabMain = new Opie::Ui::OTabWidget( this );
123 vb->addWidget( tabMain ); 122 vb->addWidget( tabMain );
124 123
125 QWidget *tabViewport = new QWidget ( tabMain ); 124 m_generalWidget = new QWidget ( tabMain );
126 125
127 vb = new QVBoxLayout( tabViewport ); 126 vb = new QVBoxLayout( m_generalWidget );
128 127
129 svGeneral = new QScrollView( tabViewport ); 128 svGeneral = new QScrollView( m_generalWidget );
130 vb->addWidget( svGeneral, 0, 0 ); 129 vb->addWidget( svGeneral, 0, 0 );
131 svGeneral->setResizePolicy( QScrollView::AutoOneFit ); 130 svGeneral->setResizePolicy( QScrollView::AutoOneFit );
132 // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); 131 // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff );
133 // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); 132 // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff );
134 svGeneral->setFrameStyle( QFrame::NoFrame ); 133 svGeneral->setFrameStyle( QFrame::NoFrame );
135 134
136 QWidget *container = new QWidget( svGeneral->viewport() ); 135 QWidget *container = new QWidget( svGeneral->viewport() );
137 svGeneral->addChild( container ); 136 svGeneral->addChild( container );
138 137
139 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); 138 QGridLayout *gl = new QGridLayout( container, 10, 2, 2, 4 );
140 gl->setResizeMode( QLayout::FreeResize );
141 139
142 btnFullName = new QPushButton( tr( "Full Name..." ), container ); 140 btnFullName = new QPushButton( tr( "Full Name..." ), container );
143 QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); 141 QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) );
144 gl->addWidget( btnFullName, 0, 0 ); 142 gl->addWidget( btnFullName, 0, 0 );
145 txtFullName = new ABOOK::NameLineEdit( container ); 143 txtFullName = new ABOOK::NameLineEdit( container );
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\"" ) ); 144 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\"" ) );
147 gl->addWidget( txtFullName, 0, 1 ); 145 gl->addWidget( txtFullName, 0, 1 );
148 146
149 QLabel *l = new QLabel( tr( "Job Title" ), container ); 147 QLabel *l = new QLabel( tr( "Job Title" ), container );
150 QWhatsThis::add( l, tr( "The jobtitle.." ) ); 148 QWhatsThis::add( l, tr( "The jobtitle.." ) );
151 gl->addWidget( l, 1, 0 ); 149 gl->addWidget( l, 1, 0 );
152 txtJobTitle = new QLineEdit( container ); 150 txtJobTitle = new QLineEdit( container );
153 QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) ); 151 QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) );
154 gl->addWidget( txtJobTitle, 1, 1 ); 152 gl->addWidget( txtJobTitle, 1, 1 );
155 153
156 l = new QLabel( tr("Suffix"), container ); 154 l = new QLabel( tr("Suffix"), container );
157 QWhatsThis::add( l, tr( "Something like \"jr.\".." ) ); 155 QWhatsThis::add( l, tr( "Something like \"jr.\".." ) );
158 gl->addWidget( l, 2, 0 ); 156 gl->addWidget( l, 2, 0 );
159 txtSuffix = new QLineEdit( container ); 157 txtSuffix = new QLineEdit( container );
160 QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) ); 158 QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) );
161 gl->addWidget( txtSuffix, 2, 1 ); 159 gl->addWidget( txtSuffix, 2, 1 );
162 160
163 l = new QLabel( tr( "Organization" ), container ); 161 l = new QLabel( tr( "Organization" ), container );
164 QWhatsThis::add( l, tr( "The working place of the contact" ) ); 162 QWhatsThis::add( l, tr( "The working place of the contact" ) );
165 gl->addWidget( l, 3, 0 ); 163 gl->addWidget( l, 3, 0 );
166 txtOrganization = new QLineEdit( container ); 164 txtOrganization = new QLineEdit( container );
167 QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); 165 QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) );
168 gl->addWidget( txtOrganization, 3, 1 ); 166 gl->addWidget( txtOrganization, 3, 1 );
169 167
170 // Chooser 1 168 // Chooser 1
171 cmbChooserField1 = new QComboBox( FALSE, container ); 169 cmbChooserField1 = new QComboBox( false, container );
172 QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); 170 QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) );
173 cmbChooserField1->setMaximumWidth( 90 ); 171 cmbChooserField1->setMaximumWidth( 90 );
174 gl->addWidget( cmbChooserField1, 4, 0 ); 172 gl->addWidget( cmbChooserField1, 4, 0 );
175 // Textfield for chooser 1. 173 // Textfield for chooser 1.
176 // Now use Widgetstack to contain the textfield and the default-email combo ! 174 // Now use Widgetstack to contain the textfield and the default-email combo !
177 m_widgetStack1 = new QWidgetStack( container ); 175 m_widgetStack1 = new QWidgetStack( container );
178 txtChooserField1 = new QLineEdit( m_widgetStack1 ); 176 txtChooserField1 = new QLineEdit( m_widgetStack1 );
179 m_widgetStack1 -> addWidget( txtChooserField1, TextField ); 177 m_widgetStack1 -> addWidget( txtChooserField1, TextField );
180 gl->addWidget( m_widgetStack1, 4, 1 ); 178 gl->addWidget( m_widgetStack1, 4, 1 );
181 m_widgetStack1 -> raiseWidget( TextField ); 179 m_widgetStack1 -> raiseWidget( TextField );
182 180
183 // Chooser 2 181 // Chooser 2
184 cmbChooserField2 = new QComboBox( FALSE, container ); 182 cmbChooserField2 = new QComboBox( false, container );
185 QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); 183 QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) );
186 cmbChooserField2->setMaximumWidth( 90 ); 184 cmbChooserField2->setMaximumWidth( 90 );
187 gl->addWidget( cmbChooserField2, 5, 0 ); 185 gl->addWidget( cmbChooserField2, 5, 0 );
188 // Textfield for chooser 2 186 // Textfield for chooser 2
189 // Now use WidgetStack to contain the textfield and the default-email combo! 187 // Now use WidgetStack to contain the textfield and the default-email combo!
190 m_widgetStack2 = new QWidgetStack( container ); 188 m_widgetStack2 = new QWidgetStack( container );
191 txtChooserField2 = new QLineEdit( m_widgetStack2 ); 189 txtChooserField2 = new QLineEdit( m_widgetStack2 );
192 m_widgetStack2 -> addWidget( txtChooserField2, TextField ); 190 m_widgetStack2 -> addWidget( txtChooserField2, TextField );
193 gl->addWidget( m_widgetStack2, 5, 1 ); 191 gl->addWidget( m_widgetStack2, 5, 1 );
194 m_widgetStack2 -> raiseWidget( TextField ); 192 m_widgetStack2 -> raiseWidget( TextField );
195 193
196 // Chooser 3 194 // Chooser 3
197 cmbChooserField3 = new QComboBox( FALSE, container ); 195 cmbChooserField3 = new QComboBox( false, container );
198 QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); 196 QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) );
199 cmbChooserField3->setMaximumWidth( 90 ); 197 cmbChooserField3->setMaximumWidth( 90 );
200 gl->addWidget( cmbChooserField3, 6, 0 ); 198 gl->addWidget( cmbChooserField3, 6, 0 );
201 // Textfield for chooser 2 199 // Textfield for chooser 2
202 // Now use WidgetStack to contain the textfield and the default-email combo! 200 // Now use WidgetStack to contain the textfield and the default-email combo!
203 m_widgetStack3 = new QWidgetStack( container ); 201 m_widgetStack3 = new QWidgetStack( container );
204 txtChooserField3 = new QLineEdit( m_widgetStack3 ); 202 txtChooserField3 = new QLineEdit( m_widgetStack3 );
205 m_widgetStack3 -> addWidget( txtChooserField3, TextField ); 203 m_widgetStack3 -> addWidget( txtChooserField3, TextField );
206 gl->addWidget( m_widgetStack3, 6, 1 ); 204 gl->addWidget( m_widgetStack3, 6, 1 );
207 m_widgetStack3 -> raiseWidget( TextField ); 205 m_widgetStack3 -> raiseWidget( TextField );
208 206
209 l = new QLabel( tr( "File As" ), container ); 207 l = new QLabel( tr( "File As" ), container );
210 QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) ); 208 QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) );
211 gl->addWidget( l, 7, 0 ); 209 gl->addWidget( l, 7, 0 );
212 cmbFileAs = new QComboBox( TRUE, container ); 210 cmbFileAs = new QComboBox( true, container );
213 gl->addWidget( cmbFileAs, 7, 1 ); 211 gl->addWidget( cmbFileAs, 7, 1 );
214 212
215 labCat = new QLabel( tr( "Category" ), container ); 213 labCat = new QLabel( tr( "Category" ), container );
216 gl->addWidget( labCat, 8, 0 ); 214 gl->addWidget( labCat, 8, 0 );
217 cmbCat = new CategorySelect( container ); 215 cmbCat = new CategorySelect( container );
218 gl->addWidget( cmbCat, 8, 1 ); 216 gl->addWidget( cmbCat, 8, 1 );
219 labCat->show(); 217 labCat->show();
220 cmbCat->show(); 218 cmbCat->show();
221 219
222 btnNote = new QPushButton( tr( "Notes..." ), container ); 220 btnNote = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Notes..." ), container );
223 gl->addWidget( btnNote, 9, 1 ); 221 gl->addWidget( btnNote, 9, 1 );
224 222
225 tabMain->insertTab( tabViewport, tr( "General" ) ); 223 tabMain->addTab( m_generalWidget, "addressbook/AddressBookSmall", tr( "General" ) );
226 224
227 tabViewport = new QWidget ( tabMain ); 225 QWidget *tabViewport = new QWidget ( tabMain );
228 226
229 vb = new QVBoxLayout( tabViewport ); 227 vb = new QVBoxLayout( tabViewport );
230 228
231 svAddress = new QScrollView( tabViewport ); 229 svAddress = new QScrollView( tabViewport );
232 vb->addWidget( svAddress, 0, 0 ); 230 vb->addWidget( svAddress, 0, 0 );
233 svAddress->setResizePolicy( QScrollView::AutoOneFit ); 231 svAddress->setResizePolicy( QScrollView::AutoOneFit );
234 svAddress->setFrameStyle( QFrame::NoFrame ); 232 svAddress->setFrameStyle( QFrame::NoFrame );
235 233
236 container = new QWidget( svAddress->viewport() ); 234 container = new QWidget( svAddress->viewport() );
237 svAddress->addChild( container ); 235 svAddress->addChild( container );
238 236
239 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem 237 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem
240 238
241 cmbAddress = new QComboBox( FALSE, container ); 239 cmbAddress = new QComboBox( false, container );
242 cmbAddress->insertItem( tr( "Business" ) ); 240 cmbAddress->insertItem( tr( "Business" ) );
243 cmbAddress->insertItem( tr( "Home" ) ); 241 cmbAddress->insertItem( tr( "Home" ) );
244 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); 242 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 );
245 243
246 l = new QLabel( tr( "Address" ), container ); 244 l = new QLabel( tr( "Address" ), container );
247 gl->addWidget( l, 1, 0 ); 245 gl->addWidget( l, 1, 0 );
248 txtAddress = new QLineEdit( container ); 246 txtAddress = new QLineEdit( container );
249 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); 247 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 );
250 248
251 l = new QLabel( tr( "City" ), container ); 249 l = new QLabel( tr( "City" ), container );
252 gl->addWidget( l, 2, 0 ); 250 gl->addWidget( l, 2, 0 );
253 txtCity = new QLineEdit( container ); 251 txtCity = new QLineEdit( container );
254 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); 252 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 );
255 253
256 l = new QLabel( tr( "State" ), container ); 254 l = new QLabel( tr( "State" ), container );
257 gl->addWidget( l, 3, 0 ); 255 gl->addWidget( l, 3, 0 );
258 txtState = new QLineEdit( container ); 256 txtState = new QLineEdit( container );
259 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); 257 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 );
260 258
261 l = new QLabel( tr( "Zip Code" ), container ); 259 l = new QLabel( tr( "Zip Code" ), container );
262 gl->addWidget( l, 4, 0 ); 260 gl->addWidget( l, 4, 0 );
263 txtZip = new QLineEdit( container ); 261 txtZip = new QLineEdit( container );
264 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); 262 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 );
265 263
266 l = new QLabel( tr( "Country" ), container ); 264 l = new QLabel( tr( "Country" ), container );
267 gl->addWidget( l, 5, 0 ); 265 gl->addWidget( l, 5, 0 );
268 cmbCountry = new QComboBox( TRUE, container ); 266 cmbCountry = new QComboBox( true, container );
269 cmbCountry->insertItem( "" ); 267 cmbCountry->insertItem( "" );
270 cmbCountry->insertItem( tr ( "United States" ) ); 268 cmbCountry->insertItem( tr ( "United States" ) );
271 cmbCountry->insertItem( tr ( "United Kingdom" ) ); 269 cmbCountry->insertItem( tr ( "United Kingdom" ) );
272 cmbCountry->insertItem( tr ( "Afghanistan" ) ); 270 cmbCountry->insertItem( tr ( "Afghanistan" ) );
273 cmbCountry->insertItem( tr ( "Albania" ) ); 271 cmbCountry->insertItem( tr ( "Albania" ) );
274 cmbCountry->insertItem( tr ( "Algeria" ) ); 272 cmbCountry->insertItem( tr ( "Algeria" ) );
275 cmbCountry->insertItem( tr ( "American Samoa" ) ); 273 cmbCountry->insertItem( tr ( "American Samoa" ) );
276 cmbCountry->insertItem( tr ( "Andorra" ) ); 274 cmbCountry->insertItem( tr ( "Andorra" ) );
277 cmbCountry->insertItem( tr ( "Angola" ) ); 275 cmbCountry->insertItem( tr ( "Angola" ) );
278 cmbCountry->insertItem( tr ( "Anguilla" ) ); 276 cmbCountry->insertItem( tr ( "Anguilla" ) );
279 cmbCountry->insertItem( tr ( "Antarctica" ) ); 277 cmbCountry->insertItem( tr ( "Antarctica" ) );
280 cmbCountry->insertItem( tr ( "Argentina" ) ); 278 cmbCountry->insertItem( tr ( "Argentina" ) );
281 cmbCountry->insertItem( tr ( "Armenia" ) ); 279 cmbCountry->insertItem( tr ( "Armenia" ) );
282 cmbCountry->insertItem( tr ( "Aruba" ) ); 280 cmbCountry->insertItem( tr ( "Aruba" ) );
283 cmbCountry->insertItem( tr ( "Australia" ) ); 281 cmbCountry->insertItem( tr ( "Australia" ) );
284 cmbCountry->insertItem( tr ( "Austria" ) ); 282 cmbCountry->insertItem( tr ( "Austria" ) );
285 cmbCountry->insertItem( tr ( "Azerbaijan" ) ); 283 cmbCountry->insertItem( tr ( "Azerbaijan" ) );
286 cmbCountry->insertItem( tr ( "Bahamas" ) ); 284 cmbCountry->insertItem( tr ( "Bahamas" ) );
287 cmbCountry->insertItem( tr ( "Bahrain" ) ); 285 cmbCountry->insertItem( tr ( "Bahrain" ) );
288 cmbCountry->insertItem( tr ( "Bangladesh" ) ); 286 cmbCountry->insertItem( tr ( "Bangladesh" ) );
289 cmbCountry->insertItem( tr ( "Barbados" ) ); 287 cmbCountry->insertItem( tr ( "Barbados" ) );
290 cmbCountry->insertItem( tr ( "Belarus" ) ); 288 cmbCountry->insertItem( tr ( "Belarus" ) );
291 cmbCountry->insertItem( tr ( "Belgium" ) ); 289 cmbCountry->insertItem( tr ( "Belgium" ) );
292 cmbCountry->insertItem( tr ( "Belize" ) ); 290 cmbCountry->insertItem( tr ( "Belize" ) );
293 cmbCountry->insertItem( tr ( "Benin" ) ); 291 cmbCountry->insertItem( tr ( "Benin" ) );
294 cmbCountry->insertItem( tr ( "Bermuda" ) ); 292 cmbCountry->insertItem( tr ( "Bermuda" ) );
295 cmbCountry->insertItem( tr ( "Bhutan" ) ); 293 cmbCountry->insertItem( tr ( "Bhutan" ) );
296 cmbCountry->insertItem( tr ( "Bolivia" ) ); 294 cmbCountry->insertItem( tr ( "Bolivia" ) );
297 cmbCountry->insertItem( tr ( "Botswana" ) ); 295 cmbCountry->insertItem( tr ( "Botswana" ) );
298 cmbCountry->insertItem( tr ( "Bouvet Island" ) ); 296 cmbCountry->insertItem( tr ( "Bouvet Island" ) );
299 cmbCountry->insertItem( tr ( "Brazil" ) ); 297 cmbCountry->insertItem( tr ( "Brazil" ) );
300 cmbCountry->insertItem( tr ( "Brunei Darussalam" ) ); 298 cmbCountry->insertItem( tr ( "Brunei Darussalam" ) );
301 cmbCountry->insertItem( tr ( "Bulgaria" ) ); 299 cmbCountry->insertItem( tr ( "Bulgaria" ) );
302 cmbCountry->insertItem( tr ( "Burkina Faso" ) ); 300 cmbCountry->insertItem( tr ( "Burkina Faso" ) );
303 cmbCountry->insertItem( tr ( "Burundi" ) ); 301 cmbCountry->insertItem( tr ( "Burundi" ) );
304 cmbCountry->insertItem( tr ( "Cambodia" ) ); 302 cmbCountry->insertItem( tr ( "Cambodia" ) );
305 cmbCountry->insertItem( tr ( "Cameroon" ) ); 303 cmbCountry->insertItem( tr ( "Cameroon" ) );
306 cmbCountry->insertItem( tr ( "Canada" ) ); 304 cmbCountry->insertItem( tr ( "Canada" ) );
307 cmbCountry->insertItem( tr ( "Cape Verde" ) ); 305 cmbCountry->insertItem( tr ( "Cape Verde" ) );
308 cmbCountry->insertItem( tr ( "Cayman Islands" ) ); 306 cmbCountry->insertItem( tr ( "Cayman Islands" ) );
309 cmbCountry->insertItem( tr ( "Chad" ) ); 307 cmbCountry->insertItem( tr ( "Chad" ) );
310 cmbCountry->insertItem( tr ( "Chile" ) ); 308 cmbCountry->insertItem( tr ( "Chile" ) );
311 cmbCountry->insertItem( tr ( "China" ) ); 309 cmbCountry->insertItem( tr ( "China" ) );
312 cmbCountry->insertItem( tr ( "Christmas Island" ) ); 310 cmbCountry->insertItem( tr ( "Christmas Island" ) );
313 cmbCountry->insertItem( tr ( "Colombia" ) ); 311 cmbCountry->insertItem( tr ( "Colombia" ) );
314 cmbCountry->insertItem( tr ( "Comoros" ) ); 312 cmbCountry->insertItem( tr ( "Comoros" ) );
315 cmbCountry->insertItem( tr ( "Congo" ) ); 313 cmbCountry->insertItem( tr ( "Congo" ) );
316 cmbCountry->insertItem( tr ( "Cook Island" ) ); 314 cmbCountry->insertItem( tr ( "Cook Island" ) );
@@ -440,220 +438,220 @@ void ContactEditor::init() {
440 cmbCountry->insertItem( tr ( "Seychelles" ) ); 438 cmbCountry->insertItem( tr ( "Seychelles" ) );
441 cmbCountry->insertItem( tr ( "Sierra Leone" ) ); 439 cmbCountry->insertItem( tr ( "Sierra Leone" ) );
442 cmbCountry->insertItem( tr ( "Singapore" ) ); 440 cmbCountry->insertItem( tr ( "Singapore" ) );
443 cmbCountry->insertItem( tr ( "Slovakia" ) ); 441 cmbCountry->insertItem( tr ( "Slovakia" ) );
444 cmbCountry->insertItem( tr ( "Slovenia" ) ); 442 cmbCountry->insertItem( tr ( "Slovenia" ) );
445 cmbCountry->insertItem( tr ( "Solomon Islands" ) ); 443 cmbCountry->insertItem( tr ( "Solomon Islands" ) );
446 cmbCountry->insertItem( tr ( "Somalia" ) ); 444 cmbCountry->insertItem( tr ( "Somalia" ) );
447 cmbCountry->insertItem( tr ( "South Africa" ) ); 445 cmbCountry->insertItem( tr ( "South Africa" ) );
448 cmbCountry->insertItem( tr ( "Spain" ) ); 446 cmbCountry->insertItem( tr ( "Spain" ) );
449 cmbCountry->insertItem( tr ( "Sri Lanka" ) ); 447 cmbCountry->insertItem( tr ( "Sri Lanka" ) );
450 cmbCountry->insertItem( tr ( "St. Helena" ) ); 448 cmbCountry->insertItem( tr ( "St. Helena" ) );
451 cmbCountry->insertItem( tr ( "Sudan" ) ); 449 cmbCountry->insertItem( tr ( "Sudan" ) );
452 cmbCountry->insertItem( tr ( "Suriname" ) ); 450 cmbCountry->insertItem( tr ( "Suriname" ) );
453 cmbCountry->insertItem( tr ( "Swaziland" ) ); 451 cmbCountry->insertItem( tr ( "Swaziland" ) );
454 cmbCountry->insertItem( tr ( "Sweden" ) ); 452 cmbCountry->insertItem( tr ( "Sweden" ) );
455 cmbCountry->insertItem( tr ( "Switzerland" ) ); 453 cmbCountry->insertItem( tr ( "Switzerland" ) );
456 cmbCountry->insertItem( tr ( "Taiwan" ) ); 454 cmbCountry->insertItem( tr ( "Taiwan" ) );
457 cmbCountry->insertItem( tr ( "Tajikistan" ) ); 455 cmbCountry->insertItem( tr ( "Tajikistan" ) );
458 cmbCountry->insertItem( tr ( "Tanzania" ) ); 456 cmbCountry->insertItem( tr ( "Tanzania" ) );
459 cmbCountry->insertItem( tr ( "Thailand" ) ); 457 cmbCountry->insertItem( tr ( "Thailand" ) );
460 cmbCountry->insertItem( tr ( "Togo" ) ); 458 cmbCountry->insertItem( tr ( "Togo" ) );
461 cmbCountry->insertItem( tr ( "Tokelau" ) ); 459 cmbCountry->insertItem( tr ( "Tokelau" ) );
462 cmbCountry->insertItem( tr ( "Tonga" ) ); 460 cmbCountry->insertItem( tr ( "Tonga" ) );
463 cmbCountry->insertItem( tr ( "Tunisia" ) ); 461 cmbCountry->insertItem( tr ( "Tunisia" ) );
464 cmbCountry->insertItem( tr ( "Turkey" ) ); 462 cmbCountry->insertItem( tr ( "Turkey" ) );
465 cmbCountry->insertItem( tr ( "Turkmenistan" ) ); 463 cmbCountry->insertItem( tr ( "Turkmenistan" ) );
466 cmbCountry->insertItem( tr ( "Tuvalu" ) ); 464 cmbCountry->insertItem( tr ( "Tuvalu" ) );
467 cmbCountry->insertItem( tr ( "Uganda" ) ); 465 cmbCountry->insertItem( tr ( "Uganda" ) );
468 cmbCountry->insertItem( tr ( "Ukraine" ) ); 466 cmbCountry->insertItem( tr ( "Ukraine" ) );
469 cmbCountry->insertItem( tr ( "Uruguay" ) ); 467 cmbCountry->insertItem( tr ( "Uruguay" ) );
470 cmbCountry->insertItem( tr ( "Uzbekistan" ) ); 468 cmbCountry->insertItem( tr ( "Uzbekistan" ) );
471 cmbCountry->insertItem( tr ( "Vanuatu" ) ); 469 cmbCountry->insertItem( tr ( "Vanuatu" ) );
472 cmbCountry->insertItem( tr ( "Venezuela" ) ); 470 cmbCountry->insertItem( tr ( "Venezuela" ) );
473 cmbCountry->insertItem( tr ( "Vietnam" ) ); 471 cmbCountry->insertItem( tr ( "Vietnam" ) );
474 cmbCountry->insertItem( tr ( "Virgin Islands" ) ); 472 cmbCountry->insertItem( tr ( "Virgin Islands" ) );
475 cmbCountry->insertItem( tr ( "Western Sahara" ) ); 473 cmbCountry->insertItem( tr ( "Western Sahara" ) );
476 cmbCountry->insertItem( tr ( "Yemen" ) ); 474 cmbCountry->insertItem( tr ( "Yemen" ) );
477 cmbCountry->insertItem( tr ( "Yugoslavia" ) ); 475 cmbCountry->insertItem( tr ( "Yugoslavia" ) );
478 cmbCountry->insertItem( tr ( "Zambia" ) ); 476 cmbCountry->insertItem( tr ( "Zambia" ) );
479 cmbCountry->insertItem( tr ( "Zimbabwe" ) ); 477 cmbCountry->insertItem( tr ( "Zimbabwe" ) );
480 if (cmbCountry->listBox()!=0) 478 if (cmbCountry->listBox()!=0)
481 cmbCountry->listBox()->sort(); 479 cmbCountry->listBox()->sort();
482 480
483 cmbCountry->setMaximumWidth( 135 ); 481 cmbCountry->setMaximumWidth( 135 );
484 482
485 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); 483 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 );
486 484
487 // Chooser 4 485 // Chooser 4
488 cmbChooserField4 = new QComboBox( FALSE, container ); 486 cmbChooserField4 = new QComboBox( false, container );
489 cmbChooserField4->setMaximumWidth( 90 ); 487 cmbChooserField4->setMaximumWidth( 90 );
490 gl->addWidget( cmbChooserField4, 6, 0 ); 488 gl->addWidget( cmbChooserField4, 6, 0 );
491 // Textfield for chooser 2 489 // Textfield for chooser 2
492 // Now use WidgetStack to contain the textfield and the default-email combo! 490 // Now use WidgetStack to contain the textfield and the default-email combo!
493 m_widgetStack4 = new QWidgetStack( container ); 491 m_widgetStack4 = new QWidgetStack( container );
494 txtChooserField4 = new QLineEdit( m_widgetStack4 ); 492 txtChooserField4 = new QLineEdit( m_widgetStack4 );
495 m_widgetStack4 -> addWidget( txtChooserField4, TextField ); 493 m_widgetStack4 -> addWidget( txtChooserField4, TextField );
496 gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); 494 gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 );
497 m_widgetStack4 -> raiseWidget( TextField ); 495 m_widgetStack4 -> raiseWidget( TextField );
498 496
499 QSpacerItem *space = new QSpacerItem(1,1, 497 QSpacerItem *space = new QSpacerItem(1,1,
500 QSizePolicy::Maximum, 498 QSizePolicy::Maximum,
501 QSizePolicy::MinimumExpanding ); 499 QSizePolicy::MinimumExpanding );
502 gl->addItem( space, 7, 0 ); 500 gl->addItem( space, 7, 0 );
503 501
504 tabMain->insertTab( tabViewport, tr( "Address" ) ); 502 tabMain->addTab( tabViewport, "home", tr( "Address" ) );
505 503
506 tabViewport = new QWidget ( tabMain ); 504 tabViewport = new QWidget ( tabMain );
507 505
508 vb = new QVBoxLayout( tabViewport ); 506 vb = new QVBoxLayout( tabViewport );
509 507
510 svDetails = new QScrollView( tabViewport ); 508 svDetails = new QScrollView( tabViewport );
511 vb->addWidget( svDetails, 0, 0 ); 509 vb->addWidget( svDetails, 0, 0 );
512 svDetails->setResizePolicy( QScrollView::AutoOneFit ); 510 svDetails->setResizePolicy( QScrollView::AutoOneFit );
513 svDetails->setFrameStyle( QFrame::NoFrame ); 511 svDetails->setFrameStyle( QFrame::NoFrame );
514 512
515 container = new QWidget( svDetails->viewport() ); 513 container = new QWidget( svDetails->viewport() );
516 svDetails->addChild( container ); 514 svDetails->addChild( container );
517 515
518 gl = new QGridLayout( container, 1, 2, 2, 4 ); 516 gl = new QGridLayout( container, 1, 2, 2, 4 );
519 517
520 int counter = 0; 518 int counter = 0;
521 519
522 // Birthday 520 // Birthday
523 QHBox* hBox = new QHBox( container ); 521 QHBox* hBox = new QHBox( container );
524 l = new QLabel( tr("Birthday"), container ); 522 l = new QLabel( tr("Birthday"), container );
525 gl->addWidget( l, counter, 0 ); 523 gl->addWidget( l, counter, 0 );
526 524
527 QPopupMenu* m1 = new QPopupMenu( container ); 525 QPopupMenu* m1 = new QPopupMenu( container );
528 birthdayPicker = new DateBookMonth( m1, 0, TRUE ); 526 birthdayPicker = new DateBookMonth( m1, 0, true );
529 m1->insertItem( birthdayPicker ); 527 m1->insertItem( birthdayPicker );
530 528
531 birthdayButton= new QToolButton( hBox, "buttonStart" ); 529 birthdayButton= new QToolButton( hBox, "buttonStart" );
532 birthdayButton->setPopup( m1 ); 530 birthdayButton->setPopup( m1 );
533 birthdayButton->setPopupDelay(0); 531 birthdayButton->setPopupDelay(0);
534 532
535 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 533 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
536 tr( "Delete" ), 534 tr( "Delete" ),
537 hBox, 0 ); 535 hBox, 0 );
538 536
539 gl->addWidget( hBox, counter , 1 ); 537 gl->addWidget( hBox, counter , 1 );
540 538
541 connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ), 539 connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ),
542 this, SLOT( slotBirthdayDateChanged(int,int,int) ) ); 540 this, SLOT( slotBirthdayDateChanged(int,int,int) ) );
543 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); 541 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
544 542
545 ++counter; 543 ++counter;
546 544
547 // Anniversary 545 // Anniversary
548 hBox = new QHBox( container ); 546 hBox = new QHBox( container );
549 l = new QLabel( tr("Anniversary"), container ); 547 l = new QLabel( tr("Anniversary"), container );
550 gl->addWidget( l, counter, 0 ); 548 gl->addWidget( l, counter, 0 );
551 549
552 m1 = new QPopupMenu( container ); 550 m1 = new QPopupMenu( container );
553 anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); 551 anniversaryPicker = new DateBookMonth( m1, 0, true );
554 m1->insertItem( anniversaryPicker ); 552 m1->insertItem( anniversaryPicker );
555 553
556 anniversaryButton= new QToolButton( hBox, "buttonStart" ); 554 anniversaryButton= new QToolButton( hBox, "buttonStart" );
557 anniversaryButton->setPopup( m1 ); 555 anniversaryButton->setPopup( m1 );
558 anniversaryButton->setPopupDelay(0); 556 anniversaryButton->setPopupDelay(0);
559 557
560 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 558 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
561 tr( "Delete" ), 559 tr( "Delete" ),
562 hBox, 0 ); 560 hBox, 0 );
563 gl->addWidget( hBox, counter , 1 ); 561 gl->addWidget( hBox, counter , 1 );
564 562
565 connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), 563 connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ),
566 this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); 564 this, SLOT( slotAnniversaryDateChanged(int,int,int) ) );
567 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); 565 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) );
568 566
569 ++counter; 567 ++counter;
570 568
571 // Gender 569 // Gender
572 l = new QLabel( tr("Gender"), container ); 570 l = new QLabel( tr("Gender"), container );
573 gl->addWidget( l, counter, 0 ); 571 gl->addWidget( l, counter, 0 );
574 cmbGender = new QComboBox( container ); 572 cmbGender = new QComboBox( container );
575 cmbGender->insertItem( "", 0 ); 573 cmbGender->insertItem( "", 0 );
576 cmbGender->insertItem( tr("Male"), 1); 574 cmbGender->insertItem( tr("Male"), 1);
577 cmbGender->insertItem( tr("Female"), 2); 575 cmbGender->insertItem( tr("Female"), 2);
578 gl->addWidget( cmbGender, counter, 1 ); 576 gl->addWidget( cmbGender, counter, 1 );
579 577
580 ++counter; 578 ++counter;
581 579
582 // Create Labels and lineedit fields for every dynamic entry 580 // Create Labels and lineedit fields for every dynamic entry
583 QStringList::ConstIterator it = slDynamicEntries.begin(); 581 QStringList::ConstIterator it = slDynamicEntries.begin();
584 QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId(); 582 QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId();
585 QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields(); 583 QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields();
586 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { 584 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) {
587 585
588 if (((*it) == "Anniversary") || 586 if (((*it) == "Anniversary") ||
589 ((*it) == "Birthday")|| ((*it) == "Gender")) continue; 587 ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
590 588
591 l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); 589 l = new QLabel( mapIdToStr[mapStrToID[*it]], container );
592 listName.append( l ); 590 listName.append( l );
593 gl->addWidget( l, i, 0 ); 591 gl->addWidget( l, i, 0 );
594 QLineEdit *e = new QLineEdit( container ); 592 QLineEdit *e = new QLineEdit( container );
595 listValue.append( e ); 593 listValue.append( e );
596 gl->addWidget( e, i, 1); 594 gl->addWidget( e, i, 1);
597 } 595 }
598 // Fill labels with names.. 596 // Fill labels with names..
599 //loadFields(); 597 //loadFields();
600 598
601 599
602 tabMain->insertTab( tabViewport, tr( "Details" ) ); 600 tabMain->addTab( tabViewport, "UtilsIcon", tr( "Details" ) );
603 601
604 dlgNote = new QDialog( this, "Note Dialog", TRUE ); 602 dlgNote = new QDialog( this, "Note Dialog", true );
605 dlgNote->setCaption( tr("Enter Note") ); 603 dlgNote->setCaption( tr("Enter Note") );
606 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); 604 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
607 txtNote = new QMultiLineEdit( dlgNote ); 605 txtNote = new QMultiLineEdit( dlgNote );
608 vbNote->addWidget( txtNote ); 606 vbNote->addWidget( txtNote );
609 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); 607 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
610 608
611 dlgName = new QDialog( this, "Name Dialog", TRUE ); 609 dlgName = new QDialog( this, "Name Dialog", true );
612 dlgName->setCaption( tr("Edit Name") ); 610 dlgName->setCaption( tr("Edit Name") );
613 gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); 611 gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
614 612
615 l = new QLabel( tr("First Name"), dlgName ); 613 l = new QLabel( tr("First Name"), dlgName );
616 gl->addWidget( l, 0, 0 ); 614 gl->addWidget( l, 0, 0 );
617 txtFirstName = new ABOOK::NameLineEdit( dlgName ); 615 txtFirstName = new ABOOK::NameLineEdit( dlgName );
618 gl->addWidget( txtFirstName, 0, 1 ); 616 gl->addWidget( txtFirstName, 0, 1 );
619 617
620 l = new QLabel( tr("Middle Name"), dlgName ); 618 l = new QLabel( tr("Middle Name"), dlgName );
621 gl->addWidget( l, 1, 0 ); 619 gl->addWidget( l, 1, 0 );
622 txtMiddleName = new ABOOK::NameLineEdit( dlgName ); 620 txtMiddleName = new ABOOK::NameLineEdit( dlgName );
623 gl->addWidget( txtMiddleName, 1, 1 ); 621 gl->addWidget( txtMiddleName, 1, 1 );
624 622
625 l = new QLabel( tr("Last Name"), dlgName ); 623 l = new QLabel( tr("Last Name"), dlgName );
626 gl->addWidget( l, 2, 0 ); 624 gl->addWidget( l, 2, 0 );
627 txtLastName = new ABOOK::NameLineEdit( dlgName ); 625 txtLastName = new ABOOK::NameLineEdit( dlgName );
628 gl->addWidget( txtLastName, 2, 1 ); 626 gl->addWidget( txtLastName, 2, 1 );
629 627
630 // l = new QLabel( tr("Suffix"), dlgName ); 628 // l = new QLabel( tr("Suffix"), dlgName );
631 // gl->addWidget( l, 3, 0 ); 629 // gl->addWidget( l, 3, 0 );
632 // txtSuffix = new QLineEdit( dlgName ); 630 // txtSuffix = new QLineEdit( dlgName );
633 // gl->addWidget( txtSuffix, 3, 1 ); 631 // gl->addWidget( txtSuffix, 3, 1 );
634 space = new QSpacerItem(1,1, 632 space = new QSpacerItem(1,1,
635 QSizePolicy::Maximum, 633 QSizePolicy::Maximum,
636 QSizePolicy::MinimumExpanding ); 634 QSizePolicy::MinimumExpanding );
637 gl->addItem( space, 4, 0 ); 635 gl->addItem( space, 4, 0 );
638 636
639 cmbChooserField1->insertStringList( trlChooserNames ); 637 cmbChooserField1->insertStringList( trlChooserNames );
640 cmbChooserField2->insertStringList( trlChooserNames ); 638 cmbChooserField2->insertStringList( trlChooserNames );
641 cmbChooserField3->insertStringList( trlChooserNames ); 639 cmbChooserField3->insertStringList( trlChooserNames );
642 cmbChooserField4->insertStringList( trlChooserNames ); 640 cmbChooserField4->insertStringList( trlChooserNames );
643 641
644 cmbChooserField1->setCurrentItem( 0 ); 642 cmbChooserField1->setCurrentItem( 0 );
645 cmbChooserField2->setCurrentItem( 1 ); 643 cmbChooserField2->setCurrentItem( 1 );
646 cmbChooserField3->setCurrentItem( 2 ); 644 cmbChooserField3->setCurrentItem( 2 );
647 645
648 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 646 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
649 647
650 connect( txtFullName, SIGNAL(textChanged(const QString&)), 648 connect( txtFullName, SIGNAL(textChanged(const QString&)),
651 this, SLOT(slotFullNameChange(const QString&)) ); 649 this, SLOT(slotFullNameChange(const QString&)) );
652 connect( txtSuffix, SIGNAL(textChanged(const QString&)), 650 connect( txtSuffix, SIGNAL(textChanged(const QString&)),
653 this, SLOT(slotSuffixChange(const QString&)) ); 651 this, SLOT(slotSuffixChange(const QString&)) );
654 connect( txtOrganization, SIGNAL(textChanged(const QString&)), 652 connect( txtOrganization, SIGNAL(textChanged(const QString&)),
655 this, SLOT(slotOrganizationChange(const QString&)) ); 653 this, SLOT(slotOrganizationChange(const QString&)) );
656 connect( txtChooserField1, SIGNAL(textChanged(const QString&)), 654 connect( txtChooserField1, SIGNAL(textChanged(const QString&)),
657 this, SLOT(slotChooser1Change(const QString&)) ); 655 this, SLOT(slotChooser1Change(const QString&)) );
658 connect( txtChooserField2, SIGNAL(textChanged(const QString&)), 656 connect( txtChooserField2, SIGNAL(textChanged(const QString&)),
659 this, SLOT(slotChooser2Change(const QString&)) ); 657 this, SLOT(slotChooser2Change(const QString&)) );
@@ -1048,142 +1046,142 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1048 1046
1049} 1047}
1050 1048
1051void ContactEditor::slotSuffixChange( const QString& ) { 1049void ContactEditor::slotSuffixChange( const QString& ) {
1052 // Just want to update the FileAs combo if the suffix was changed.. 1050 // Just want to update the FileAs combo if the suffix was changed..
1053 slotFullNameChange( txtFullName->text() ); 1051 slotFullNameChange( txtFullName->text() );
1054} 1052}
1055 1053
1056void ContactEditor::slotOrganizationChange( const QString &textChanged ){ 1054void ContactEditor::slotOrganizationChange( const QString &textChanged ){
1057 odebug << "ContactEditor::slotOrganizationChange( " << textChanged << " )" << oendl; 1055 odebug << "ContactEditor::slotOrganizationChange( " << textChanged << " )" << oendl;
1058 // Special handling for storing Companies: 1056 // Special handling for storing Companies:
1059 // If no Fullname is given, we store the Company-Name as lastname 1057 // If no Fullname is given, we store the Company-Name as lastname
1060 // to handle it like a person.. 1058 // to handle it like a person..
1061 if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) ) 1059 if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) )
1062 txtFullName->setText( textChanged ); 1060 txtFullName->setText( textChanged );
1063 1061
1064} 1062}
1065 1063
1066void ContactEditor::accept() { 1064void ContactEditor::accept() {
1067 1065
1068 if ( isEmpty() ) { 1066 if ( isEmpty() ) {
1069 cleanupFields(); 1067 cleanupFields();
1070 reject(); 1068 reject();
1071 } else { 1069 } else {
1072 saveEntry(); 1070 saveEntry();
1073 cleanupFields(); 1071 cleanupFields();
1074 QDialog::accept(); 1072 QDialog::accept();
1075 } 1073 }
1076 1074
1077} 1075}
1078 1076
1079void ContactEditor::slotNote() { 1077void ContactEditor::slotNote() {
1080 1078
1081 if ( ! QPEApplication::execDialog( dlgNote ) ) { 1079 if ( ! QPEApplication::execDialog( dlgNote ) ) {
1082 txtNote->setText( ent.notes() ); 1080 txtNote->setText( ent.notes() );
1083 } 1081 }
1084} 1082}
1085 1083
1086void ContactEditor::slotName() { 1084void ContactEditor::slotName() {
1087 1085
1088 QString tmpName; 1086 QString tmpName;
1089 1087
1090 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 1088 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
1091 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 1089 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
1092 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1090 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1093 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1091 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1094 1092
1095 if ( QPEApplication::execDialog( dlgName ) ) { 1093 if ( QPEApplication::execDialog( dlgName ) ) {
1096 if ( txtLastName->text().contains( ' ', TRUE ) ) 1094 if ( txtLastName->text().contains( ' ', true ) )
1097 tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); 1095 tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text();
1098 else 1096 else
1099 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); 1097 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text();
1100 1098
1101 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 1099 txtFullName->setText( tmpName.simplifyWhiteSpace() );
1102 slotFullNameChange( txtFullName->text() ); 1100 slotFullNameChange( txtFullName->text() );
1103 } 1101 }
1104 1102
1105} 1103}
1106 1104
1107void ContactEditor::setNameFocus() { 1105void ContactEditor::setNameFocus() {
1108 1106
1109 txtFullName->setFocus(); 1107 txtFullName->setFocus();
1110 1108
1111} 1109}
1112 1110
1113bool ContactEditor::isEmpty() { 1111bool ContactEditor::isEmpty() {
1114 // Test and see if the record should be saved. 1112 // Test and see if the record should be saved.
1115 // More strict than the original qtopia, needs name or fileas to save 1113 // More strict than the original qtopia, needs name or fileas to save
1116 1114
1117 QString t = txtFullName->text(); 1115 QString t = txtFullName->text();
1118 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1116 if ( !t.isEmpty() && containsAlphaNum( t ) )
1119 return false; 1117 return false;
1120 1118
1121 t = cmbFileAs->currentText(); 1119 t = cmbFileAs->currentText();
1122 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1120 if ( !t.isEmpty() && containsAlphaNum( t ) )
1123 return false; 1121 return false;
1124 1122
1125 return true; 1123 return true;
1126 1124
1127} 1125}
1128 1126
1129QString ContactEditor::parseName( const QString fullName, int type ) { 1127QString ContactEditor::parseName( const QString fullName, int type ) {
1130 1128
1131 QString simplifiedName( fullName.simplifyWhiteSpace() ); 1129 QString simplifiedName( fullName.simplifyWhiteSpace() );
1132 QString strFirstName; 1130 QString strFirstName;
1133 QString strMiddleName; 1131 QString strMiddleName;
1134 QString strLastName; 1132 QString strLastName;
1135 QString strTitle; 1133 QString strTitle;
1136 int commapos; 1134 int commapos;
1137 bool haveLastName = false; 1135 bool haveLastName = false;
1138 1136
1139 odebug << "Fullname: " << simplifiedName << oendl; 1137 odebug << "Fullname: " << simplifiedName << oendl;
1140 1138
1141 commapos = simplifiedName.find( ',', 0, TRUE); 1139 commapos = simplifiedName.find( ',', 0, true);
1142 if ( commapos >= 0 ) { 1140 if ( commapos >= 0 ) {
1143 odebug << " Commapos: " << commapos << oendl; 1141 odebug << " Commapos: " << commapos << oendl;
1144 1142
1145 // A comma (",") separates the lastname from one or 1143 // A comma (",") separates the lastname from one or
1146 // many first names. Thus, remove the lastname from the 1144 // many first names. Thus, remove the lastname from the
1147 // String and parse the firstnames. 1145 // String and parse the firstnames.
1148 1146
1149 strLastName = simplifiedName.left( commapos ); 1147 strLastName = simplifiedName.left( commapos );
1150 simplifiedName= simplifiedName.mid( commapos + 1 ); 1148 simplifiedName= simplifiedName.mid( commapos + 1 );
1151 haveLastName = true; 1149 haveLastName = true;
1152 odebug << "Fullname without ',': " << simplifiedName << oendl; 1150 odebug << "Fullname without ',': " << simplifiedName << oendl;
1153 1151
1154 // If we have any lastname, we should now split all first names. 1152 // If we have any lastname, we should now split all first names.
1155 // The first one will be the used as first, the rest as "middle names" 1153 // The first one will be the used as first, the rest as "middle names"
1156 1154
1157 QStringList allFirstNames = QStringList::split(" ", simplifiedName); 1155 QStringList allFirstNames = QStringList::split(" ", simplifiedName);
1158 QStringList::Iterator it = allFirstNames.begin(); 1156 QStringList::Iterator it = allFirstNames.begin();
1159 strFirstName = *it++; 1157 strFirstName = *it++;
1160 QStringList allSecondNames; 1158 QStringList allSecondNames;
1161 for ( ; it != allFirstNames.end(); ++it ) 1159 for ( ; it != allFirstNames.end(); ++it )
1162 allSecondNames.append( *it ); 1160 allSecondNames.append( *it );
1163 1161
1164 strMiddleName = allSecondNames.join(" "); 1162 strMiddleName = allSecondNames.join(" ");
1165 1163
1166 } else { 1164 } else {
1167 1165
1168 // No comma separator used: We use the first word as firstname, the 1166 // No comma separator used: We use the first word as firstname, the
1169 // last as second/lastname and everything in the middle as middlename 1167 // last as second/lastname and everything in the middle as middlename
1170 1168
1171 QStringList allNames = QStringList::split(" ", simplifiedName); 1169 QStringList allNames = QStringList::split(" ", simplifiedName);
1172 QStringList::Iterator it = allNames.begin(); 1170 QStringList::Iterator it = allNames.begin();
1173 strFirstName = *it++; 1171 strFirstName = *it++;
1174 QStringList allSecondNames; 1172 QStringList allSecondNames;
1175 for ( ; it != --allNames.end(); ++it ) 1173 for ( ; it != --allNames.end(); ++it )
1176 allSecondNames.append( *it ); 1174 allSecondNames.append( *it );
1177 1175
1178 strMiddleName = allSecondNames.join(" "); 1176 strMiddleName = allSecondNames.join(" ");
1179 strLastName = *(--allNames.end()); 1177 strLastName = *(--allNames.end());
1180 1178
1181 } 1179 }
1182 1180
1183 if ( strFirstName == strLastName ) 1181 if ( strFirstName == strLastName )
1184 strFirstName = ""; 1182 strFirstName = "";
1185 1183
1186 odebug << "strFirstName: " << strFirstName << oendl; 1184 odebug << "strFirstName: " << strFirstName << oendl;
1187 odebug << "strMiddletName: " << strMiddleName << oendl; 1185 odebug << "strMiddletName: " << strMiddleName << oendl;
1188 odebug << "strLastName: " << strLastName << oendl; 1186 odebug << "strLastName: " << strLastName << oendl;
1189 odebug << "strTitle: " << strTitle << oendl; 1187 odebug << "strTitle: " << strTitle << oendl;
@@ -1217,118 +1215,118 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1217 return QString::null; 1215 return QString::null;
1218} 1216}
1219 1217
1220void ContactEditor::cleanupFields() { 1218void ContactEditor::cleanupFields() {
1221 QStringList::Iterator it = slChooserValues.begin(); 1219 QStringList::Iterator it = slChooserValues.begin();
1222 1220
1223 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { 1221 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
1224 (*it) = ""; 1222 (*it) = "";
1225 } 1223 }
1226 1224
1227 for ( int i = 0; i < 7; i++ ) { 1225 for ( int i = 0; i < 7; i++ ) {
1228 slHomeAddress[i] = ""; 1226 slHomeAddress[i] = "";
1229 slBusinessAddress[i] = ""; 1227 slBusinessAddress[i] = "";
1230 } 1228 }
1231 1229
1232 QListIterator<QLineEdit> itLV( listValue ); 1230 QListIterator<QLineEdit> itLV( listValue );
1233 for ( ; itLV.current(); ++itLV ) { 1231 for ( ; itLV.current(); ++itLV ) {
1234 (*itLV)->setText( "" ); 1232 (*itLV)->setText( "" );
1235 } 1233 }
1236 1234
1237 txtFirstName->setText(""); 1235 txtFirstName->setText("");
1238 txtMiddleName->setText(""); 1236 txtMiddleName->setText("");
1239 txtLastName->setText(""); 1237 txtLastName->setText("");
1240 txtSuffix->setText(""); 1238 txtSuffix->setText("");
1241 txtNote->setText(""); 1239 txtNote->setText("");
1242 txtFullName->setText(""); 1240 txtFullName->setText("");
1243 txtJobTitle->setText(""); 1241 txtJobTitle->setText("");
1244 txtOrganization->setText(""); 1242 txtOrganization->setText("");
1245 txtChooserField1->setText(""); 1243 txtChooserField1->setText("");
1246 txtChooserField2->setText(""); 1244 txtChooserField2->setText("");
1247 txtChooserField3->setText(""); 1245 txtChooserField3->setText("");
1248 txtAddress->setText(""); 1246 txtAddress->setText("");
1249 txtCity->setText(""); 1247 txtCity->setText("");
1250 txtState->setText(""); 1248 txtState->setText("");
1251 txtZip->setText(""); 1249 txtZip->setText("");
1252 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1250 QLineEdit *txtTmp = cmbCountry->lineEdit();
1253 txtTmp->setText(""); 1251 txtTmp->setText("");
1254 txtTmp = cmbFileAs->lineEdit(); 1252 txtTmp = cmbFileAs->lineEdit();
1255 txtTmp->setText(""); 1253 txtTmp->setText("");
1256 1254
1257} 1255}
1258 1256
1259void ContactEditor::setEntry( const Opie::OPimContact &entry ) { 1257void ContactEditor::setEntry( const Opie::OPimContact &entry ) {
1260 1258
1261 initializing = true; 1259 initializing = true;
1262 1260
1263 // Cleanup and activate the general Page .. 1261 // Cleanup and activate the general Page ..
1264 cleanupFields(); 1262 cleanupFields();
1265 tabMain->setCurrentPage( 0 ); 1263 tabMain->setCurrentTab( m_generalWidget );
1266 1264
1267 ent = entry; 1265 ent = entry;
1268 1266
1269 emails = QStringList(ent.emailList()); 1267 emails = QStringList(ent.emailList());
1270 defaultEmail = ent.defaultEmail(); 1268 defaultEmail = ent.defaultEmail();
1271 if (defaultEmail.isEmpty()) defaultEmail = emails[0]; 1269 if (defaultEmail.isEmpty()) defaultEmail = emails[0];
1272 odebug << "default email=" << defaultEmail << oendl; 1270 odebug << "default email=" << defaultEmail << oendl;
1273 1271
1274 txtFirstName->setText( ent.firstName() ); 1272 txtFirstName->setText( ent.firstName() );
1275 txtMiddleName->setText( ent.middleName() ); 1273 txtMiddleName->setText( ent.middleName() );
1276 txtLastName->setText( ent.lastName() ); 1274 txtLastName->setText( ent.lastName() );
1277 txtSuffix->setText( ent.suffix() ); 1275 txtSuffix->setText( ent.suffix() );
1278 1276
1279 // QString *tmpString = new QString; 1277 // QString *tmpString = new QString;
1280 // *tmpString = ent.firstName() + " " + ent.middleName() + 1278 // *tmpString = ent.firstName() + " " + ent.middleName() +
1281 // + " " + ent.lastName() + " " + ent.suffix(); 1279 // + " " + ent.lastName() + " " + ent.suffix();
1282 //txtFullName->setText( tmpString->simplifyWhiteSpace() ); 1280 //txtFullName->setText( tmpString->simplifyWhiteSpace() );
1283 1281
1284 if ( !ent.isEmpty() ){ 1282 if ( !ent.isEmpty() ){
1285 // Lastnames with multiple words need to be protected by a comma ! 1283 // Lastnames with multiple words need to be protected by a comma !
1286 if ( ent.lastName().contains( ' ', TRUE ) ) 1284 if ( ent.lastName().contains( ' ', true ) )
1287 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); 1285 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
1288 else 1286 else
1289 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); 1287 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
1290 } 1288 }
1291 1289
1292 cmbFileAs->setEditText( ent.fileAs() ); 1290 cmbFileAs->setEditText( ent.fileAs() );
1293 1291
1294 //if (hasTitle) 1292 //if (hasTitle)
1295 txtJobTitle->setText( ent.jobTitle() ); 1293 txtJobTitle->setText( ent.jobTitle() );
1296 1294
1297 //if (hasCompany) 1295 //if (hasCompany)
1298 txtOrganization->setText( ent.company() ); 1296 txtOrganization->setText( ent.company() );
1299 1297
1300 //if (hasNotes) 1298 //if (hasNotes)
1301 txtNote->setText( ent.notes() ); 1299 txtNote->setText( ent.notes() );
1302 1300
1303 //if (hasStreet) { 1301 //if (hasStreet) {
1304 slHomeAddress[0] = ent.homeStreet(); 1302 slHomeAddress[0] = ent.homeStreet();
1305 slBusinessAddress[0] = ent.businessStreet(); 1303 slBusinessAddress[0] = ent.businessStreet();
1306 //} 1304 //}
1307 1305
1308 //if (hasCity) { 1306 //if (hasCity) {
1309 slHomeAddress[3] = ent.homeCity(); 1307 slHomeAddress[3] = ent.homeCity();
1310 slBusinessAddress[3] = ent.businessCity(); 1308 slBusinessAddress[3] = ent.businessCity();
1311 //} 1309 //}
1312 1310
1313 //if (hasState) { 1311 //if (hasState) {
1314 slHomeAddress[4] = ent.homeState(); 1312 slHomeAddress[4] = ent.homeState();
1315 slBusinessAddress[4] = ent.businessState(); 1313 slBusinessAddress[4] = ent.businessState();
1316 //} 1314 //}
1317 1315
1318 //if (hasZip) { 1316 //if (hasZip) {
1319 slHomeAddress[5] = ent.homeZip(); 1317 slHomeAddress[5] = ent.homeZip();
1320 slBusinessAddress[5] = ent.businessZip(); 1318 slBusinessAddress[5] = ent.businessZip();
1321 //} 1319 //}
1322 1320
1323 //if (hasCountry) { 1321 //if (hasCountry) {
1324 slHomeAddress[6] = ent.homeCountry(); 1322 slHomeAddress[6] = ent.homeCountry();
1325 slBusinessAddress[6] = ent.businessCountry(); 1323 slBusinessAddress[6] = ent.businessCountry();
1326 //} 1324 //}
1327 1325
1328 QStringList::ConstIterator it; 1326 QStringList::ConstIterator it;
1329 QListIterator<QLineEdit> itLE( listValue ); 1327 QListIterator<QLineEdit> itLE( listValue );
1330 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { 1328 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
1331 1329
1332 odebug << " Filling dynamic Field: " << (*it) << oendl; 1330 odebug << " Filling dynamic Field: " << (*it) << oendl;
1333 1331
1334 if ( *it == "Department" ) 1332 if ( *it == "Department" )
@@ -1642,108 +1640,108 @@ void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
1642 strDefaultEmail = txt.left( where ).stripWhiteSpace(); 1640 strDefaultEmail = txt.left( where ).stripWhiteSpace();
1643 strAll = strDefaultEmail; 1641 strAll = strDefaultEmail;
1644 while ( where > -1 ) { 1642 while ( where > -1 ) {
1645 strAll.append(" "); 1643 strAll.append(" ");
1646 start = where; 1644 start = where;
1647 where = txt.find( ',', where + 1 ); 1645 where = txt.find( ',', where + 1 );
1648 if ( where > - 1 ) 1646 if ( where > - 1 )
1649 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); 1647 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
1650 else // grab until the end... 1648 else // grab until the end...
1651 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); 1649 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
1652 } 1650 }
1653 } 1651 }
1654} 1652}
1655 1653
1656void parseEmailTo( const QString &strDefaultEmail, 1654void parseEmailTo( const QString &strDefaultEmail,
1657 const QString &strOtherEmail, QString &strBack ) 1655 const QString &strOtherEmail, QString &strBack )
1658{ 1656{
1659 // create a comma dilimeted set of emails... 1657 // create a comma dilimeted set of emails...
1660 // use the power of short circuiting... 1658 // use the power of short circuiting...
1661 bool foundDefault = false; 1659 bool foundDefault = false;
1662 QString strTmp; 1660 QString strTmp;
1663 int start = 0; 1661 int start = 0;
1664 int where; 1662 int where;
1665 // start at the beginng. 1663 // start at the beginng.
1666 strBack = strDefaultEmail; 1664 strBack = strDefaultEmail;
1667 where = 0; 1665 where = 0;
1668 while ( where > -1 ) { 1666 while ( where > -1 ) {
1669 start = where; 1667 start = where;
1670 where = strOtherEmail.find( ' ', where + 1 ); 1668 where = strOtherEmail.find( ' ', where + 1 );
1671 if ( where > 0 ) { 1669 if ( where > 0 ) {
1672 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); 1670 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
1673 } else 1671 } else
1674 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); 1672 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
1675 if ( foundDefault || strTmp != strDefaultEmail ) { 1673 if ( foundDefault || strTmp != strDefaultEmail ) {
1676 strBack.append( ", " ); 1674 strBack.append( ", " );
1677 strBack.append( strTmp ); 1675 strBack.append( strTmp );
1678 } else 1676 } else
1679 foundDefault = true; 1677 foundDefault = true;
1680 } 1678 }
1681} 1679}
1682 1680
1683 1681
1684static inline bool containsAlphaNum( const QString &str ) 1682static inline bool containsAlphaNum( const QString &str )
1685{ 1683{
1686 int i, 1684 int i,
1687 count = str.length(); 1685 count = str.length();
1688 for ( i = 0; i < count; i++ ) 1686 for ( i = 0; i < count; i++ )
1689 if ( !str[i].isSpace() ) 1687 if ( !str[i].isSpace() )
1690 return TRUE; 1688 return true;
1691 return FALSE; 1689 return false;
1692} 1690}
1693 1691
1694static inline bool constainsWhiteSpace( const QString &str ) 1692static inline bool constainsWhiteSpace( const QString &str )
1695{ 1693{
1696 int i, 1694 int i,
1697 count = str.length(); 1695 count = str.length();
1698 for (i = 0; i < count; i++ ) 1696 for (i = 0; i < count; i++ )
1699 if ( str[i].isSpace() ) 1697 if ( str[i].isSpace() )
1700 return TRUE; 1698 return true;
1701 return FALSE; 1699 return false;
1702} 1700}
1703 1701
1704void ContactEditor::setPersonalView( bool personal ) 1702void ContactEditor::setPersonalView( bool personal )
1705{ 1703{
1706 m_personalView = personal; 1704 m_personalView = personal;
1707 1705
1708 // Currently disbled due to the fact that 1706 // Currently disbled due to the fact that
1709 // show will not work... 1707 // show will not work...
1710 return; 1708 return;
1711 1709
1712 if ( personal ){ 1710 if ( personal ){
1713 cmbCat->hide(); 1711 cmbCat->hide();
1714 labCat->hide(); 1712 labCat->hide();
1715 1713
1716 } else{ 1714 } else{
1717 cmbCat->show(); 1715 cmbCat->show();
1718 labCat->show(); 1716 labCat->show();
1719 } 1717 }
1720} 1718}
1721 1719
1722void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) 1720void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
1723{ 1721{
1724 QDate date; 1722 QDate date;
1725 date.setYMD( year, month, day ); 1723 date.setYMD( year, month, day );
1726 QString dateString = TimeString::numberDateString( date ); 1724 QString dateString = TimeString::numberDateString( date );
1727 anniversaryButton->setText( dateString ); 1725 anniversaryButton->setText( dateString );
1728 ent.setAnniversary ( date ); 1726 ent.setAnniversary ( date );
1729} 1727}
1730 1728
1731void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) 1729void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
1732{ 1730{
1733 QDate date; 1731 QDate date;
1734 date.setYMD( year, month, day ); 1732 date.setYMD( year, month, day );
1735 QString dateString = TimeString::numberDateString( date ); 1733 QString dateString = TimeString::numberDateString( date );
1736 birthdayButton->setText( dateString ); 1734 birthdayButton->setText( dateString );
1737 ent.setBirthday ( date ); 1735 ent.setBirthday ( date );
1738} 1736}
1739 1737
1740void ContactEditor::slotRemoveBirthday() 1738void ContactEditor::slotRemoveBirthday()
1741{ 1739{
1742 odebug << "void ContactEditor::slotRemoveBirthday()" << oendl; 1740 odebug << "void ContactEditor::slotRemoveBirthday()" << oendl;
1743 ent.setBirthday( QDate() ); 1741 ent.setBirthday( QDate() );
1744 updateDatePicker(); 1742 updateDatePicker();
1745} 1743}
1746 1744
1747void ContactEditor::slotRemoveAnniversary() 1745void ContactEditor::slotRemoveAnniversary()
1748{ 1746{
1749 odebug << "void ContactEditor::slotRemoveAnniversary()" << oendl; 1747 odebug << "void ContactEditor::slotRemoveAnniversary()" << oendl;
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index 1b86e6f..f3cbbd4 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -1,95 +1,94 @@
1/* 1/*
2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> 2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
3 * 3 *
4 * This file is an add-on for the OPIE Palmtop Environment 4 * This file is an add-on for the OPIE Palmtop Environment
5 * 5 *
6 * This file may be distributed and/or modified under the terms of the 6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software 7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging 8 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
9 * of this file. 9 * of this file.
10 * 10 *
11 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 * 13 *
14 * 14 *
15 * This is a rewrite of the abeditor.h file, modified to provide a more 15 * This is a rewrite of the abeditor.h file, modified to provide a more
16 * intuitive interface to TrollTech's original Address Book editor. This 16 * intuitive interface to TrollTech's original Address Book editor. This
17 * is made to operate exactly in interface with the exception of name. 17 * is made to operate exactly in interface with the exception of name.
18 * 18 *
19 */ 19 */
20 20
21#ifndef CONTACTEDITOR_H 21#ifndef CONTACTEDITOR_H
22#define CONTACTEDITOR_H 22#define CONTACTEDITOR_H
23 23
24#include <opie2/opimcontact.h> 24#include <opie2/opimcontact.h>
25#include <opie2/opimcontactfields.h> 25#include <opie2/opimcontactfields.h>
26#include <opie2/otabwidget.h>
26 27
27#include <qpe/datebookmonth.h> 28#include <qpe/datebookmonth.h>
28 29
29#include <qdialog.h> 30#include <qdialog.h>
30#include <qlist.h> 31#include <qlist.h>
31#include <qmap.h> 32#include <qmap.h>
32#include <qstringlist.h> 33#include <qstringlist.h>
33#include <qwidgetstack.h> 34#include <qwidgetstack.h>
34 35
35const int NAME_LF = 0; 36const int NAME_LF = 0;
36const int NAME_LFM = 1; 37const int NAME_LFM = 1;
37const int NAME_FL = 2; 38const int NAME_FL = 2;
38const int NAME_FML = 3; 39const int NAME_FML = 3;
39 40
40const int NAME_F = 4; 41const int NAME_F = 4;
41const int NAME_M = 5; 42const int NAME_M = 5;
42const int NAME_L = 6; 43const int NAME_L = 6;
43const int NAME_S = 7; 44const int NAME_S = 7;
44 45
45
46class QScrollView; 46class QScrollView;
47class QTabWidget;
48class QMultiLineEdit; 47class QMultiLineEdit;
49class QLineEdit; 48class QLineEdit;
50class QComboBox; 49class QComboBox;
51class QPushButton; 50class QPushButton;
52class CategorySelect; 51class CategorySelect;
53class QLabel; 52class QLabel;
54 53
55class ContactEditor : public QDialog { 54class ContactEditor : public QDialog {
56 Q_OBJECT 55 Q_OBJECT
57 56
58 public: 57 public:
59 ContactEditor(const Opie::OPimContact &entry, 58 ContactEditor(const Opie::OPimContact &entry,
60 QWidget *parent = 0, 59 QWidget *parent = 0,
61 const char *name = 0, 60 const char *name = 0,
62 WFlags fl = 0 ); 61 WFlags fl = 0 );
63 ~ContactEditor(); 62 ~ContactEditor();
64 void setNameFocus(); 63 void setNameFocus();
65 void setPersonalView( bool personal = true ); 64 void setPersonalView( bool personal = true );
66 Opie::OPimContact entry() const { return ent; } 65 Opie::OPimContact entry() const { return ent; }
67 66
68 public slots: 67 public slots:
69 void slotNote(); 68 void slotNote();
70 void slotName(); 69 void slotName();
71 void setEntry(const Opie::OPimContact &entry); 70 void setEntry(const Opie::OPimContact &entry);
72 71
73 protected slots: 72 protected slots:
74 void accept(); 73 void accept();
75 74
76 private: 75 private:
77 void init(); 76 void init();
78 void saveEntry(); 77 void saveEntry();
79 bool isEmpty(); 78 bool isEmpty();
80 void cleanupFields(); 79 void cleanupFields();
81 void updateDatePicker(); 80 void updateDatePicker();
82 QString parseName( QString fullName, int type ); 81 QString parseName( QString fullName, int type );
83 void chooserError( int index ); 82 void chooserError( int index );
84 private slots: 83 private slots:
85 void slotChooser1Change( const QString &textChanged ); 84 void slotChooser1Change( const QString &textChanged );
86 void slotChooser2Change( const QString &textChanged ); 85 void slotChooser2Change( const QString &textChanged );
87 void slotChooser3Change( const QString &textChanged ); 86 void slotChooser3Change( const QString &textChanged );
88 void slotChooser4Change( const QString &textChanged ); 87 void slotChooser4Change( const QString &textChanged );
89 void slotCmbChooser1Change( int index ); 88 void slotCmbChooser1Change( int index );
90 void slotCmbChooser2Change( int index ); 89 void slotCmbChooser2Change( int index );
91 void slotCmbChooser3Change( int index ); 90 void slotCmbChooser3Change( int index );
92 void slotCmbChooser4Change( int index ); 91 void slotCmbChooser4Change( int index );
93 void slotAddressTypeChange( int index ); 92 void slotAddressTypeChange( int index );
94 void slotAddressChange( const QString &textChanged ); 93 void slotAddressChange( const QString &textChanged );
95 void slotAddress2Change( const QString &textChanged ); 94 void slotAddress2Change( const QString &textChanged );
@@ -99,93 +98,94 @@ class ContactEditor : public QDialog {
99 void slotZipChange( const QString &textChanged ); 98 void slotZipChange( const QString &textChanged );
100 void slotCountryChange( const QString &textChanged ); 99 void slotCountryChange( const QString &textChanged );
101 void slotFullNameChange( const QString &textChanged ); 100 void slotFullNameChange( const QString &textChanged );
102 void slotSuffixChange( const QString &textChanged ); 101 void slotSuffixChange( const QString &textChanged );
103 void slotOrganizationChange( const QString &textChanged ); 102 void slotOrganizationChange( const QString &textChanged );
104 void slotAnniversaryDateChanged( int year, int month, int day); 103 void slotAnniversaryDateChanged( int year, int month, int day);
105 void slotBirthdayDateChanged( int year, int month, int day); 104 void slotBirthdayDateChanged( int year, int month, int day);
106 void slotRemoveBirthday(); 105 void slotRemoveBirthday();
107 void slotRemoveAnniversary(); 106 void slotRemoveAnniversary();
108 void defaultEmailChanged(int); 107 void defaultEmailChanged(int);
109 108
110 private: 109 private:
111 enum StackWidgets { TextField = 1, Combo }; 110 enum StackWidgets { TextField = 1, Combo };
112 int defaultEmailChooserPosition; 111 int defaultEmailChooserPosition;
113 void populateDefaultEmailCmb(); 112 void populateDefaultEmailCmb();
114 void chooserChange( const QString&, int , QLineEdit*, int ); 113 void chooserChange( const QString&, int , QLineEdit*, int );
115 bool cmbChooserChange( int , QWidgetStack*, int ); 114 bool cmbChooserChange( int , QWidgetStack*, int );
116 Opie::OPimContactFields contactfields; 115 Opie::OPimContactFields contactfields;
117 116
118 Opie::OPimContact ent; 117 Opie::OPimContact ent;
119 118
120 QDialog *dlgNote; 119 QDialog *dlgNote;
121 QDialog *dlgName; 120 QDialog *dlgName;
122 121
123 QList<QLineEdit> listValue; 122 QList<QLineEdit> listValue;
124 QList<QLabel> listName; 123 QList<QLabel> listName;
125 124
126 QStringList slDynamicEntries; 125 QStringList slDynamicEntries;
127 QStringList trlDynamicEntries; 126 QStringList trlDynamicEntries;
128 127
129 bool m_personalView; 128 bool m_personalView;
130 129
131 QStringList slHomeAddress; 130 QStringList slHomeAddress;
132 QStringList slBusinessAddress; 131 QStringList slBusinessAddress;
133 QStringList slChooserNames; 132 QStringList slChooserNames;
134 QStringList slChooserValues; 133 QStringList slChooserValues;
135 QStringList emails; 134 QStringList emails;
136 QString defaultEmail; 135 QString defaultEmail;
137 136
138 QMultiLineEdit *txtNote; 137 QMultiLineEdit *txtNote;
139 QLabel *lblNote; 138 QLabel *lblNote;
140 139
141 //QLineEdit *txtTitle; 140 //QLineEdit *txtTitle;
142 QLineEdit *txtFirstName; 141 QLineEdit *txtFirstName;
143 QLineEdit *txtMiddleName; 142 QLineEdit *txtMiddleName;
144 QLineEdit *txtLastName; 143 QLineEdit *txtLastName;
145 QLineEdit *txtSuffix; 144 QLineEdit *txtSuffix;
146 145
147 QTabWidget *tabMain; 146 Opie::Ui::OTabWidget *tabMain;
147 QWidget *m_generalWidget;
148 QScrollView *svGeneral; 148 QScrollView *svGeneral;
149 QPushButton *btnFullName; 149 QPushButton *btnFullName;
150 QPushButton *btnNote; 150 QPushButton *btnNote;
151 QLineEdit *txtFullName; 151 QLineEdit *txtFullName;
152 QLineEdit *txtJobTitle; 152 QLineEdit *txtJobTitle;
153 QLineEdit *txtOrganization; 153 QLineEdit *txtOrganization;
154 QLineEdit *txtChooserField1; 154 QLineEdit *txtChooserField1;
155 QLineEdit *txtChooserField2; 155 QLineEdit *txtChooserField2;
156 QLineEdit *txtChooserField3; 156 QLineEdit *txtChooserField3;
157 QLineEdit *txtChooserField4; 157 QLineEdit *txtChooserField4;
158 QWidgetStack* m_widgetStack1; 158 QWidgetStack* m_widgetStack1;
159 QWidgetStack* m_widgetStack2; 159 QWidgetStack* m_widgetStack2;
160 QWidgetStack* m_widgetStack3; 160 QWidgetStack* m_widgetStack3;
161 QWidgetStack* m_widgetStack4; 161 QWidgetStack* m_widgetStack4;
162 QComboBox *cmbChooserField1; 162 QComboBox *cmbChooserField1;
163 QComboBox *cmbChooserField2; 163 QComboBox *cmbChooserField2;
164 QComboBox *cmbChooserField3; 164 QComboBox *cmbChooserField3;
165 QComboBox *cmbChooserField4; 165 QComboBox *cmbChooserField4;
166 QComboBox *cmbDefaultEmail; 166 QComboBox *cmbDefaultEmail;
167 QComboBox *cmbFileAs; 167 QComboBox *cmbFileAs;
168 CategorySelect *cmbCat; 168 CategorySelect *cmbCat;
169 QLabel *labCat; 169 QLabel *labCat;
170 170
171 QScrollView *svAddress; 171 QScrollView *svAddress;
172 QLineEdit *txtAddress; 172 QLineEdit *txtAddress;
173 //QLineEdit *txtAddress2; 173 //QLineEdit *txtAddress2;
174 //QLineEdit *txtPOBox; 174 //QLineEdit *txtPOBox;
175 QLineEdit *txtCity; 175 QLineEdit *txtCity;
176 QLineEdit *txtState; 176 QLineEdit *txtState;
177 QLineEdit *txtZip; 177 QLineEdit *txtZip;
178 QComboBox *cmbAddress; 178 QComboBox *cmbAddress;
179 QComboBox *cmbCountry; 179 QComboBox *cmbCountry;
180 180
181 QScrollView *svDetails; 181 QScrollView *svDetails;
182 QComboBox *cmbGender; 182 QComboBox *cmbGender;
183 DateBookMonth* birthdayPicker; 183 DateBookMonth* birthdayPicker;
184 QToolButton* birthdayButton; 184 QToolButton* birthdayButton;
185 DateBookMonth* anniversaryPicker; 185 DateBookMonth* anniversaryPicker;
186 QToolButton* anniversaryButton; 186 QToolButton* anniversaryButton;
187 187
188 bool initializing; 188 bool initializing;
189 }; 189 };
190 190
191#endif 191#endif