summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO79
-rw-r--r--core/pim/addressbook/abconfig.cpp184
-rw-r--r--core/pim/addressbook/abconfig.h55
-rw-r--r--core/pim/addressbook/ablabel.cpp98
-rw-r--r--core/pim/addressbook/ablabel.h24
-rw-r--r--core/pim/addressbook/abtable.cpp914
-rw-r--r--core/pim/addressbook/abtable.h87
-rw-r--r--core/pim/addressbook/abview.cpp186
-rw-r--r--core/pim/addressbook/abview.h15
-rw-r--r--core/pim/addressbook/addressbook.cpp847
-rw-r--r--core/pim/addressbook/addressbook.h45
-rw-r--r--core/pim/addressbook/addressbook.pro17
-rw-r--r--core/pim/addressbook/addresssettings.cpp4
-rw-r--r--core/pim/addressbook/addresssettingsbase.ui2
-rw-r--r--core/pim/addressbook/configdlg.cpp156
-rw-r--r--core/pim/addressbook/configdlg.h30
-rw-r--r--core/pim/addressbook/configdlg_base.ui404
-rw-r--r--core/pim/addressbook/contacteditor.cpp605
-rw-r--r--core/pim/addressbook/contacteditor.h14
-rw-r--r--core/pim/addressbook/ocontactfields.cpp283
-rw-r--r--core/pim/addressbook/ocontactfields.h24
-rw-r--r--core/pim/addressbook/opie-addressbook.control2
-rw-r--r--core/pim/addressbook/picker.cpp5
-rw-r--r--core/pim/addressbook/picker.h4
-rw-r--r--core/pim/addressbook/version.h10
25 files changed, 2122 insertions, 1972 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 517d702..0380fa3 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -1,52 +1,93 @@
1Stuff todo until OPIE 1.0 : 1Stuff todo until OPIE 1.0 :
2===========================
2 3
3----> This main branch ist currently stable enough for 4Feature requests:
4----> snapshots.. To avoid corrupted snapshots, we currently 5-----------------
5----> working on a different branch.. 6- Dial by mobile phone by tapping the number..
6----> YOU FIND THE CURRENT WORK IN THE BRANCH "GO_FOR_OPIE_1_0" 7 (Maybe using gsmtool. And we may
8 add a library class for this)
9- dial with dtmfdial incase it's installed and there's no mobile
10- 3rd column for 2. Contact
11- Implementing additional Views (Phonebook, ...)
12- Birthday & Anniversary Reminder
13- Plugin for Today for Birthdays and Anniversaries
7 14
15Known Bugs:
16-----------
17- OK-Key does not switch from Detailview (ablable) to Listview
18
19Bugs but not in addressbook:
20-----------------------------
21- VCARD: Import of Anniversary does not work correctly (currently disabled)
22- VCARD: If umlaut (äöüß) in address, the parser gets confused..
8 23
9Pending bugfixes from previous work:
10 24
11Urgent: 25Urgent:
26--------
27- Contact-Editor is temporarely reanabled. Wait for replacement.
28- Redesign of Contacteditor
29- Store last settings of combo-boxes
30- Name order selected in "contacteditor" not used in list view.
31- Category is on the wrong position after changing to personal and back to normal
32 ( Temporarily workaround: Category is never deactivated.. :S )
12 33
13 34
14Important: 35Important:
36----------
15 37
16- Name order selected in "contacteditor" not used in list view. 38- After search (Started with Return): KeyFocus should be on Tabelle
39- Searchwidget closed: Selected user is jumping
40- Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist)
41 zu lange..
17 42
18- Overview window cleanup needed.. 43- Store position and state of toolbar
19- Cursor keys should work in detail-view (ablabel)
20 -> Ablabel should be removed and Abtable should be increased with
21 different views (as started by darwin zins)..
22- Store last settings of combo-boxes
23- Finishing of new View functions (List, Phonebook...)
24- Reload if contacts were changed externally
25- "What's this" should be added
26 44
27Less important: 45- IRDA Receive: Contact is added, but start of editor with new entry expected..
46- "What's this" should be added (Deleyed after Feature Freeze)
28 47
29- The picker (alphabetical sort widget) should be 48Less important:
49---------------
50- Reload if contacts were changed externally
51- Overview window cleanup needed..
52- The picker (alphabetical sort widget) should be
30 placed verticaly or horizontally (configurable) 53 placed verticaly or horizontally (configurable)
31- Use advanced database functions in abtable to decrease 54- Find a smart solution for activating/deactivating the "send email" event
32 memory footprint and to make everything more easy !
33 (abtable should store Iterator for selected Category)
34 55
35Should be Fixed (not absolute sure, need further validation): 56Should be Fixed (not absolute sure, need further validation):
57-------------------------------------------------------------
36 58
37 59
38Fixed: 60Fixed:
61-------
39- Syncing: abtable not reloaded after sync. 62- Syncing: abtable not reloaded after sync.
40- Find widget should be replaced by something like 63- Find widget should be replaced by something like
41 qpdf has. 64 qpdf has.
42- Adding a configuration dialog 65- Adding a configuration dialog
43- Picker: Activated letter schould be more visible 66- Picker: Activated letter schould be more visible
44- Advanced handling of cursor keys (search..) 67- Advanced handling of cursor keys (search..)
45- Mail-Icon is missing 68- Mail-Icon is missing
46- Use opie-mail insted of qt-mail if possible. 69- Use opie-mail insted of qt-mail if possible.
47- Font menu is invisible using german translation 70- Font menu is invisible using german translation
48- Personal contact editor: Disable categories 71- Personal contact editor: Disable categories
49- "Nonenglish" translation bug has to be fixed. 72- "Nonenglish" translation bug has to be fixed.
50- contacteditor: Birthday, annyversary, ... : Use Dateselector 73- contacteditor: Birthday, annyversary, ... : Use Dateselector
51- The names of the countries are sorted by there english names, only.. 74- The names of the countries are sorted by there english names, only..
52 Even if they are translated.. :S 75 Even if they are translated.. :S
76- Cursor keys should work in detail-view (ablabel)
77 -> Ablabel should be removed and Abtable should be increased with
78 different views (as started by darwin zins)..
79- Use advanced database functions in abtable to decrease
80 memory footprint and to make everything more easy !
81 (abtable should store Iterator for selected Category)
82- Abtable: Configure Contact column (internally already available,
83 need configuration)
84- Select of primary contact (see #274 on mantis)
85- Category-select does not work completely: "Unfiled" is always in listview ..
86- Return from Contacteditor: Category resettet to all
87- Personal Details not working
88- If category changed, the letterpicker should be resetted
89- There should be some icons for List and Cardview
90- If in Cardview and a category change removes all entries:
91 There are already entries in Cardview after up/down
92- Personal Details: Anniversary zeigt Fantasie-Werte
93- Unfiled shown just in Category "All" and "Unfiled".
diff --git a/core/pim/addressbook/abconfig.cpp b/core/pim/addressbook/abconfig.cpp
new file mode 100644
index 0000000..703faac
--- a/dev/null
+++ b/core/pim/addressbook/abconfig.cpp
@@ -0,0 +1,184 @@
1#include "abconfig.h"
2#include "version.h"
3
4#include <qpe/config.h>
5#include <qpe/recordfields.h>
6
7AbConfig::AbConfig( ):
8 m_useQtMail( true ),
9 m_useOpieMail( false ),
10 m_useRegExp( false ),
11 m_beCaseSensitive( false ),
12 m_fontSize( 1 ),
13 m_barPos( QMainWindow::Top ),
14 m_changed( false )
15{
16}
17
18AbConfig::~AbConfig()
19{
20}
21
22bool AbConfig::useRegExp() const
23{
24 return m_useRegExp;
25}
26bool AbConfig::useWildCards() const
27{
28 return !m_useRegExp;
29}
30bool AbConfig::useQtMail() const
31{
32 return m_useQtMail;
33}
34bool AbConfig::useOpieMail() const
35{
36 return m_useOpieMail;
37}
38bool AbConfig::beCaseSensitive() const
39{
40 return m_beCaseSensitive;
41}
42int AbConfig::fontSize() const
43{
44 return m_fontSize;
45}
46
47QValueList<int> AbConfig::orderList() const
48{
49 return m_ordered;
50}
51
52QMainWindow::ToolBarDock AbConfig::getToolBarPos() const
53{
54 return (QMainWindow::ToolBarDock) m_barPos;
55}
56
57
58void AbConfig::setUseRegExp( bool v )
59{
60 m_useRegExp = v ;
61 m_changed = true;
62}
63void AbConfig::setUseWildCards( bool v )
64{
65 m_useRegExp = !v;
66 m_changed = true;
67}
68void AbConfig::setBeCaseSensitive( bool v )
69{
70 m_beCaseSensitive = v;
71 m_changed = true;
72}
73void AbConfig::setUseQtMail( bool v )
74{
75 m_useQtMail = v;
76 m_changed = true;
77}
78void AbConfig::setUseOpieMail( bool v )
79{
80 m_useOpieMail = v;
81 m_changed = true;
82}
83void AbConfig::setFontSize( int v )
84{
85 m_fontSize = v;
86 m_changed = true;
87}
88
89void AbConfig::setOrderList( const QValueList<int>& list )
90{
91 m_ordered = list;
92 m_changed = true;
93}
94
95void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v )
96{
97 m_barPos = v;
98 m_changed = true;
99}
100
101void AbConfig::load()
102{
103 // Read Config settings
104 Config cfg("AddressBook");
105
106 cfg.setGroup("Font");
107 m_fontSize = cfg.readNumEntry( "fontSize", 1 );
108
109 cfg.setGroup("Search");
110 m_useRegExp = cfg.readBoolEntry( "useRegExp" );
111 m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive" );
112
113 cfg.setGroup("Mail");
114 m_useQtMail = cfg.readBoolEntry( "useQtMail", true );
115 m_useOpieMail=cfg.readBoolEntry( "useOpieMail" );
116
117 cfg.setGroup("ContactOrder");
118 int ID = 0;
119 int i = 0;
120 ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 );
121 while ( ID != 0 ){
122 m_ordered.append( ID );
123 ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 );
124 }
125
126 // If no contact order is defined, we set the default
127 if ( m_ordered.count() == 0 ) {
128 m_ordered.append( Qtopia::DefaultEmail );
129 m_ordered.append( Qtopia::HomePhone);
130 m_ordered.append( Qtopia::HomeMobile);
131 m_ordered.append( Qtopia::BusinessPhone);
132 }
133
134 cfg.setGroup("ToolBar");
135 m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top );
136
137 m_changed = false;
138}
139
140void AbConfig::save()
141{
142 if ( m_changed ){
143 Config cfg("AddressBook");
144 cfg.setGroup("Font");
145 cfg.writeEntry("fontSize", m_fontSize);
146
147 cfg.setGroup("Search");
148 cfg.writeEntry("useRegExp", m_useRegExp);
149 cfg.writeEntry("caseSensitive", m_beCaseSensitive);
150
151 cfg.setGroup("Mail");
152 cfg.writeEntry( "useQtMail", m_useQtMail );
153 cfg.writeEntry( "useOpieMail", m_useOpieMail);
154
155 cfg.setGroup("ContactOrder");
156 cfg.clearGroup();
157 for ( uint i = 0; i < m_ordered.count(); i++ ){
158 cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] );
159 }
160
161 cfg.setGroup("ToolBar");
162 cfg.writeEntry( "Position", m_barPos );
163
164 cfg.setGroup("Version");
165 cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION);
166 cfg.writeEntry( "Mainversion", MAINVERSION );
167 cfg.writeEntry( "SubVersion", SUBVERSION );
168 cfg.writeEntry( "PatchVersion", PATCHVERSION );
169
170 }
171
172}
173
174void AbConfig::operator= ( const AbConfig& cnf )
175{
176 m_useQtMail = cnf.m_useQtMail;
177 m_useOpieMail = cnf.m_useOpieMail;
178 m_useRegExp = cnf.m_useRegExp;
179 m_beCaseSensitive = cnf.m_beCaseSensitive;
180 m_fontSize = cnf.m_fontSize;
181 m_ordered = cnf.m_ordered;
182
183}
184
diff --git a/core/pim/addressbook/abconfig.h b/core/pim/addressbook/abconfig.h
new file mode 100644
index 0000000..b8460d7
--- a/dev/null
+++ b/core/pim/addressbook/abconfig.h
@@ -0,0 +1,55 @@
1#ifndef _ABCONFIG_H_
2#define _ABCONFIG_H_
3
4#include <qstringlist.h>
5#include <qmainwindow.h>
6
7class AbConfig
8{
9public:
10 AbConfig();
11 ~AbConfig();
12
13 // Search Settings
14 bool useRegExp() const;
15 bool useWildCards() const;
16 bool beCaseSensitive() const;
17 bool useQtMail() const;
18 bool useOpieMail() const;
19 int fontSize() const;
20 QValueList<int> orderList() const;
21 QMainWindow::ToolBarDock getToolBarPos() const;
22
23 void setUseRegExp( bool v );
24 void setUseWildCards( bool v );
25 void setBeCaseSensitive( bool v );
26 void setUseQtMail( bool v );
27 void setUseOpieMail( bool v );
28 void setFontSize( int v );
29 void setOrderList( const QValueList<int>& list );
30 void setToolBarDock( const QMainWindow::ToolBarDock v );
31
32 void operator= ( const AbConfig& cnf );
33
34 void load();
35 void save();
36
37protected:
38/* virtual void itemUp(); */
39/* virtual void itemDown(); */
40
41 QStringList contFields;
42
43 bool m_useQtMail;
44 bool m_useOpieMail;
45 bool m_useRegExp;
46 bool m_beCaseSensitive;
47 int m_fontSize;
48 QValueList<int> m_ordered;
49 int m_barPos;
50
51 bool m_changed;
52};
53
54
55#endif
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp
index ea80700..5b40dc1 100644
--- a/core/pim/addressbook/ablabel.cpp
+++ b/core/pim/addressbook/ablabel.cpp
@@ -1,90 +1,116 @@
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 20
21#include "ablabel.h" 21#include "ablabel.h"
22 22
23#include <qpe/stringutil.h> 23#include <qpe/stringutil.h>
24 24
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qstylesheet.h> 26#include <qstylesheet.h>
27 27
28AbLabel::AbLabel( QWidget *parent, const char *name ) 28AbLabel::AbLabel( QWidget *parent, const char *name ):
29 : QTextView( parent, name ) 29 QTextView( parent, name ),
30 m_empty( false )
30{ 31{
31} 32}
32 33
33AbLabel::~AbLabel() 34AbLabel::~AbLabel()
34{ 35{
35} 36}
36 37
37void AbLabel::init( const OContact &entry ) 38void AbLabel::setContacts( const OContactAccess::List& viewList )
38{ 39{
39 ent = entry; 40 m_viewList = viewList;
41 if (m_viewList.count() != 0){
42 m_empty = false;
43 m_itCurContact = m_viewList.begin();
44 sync();
45 }else{
46 // m_itCurContact.clear();
47 m_empty = true;
48 setText( "" );
49 }
50}
51
52int AbLabel::currentEntry_UID()
53{
54 return ( (*m_itCurContact).uid() );
55}
56
57OContact AbLabel::currentEntry()
58{
59 return ( *m_itCurContact );
40} 60}
41 61
62
63bool AbLabel::selectContact( int UID )
64{
65
66 for ( m_itCurContact = m_viewList.begin(); m_itCurContact != m_viewList.end(); ++m_itCurContact){
67 if ( (*m_itCurContact).uid() == UID )
68 break;
69 }
70 sync();
71
72 return true;
73}
74
75
76
42void AbLabel::sync() 77void AbLabel::sync()
43{ 78{
44 QString text = ent.toRichText(); 79 QString text = (*m_itCurContact).toRichText();
45 setText( text ); 80 setText( text );
46} 81}
47 82
48void AbLabel::keyPressEvent( QKeyEvent *e ) 83void AbLabel::keyPressEvent( QKeyEvent *e )
49{ 84{
50 // Commonly handled keys 85 // Commonly handled keys
51 switch( e->key() ) { 86 if ( !m_empty ){
52 case Qt::Key_Left:
53 qWarning( "Left..");
54 case Qt::Key_F33:
55 qWarning( "OK..");
56 emit okPressed();
57 break;
58 }
59
60
61 if ( /* m_inSearch */ false ) {
62 // Running in seach-mode, therefore we will interprete
63 // some key differently
64 qWarning("Received key in search mode");
65 switch( e->key() ) { 87 switch( e->key() ) {
66 case Qt::Key_Up: 88 case Qt::Key_Left:
67 qWarning("a"); 89 qWarning( "Left..");
68 // emit signalSearchBackward(); 90 case Qt::Key_Right:
69 break; 91 qWarning( "Right..");
70 case Qt::Key_Down: 92 case Qt::Key_F33:
71 qWarning("b"); 93 qWarning( "OK..");
72 // emit signalSearchNext(); 94 emit signalOkPressed();
73 break; 95 break;
74 }
75
76 } else {
77 qWarning("Received key in NON search mode");
78
79 switch( e->key() ) {
80 case Qt::Key_Up: 96 case Qt::Key_Up:
81 qWarning("a"); 97 qWarning( "UP..");
82 // emit signalSearchBackward(); 98 --m_itCurContact;
99 if ( *m_itCurContact != OContact() )
100 sync();
101 else
102 m_itCurContact = m_viewList.end();
103
83 break; 104 break;
84 case Qt::Key_Down: 105 case Qt::Key_Down:
85 qWarning("b"); 106 qWarning( "DOWN..");
86 // emit signalSearchNext(); 107 ++m_itCurContact;
108 if ( *m_itCurContact != OContact() )
109 sync();
110 else
111 m_itCurContact = m_viewList.begin();
87 break; 112 break;
88 } 113 }
89 } 114 }
115
90} 116}
diff --git a/core/pim/addressbook/ablabel.h b/core/pim/addressbook/ablabel.h
index 9086c4a..b1e35de 100644
--- a/core/pim/addressbook/ablabel.h
+++ b/core/pim/addressbook/ablabel.h
@@ -1,50 +1,64 @@
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 ABLABEL_H 20#ifndef ABLABEL_H
21#define ABLABEL_H 21#define ABLABEL_H
22 22
23#include <opie/ocontact.h> 23#include <opie/ocontact.h>
24#include <qtextview.h> 24#include <qtextview.h>
25 25
26#include <opie/ocontactaccess.h>
27
26class AbLabel : public QTextView 28class AbLabel : public QTextView
27{ 29{
28 Q_OBJECT 30 Q_OBJECT
29 31
30public: 32public:
31 AbLabel( QWidget *parent, const char *name = 0 ); 33 AbLabel( QWidget *parent, const char *name = 0 );
32 ~AbLabel(); 34 ~AbLabel();
33 35
34public slots: 36 // Set the contacts
35 void init( const OContact &entry ); 37 void setContacts( const OContactAccess::List& viewList );
36 void sync(); 38
39 // Selects a contact
40 bool selectContact( int UID );
41
42 // Get the UID of the current selected Entry
43 int currentEntry_UID();
44
45 //
46 OContact currentEntry();
37 47
38signals: 48signals:
39 void okPressed(); 49 void signalOkPressed();
40 50
41protected: 51protected:
52 void sync();
42 void keyPressEvent( QKeyEvent * ); 53 void keyPressEvent( QKeyEvent * );
43 54
44private: 55private:
45 OContact ent; 56 OContactAccess::List m_viewList;
57 OContactAccess::List::Iterator m_itCurContact;
58
59 bool m_empty;
46 60
47}; 61};
48 62
49#endif // ABLABEL_H 63#endif // ABLABEL_H
50 64
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 5222f16..b8127e9 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -1,1056 +1,712 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
3** 4**
4** This file is part of Qt Palmtop Environment. 5** This file is part of Qt Palmtop Environment.
5** 6**
6** 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
7** 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
8** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 10** packaging of this file.
10** 11**
11** 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
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 14**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 16**
16** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 18** not clear to you.
18** 19**
19**********************************************************************/ 20**********************************************************************/
20 21
21#define QTOPIA_INTERNAL_CONTACT_MRE
22 22
23#include <qpe/categoryselect.h> 23#include <qpe/categoryselect.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/stringutil.h> 25#include <qpe/stringutil.h>
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#include <qpe/timestring.h> 27#include <qpe/timestring.h>
28 28
29#include <opie/orecordlist.h> 29#include <opie/orecordlist.h>
30 30
31#include <qasciidict.h> 31#include <qasciidict.h>
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qregexp.h> 34#include <qregexp.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36 36
37#include "abtable.h" 37#include "abtable.h"
38 38
39#include <errno.h> 39#include <errno.h>
40#include <fcntl.h> 40#include <fcntl.h>
41#include <unistd.h> 41#include <unistd.h>
42#include <stdlib.h> 42#include <stdlib.h>
43 43
44#include <ctype.h> //toupper() for key hack 44#include <ctype.h> //toupper() for key hack
45 45
46static bool contactCompare( const OContact &cnt, const QRegExp &r, int category );
47
48
49/*! 46/*!
50 \class AbTableItem abtable.h 47 \class AbTableItem abtable.h
51 48
52 \brief QTableItem based class for showing a field of an entry 49 \brief QTableItem based class for showing a field of an entry
53*/ 50*/
54 51
55AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, 52AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s,
56 const QString &secondSortKey) 53 const QString &secondSortKey)
57 : QTableItem( t, et, s ) 54 : QTableItem( t, et, s )
58{ 55{
59 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); 56 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower();
60 sortKey = Qtopia::buildSortKey( s, secondSortKey ); 57 sortKey = Qtopia::buildSortKey( s, secondSortKey );
61} 58}
62 59
63int AbTableItem::alignment() const 60int AbTableItem::alignment() const
64{ 61{
65 return AlignLeft|AlignVCenter; 62 return AlignLeft|AlignVCenter;
66} 63}
67 64
68QString AbTableItem::key() const 65QString AbTableItem::key() const
69{ 66{
70 return sortKey; 67 return sortKey;
71} 68}
72 69
73// A way to reset the item, without out doing a delete or a new... 70// A way to reset the item, without out doing a delete or a new...
74void AbTableItem::setItem( const QString &txt, const QString &secondKey ) 71void AbTableItem::setItem( const QString &txt, const QString &secondKey )
75{ 72{
76 setText( txt ); 73 setText( txt );
77 sortKey = Qtopia::buildSortKey( txt, secondKey ); 74 sortKey = Qtopia::buildSortKey( txt, secondKey );
78 75
79 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); 76 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower();
80} 77}
81 78
82/*! 79/*!
83 \class AbPickItem abtable.h 80 \class AbPickItem abtable.h
84 81
85 \brief QTableItem based class for showing slection of an entry 82 \brief QTableItem based class for showing slection of an entry
86*/ 83*/
87 84
88AbPickItem::AbPickItem( QTable *t ) : 85AbPickItem::AbPickItem( QTable *t ) :
89 QTableItem(t, WhenCurrent, "?") 86 QTableItem(t, WhenCurrent, "?")
90{ 87{
91} 88}
92 89
93QWidget *AbPickItem::createEditor() const 90QWidget *AbPickItem::createEditor() const
94{ 91{
95 QComboBox* combo = new QComboBox( table()->viewport() ); 92 QComboBox* combo = new QComboBox( table()->viewport() );
96 ( (AbPickItem*)this )->cb = combo; 93 ( (AbPickItem*)this )->cb = combo;
97 AbTable* t = static_cast<AbTable*>(table()); 94 AbTable* t = static_cast<AbTable*>(table());
98 QStringList c = t->choiceNames(); 95 QStringList c = t->choiceNames();
99 int cur = 0; 96 int cur = 0;
100 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { 97 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
101 if ( *it == text() ) 98 if ( *it == text() )
102 cur = combo->count(); 99 cur = combo->count();
103 combo->insertItem(*it); 100 combo->insertItem(*it);
104 } 101 }
105 combo->setCurrentItem(cur); 102 combo->setCurrentItem(cur);
106 return combo; 103 return combo;
107} 104}
108 105
109void AbPickItem::setContentFromEditor( QWidget *w ) 106void AbPickItem::setContentFromEditor( QWidget *w )
110{ 107{
111 if ( w->inherits("QComboBox") ) 108 if ( w->inherits("QComboBox") )
112 setText( ( (QComboBox*)w )->currentText() ); 109 setText( ( (QComboBox*)w )->currentText() );
113 else 110 else
114 QTableItem::setContentFromEditor( w ); 111 QTableItem::setContentFromEditor( w );
115} 112}
116 113
117/*! 114/*!
118 \class AbTable abtable.h 115 \class AbTable abtable.h
119 116
120 \brief QTable based class for showing a list of entries 117 \brief QTable based class for showing a list of entries
121*/ 118*/
122 119
123AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) 120AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
124 // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
125 // : QTable( 0, 0, parent, name, TRUE ),
126 // #else
127 : QTable( parent, name ), 121 : QTable( parent, name ),
128 // #endif 122 lastSortCol( -1 ),
129 lastSortCol( -1 ), 123 asc( TRUE ),
130 asc( TRUE ), 124 intFields( order ),
131 intFields( order ), 125 enablePainting( true ),
132 currFindRow( -1 ), 126 columnVisible( true )
133 mCat( 0 ),
134 m_inSearch (false),
135 m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. !
136{ 127{
137 mCat.load( categoryFileName() ); 128 qWarning("C'tor start");
129
138 setSelectionMode( NoSelection ); 130 setSelectionMode( NoSelection );
139 init(); 131 init();
140 setSorting( TRUE ); 132 setSorting( TRUE );
141 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), 133 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
142 this, SLOT(itemClicked(int,int)) ); 134 this, SLOT(itemClicked(int,int)) );
135
136 contactList.clear();
137 qWarning("C'tor end");
143} 138}
144 139
145AbTable::~AbTable() 140AbTable::~AbTable()
146{ 141{
147} 142}
148 143
149void AbTable::init() 144void AbTable::init()
150{ 145{
151 showChar = '\0'; 146 // :SX showChar = '\0';
152 setNumRows( 0 ); 147 setNumRows( 0 );
153 setNumCols( 2 ); 148 setNumCols( 2 );
154 149
155 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 150 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
156 horizontalHeader()->setLabel( 1, tr( "Contact" )); 151 horizontalHeader()->setLabel( 1, tr( "Contact" ));
157 setLeftMargin( 0 ); 152 setLeftMargin( 0 );
158 verticalHeader()->hide(); 153 verticalHeader()->hide();
159 columnVisible = true; 154 columnVisible = true;
160} 155}
161 156
157void AbTable::setContacts( const OContactAccess::List& viewList )
158{
159 qWarning("AbTable::setContacts()");
160
161 clear();
162 m_viewList = viewList;
163
164 setSorting( false );
165 setUpdatesEnabled( FALSE );
166
167 OContactAccess::List::Iterator it;
168 setNumRows( m_viewList.count() );
169 int row = 0;
170 for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
171 insertIntoTable( *it, row++ );
172
173 setUpdatesEnabled( TRUE );
174
175 setSorting( true );
176
177 resort();
178
179 updateVisible();
180
181}
182
183bool AbTable::selectContact( int UID )
184{
185 qWarning( "AbTable::selectContact( %d )", UID );
186 int rows = numRows();
187 AbTableItem *abi;
188 OContact* foundContact = 0l;
189 bool found = false;
190
191 for ( int r = 0; r < rows; ++r ) {
192 abi = static_cast<AbTableItem*>( item(r, 0) );
193 foundContact = &contactList[abi];
194 if ( foundContact -> uid() == UID ){
195 ensureCellVisible( r, 0 );
196 setCurrentCell( r, 0 );
197 found = true;
198 break;
199 }
200 }
201
202 if ( !found ){
203 ensureCellVisible( 0,0 );
204 setCurrentCell( 0, 0 );
205 }
206
207 return true;
208}
209
210void AbTable::insertIntoTable( const OContact& cnt, int row )
211{
212 // qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
213 QString strName,
214 strContact;
215
216 strName = findContactName( cnt );
217 strContact = findContactContact( cnt, row );
218
219 AbTableItem *ati;
220 ati = new AbTableItem( this, QTableItem::Never, strName, strContact);
221 contactList.insert( ati, cnt );
222 setItem( row, 0, ati );
223 ati = new AbTableItem( this, QTableItem::Never, strContact, strName);
224 setItem( row, 1, ati );
225
226 //### cannot do this; table only has two columns at this point
227 // setItem( row, 2, new AbPickItem( this ) );
228
229}
230
231
232
162void AbTable::columnClicked( int col ) 233void AbTable::columnClicked( int col )
163{ 234{
164 if ( !sorting() ) 235 if ( !sorting() )
165 return; 236 return;
166 237
167 if ( lastSortCol == -1 ) 238 if ( lastSortCol == -1 )
168 lastSortCol = col; 239 lastSortCol = col;
169 240
170 if ( col == lastSortCol ) { 241 if ( col == lastSortCol ) {
171 asc = !asc; 242 asc = !asc;
172 } else { 243 } else {
173 lastSortCol = col; 244 lastSortCol = col;
174 asc = TRUE; 245 asc = TRUE;
175 } 246 }
176 //QMessageBox::information( this, "resort", "columnClicked" ); 247 //QMessageBox::information( this, "resort", "columnClicked" );
177 resort(); 248 resort();
178} 249}
179 250
180void AbTable::resort() 251void AbTable::resort()
181{ 252{
253 qWarning( "void AbTable::resort()" );
182 if ( sorting() ) { 254 if ( sorting() ) {
183 if ( lastSortCol == -1 ) 255 if ( lastSortCol == -1 )
184 lastSortCol = 0; 256 lastSortCol = 0;
185 sortColumn( lastSortCol, asc, TRUE ); 257 sortColumn( lastSortCol, asc, TRUE );
186 //QMessageBox::information( this, "resort", "resort" ); 258 //QMessageBox::information( this, "resort", "resort" );
187 updateVisible(); 259 updateVisible();
188 } 260 }
189} 261}
190 262
191OContact AbTable::currentEntry() 263OContact AbTable::currentEntry()
192{ 264{
265 qWarning( "OContact AbTable::currentEntry()" );
193 OContact cnt; 266 OContact cnt;
194 AbTableItem *abItem; 267 AbTableItem *abItem;
195 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); 268 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
196 if ( abItem ) { 269 if ( abItem ) {
197 cnt = contactList[abItem]; 270 cnt = contactList[abItem];
198 //cnt = contactList[currentRow()]; 271 //cnt = contactList[currentRow()];
199 } 272 }
200 return cnt; 273 return cnt;
201} 274}
202 275
203void AbTable::replaceCurrentEntry( const OContact &newContact ) 276int AbTable::currentEntry_UID()
204{ 277{
205 int row = currentRow(); 278 return ( currentEntry().uid() );
206 updateVisible();
207
208 journalFreeReplace( newContact, row );
209
210}
211
212void AbTable::deleteCurrentEntry()
213{
214 int row = currentRow();
215
216 // a little wasteful, but it ensure's there is only one place
217 // where we delete.
218 journalFreeRemove( row );
219 updateVisible();
220
221 if ( numRows() == 0 )
222 emit empty( TRUE );
223
224} 279}
225 280
226void AbTable::clear() 281void AbTable::clear()
227{ 282{
283 qWarning( "void AbTable::clear()" );
228 contactList.clear(); 284 contactList.clear();
229 for ( int r = 0; r < numRows(); ++r ) { 285 for ( int r = 0; r < numRows(); ++r ) {
230 for ( int c = 0; c < numCols(); ++c ) { 286 for ( int c = 0; c < numCols(); ++c ) {
231 if ( cellWidget( r, c ) ) 287 if ( cellWidget( r, c ) )
232 clearCellWidget( r, c ); 288 clearCellWidget( r, c );
233 clearCell( r, c ); 289 clearCell( r, c );
234 } 290 }
235 } 291 }
236 setNumRows( 0 ); 292 setNumRows( 0 );
237} 293}
238 294
295// Refresh updates column 2 if the contactsettings changed
239void AbTable::refresh() 296void AbTable::refresh()
240{ 297{
298 qWarning( "void AbTable::refresh()" );
241 int rows = numRows(); 299 int rows = numRows();
242 QString value; 300 QString value;
243 AbTableItem *abi; 301 AbTableItem *abi;
244 302
245 // hide columns so no flashing ?
246 if ( showBk == "Cards" ) {
247 hideColumn(0);
248 hideColumn(1);
249 }
250 for ( int r = 0; r < rows; ++r ) { 303 for ( int r = 0; r < rows; ++r ) {
251 abi = static_cast<AbTableItem*>( item(r, 0) ); 304 abi = static_cast<AbTableItem*>( item(r, 0) );
252 value = findContactContact( contactList[abi], r ); 305 value = findContactContact( contactList[abi], r );
253 static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); 306 static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() );
254 } 307 }
255 resort(); 308 resort();
256} 309}
257 310
258void AbTable::keyPressEvent( QKeyEvent *e ) 311void AbTable::keyPressEvent( QKeyEvent *e )
259{ 312{
260 char key = toupper( e->ascii() ); 313 char key = toupper( e->ascii() );
261 314
262 if ( key >= 'A' && key <= 'Z' ) 315 if ( key >= 'A' && key <= 'Z' )
263 moveTo( key ); 316 moveTo( key );
264 317
265 if ( m_inSearch ) { 318 qWarning("Received key ..");
266 // Running in seach-mode, therefore we will interprete 319 switch( e->key() ) {
267 // some key differently 320 case Qt::Key_Space:
268 qWarning("Received key in search mode"); 321 case Qt::Key_Return:
269 switch( e->key() ) { 322 case Qt::Key_Enter:
270 case Qt::Key_Space: 323 emit signalSwitch();
271 case Qt::Key_Return: 324 break;
272 case Qt::Key_Enter: 325 // case Qt::Key_Up:
273 emit details(); 326 // qWarning("a");
274 break; 327 // emit signalKeyUp();
275 case Qt::Key_Up: 328 // break;
276 qWarning("a"); 329 // case Qt::Key_Down:
277 emit signalSearchBackward(); 330 // qWarning("b");
278 break; 331 // emit signalKeyDown();
279 case Qt::Key_Down: 332 // break;
280 qWarning("b"); 333 default:
281 emit signalSearchNext(); 334 QTable::keyPressEvent( e );
282 break;
283 default:
284 QTable::keyPressEvent( e );
285 }
286
287 } else {
288 qWarning("Received key in NON search mode");
289
290 switch( e->key() ) {
291 case Qt::Key_Space:
292 case Qt::Key_Return:
293 case Qt::Key_Enter:
294 emit details();
295 break;
296 default:
297 QTable::keyPressEvent( e );
298 }
299 } 335 }
336
300} 337}
301 338
302void AbTable::moveTo( char c ) 339void AbTable::moveTo( char c )
303{ 340{
341 qWarning( "void AbTable::moveTo( char c )" );
304 342
305 int rows = numRows(); 343 int rows = numRows();
306 QString value; 344 QString value;
307 AbTableItem *abi; 345 AbTableItem *abi;
308 int r; 346 int r;
309 if ( asc ) { 347 if ( asc ) {
310 r = 0; 348 r = 0;
311 while ( r < rows-1) { 349 while ( r < rows-1) {
312 abi = static_cast<AbTableItem*>( item(r, 0) ); 350 abi = static_cast<AbTableItem*>( item(r, 0) );
313 QChar first = abi->key()[0]; 351 QChar first = abi->key()[0];
314 //### is there a bug in QChar to char comparison??? 352 //### is there a bug in QChar to char comparison???
315 if ( first.row() || first.cell() >= c ) 353 if ( first.row() || first.cell() >= c )
316 break; 354 break;
317 r++; 355 r++;
318 } 356 }
319 } else { 357 } else {
320 //### should probably disable reverse sorting instead 358 //### should probably disable reverse sorting instead
321 r = rows - 1; 359 r = rows - 1;
322 while ( r > 0 ) { 360 while ( r > 0 ) {
323 abi = static_cast<AbTableItem*>( item(r, 0) ); 361 abi = static_cast<AbTableItem*>( item(r, 0) );
324 QChar first = abi->key()[0]; 362 QChar first = abi->key()[0];
325 //### is there a bug in QChar to char comparison??? 363 //### is there a bug in QChar to char comparison???
326 if ( first.row() || first.cell() >= c ) 364 if ( first.row() || first.cell() >= c )
327 break; 365 break;
328 r--; 366 r--;
329 } 367 }
330 } 368 }
331 setCurrentCell( r, currentColumn() ); 369 setCurrentCell( r, currentColumn() );
332} 370}
333 371
334 372
335QString AbTable::findContactName( const OContact &entry ) 373QString AbTable::findContactName( const OContact &entry )
336{ 374{
337 // We use the fileAs, then company, defaultEmail 375 // We use the fileAs, then company, defaultEmail
338 QString str; 376 QString str;
339 str = entry.fileAs(); 377 str = entry.fileAs();
340 if ( str.isEmpty() ) { 378 if ( str.isEmpty() ) {
341 str = entry.company(); 379 str = entry.company();
342 if ( str.isEmpty() ) { 380 if ( str.isEmpty() ) {
343 str = entry.defaultEmail(); 381 str = entry.defaultEmail();
344 } 382 }
345 } 383 }
346 return str; 384 return str;
347} 385}
348 386
349QString AbTable::findContactContact( const OContact &entry, int /* row */ )
350{
351 QString value;
352 value = "";
353 for ( QValueList<int>::ConstIterator it = intFields->begin();
354 it != intFields->end(); ++it ) {
355 switch ( *it ) {
356 default:
357 break;
358 case Qtopia::Title:
359 value = entry.title();
360 break;
361 case Qtopia::Suffix:
362 value = entry.suffix();
363 break;
364 case Qtopia::FileAs:
365 value = entry.fileAs();
366 break;
367 case Qtopia::DefaultEmail:
368 value = entry.defaultEmail();
369 case Qtopia::Emails:
370 value = entry.emails();
371 break;
372 case Qtopia::HomeStreet:
373 value = entry.homeStreet();
374 break;
375 case Qtopia::HomeCity:
376 value = entry.homeCity();
377 break;
378 case Qtopia::HomeState:
379 value = entry.homeState();
380 break;
381 case Qtopia::HomeZip:
382 value = entry.homeZip();
383 break;
384 case Qtopia::HomeCountry:
385 value = entry.homeCountry();
386 break;
387 case Qtopia::HomePhone:
388 value = entry.homePhone();
389 break;
390 case Qtopia::HomeFax:
391 value = entry.homeFax();
392 break;
393 case Qtopia::HomeMobile:
394 value = entry.homeMobile();
395 break;
396 case Qtopia::HomeWebPage:
397 value = entry.homeWebpage();
398 break;
399 case Qtopia::Company:
400 value = entry.company();
401 break;
402 case Qtopia::BusinessCity:
403 value = entry.businessCity();
404 break;
405 case Qtopia::BusinessStreet:
406 value = entry.businessStreet();
407 break;
408 case Qtopia::BusinessZip:
409 value = entry.businessZip();
410 break;
411 case Qtopia::BusinessCountry:
412 value = entry.businessCountry();
413 break;
414 case Qtopia::BusinessWebPage:
415 value = entry.businessWebpage();
416 break;
417 case Qtopia::JobTitle:
418 value = entry.jobTitle();
419 break;
420 case Qtopia::Department:
421 value = entry.department();
422 break;
423 case Qtopia::Office:
424 value = entry.office();
425 break;
426 case Qtopia::BusinessPhone:
427 value = entry.businessPhone();
428 break;
429 case Qtopia::BusinessFax:
430 value = entry.businessFax();
431 break;
432 case Qtopia::BusinessMobile:
433 value = entry.businessMobile();
434 break;
435 case Qtopia::BusinessPager:
436 value = entry.businessPager();
437 break;
438 case Qtopia::Profession:
439 value = entry.profession();
440 break;
441 case Qtopia::Assistant:
442 value = entry.assistant();
443 break;
444 case Qtopia::Manager:
445 value = entry.manager();
446 break;
447 case Qtopia::Spouse:
448 value = entry.spouse();
449 break;
450 case Qtopia::Gender:
451 value = entry.gender();
452 break;
453 case Qtopia::Birthday:
454 value = TimeString::numberDateString( entry.birthday() );
455 break;
456 case Qtopia::Anniversary:
457 value = TimeString::numberDateString( entry.anniversary() );
458 break;
459 case Qtopia::Nickname:
460 value = entry.nickname();
461 break;
462 case Qtopia::Children:
463 value = entry.children();
464 break;
465 case Qtopia::Notes:
466 value = entry.notes();
467 break;
468 }
469 if ( !value.isEmpty() )
470 break;
471 }
472 return value;
473}
474 387
475void AbTable::addEntry( const OContact &newCnt )
476{
477 int row = numRows();
478
479 setNumRows( row + 1 );
480 insertIntoTable( newCnt, row );
481
482 qWarning("abtable:AddContact");
483 m_contactdb.add ( newCnt );
484
485 setCurrentCell( row, 0 );
486 // updateVisible();
487}
488 388
489void AbTable::resizeRows() { 389void AbTable::resizeRows() {
490 /* 390 /*
491 if (numRows()) { 391 if (numRows()) {
492 for (int i = 0; i < numRows(); i++) { 392 for (int i = 0; i < numRows(); i++) {
493 setRowHeight( i, size ); 393 setRowHeight( i, size );
494 } 394 }
495 } 395 }
496 updateVisible(); 396 updateVisible();
497 */ 397 */
498} 398}
499 399
500 400
501bool AbTable::save() 401void AbTable::realignTable()
502{
503 // QTime t;
504 // t.start();
505 qWarning("abtable:Save data");
506
507 return m_contactdb.save();
508}
509
510void AbTable::load()
511{ 402{
512 setSorting( false ); 403 qWarning( "void AbTable::realignTable()" );
513 setUpdatesEnabled( FALSE );
514
515 qWarning("abtable:Load data");
516
517 OContactAccess::List list = m_contactdb.allRecords();
518 OContactAccess::List::Iterator it;
519 setNumRows( list.count() );
520 int row = 0;
521 for ( it = list.begin(); it != list.end(); ++it )
522 insertIntoTable( *it, row++ );
523
524 setUpdatesEnabled( TRUE );
525 404
526 setSorting( true ); 405 setPaintingEnabled( FALSE );
527 resort();
528}
529 406
407 resizeRows();
408 fitColumns();
530 409
531void AbTable::reload() 410 setPaintingEnabled( TRUE );
532{
533 m_contactdb.reload();
534 load();
535}
536 411
537void AbTable::realignTable( int row )
538{
539 QTableItem *ti1,
540 *ti2;
541 int totalRows = numRows();
542 for ( int curr = row; curr < totalRows - 1; curr++ ) {
543 // the same info from the todo list still applies, but I
544 // don't think it is _too_ bad.
545 ti1 = item( curr + 1, 0 );
546 ti2 = item( curr + 1, 1 );
547 takeItem( ti1 );
548 takeItem( ti2 );
549 setItem( curr, 0, ti1 );
550 setItem( curr, 1, ti2 );
551 }
552 setNumRows( totalRows - 1 );
553 resort();
554} 412}
555 413
556// Add contact into table.
557void AbTable::insertIntoTable( const OContact &cnt, int row )
558{
559 QString strName,
560 strContact;
561
562 strName = findContactName( cnt );
563 strContact = findContactContact( cnt, row );
564
565 AbTableItem *ati;
566 ati = new AbTableItem( this, QTableItem::Never, strName, strContact);
567 contactList.insert( ati, cnt );
568 setItem( row, 0, ati );
569 ati = new AbTableItem( this, QTableItem::Never, strContact, strName);
570 setItem( row, 1, ati );
571
572 //### cannot do this; table only has two columns at this point
573 // setItem( row, 2, new AbPickItem( this ) );
574
575 // resort at some point?
576}
577 414
578 415
579// Replace or add an entry
580void AbTable::journalFreeReplace( const OContact &cnt, int row )
581{
582 QString strName,
583 strContact;
584 AbTableItem *ati = 0l;
585
586 strName = findContactName( cnt );
587 strContact = findContactContact( cnt, row );
588 ati = static_cast<AbTableItem*>(item(row, 0));
589
590 // Replace element if found in row "row"
591 // or add this element if not.
592 if ( ati != 0 ) { // replace
593 // :SX db access -> replace
594 qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() );
595 m_contactdb.replace ( cnt );
596
597 contactList.remove( ati );
598 ati->setItem( strName, strContact );
599 contactList.insert( ati, cnt );
600
601 ati = static_cast<AbTableItem*>(item(row, 1));
602 ati->setItem( strContact, strName );
603
604 }else{ // add
605 int myrows = numRows();
606 setNumRows( myrows + 1 );
607 insertIntoTable( cnt, myrows );
608 // gets deleted when returning -- Why ? (se)
609 // :SX db access -> add
610 qWarning ("Are you sure to add to database ? -> Currently disabled !!");
611 // m_contactdb.add( cnt );
612 }
613}
614
615// Remove entry
616void AbTable::journalFreeRemove( int row )
617{
618 AbTableItem *ati;
619 ati = static_cast<AbTableItem*>(item(row, 0));
620 if ( !ati )
621 return;
622
623 // :SX db access -> remove
624 qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() );
625 m_contactdb.remove( contactList[ati].uid() );
626
627 contactList.remove( ati );
628
629 realignTable( row );
630
631}
632 416
633#if QT_VERSION <= 230 417#if QT_VERSION <= 230
634#ifndef SINGLE_APP 418#ifndef SINGLE_APP
635void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) 419void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
636{ 420{
637 // Region of the rect we should draw 421 // Region of the rect we should draw
638 QRegion reg( QRect( cx, cy, cw, ch ) ); 422 QRegion reg( QRect( cx, cy, cw, ch ) );
639 // Subtract the table from it 423 // Subtract the table from it
640 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); 424 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
641 // And draw the rectangles (transformed as needed) 425 // And draw the rectangles (transformed as needed)
642 QArray<QRect> r = reg.rects(); 426 QArray<QRect> r = reg.rects();
643 for (unsigned int i=0; i<r.count(); i++) 427 for (unsigned int i=0; i<r.count(); i++)
644 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); 428 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
645} 429}
646#endif 430#endif
647#endif 431#endif
648 432
649 433
650// int AbTable::rowHeight( int ) const 434// int AbTable::rowHeight( int ) const
651// { 435// {
652// return 18; 436// return 18;
653// } 437// }
654 438
655// int AbTable::rowPos( int row ) const 439// int AbTable::rowPos( int row ) const
656// { 440// {
657// return 18*row; 441// return 18*row;
658// } 442// }
659 443
660// int AbTable::rowAt( int pos ) const 444// int AbTable::rowAt( int pos ) const
661// { 445// {
662// return QMIN( pos/18, numRows()-1 ); 446// return QMIN( pos/18, numRows()-1 );
663// } 447// }
664 448
665void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool useRegExp,
666 bool backwards, QString cat /* int category */ )
667{
668 int category = 0;
669
670 // Use the current Category if nothing else selected
671 if ( cat.isEmpty() )
672 category = mCat.id( "Contacts", showCat );
673 else{
674 category = mCat.id("Contacts", cat );
675 }
676
677 qWarning ("Found in Category %d", category);
678
679 if ( currFindRow < -1 )
680 currFindRow = - 1;
681 449
682 clearSelection( TRUE );
683 int rows, row;
684 AbTableItem *ati;
685 QRegExp r( findString );
686 r.setCaseSensitive( caseSensitive );
687 r.setWildcard( !useRegExp );
688 rows = numRows();
689 static bool wrapAround = true;
690 bool try_again = false;
691
692 // We will loop until we found an entry or found nothing.
693 do {
694 if ( !backwards ) {
695 for ( row = currFindRow + 1; row < rows; row++ ) {
696 ati = static_cast<AbTableItem*>( item(row, 0) );
697 if ( contactCompare( contactList[ati], r, category ) ){
698 try_again = false;
699 break;
700 }
701 }
702 } else {
703 for ( row = currFindRow - 1; row > -1; row-- ) {
704 ati = static_cast<AbTableItem*>( item(row, 0) );
705 if ( contactCompare( contactList[ati], r, category ) ){
706 try_again = false;
707 break;
708 }
709 }
710 }
711 if ( row >= rows || row < 0 ) {
712 if ( row < 0 )
713 currFindRow = rows;
714 else
715 currFindRow = -1;
716
717 if ( wrapAround ){
718 emit signalWrapAround();
719 try_again = true;
720 }else{
721 emit signalNotFound();
722 try_again = false;
723 }
724
725 wrapAround = !wrapAround;
726 } else {
727 currFindRow = row;
728 QTableSelection foundSelection;
729 foundSelection.init( currFindRow, 0 );
730 foundSelection.expandTo( currFindRow, numCols() - 1 );
731 addSelection( foundSelection );
732 setCurrentCell( currFindRow, 0 /* numCols() - 1 */ );
733 wrapAround = true;
734 try_again = false;
735 }
736 } while ( try_again );
737}
738 450
739static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) 451void AbTable::fitColumns()
740{ 452{
741 bool returnMe; 453 qWarning( "void AbTable::fitColumns()" );
742 QArray<int> cats; 454 int contentsWidth = visibleWidth() / 2; // :SX Why too low
743 cats = cnt.categories(); 455 // Fix to better value
456 // contentsWidth = 130;
744 457
745 returnMe = false; 458 if ( columnVisible == false ){
746 if ( (cats.count() == 0) || (category == 0) ) 459 showColumn(0);
747 returnMe = cnt.match( r ); 460 columnVisible = true;
748 else {
749 int i;
750 for ( i = 0; i < int(cats.count()); i++ ) {
751 if ( cats[i] == category ) {
752 returnMe = cnt.match( r );
753 break;
754 }
755 }
756 } 461 }
757 462
758 return returnMe; 463 qWarning("Width: %d", contentsWidth);
759}
760 464
761void AbTable::fitColumns() 465 setColumnWidth( 0, contentsWidth );
762{ 466 adjustColumn(1);
763 int contentsWidth = visibleWidth() / 2; 467 if ( columnWidth(1) < contentsWidth )
764 468 setColumnWidth( 1, contentsWidth );
765 if ( showBk == "Cards" ) {
766 showColumn(1);
767 //adjustColumn(1);
768 setColumnWidth( 1, visibleWidth() );
769 columnVisible = false;
770 } else {
771 if ( columnVisible == false ){
772 showColumn(0);
773 columnVisible = true;
774 }
775 setColumnWidth( 0, contentsWidth );
776 adjustColumn(1);
777 if ( columnWidth(1) < contentsWidth )
778 setColumnWidth( 1, contentsWidth );
779 }
780} 469}
781 470
782void AbTable::show() 471void AbTable::show()
783{ 472{
784 fitColumns(); 473 qWarning( "void AbTable::show()" );
474 realignTable();
785 QTable::show(); 475 QTable::show();
786} 476}
787 477
788void AbTable::setChoiceNames( const QStringList& list) 478void AbTable::setChoiceNames( const QStringList& list)
789{ 479{
790 choicenames = list; 480 choicenames = list;
791 if ( choicenames.isEmpty() ) { 481 if ( choicenames.isEmpty() ) {
792 // hide pick column 482 // hide pick column
793 setNumCols( 2 ); 483 setNumCols( 2 );
794 } else { 484 } else {
795 // show pick column 485 // show pick column
796 setNumCols( 3 ); 486 setNumCols( 3 );
797 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); 487 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
798 horizontalHeader()->setLabel( 2, tr( "Pick" )); 488 horizontalHeader()->setLabel( 2, tr( "Pick" ));
799 } 489 }
800 fitColumns(); 490 fitColumns();
801} 491}
802 492
803void AbTable::itemClicked(int,int col) 493void AbTable::itemClicked(int,int col)
804{ 494{
495 qWarning( "AbTable::itemClicked(int, col:%d)", col);
805 if ( col == 2 ) { 496 if ( col == 2 ) {
806 return; 497 return;
807 } else { 498 } else {
808 emit details(); 499 qWarning ("Emitting signalSwitch()");
500 emit signalSwitch();
809 } 501 }
810} 502}
811 503
812QStringList AbTable::choiceNames() const 504QStringList AbTable::choiceNames() const
813{ 505{
814 return choicenames; 506 return choicenames;
815} 507}
816 508
817void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) 509void AbTable::setChoiceSelection( const QValueList<int>& list )
818{ 510{
819 /* ###### 511 intFields = list;
820
821 QString selname = choicenames.at(index);
822 for (each row) {
823 OContact *c = contactForRow(row);
824 if ( list.contains(c->email) ) {
825 list.remove(c->email);
826 setText(row, 2, selname);
827 }
828 }
829 for (remaining list items) {
830 OContact *c = new contact(item);
831 setText(newrow, 2, selname);
832 }
833
834 */
835} 512}
836 513
837QStringList AbTable::choiceSelection(int /*index*/) const 514QStringList AbTable::choiceSelection(int /*index*/) const
838{ 515{
839 QStringList r; 516 QStringList r;
840 /* ###### 517 /* ######
841 518
842 QString selname = choicenames.at(index); 519 QString selname = choicenames.at(index);
843 for (each row) { 520 for (each row) {
844 OContact *c = contactForRow(row); 521 OContact *c = contactForRow(row);
845 if ( text(row,2) == selname ) { 522 if ( text(row,2) == selname ) {
846 r.append(c->email); 523 r.append(c->email);
847 } 524 }
848 } 525 }
849 526
850 */ 527 */
851 return r; 528 return r;
852} 529}
853 530
854void AbTable::setShowCategory( const QString &b, const QString &c )
855{
856 showBk = b;
857 showCat = c;
858 //QMessageBox::information( this, "setShowCategory", "setShowCategory" );
859 //updateVisible();
860 refresh();
861 ensureCellVisible( currentRow(), 0 );
862 updateVisible(); // :SX
863}
864 531
865void AbTable::setShowByLetter( char c )
866{
867 showChar = tolower(c);
868 updateVisible();
869}
870 532
871QString AbTable::showCategory() const
872{
873 return showCat;
874}
875
876QString AbTable::showBook() const
877{
878 return showBk;
879}
880
881QStringList AbTable::categories()
882{
883 mCat.load( categoryFileName() );
884 QStringList categoryList = mCat.labels( "Contacts" );
885 return categoryList;
886}
887 533
888void AbTable::updateVisible() 534void AbTable::updateVisible()
889{ 535{
890 int visible, 536 int visible,
891 totalRows, 537 totalRows,
892 id, 538 row,
893 totalCats, 539 selectedRow = 0;
894 it, 540
895 row;
896 bool hide;
897 AbTableItem *ati;
898 OContact *cnt;
899 QString fileAsName;
900 QString tmpStr;
901 visible = 0; 541 visible = 0;
902 542
543 realignTable();
544
903 setPaintingEnabled( FALSE ); 545 setPaintingEnabled( FALSE );
904 546
905 totalRows = numRows(); 547 totalRows = numRows();
906 id = mCat.id( "Contacts", showCat );
907 QArray<int> cats;
908 for ( row = 0; row < totalRows; row++ ) { 548 for ( row = 0; row < totalRows; row++ ) {
909 ati = static_cast<AbTableItem*>( item(row, 0) ); 549 if ( rowHeight(row) == 0 ) {
910 cnt = &contactList[ati]; 550 showRow( row );
911 cats = cnt->categories(); 551 adjustRow( row );
912 fileAsName = cnt->fileAs(); 552 if ( isSelected( row,0 ) || isSelected( row,1 ) )
913 hide = false; 553 selectedRow = row;
914 if ( !showCat.isEmpty() ) {
915 if ( showCat == tr( "Unfiled" ) ) {
916 if ( cats.count() > 0 )
917 hide = true;
918 } else {
919 // do some comparing
920 if ( !hide ) {
921 hide = true;
922 totalCats = int(cats.count());
923 for ( it = 0; it < totalCats; it++ ) {
924 if ( cats[it] == id ) {
925 hide = false;
926 break;
927 }
928 }
929 }
930 }
931 }
932 if ( showChar != '\0' ) {
933 tmpStr = fileAsName.left(1);
934 tmpStr = tmpStr.lower();
935 if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) {
936 hide = true;
937 }
938 if ( showChar == '#' ) {
939 if (tmpStr == "a")
940 hide = true;
941
942 if (tmpStr == "b")
943 hide = true;
944
945 if (tmpStr == "c")
946 hide = true;
947
948 if (tmpStr == "d")
949 hide = true;
950
951 if (tmpStr == "e")
952 hide = true;
953
954 if (tmpStr == "f")
955 hide = true;
956
957 if (tmpStr == "g")
958 hide = true;
959
960 if (tmpStr == "h")
961 hide = true;
962
963 if (tmpStr == "i")
964 hide = true;
965
966 if (tmpStr == "j")
967 hide = true;
968
969 if (tmpStr == "k")
970 hide = true;
971
972 if (tmpStr == "l")
973 hide = true;
974
975 if (tmpStr == "m")
976 hide = true;
977
978 if (tmpStr == "n")
979 hide = true;
980
981 if (tmpStr == "o")
982 hide = true;
983
984 if (tmpStr == "p")
985 hide = true;
986
987 if (tmpStr == "q")
988 hide = true;
989
990 if (tmpStr == "r")
991 hide = true;
992
993 if (tmpStr == "s")
994 hide = true;
995
996 if (tmpStr == "t")
997 hide = true;
998
999 if (tmpStr == "u")
1000 hide = true;
1001
1002 if (tmpStr == "v")
1003 hide = true;
1004
1005 if (tmpStr == "w")
1006 hide = true;
1007
1008 if (tmpStr == "x")
1009 hide = true;
1010
1011 if (tmpStr == "y")
1012 hide = true;
1013
1014 if (tmpStr == "z")
1015 hide = true;
1016 }
1017
1018 }
1019 if ( hide ) {
1020 if ( currentRow() == row )
1021 setCurrentCell( -1, 0 );
1022 if ( rowHeight(row) > 0 )
1023 hideRow( row );
1024 } else {
1025 if ( rowHeight(row) == 0 ) {
1026 showRow( row );
1027 adjustRow( row );
1028 }
1029 visible++;
1030 } 554 }
555 visible++;
1031 } 556 }
557
558 if ( selectedRow )
559 setCurrentCell( selectedRow, 0 );
560
1032 if ( !visible ) 561 if ( !visible )
1033 setCurrentCell( -1, 0 ); 562 setCurrentCell( -1, 0 );
1034 563
1035 setPaintingEnabled( TRUE ); 564 setPaintingEnabled( TRUE );
565
566
1036} 567}
1037 568
1038 569
1039void AbTable::setPaintingEnabled( bool e ) 570void AbTable::setPaintingEnabled( bool e )
1040{ 571{
1041 if ( e != enablePainting ) { 572 if ( e != enablePainting ) {
1042 if ( !enablePainting ) { 573 if ( !enablePainting ) {
1043 enablePainting = true; 574 enablePainting = true;
1044 rowHeightChanged( 0 ); 575 rowHeightChanged( 0 );
1045 viewport()->update(); 576 viewport()->update();
1046 } else { 577 } else {
1047 enablePainting = false; 578 enablePainting = false;
1048 } 579 }
1049 } 580 }
1050} 581}
1051 582
1052void AbTable::rowHeightChanged( int row ) 583void AbTable::rowHeightChanged( int row )
1053{ 584{
1054 if ( enablePainting ) 585 if ( enablePainting )
1055 QTable::rowHeightChanged( row ); 586 QTable::rowHeightChanged( row );
1056} 587}
588QString AbTable::findContactContact( const OContact &entry, int /* row */ )
589{
590 QString value;
591 value = "";
592 for ( QValueList<int>::ConstIterator it = intFields.begin();
593 it != intFields.end(); ++it ) {
594 switch ( *it ) {
595 default:
596 break;
597 case Qtopia::Title:
598 value = entry.title();
599 break;
600 case Qtopia::Suffix:
601 value = entry.suffix();
602 break;
603 case Qtopia::FileAs:
604 value = entry.fileAs();
605 break;
606 case Qtopia::DefaultEmail:
607 value = entry.defaultEmail();
608 case Qtopia::Emails:
609 value = entry.emails();
610 break;
611 case Qtopia::HomeStreet:
612 value = entry.homeStreet();
613 break;
614 case Qtopia::HomeCity:
615 value = entry.homeCity();
616 break;
617 case Qtopia::HomeState:
618 value = entry.homeState();
619 break;
620 case Qtopia::HomeZip:
621 value = entry.homeZip();
622 break;
623 case Qtopia::HomeCountry:
624 value = entry.homeCountry();
625 break;
626 case Qtopia::HomePhone:
627 value = entry.homePhone();
628 break;
629 case Qtopia::HomeFax:
630 value = entry.homeFax();
631 break;
632 case Qtopia::HomeMobile:
633 value = entry.homeMobile();
634 break;
635 case Qtopia::HomeWebPage:
636 value = entry.homeWebpage();
637 break;
638 case Qtopia::Company:
639 value = entry.company();
640 break;
641 case Qtopia::BusinessCity:
642 value = entry.businessCity();
643 break;
644 case Qtopia::BusinessStreet:
645 value = entry.businessStreet();
646 break;
647 case Qtopia::BusinessZip:
648 value = entry.businessZip();
649 break;
650 case Qtopia::BusinessCountry:
651 value = entry.businessCountry();
652 break;
653 case Qtopia::BusinessWebPage:
654 value = entry.businessWebpage();
655 break;
656 case Qtopia::JobTitle:
657 value = entry.jobTitle();
658 break;
659 case Qtopia::Department:
660 value = entry.department();
661 break;
662 case Qtopia::Office:
663 value = entry.office();
664 break;
665 case Qtopia::BusinessPhone:
666 value = entry.businessPhone();
667 break;
668 case Qtopia::BusinessFax:
669 value = entry.businessFax();
670 break;
671 case Qtopia::BusinessMobile:
672 value = entry.businessMobile();
673 break;
674 case Qtopia::BusinessPager:
675 value = entry.businessPager();
676 break;
677 case Qtopia::Profession:
678 value = entry.profession();
679 break;
680 case Qtopia::Assistant:
681 value = entry.assistant();
682 break;
683 case Qtopia::Manager:
684 value = entry.manager();
685 break;
686 case Qtopia::Spouse:
687 value = entry.spouse();
688 break;
689 case Qtopia::Gender:
690 value = entry.gender();
691 break;
692 case Qtopia::Birthday:
693 value = TimeString::numberDateString( entry.birthday() );
694 break;
695 case Qtopia::Anniversary:
696 value = TimeString::numberDateString( entry.anniversary() );
697 break;
698 case Qtopia::Nickname:
699 value = entry.nickname();
700 break;
701 case Qtopia::Children:
702 value = entry.children();
703 break;
704 case Qtopia::Notes:
705 value = entry.notes();
706 break;
707 }
708 if ( !value.isEmpty() )
709 break;
710 }
711 return value;
712}
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 35a1e9e..83bd5a7 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -1,161 +1,136 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
3** 4**
4** This file is part of Qt Palmtop Environment. 5** This file is part of Qt Palmtop Environment.
5** 6**
6** 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
7** 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
8** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 10** packaging of this file.
10** 11**
11** 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
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 14**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 16**
16** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 18** not clear to you.
18** 19**
19**********************************************************************/ 20**********************************************************************/
20 21
21#ifndef ABTABLE_H 22#ifndef ABTABLE_H
22#define ABTABLE_H 23#define ABTABLE_H
23 24
24#include <qpe/categories.h> 25#include <qpe/categories.h>
25#include <opie/ocontact.h> 26#include <opie/ocontact.h>
27#include <opie/ocontactaccess.h>
26 28
27#include <qmap.h> 29#include <qmap.h>
28#include <qtable.h> 30#include <qtable.h>
29#include <qstringlist.h> 31#include <qstringlist.h>
30#include <qcombobox.h> 32#include <qcombobox.h>
31 33
32#include <opie/ocontactaccess.h>
33
34class AbTableItem : public QTableItem 34class AbTableItem : public QTableItem
35{ 35{
36public: 36public:
37 AbTableItem( QTable *t, EditType et, const QString &s, 37 AbTableItem( QTable *t, EditType et, const QString &s,
38 const QString &secondSortKey); 38 const QString &secondSortKey);
39 QString entryKey() const; 39 QString entryKey() const;
40 void setEntryKey( const QString & k ); 40 void setEntryKey( const QString & k );
41 virtual int alignment() const; 41 virtual int alignment() const;
42 virtual QString key() const; 42 virtual QString key() const;
43 void setItem( const QString &txt, const QString &secondKey ); 43 void setItem( const QString &txt, const QString &secondKey );
44 44
45private: 45private:
46 QString sortKey; 46 QString sortKey;
47}; 47};
48 48
49class AbPickItem : public QTableItem 49class AbPickItem : public QTableItem
50{ 50{
51public: 51public:
52 AbPickItem( QTable *t ); 52 AbPickItem( QTable *t );
53 53
54 QWidget *createEditor() const; 54 QWidget *createEditor() const;
55 void setContentFromEditor( QWidget *w ); 55 void setContentFromEditor( QWidget *w );
56 56
57private: 57private:
58 QGuardedPtr<QComboBox> cb; 58 QGuardedPtr<QComboBox> cb;
59}; 59};
60 60
61class AbTable : public QTable 61class AbTable : public QTable
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 64
65public: 65public:
66 AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); 66 AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 );
67 ~AbTable(); 67 ~AbTable();
68 // NEW 68
69 void addEntry( const OContact &newContact ); 69 // Set the contacts shown in the table
70 void setContacts( const OContactAccess::List& viewList );
71 // Selects a contact of a specific UID
72 bool selectContact( int UID );
73
74 // Get the current selected entry
70 OContact currentEntry(); 75 OContact currentEntry();
71 void replaceCurrentEntry( const OContact &newContact );
72 76
73 void init(); 77 // Get the UID of the current selected Entry
78 int currentEntry_UID();
79
80 QString findContactName( const OContact &entry );
74 81
75 void deleteCurrentEntry(); 82 void init();
76 void clear(); 83 void clear();
77 void clearFindRow() { currFindRow = -1; }
78 void loadFields();
79 void refresh(); 84 void refresh();
80 bool save();
81 void load();
82 void reload();
83
84 // addresspicker mode
85 void setChoiceNames( const QStringList& list);
86 QStringList choiceNames() const;
87 void setChoiceSelection(int index, const QStringList& list);
88 QStringList choiceSelection(int index) const;
89 void setShowCategory( const QString &b, const QString &c );
90 void setShowByLetter( char c );
91 QString showCategory() const;
92 QStringList categories();
93
94 void resizeRows();
95 85
96 void show(); 86 void show();
97 void setPaintingEnabled( bool e ); 87 void setPaintingEnabled( bool e );
98 88
99 QString showBook() const; 89 // addresspicker mode (What's that ? se)
100 90 void setChoiceNames( const QStringList& list);
101 void inSearch() { m_inSearch = true; } 91 QStringList choiceNames() const;
102 void offSearch() { m_inSearch = false; } 92 void setChoiceSelection( const QValueList<int>& list );
93 QStringList choiceSelection(int index) const;
103 94
104public slots:
105 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, bool backwards,
106 QString category = QString::null );
107signals: 95signals:
108 void empty( bool ); 96 void signalSwitch();
109 void details(); 97 void signalEditor();
110 void signalNotFound(); 98 void signalKeyDown();
111 void signalWrapAround(); 99 void signalKeyUp();
112 void signalSearchBackward(); // Signalled if backward search is requested
113 void signalSearchNext(); // Singalled if forward search is requested
114 100
115protected: 101protected:
116 virtual void keyPressEvent( QKeyEvent *e ); 102 virtual void keyPressEvent( QKeyEvent *e );
117 103
118// int rowHeight( int ) const; 104// int rowHeight( int ) const;
119// int rowPos( int row ) const; 105// int rowPos( int row ) const;
120// virtual int rowAt( int pos ) const; 106// virtual int rowAt( int pos ) const;
121 107
122 108
123protected slots: 109protected slots:
124 void moveTo( char ); 110 void moveTo( char );
125 virtual void columnClicked( int col ); 111 virtual void columnClicked( int col );
126 void itemClicked(int,int col); 112 void itemClicked(int,int col);
127 void rowHeightChanged( int row ); 113 void rowHeightChanged( int row );
128 114
129private: 115private:
130 void loadFile( const QString &strFile, bool journalFile ); 116 void insertIntoTable( const OContact &cnt, int row );
117 QString findContactContact( const OContact &entry, int row );
131 void fitColumns(); 118 void fitColumns();
119 void resizeRows();
120 void realignTable();
132 void resort(); 121 void resort();
133 void updateJournal( const OContact &contact, OContact::journal_action action,
134 int row = -1 );
135 void insertIntoTable( const OContact &contact, int row );
136 QString findContactName( const OContact &entry );
137 QString findContactContact( const OContact &entry, int row );
138 void journalFreeReplace( const OContact &cnt, int row );
139 void journalFreeRemove( int row );
140 void realignTable( int );
141 void updateVisible(); 122 void updateVisible();
123
142 int lastSortCol; 124 int lastSortCol;
143 bool asc; 125 bool asc;
144 char showChar;
145 QMap<AbTableItem*, OContact> contactList; 126 QMap<AbTableItem*, OContact> contactList;
146 const QValueList<int> *intFields; 127 QValueList<int> intFields;
147 int currFindRow;
148 QString showCat;
149 QStringList choicenames; 128 QStringList choicenames;
150 bool enablePainting; 129 bool enablePainting;
151 Categories mCat;
152 130
153 QString showBk;
154 bool columnVisible; 131 bool columnVisible;
155 132
156 bool m_inSearch; 133 OContactAccess::List m_viewList;
157
158 OContactAccess m_contactdb;
159 134
160}; 135};
161#endif // ABTABLE_H 136#endif // ABTABLE_H
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index d35e392..8d22129 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,331 +1,445 @@
1#include "abview.h" 1#include "abview.h"
2 2
3#include <qlayout.h>
4
5#include <qpe/global.h>
6
7#include <opie/ocontactaccessbackend_vcard.h>
8
9
3// Is defined in LibQPE 10// Is defined in LibQPE
4extern QString categoryFileName(); 11extern QString categoryFileName();
5 12
6#include <qlayout.h> 13QString addressbookPersonalVCardName()
14{
15 QString filename = Global::applicationFileName("addressbook",
16 "businesscard.vcf");
17 return filename;
18}
7 19
8AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringList& slOrderedFields ): 20
21AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ):
9 QWidget(parent), 22 QWidget(parent),
10 mCat(0), 23 mCat(0),
11 m_inSearch( false ), 24 m_inSearch( false ),
12 m_curr_category( 0 ), 25 m_inPersonal( false ),
26 m_curr_category( -1 ),
13 m_curr_View( TableView ), 27 m_curr_View( TableView ),
14 m_prev_View( TableView ), 28 m_prev_View( TableView ),
15 m_curr_Contact ( 0 ), 29 m_curr_Contact ( 0 ),
16 m_contactdb ( "addressbook", 0l, 0l, false ), // Handle syncing myself.. ! 30 m_contactdb ( 0l ),
31 m_storedDB ( 0l ),
17 m_viewStack( 0l ), 32 m_viewStack( 0l ),
18 m_abTable( 0l ), 33 m_abTable( 0l ),
19 m_orderedFields( ordered ), 34 m_orderedFields( ordered )
20 m_slOrderedFields( slOrderedFields )
21{ 35{
36 // Load default database and handle syncing myself.. !
37 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ),
22 mCat.load( categoryFileName() ); 38 mCat.load( categoryFileName() );
23 39
24 // Create Layout and put WidgetStack into it. 40 // Create Layout and put WidgetStack into it.
25 QVBoxLayout *vb = new QVBoxLayout( this ); 41 QVBoxLayout *vb = new QVBoxLayout( this );
26 m_viewStack = new QWidgetStack( this ); 42 m_viewStack = new QWidgetStack( this );
27 vb->addWidget( m_viewStack ); 43 vb->addWidget( m_viewStack );
28 44
29 // Creat TableView 45 // Creat TableView
30 QVBox* tableBox = new QVBox( m_viewStack ); 46 QVBox* tableBox = new QVBox( m_viewStack );
31 m_abTable = new AbTable( &m_orderedFields, tableBox, "table" ); 47 m_abTable = new AbTable( m_orderedFields, tableBox, "table" );
32 m_abTable->setCurrentCell( 0, 0 ); 48 m_abTable->setCurrentCell( 0, 0 );
33 m_abTable->setFocus(); 49 m_abTable->setFocus();
34 50
35 // Add TableView to WidgetStack and raise it 51 // Add TableView to WidgetStack and raise it
36 m_viewStack -> addWidget( tableBox , TableView ); 52 m_viewStack -> addWidget( tableBox , TableView );
37 53
38 // Create CardView and add it to WidgetStack 54 // Create CardView and add it to WidgetStack
39 QVBox* cardBox = new QVBox( m_viewStack ); 55 QVBox* cardBox = new QVBox( m_viewStack );
40 m_ablabel = new AbLabel( cardBox, "CardView"); 56 m_ablabel = new AbLabel( cardBox, "CardView");
41 m_viewStack -> addWidget( cardBox , CardView ); 57 m_viewStack -> addWidget( cardBox , CardView );
42 58
43 // Connect views to me 59 // Connect views to me
44 connect ( m_abTable, SIGNAL( signalSwitch( void ) ), 60 connect ( m_abTable, SIGNAL( signalSwitch( void ) ),
45 this, SLOT( slotSwitch( void ) ) ); 61 this, SLOT( slotSwitch( void ) ) );
46 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), 62 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ),
47 this, SLOT( slotSwitch( void ) ) ); 63 this, SLOT( slotSwitch( void ) ) );
48 64
49 load(); 65 load();
50} 66}
51 67
68AbView::~AbView()
69{
70 m_contactdb -> save();
71 delete m_contactdb;
72
73 if ( m_storedDB ){
74 m_storedDB -> save();
75 delete m_storedDB;
76 }
77}
78
79
52void AbView::setView( Views view ) 80void AbView::setView( Views view )
53{ 81{
54 qWarning("AbView::setView( Views view )"); 82 qWarning("AbView::setView( Views view )");
55 m_curr_View = view; 83 m_curr_View = view;
56 load(); 84 load();
57} 85}
58 86
59void AbView::addEntry( const OContact &newContact ) 87void AbView::addEntry( const OContact &newContact )
60{ 88{
61 qWarning("abview:AddContact"); 89 qWarning("abview:AddContact");
62 m_contactdb.add ( newContact ); 90 m_contactdb->add ( newContact );
63 load(); 91 load();
64 92
65} 93}
66void AbView::removeEntry( const int UID ) 94void AbView::removeEntry( const int UID )
67{ 95{
68 qWarning("abview:RemoveContact"); 96 qWarning("abview:RemoveContact");
69 m_contactdb.remove( UID ); 97 m_contactdb->remove( UID );
70 load(); 98 load();
71} 99}
72 100
73void AbView::replaceEntry( const OContact &contact ) 101void AbView::replaceEntry( const OContact &contact )
74{ 102{
75 qWarning("abview:ReplaceContact"); 103 qWarning("abview:ReplaceContact");
76 m_contactdb.replace( contact ); 104 m_contactdb->replace( contact );
77 load(); 105 load();
78 106
79} 107}
80 108
81OContact AbView::currentEntry() 109OContact AbView::currentEntry()
82{ 110{
83 switch ( (int) m_curr_View ) { 111 switch ( (int) m_curr_View ) {
84 case TableView: 112 case TableView:
85 return ( m_abTable -> currentEntry() ); 113 return ( m_abTable -> currentEntry() );
86 break; 114 break;
87 case CardView: 115 case CardView:
88 return ( m_ablabel -> currentEntry() ); 116 return ( m_ablabel -> currentEntry() );
89 break; 117 break;
90 } 118 }
91 return OContact(); 119 return OContact();
92} 120}
93 121
94bool AbView::save() 122bool AbView::save()
95{ 123{
96 qWarning("abView:Save data"); 124 qWarning("abView:Save data");
97 125
98 return m_contactdb.save(); 126 return m_contactdb->save();
99} 127}
100 128
101// :SX Add: Just load for specific Category
102void AbView::load() 129void AbView::load()
103{ 130{
104 qWarning("abView:Load data"); 131 qWarning("abView:Load data");
105 132
106 m_list = m_contactdb.allRecords(); 133 if ( m_inPersonal )
134 m_list = m_contactdb->allRecords();
135 else
136 m_list = m_contactdb->sorted( true, 0, 0, 0 );
137
107 clearForCategory(); 138 clearForCategory();
108 m_curr_Contact = 0; 139
140 // Feed all views with new lists
141 updateListinViews();
109 142
110 qWarning ("Number of contacts: %d", m_list.count()); 143 qWarning ("Number of contacts: %d", m_list.count());
111 144
112 updateView(); 145 updateView();
113 146
114} 147}
115 148
116void AbView::reload() 149void AbView::reload()
117{ 150{
118 m_contactdb.reload(); 151 qWarning( "void AbView::reload()" );
152
153 m_contactdb->reload();
119 load(); 154 load();
120} 155}
121 156
122void AbView::clear() 157void AbView::clear()
123{ 158{
124 // :SX 159 // :SX
125} 160}
126 161
127void AbView::setShowByCategory( Views view, const QString& cat ) 162void AbView::setShowByCategory( Views view, const QString& cat )
128{ 163{
129 qWarning("AbView::setShowCategory( Views view, const QString& cat )"); 164 qWarning("AbView::setShowCategory( Views view, const QString& cat )");
130 m_curr_View = view;
131 165
132 emit signalClearLetterPicker(); 166 // if ( view == PersonalView ){
167 // if ( ! m_inPersonal )
168 // showPersonal( true );
169
170 // }else{
171 // if ( m_inPersonal )
172 // showPersonal( false );
133 173
134 if ( !cat.isNull() ) 174 // m_curr_View = view;
135 m_curr_category = mCat.id("Contacts", cat ); 175 // }
176
177 int intCat = 0;
178
179 // All (cat == NULL) will be stored as -1
180 if ( cat.isNull() )
181 intCat = -1;
136 else 182 else
137 m_curr_category = -1; // Set to all 183 intCat = mCat.id("Contacts", cat );
138 184
139 qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); 185 // If we just change the view, we don't have to reload any data..
186 // This speeds up a lot of things !
187 if ( intCat == m_curr_category ){
188 qWarning ("Just change the View (Category is: %d)", m_curr_category);
189 m_prev_View = m_curr_View;
190 m_curr_View = view;
140 191
141 load(); 192 updateView();
193 }else{
194 qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category);
195
196 m_curr_View = view;
197 m_curr_category = intCat;
198 emit signalClearLetterPicker();
199
200 load();
201 }
142 202
143} 203}
144void AbView::setShowByLetter( char c ) 204void AbView::setShowByLetter( char c )
145{ 205{
146 qWarning("void AbView::setShowByLetter( %c )", c ); 206 qWarning("void AbView::setShowByLetter( %c )", c );
147 OContact query; 207 OContact query;
148 if ( c == 0 ){ 208 if ( c == 0 ){
149 load(); 209 load();
150 return; 210 return;
151 }else{ 211 }else{
152 query.setLastName( QString("%1*").arg(c) ); 212 query.setLastName( QString("%1*").arg(c) );
153 m_list = m_contactdb.queryByExample( query, OContactAccess::WildCards ); 213 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards );
154 clearForCategory(); 214 clearForCategory();
155 m_curr_Contact = 0; 215 m_curr_Contact = 0;
156 } 216 }
157 updateView(); 217 updateView();
158} 218}
159 219
220void AbView::setListOrder( const QValueList<int>& ordered )
221{
222 m_orderedFields = ordered;
223 updateView();
224}
225
226
160QString AbView::showCategory() const 227QString AbView::showCategory() const
161{ 228{
162 return mCat.label( "Contacts", m_curr_category ); 229 return mCat.label( "Contacts", m_curr_category );
163} 230}
164 231
165void AbView::showContact( const OContact& cnt ) 232void AbView::showPersonal( bool personal )
166{ 233{
167 qWarning ("void AbView::showContact( const OContact& cnt )"); 234 qWarning ("void AbView::showPersonal( %d )", personal);
168 // :SX 235
236 if ( personal ){
237
238 if ( m_inPersonal )
239 return;
240
241 // Now switch to vCard Backend and load data.
242 // The current default backend will be stored
243 // to avoid unneeded load/stores.
244 m_storedDB = m_contactdb;
245
246 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
247 addressbookPersonalVCardName() );
248 m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
249
250 m_inPersonal = true;
251 m_curr_View = CardView;
252
253 }else{
254
255 if ( !m_inPersonal )
256 return;
257
258 // Remove vCard Backend and restore default
259 m_contactdb->save();
260 delete m_contactdb;
261
262 m_contactdb = m_storedDB;
263 m_storedDB = 0l;
264
265 m_curr_View = TableView;
266 m_inPersonal = false;
267
268 }
269 load();
169} 270}
170 271
171QStringList AbView::categories() 272QStringList AbView::categories()
172{ 273{
173 mCat.load( categoryFileName() ); 274 mCat.load( categoryFileName() );
174 QStringList categoryList = mCat.labels( "Contacts" ); 275 QStringList categoryList = mCat.labels( "Contacts" );
175 return categoryList; 276 return categoryList;
176} 277}
177 278
178// BEGIN: Slots 279// BEGIN: Slots
179void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 280void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
180 bool , QString cat = QString::null ) 281 bool , QString cat = QString::null )
181{ 282{
182 qWarning( "void AbView::slotDoFind" ); 283 qWarning( "void AbView::slotDoFind" );
183 // Use the current Category if nothing else selected
184 284
285 // We reloading the data: Deselect Letterpicker
286 emit signalClearLetterPicker();
287
288 // Use the current Category if nothing else selected
185 int category = 0; 289 int category = 0;
186 290
187 if ( cat.isEmpty() ) 291 if ( cat.isEmpty() )
188 category = m_curr_category; 292 category = m_curr_category;
189 else{ 293 else{
190 category = mCat.id("Contacts", cat ); 294 category = mCat.id("Contacts", cat );
191 } 295 }
192 296
193 qWarning ("Find in Category %d", category); 297 qWarning ("Find in Category %d", category);
194 298
195 QRegExp r( str ); 299 QRegExp r( str );
196 r.setCaseSensitive( caseSensitive ); 300 r.setCaseSensitive( caseSensitive );
197 r.setWildcard( !useRegExp ); 301 r.setWildcard( !useRegExp );
198 302
199 // Get all matching entries out of the database 303 // Get all matching entries out of the database
200 m_list = m_contactdb.matchRegexp( r ); 304 m_list = m_contactdb->matchRegexp( r );
201 305
202 qWarning( "found: %d", m_list.count() ); 306 qWarning( "found: %d", m_list.count() );
203 if ( m_list.count() == 0 ){ 307 if ( m_list.count() == 0 ){
204 emit signalNotFound(); 308 emit signalNotFound();
205 return; 309 return;
206 } 310 }
207 311
208 // Now remove all contacts with wrong category (if any selected) 312 // Now remove all contacts with wrong category (if any selected)
209 // This algorithm is a litte bit ineffective, but 313 // This algorithm is a litte bit ineffective, but
210 // we will not have a lot of matching entries.. 314 // we will not have a lot of matching entries..
211 clearForCategory(); 315 clearForCategory();
212 316
213 // Now show all found entries 317 // Now show all found entries
214 updateView(); 318 updateView();
215} 319}
216 320
217void AbView::offSearch() 321void AbView::offSearch()
218{ 322{
219 m_inSearch = false; 323 m_inSearch = false;
220 324
221 load(); 325 load();
222} 326}
223 327
224void AbView::slotSwitch(){ 328void AbView::slotSwitch(){
225 qWarning("AbView::slotSwitch()"); 329 qWarning("AbView::slotSwitch()");
226 330
227 m_prev_View = m_curr_View; 331 m_prev_View = m_curr_View;
228 switch ( (int) m_curr_View ){ 332 switch ( (int) m_curr_View ){
229 case TableView: 333 case TableView:
230 qWarning("Switching to CardView"); 334 qWarning("Switching to CardView");
231 m_curr_View = CardView; 335 m_curr_View = CardView;
232 break; 336 break;
233 case CardView: 337 case CardView:
234 qWarning("Switching to TableView"); 338 qWarning("Switching to TableView");
235 m_curr_View = TableView; 339 m_curr_View = TableView;
236 break; 340 break;
237 } 341 }
238 updateView(); 342 updateView();
239 343
240} 344}
241 345
242// END: Slots 346// END: Slots
243 347
244void AbView::clearForCategory() 348void AbView::clearForCategory()
245{ 349{
246 OContactAccess::List::Iterator it; 350 OContactAccess::List::Iterator it;
247 // Now remove all contacts with wrong category if any category selected 351 // Now remove all contacts with wrong category if any category selected
248 // This algorithm is a litte bit ineffective 352
353 OContactAccess::List allList = m_list;
249 if ( m_curr_category != -1 ){ 354 if ( m_curr_category != -1 ){
250 for ( it = m_list.begin(); it != m_list.end(); ++it ){ 355 for ( it = allList.begin(); it != allList.end(); ++it ){
251 if ( !contactCompare( *it, m_curr_category ) ){ 356 if ( !contactCompare( *it, m_curr_category ) ){
252 qWarning("Removing %d", (*it).uid()); 357 qWarning("Removing %d", (*it).uid());
253 m_list.remove( (*it).uid() ); 358 m_list.remove( (*it).uid() );
254 it = m_list.begin();
255 } 359 }
256 } 360 }
257 } 361 }
362
258} 363}
259 364
260bool AbView::contactCompare( const OContact &cnt, int category ) 365bool AbView::contactCompare( const OContact &cnt, int category )
261{ 366{
262 qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); 367 qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category);
263 368
264 bool returnMe; 369 bool returnMe;
265 QArray<int> cats; 370 QArray<int> cats;
266 cats = cnt.categories(); 371 cats = cnt.categories();
267 372
268 qWarning ("Number of categories: %d", cats.count() ); 373 qWarning ("Number of categories: %d", cats.count() );
269 374
270 returnMe = false; 375 returnMe = false;
271 if ( cats.count() == 0 ) 376 if ( cats.count() == 0 && category == 0 )
377 // Contacts with no category will just shown on "All" and "Unfiled"
272 returnMe = true; 378 returnMe = true;
273 else { 379 else {
274 int i; 380 int i;
275 for ( i = 0; i < int(cats.count()); i++ ) { 381 for ( i = 0; i < int(cats.count()); i++ ) {
276 qWarning("Comparing %d with %d",cats[i],category ); 382 qWarning("Comparing %d with %d",cats[i],category );
277 if ( cats[i] == category ) { 383 if ( cats[i] == category ) {
278 returnMe = true; 384 returnMe = true;
279 break; 385 break;
280 } 386 }
281 } 387 }
282 } 388 }
283 qWarning ("Return: %d", returnMe); 389 qWarning ("Return: %d", returnMe);
284 return returnMe; 390 return returnMe;
285} 391}
286 392
393// In Some rare cases we have to update all lists..
394void AbView::updateListinViews()
395{
396 m_abTable -> setContacts( m_list );
397 m_ablabel -> setContacts( m_list );
398}
399
287void AbView::updateView() 400void AbView::updateView()
288{ 401{
289 qWarning("AbView::updateView()"); 402 qWarning("AbView::updateView()");
290 403
291 if ( m_viewStack -> visibleWidget() ){ 404 if ( m_viewStack -> visibleWidget() ){
292 m_viewStack -> visibleWidget() -> clearFocus(); 405 m_viewStack -> visibleWidget() -> clearFocus();
293 } 406 }
294 407
295 // If we switching the view, we have to store some information 408 // If we switching the view, we have to store some information
296 if ( m_prev_View != m_curr_View ){ 409 if ( m_list.count() ){
297 switch ( (int) m_prev_View ) { 410 switch ( (int) m_prev_View ) {
298 case TableView: 411 case TableView:
299 m_curr_Contact = m_abTable -> currentEntry_UID(); 412 m_curr_Contact = m_abTable -> currentEntry_UID();
300 break; 413 break;
301 case CardView: 414 case CardView:
302 m_curr_Contact = m_ablabel -> currentEntry_UID(); 415 m_curr_Contact = m_ablabel -> currentEntry_UID();
303 break; 416 break;
304 } 417 }
305 } 418 emit signalViewSwitched ( (int) m_curr_View );
419 }else
420 m_curr_Contact = 0;
306 421
307 m_prev_View = m_curr_View; 422 m_prev_View = m_curr_View;
308 423
309 // Switch to new View 424 // Switch to new View
310 switch ( (int) m_curr_View ) { 425 switch ( (int) m_curr_View ) {
311 case TableView: 426 case TableView:
427 m_abTable -> setChoiceSelection( m_orderedFields );
312 m_abTable -> setContacts( m_list ); 428 m_abTable -> setContacts( m_list );
313 if ( m_curr_Contact != 0 ) 429 if ( m_curr_Contact != 0 )
314 m_abTable -> selectContact ( m_curr_Contact ); 430 m_abTable -> selectContact ( m_curr_Contact );
315 m_abTable -> setFocus(); 431 m_abTable -> setFocus();
316 emit signalViewSwitched ( (int) m_curr_View );
317 break; 432 break;
318 case CardView: 433 case CardView:
319 m_ablabel -> setContacts( m_list ); 434 m_ablabel -> setContacts( m_list );
320 if ( m_curr_Contact != 0 ) 435 if ( m_curr_Contact != 0 )
321 m_ablabel -> selectContact( m_curr_Contact ); 436 m_ablabel -> selectContact( m_curr_Contact );
322 m_ablabel -> setFocus(); 437 m_ablabel -> setFocus();
323 emit signalViewSwitched ( (int) m_curr_View );
324 break; 438 break;
325 } 439 }
326 440
327 // Raise the current View 441 // Raise the current View
328 m_viewStack -> raiseWidget( m_curr_View ); 442 m_viewStack -> raiseWidget( m_curr_View );
329} 443}
330 444
331 445
diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h
index 4d35338..201b521 100644
--- a/core/pim/addressbook/abview.h
+++ b/core/pim/addressbook/abview.h
@@ -1,81 +1,86 @@
1#ifndef _ABVIEW_H_ 1#ifndef _ABVIEW_H_
2#define _ABVIEW_H_ 2#define _ABVIEW_H_
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qwidgetstack.h> 5#include <qwidgetstack.h>
6 6
7#include <qpe/categories.h> 7#include <qpe/categories.h>
8#include <opie/ocontact.h> 8#include <opie/ocontact.h>
9#include <opie/ocontactaccess.h> 9#include <opie/ocontactaccess.h>
10 10
11#include "contacteditor.h" 11#include "contacteditor.h"
12#include "abtable.h" 12#include "abtable.h"
13#include "ablabel.h" 13#include "ablabel.h"
14 14
15class AbView: public QWidget 15class AbView: public QWidget
16{ 16{
17 Q_OBJECT 17 Q_OBJECT
18 18
19public: 19public:
20 enum Views{ TableView=0, CardView, PhoneBook, CompanyBook, EmailBook }; 20 enum Views{ TableView=0, CardView, PersonalView };
21 21
22 AbView( QWidget* parent, const QValueList<int>& ordered, const QStringList& slOrderedFields ); 22 AbView( QWidget* parent, const QValueList<int>& ordered );
23 ~AbView();
23 24
24 bool save(); 25 bool save();
25 void load(); 26 void load();
26 void reload(); 27 void reload();
27 void clear(); 28 void clear();
28 29
29 void setView( Views view ); 30 void setView( Views view );
30 void showContact( const OContact& cnt ); 31 void showPersonal( bool personal );
31 void setShowByCategory( Views view, const QString& cat ); 32 void setShowByCategory( Views view, const QString& cat );
32 void setShowByLetter( char c ); 33 void setShowByLetter( char c );
34 void setListOrder( const QValueList<int>& ordered );
35
33 // Add Entry and put to current 36 // Add Entry and put to current
34 void addEntry( const OContact &newContact ); 37 void addEntry( const OContact &newContact );
35 void removeEntry( const int UID ); 38 void removeEntry( const int UID );
36 void replaceEntry( const OContact &contact ); 39 void replaceEntry( const OContact &contact );
37 OContact currentEntry(); 40 OContact currentEntry();
38 41
39 void inSearch() { m_inSearch = true; } 42 void inSearch() { m_inSearch = true; }
40 void offSearch(); 43 void offSearch();
41 44
42 QString showCategory() const; 45 QString showCategory() const;
43 QStringList categories(); 46 QStringList categories();
44 47
45signals: 48signals:
46 void signalNotFound(); 49 void signalNotFound();
47 void signalClearLetterPicker(); 50 void signalClearLetterPicker();
48 void signalViewSwitched ( int ); 51 void signalViewSwitched ( int );
49 52
50public slots: 53public slots:
51 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 54 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
52 bool backwards, QString category = QString::null ); 55 bool backwards, QString category = QString::null );
53 void slotSwitch(); 56 void slotSwitch();
54 57
55private: 58private:
59 void updateListinViews();
56 void updateView(); 60 void updateView();
57 void clearForCategory(); 61 void clearForCategory();
58 bool contactCompare( const OContact &cnt, int category ); 62 bool contactCompare( const OContact &cnt, int category );
59 void parseName( const QString& name, QString *first, QString *middle, 63 void parseName( const QString& name, QString *first, QString *middle,
60 QString * last ); 64 QString * last );
61 65
62 Categories mCat; 66 Categories mCat;
63 bool m_inSearch; 67 bool m_inSearch;
68 bool m_inPersonal;
64 int m_curr_category; 69 int m_curr_category;
65 Views m_curr_View; 70 Views m_curr_View;
66 Views m_prev_View; 71 Views m_prev_View;
67 int m_curr_Contact; 72 int m_curr_Contact;
68 73
69 OContactAccess m_contactdb; 74 OContactAccess* m_contactdb;
75 OContactAccess* m_storedDB;
70 OContactAccess::List m_list; 76 OContactAccess::List m_list;
71 77
72 QWidgetStack* m_viewStack; 78 QWidgetStack* m_viewStack;
73 AbTable* m_abTable; 79 AbTable* m_abTable;
74 AbLabel* m_ablabel; 80 AbLabel* m_ablabel;
75 81
76 QValueList<int> m_orderedFields; 82 QValueList<int> m_orderedFields;
77 QStringList m_slOrderedFields;
78}; 83};
79 84
80 85
81#endif 86#endif
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 108e66d..e5addec 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,1134 +1,963 @@
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** OContact info@trolltech.com if any conditions of this licensing are 16** OContact 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 20
21#define QTOPIA_INTERNAL_FD 21#define QTOPIA_INTERNAL_FD
22 22
23#include "contacteditor.h" 23#include "contacteditor.h"
24#include "ablabel.h" 24#include "ablabel.h"
25#include "abview.h"
25#include "abtable.h" 26#include "abtable.h"
26#include "addresssettings.h" 27// #include "addresssettings.h"
27#include "addressbook.h" 28#include "addressbook.h"
28 29
29 30
30#include <opie/ofileselector.h> 31#include <opie/ofileselector.h>
31#include <opie/ofiledialog.h> 32#include <opie/ofiledialog.h>
32#include <qpe/qpeapplication.h>
33#include <qpe/config.h>
34#include <opie/ocontact.h> 33#include <opie/ocontact.h>
34#include <opie/ocontactaccessbackend_vcard.h>
35 35
36#include <qpe/global.h>
37#include <qpe/resource.h> 36#include <qpe/resource.h>
38#include <qpe/ir.h> 37#include <qpe/ir.h>
39#include <qpe/qpemessagebox.h> 38#include <qpe/qpemessagebox.h>
40#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/qpetoolbar.h>
41#include <qpe/qpemenubar.h>
42// #include <qtoolbar.h>
43// #include <qmenubar.h>
44#include <qpe/qpeapplication.h>
45#include <qpe/config.h>
41 46
42#include <qaction.h> 47#include <qaction.h>
43#include <qdialog.h> 48#include <qdialog.h>
44#include <qdir.h> 49#include <qdir.h>
45#include <qfile.h> 50#include <qfile.h>
46#include <qimage.h> 51#include <qimage.h>
47#include <qlayout.h> 52#include <qlayout.h>
48#include <qpe/qpemenubar.h>
49#include <qmessagebox.h> 53#include <qmessagebox.h>
50#include <qpixmap.h> 54#include <qpixmap.h>
51#include <qpopupmenu.h> 55#include <qpopupmenu.h>
52#include <qpe/qpetoolbar.h>
53#include <qstringlist.h> 56#include <qstringlist.h>
54#include <qtoolbutton.h> 57#include <qtoolbutton.h>
55#include <qwhatsthis.h> 58#include <qwhatsthis.h>
59#include <qdatetime.h>
56 60
57#include <stdlib.h> 61#include <stdlib.h>
58#include <sys/stat.h> 62#include <sys/stat.h>
59#include <sys/types.h> 63#include <sys/types.h>
60#include <fcntl.h> 64#include <fcntl.h>
61#include <unistd.h> 65#include <unistd.h>
62 66
63#include <qdatetime.h>
64 67
65#include "picker.h" 68#include "picker.h"
66#include "configdlg.h" 69#include "configdlg.h"
67 70
68static QString addressbookPersonalVCardName() 71extern QString addressbookPersonalVCardName();
69{
70 QString filename = Global::applicationFileName("addressbook",
71 "businesscard.vcf");
72 return filename;
73}
74
75 72
76AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 73AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
77 WFlags f ) 74 WFlags f )
78 : QMainWindow( parent, name, f ), 75 : QMainWindow( parent, name, f ),
79 abEditor(0), 76 catMenu (0l),
80 useRegExp(false), 77 abEditor(0l),
81 doNotifyWrapAround(true), 78 syncing(FALSE),
82 caseSensitive(false), 79 m_tableViewButton(0l),
83 m_useQtMail(true), 80 m_cardViewButton(0l)
84 m_useOpieMail(false),
85 bAbEditFirstTime(TRUE),
86 syncing(FALSE)
87{ 81{
88 isLoading = true; 82 isLoading = true;
89 83
90 // Read Config settings 84 m_config.load();
91 Config cfg("AddressBook");
92 cfg.setGroup("Search");
93 useRegExp = cfg.readBoolEntry( "useRegExp" );
94 caseSensitive = cfg.readBoolEntry( "caseSensitive" );
95 doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" );
96 cfg.setGroup("Mail");
97 m_useQtMail = cfg.readBoolEntry( "useQtMail", true );
98 m_useOpieMail=cfg.readBoolEntry( "useOpieMail" );
99
100 85
101 initFields();
102
103 setCaption( tr("Contacts") ); 86 setCaption( tr("Contacts") );
104 setIcon( Resource::loadPixmap( "AddressBook" ) ); 87 setIcon( Resource::loadPixmap( "AddressBook" ) );
88
89 // Settings for Main Menu
90 setToolBarsMovable( true );
91 setRightJustification( true );
105 92
106 setToolBarsMovable( FALSE ); 93 // Create Toolbar
107 94 listTools = new QPEToolBar( this, "list operations" );
108 // Create Toolbars 95 listTools->setHorizontalStretchable( true );
109 96 addToolBar( listTools );
110 QPEToolBar *bar = new QPEToolBar( this ); 97 moveToolBar( listTools, m_config.getToolBarPos() );
111 bar->setHorizontalStretchable( TRUE );
112 98
113 QPEMenuBar *mbList = new QPEMenuBar( bar ); 99 QPEMenuBar *mbList = new QPEMenuBar( this );
114 mbList->setMargin( 0 ); 100 mbList->setMargin( 0 );
115 101
116 QPopupMenu *edit = new QPopupMenu( this ); 102 QPopupMenu *edit = new QPopupMenu( mbList );
117 mbList->insertItem( tr( "Contact" ), edit ); 103 mbList->insertItem( tr( "Contact" ), edit );
118 104
119 listTools = new QPEToolBar( this, "list operations" );
120
121 105
106 // View Icons
107 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "datebook/weeklst" ),
108 QString::null, 0, this, 0 );
109 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
110 m_tableViewButton->setToggleAction( true );
111 m_tableViewButton->addTo( listTools );
112 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 );
113 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
114 m_cardViewButton->setToggleAction( true );
115 m_cardViewButton->addTo( listTools );
116
117 listTools->addSeparator();
118
119 // Other Buttons
122 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
123 0, this, 0 ); 121 0, this, 0 );
124 actionNew = a; 122 actionNew = a;
125 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 123 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
126 a->addTo( edit ); 124 a->addTo( edit );
127 a->addTo( listTools ); 125 a->addTo( listTools );
128 126
129 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 127 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
130 0, this, 0 ); 128 0, this, 0 );
131 actionEdit = a; 129 actionEdit = a;
132 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 130 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
133 a->addTo( edit ); 131 a->addTo( edit );
134 a->addTo( listTools ); 132 a->addTo( listTools );
135 133
136 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 134 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
137 0, this, 0 ); 135 0, this, 0 );
138 actionTrash = a; 136 actionTrash = a;
139 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 137 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
140 a->addTo( edit ); 138 a->addTo( edit );
141 a->addTo( listTools ); 139 a->addTo( listTools );
142 140
143 141
144 // make it possible to go directly to businesscard via qcop call 142 // make it possible to go directly to businesscard via qcop call
145#if defined(Q_WS_QWS) 143#if defined(Q_WS_QWS)
146#if !defined(QT_NO_COP) 144#if !defined(QT_NO_COP)
147 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); 145 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
148 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 146 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
149 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 147 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
150#endif 148#endif
151#endif 149#endif
152 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 150 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
153 QString::null, 0, this, 0 ); 151 QString::null, 0, this, 0 );
154 actionFind = a; 152 actionFind = a;
155 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); 153 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
156 a->addTo( edit ); 154 a->addTo( edit );
157 a->addTo( listTools ); 155 a->addTo( listTools );
158 156
159 // Much better search widget, taken from QTReader.. (se) 157 // Much better search widget, taken from QTReader.. (se)
160 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); 158 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
161 searchBar->setHorizontalStretchable( TRUE ); 159 searchBar->setHorizontalStretchable( TRUE );
162 searchBar->hide(); 160 searchBar->hide();
163 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 161 searchEdit = new QLineEdit( searchBar, "searchEdit" );
164// QFont f("unifont", 16 /*, QFont::Bold*/); 162
165// searchEdit->setFont( f ); 163 // QFont f("unifont", 16 /*, QFont::Bold*/);
164 // searchEdit->setFont( f );
165
166 searchBar->setStretchableWidget( searchEdit ); 166 searchBar->setStretchableWidget( searchEdit );
167 connect( searchEdit, SIGNAL( returnPressed( ) ), 167 connect( searchEdit, SIGNAL( returnPressed( ) ),
168 this, SLOT( slotFind( ) ) ); 168 this, SLOT( slotFind( ) ) );
169 169
170 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 170 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
171 connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); 171 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
172 a->addTo( searchBar ); 172 a->addTo( searchBar );
173 173
174 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 174 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
175 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); 175 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
176 a->addTo( searchBar ); 176 a->addTo( searchBar );
177 177
178 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "mail/sendmail" ), 178 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "mail/sendmail" ),
179 QString::null, 0, this, 0 ); 179 QString::null, 0, this, 0 );
180 //a->setEnabled( FALSE ); we got support for it now :) zecke 180 //a->setEnabled( FALSE ); we got support for it now :) zecke
181 actionMail = a; 181 actionMail = a;
182 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 182 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
183 a->addTo( edit ); 183 a->addTo( edit );
184 a->addTo( listTools ); 184 a->addTo( listTools );
185 185
186
187
188 if ( Ir::supported() ) { 186 if ( Ir::supported() ) {
189 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 187 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
190 0, this, 0 ); 188 0, this, 0 );
191 actionBeam = a; 189 actionBeam = a;
192 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 190 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
193 a->addTo( edit ); 191 a->addTo( edit );
194 a->addTo( listTools ); 192 a->addTo( listTools );
195 } 193 }
196 194
197 edit->insertSeparator(); 195 edit->insertSeparator();
198 196
199 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); 197 a = new QAction( tr("Import vCard"), QString::null, 0, 0);
200 actionPersonal = a; 198 actionPersonal = a;
201 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 199 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
202 a->addTo( edit ); 200 a->addTo( edit );
203 201
204 edit->insertSeparator(); 202 edit->insertSeparator();
205 203
206 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 204 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
207 actionPersonal = a; 205 actionPersonal = a;
208 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 206 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
209 a->addTo( edit ); 207 a->addTo( edit );
210 208
211 // Do we need this function ? (se)
212 // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
213 // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
214 // a->addTo( edit );
215
216 209
217#ifdef __DEBUG_RELEASE 210#ifdef __DEBUG_RELEASE
218 // Remove this function for public Release ! This is only 211 // Remove this function for public Release ! This is only
219 // for debug purposes .. 212 // for debug purposes ..
220 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 213 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
221 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 214 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
222 a->addTo( edit ); 215 a->addTo( edit );
223#endif 216#endif
224 a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 217 a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null,
225 0, this, 0 ); 218 0, this, 0 );
226 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 219 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
227 a->addTo( edit ); 220 a->addTo( edit );
228 221
229 // Create Views 222 // Create Views
230 listContainer = new QWidget( this ); 223 listContainer = new QWidget( this );
231
232 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 224 QVBoxLayout *vb = new QVBoxLayout( listContainer );
233 225
234 abList = new AbTable( &orderedFields, listContainer, "table" ); 226 m_abView = new AbView( listContainer, m_config.orderList() );
235 vb->addWidget(abList); 227 vb->addWidget( m_abView );
236 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 228 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
237 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); 229 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
238 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); 230 this, SLOT( slotViewSwitched( int ) ) );
239 connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) ); 231
240 connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) );
241 connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) );
242
243 // Maybe we should react on Wraparound and notfound ?
244 QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
245 QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) );
246 232
247 mView = 0; 233 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
248 234
249 abList->load(); 235 m_abView->load();
250 236
237 // Letter Picker
251 pLabel = new LetterPicker( listContainer ); 238 pLabel = new LetterPicker( listContainer );
252 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 239 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
253 vb->addWidget(pLabel); 240 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
241
242 vb->addWidget( pLabel );
243
244 // Category Menu
254 catMenu = new QPopupMenu( this ); 245 catMenu = new QPopupMenu( this );
255 catMenu->setCheckable( TRUE ); 246 catMenu->setCheckable( TRUE );
256 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 247 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
257 populateCategories(); 248 populateCategories();
258
259 mbList->insertItem( tr("View"), catMenu ); 249 mbList->insertItem( tr("View"), catMenu );
260 // setCentralWidget( listContainer );
261 250
262 fontMenu = new QPopupMenu(this); 251 defaultFont = new QFont( m_abView->font() );
263 fontMenu->setCheckable( true ); 252 slotSetFont(m_config.fontSize());
264 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); 253 m_curFontSize = m_config.fontSize();
265 254
266 fontMenu->insertItem(tr( "Small" ), 0);
267 fontMenu->insertItem(tr( "Normal" ), 1);
268 fontMenu->insertItem(tr( "Large" ), 2);
269
270 defaultFont = new QFont( abList->font() );
271
272 slotSetFont(startFontSize);
273
274 mbList->insertItem( tr("Font"), fontMenu);
275 setCentralWidget(listContainer); 255 setCentralWidget(listContainer);
276 256
277 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 257 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
278 258
279 abList->setCurrentCell( 0, 0 );
280 259
281 isLoading = false; 260 isLoading = false;
282} 261}
283 262
284 263
285void AddressbookWindow::slotConfig() 264void AddressbookWindow::slotConfig()
286{ 265{
287 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 266 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
288 dlg -> setUseRegExp ( useRegExp ); 267 dlg -> setConfig( m_config );
289 dlg -> setBeCaseSensitive( caseSensitive );
290 dlg -> setSignalWrapAround( doNotifyWrapAround );
291 dlg -> setQtMail ( m_useQtMail );
292 dlg -> setOpieMail ( m_useOpieMail );
293 dlg -> showMaximized(); 268 dlg -> showMaximized();
294 if ( dlg -> exec() ) { 269 if ( dlg -> exec() ) {
295 qWarning ("Config Dialog accepted !"); 270 qWarning ("Config Dialog accepted !");
296 useRegExp = dlg -> useRegExp(); 271 m_config = dlg -> getConfig();
297 caseSensitive = dlg -> beCaseSensitive(); 272 if ( m_curFontSize != m_config.fontSize() ){
298 doNotifyWrapAround = dlg -> signalWrapAround(); 273 qWarning("Font was changed!");
299 m_useQtMail = dlg -> useQtMail(); 274 m_curFontSize = m_config.fontSize();
300 m_useOpieMail= dlg -> useOpieMail(); 275 emit slotSetFont( m_curFontSize );
276 }
277 m_abView -> setListOrder( m_config.orderList() );
301 } 278 }
302 279
303 delete dlg; 280 delete dlg;
304} 281}
305 282
306 283
307void AddressbookWindow::slotSetFont( int size ) { 284void AddressbookWindow::slotSetFont( int size )
285{
286 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
308 287
309 if (size > 2 || size < 0) 288 if (size > 2 || size < 0)
310 size = 1; 289 size = 1;
311 290
312 startFontSize = size; 291 m_config.setFontSize( size );
313 292
314 QFont *currentFont; 293 QFont *currentFont;
315 294
316 switch (size) { 295 switch (size) {
317 case 0: 296 case 0:
318 fontMenu->setItemChecked(0, true); 297 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
319 fontMenu->setItemChecked(1, false); 298 currentFont = new QFont (m_abView->font());
320 fontMenu->setItemChecked(2, false); 299 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
321 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 300 // abList->resizeRows();
322 currentFont = new QFont (abList->font());
323 // abList->resizeRows(currentFont->pixelSize() + 7);
324 abList->resizeRows();
325 break; 301 break;
326 case 1: 302 case 1:
327 fontMenu->setItemChecked(0, false); 303 m_abView->setFont( *defaultFont );
328 fontMenu->setItemChecked(1, true); 304 currentFont = new QFont (m_abView->font());
329 fontMenu->setItemChecked(2, false); 305 // // abList->resizeRows(currentFont->pixelSize() + 7);
330 abList->setFont( *defaultFont ); 306 // abList->resizeRows();
331 currentFont = new QFont (abList->font());
332 // abList->resizeRows(currentFont->pixelSize() + 7);
333 abList->resizeRows();
334 break; 307 break;
335 case 2: 308 case 2:
336 fontMenu->setItemChecked(0, false); 309 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
337 fontMenu->setItemChecked(1, false); 310 currentFont = new QFont (m_abView->font());
338 fontMenu->setItemChecked(2, true); 311 // //abList->resizeRows(currentFont->pixelSize() + 7);
339 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 312 // abList->resizeRows();
340 currentFont = new QFont (abList->font());
341 //abList->resizeRows(currentFont->pixelSize() + 7);
342 abList->resizeRows();
343 break; 313 break;
344 } 314 }
345} 315}
346 316
347 317
348 318
349void AddressbookWindow::importvCard() { 319void AddressbookWindow::importvCard() {
350 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 320 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
351 if(!str.isEmpty() ) 321 if(!str.isEmpty() ){
352 setDocument((const QString&) str ); 322 setDocument((const QString&) str );
323 }
353 324
354} 325}
355 326
356void AddressbookWindow::setDocument( const QString &filename ) 327void AddressbookWindow::setDocument( const QString &filename )
357{ 328{
358 if ( filename.find(".vcf") != int(filename.length()) - 4 ) 329 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
359 return; 330
360 331 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
361 QValueList<OContact> cl = OContact::readVCard( filename ); 332
362 for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { 333
363 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") 334
364 // .arg( (*it).fullName() ); 335 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
365 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == 336 tr( "The selected File" ) + ( "\n" ) +
366 // QMessageBox::Ok ) { 337 tr ("does not end with \".vcf\" ") + ( "\n" ) +
367 abList->addEntry( *it ); 338 tr ( "Do you really want to open it?" ),
368 // } 339 tr( "&Yes" ), tr( "&No" ), QString::null,
340 0, // Enter == button 0
341 2 ) ) { // Escape == button 2
342 case 0:
343 qWarning("YES clicked");
344 break;
345 case 1:
346 qWarning("NO clicked");
347 return;
348 break;
349 }
350 }
351
352 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
353 filename );
354 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
355 OContactAccess::List allList = access->allRecords();
356
357 OContactAccess::List::Iterator it;
358 for ( it = allList.begin(); it != allList.end(); ++it ){
359 m_abView->addEntry( *it );
369 } 360 }
370 361
362 delete access;
371} 363}
372 364
373void AddressbookWindow::resizeEvent( QResizeEvent *e ) 365void AddressbookWindow::resizeEvent( QResizeEvent *e )
374{ 366{
375 QMainWindow::resizeEvent( e ); 367 QMainWindow::resizeEvent( e );
376 368
377 if ( centralWidget() == listContainer ) 369
378 showList();
379 else if ( centralWidget() == mView )
380 showView();
381} 370}
382 371
383AddressbookWindow::~AddressbookWindow() 372AddressbookWindow::~AddressbookWindow()
384{ 373{
385 Config cfg("AddressBook"); 374 ToolBarDock dock;
386 cfg.setGroup("Font"); 375 int dummy;
387 cfg.writeEntry("fontSize", startFontSize); 376 bool bDummy;
388 377 getLocation ( listTools, dock, dummy, bDummy, dummy );
389 cfg.setGroup("Search"); 378 m_config.setToolBarDock( dock );
390 cfg.writeEntry("useRegExp", useRegExp); 379 m_config.save();
391 cfg.writeEntry("caseSensitive", caseSensitive);
392 cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround);
393 cfg.setGroup("Mail");
394 cfg.writeEntry( "useQtMail", m_useQtMail );
395 cfg.writeEntry( "useOpieMail", m_useOpieMail);
396} 380}
397 381
398void AddressbookWindow::slotUpdateToolbar() 382void AddressbookWindow::slotUpdateToolbar()
399{ 383{
400 OContact ce = abList->currentEntry(); 384 OContact ce = m_abView->currentEntry();
401 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 385 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
402} 386}
403 387
404void AddressbookWindow::showList()
405{
406 bool visiblemView;
407
408 visiblemView = false;
409 if ( mView ) {
410 mView->hide();
411 visiblemView = true;
412 }
413 setCentralWidget( listContainer );
414 listContainer->show();
415 // update our focues... (or use a stack widget!);
416 abList->setFocus();
417
418 // This makes sure we are scrolled all the way to the left
419 abList->setContentsPos( 0, abList->contentsY() );
420
421 //if ( visiblemView && abList->showBook() == "Cards" )
422 //abList->setShowCategory( abList->showBook(), abList->showCategory() );
423
424}
425
426void AddressbookWindow::showView()
427{
428 if ( abList->numRows() > 0 ) {
429 listContainer->hide();
430 setCentralWidget( abView() );
431 mView->show();
432 mView->setFocus();
433 }
434}
435
436void AddressbookWindow::slotListNew() 388void AddressbookWindow::slotListNew()
437{ 389{
438 OContact cnt; 390 OContact cnt;
439 if( !syncing ) { 391 if( !syncing ) {
440 if ( abEditor )
441 abEditor->setEntry( cnt );
442 abView()->init( cnt );
443 editEntry( NewEntry ); 392 editEntry( NewEntry );
444 } else { 393 } else {
445 QMessageBox::warning(this, tr("OContacts"), 394 QMessageBox::warning(this, tr("OContacts"),
446 tr("Can not edit data, currently syncing")); 395 tr("Can not edit data, currently syncing"));
447 } 396 }
448} 397}
449 398
450void AddressbookWindow::slotListView() 399// void AddressbookWindow::slotListView()
451{ 400// {
452 abView()->init( abList->currentEntry() ); 401 // m_abView -> init( abList->currentEntry() );
453 mView->sync(); 402 // // :SX mView->sync();
454 showView(); 403 // //:SXshowView();
455} 404// }
456 405
457void AddressbookWindow::slotListDelete() 406void AddressbookWindow::slotListDelete()
458{ 407{
459 if(!syncing) { 408 if(!syncing) {
460 OContact tmpEntry = abList->currentEntry(); 409 OContact tmpEntry = m_abView ->currentEntry();
461 410
462 // get a name, do the best we can... 411 // get a name, do the best we can...
463 QString strName = tmpEntry.fullName(); 412 QString strName = tmpEntry.fullName();
464 if ( strName.isEmpty() ) { 413 if ( strName.isEmpty() ) {
465 strName = tmpEntry.company(); 414 strName = tmpEntry.company();
466 if ( strName.isEmpty() ) 415 if ( strName.isEmpty() )
467 strName = "No Name"; 416 strName = "No Name";
468 } 417 }
469 418
470 419
471 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 420 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
472 strName ) ) { 421 strName ) ) {
473 abList->deleteCurrentEntry(); 422 m_abView->removeEntry( tmpEntry.uid() );
474 showList();
475 } 423 }
476 } else { 424 } else {
477 QMessageBox::warning( this, tr("Contacts"), 425 QMessageBox::warning( this, tr("Contacts"),
478 tr("Can not edit data, currently syncing") ); 426 tr("Can not edit data, currently syncing") );
479 } 427 }
480} 428}
481 429
430void AddressbookWindow::slotFindOpen()
431{
432 searchBar->show();
433 m_abView -> inSearch();
434 searchEdit->setFocus();
435}
436void AddressbookWindow::slotFindClose()
437{
438 searchBar->hide();
439 m_abView -> offSearch();
440 // m_abView->setFocus();
441}
442
443
444void AddressbookWindow::slotFind()
445{
446 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
447
448 searchEdit->clearFocus();
449 // m_abView->setFocus();
450
451}
452
482void AddressbookWindow::slotViewBack() 453void AddressbookWindow::slotViewBack()
483{ 454{
484 showList(); 455 // :SX showList();
485} 456}
486 457
487void AddressbookWindow::slotViewEdit() 458void AddressbookWindow::slotViewEdit()
488{ 459{
489 if(!syncing) { 460 if(!syncing) {
490 if (actionPersonal->isOn()) { 461 if (actionPersonal->isOn()) {
491 editPersonal(); 462 editPersonal();
492 } else { 463 } else {
493 if ( !bAbEditFirstTime )
494 abEditor->setEntry( abList->currentEntry() );
495 editEntry( EditEntry ); 464 editEntry( EditEntry );
496 } 465 }
497 } else { 466 } else {
498 QMessageBox::warning( this, tr("Contacts"), 467 QMessageBox::warning( this, tr("Contacts"),
499 tr("Can not edit data, currently syncing") ); 468 tr("Can not edit data, currently syncing") );
500 } 469 }
501} 470}
502 471
503 472
504 473
505void AddressbookWindow::writeMail() 474void AddressbookWindow::writeMail()
506{ 475{
507 OContact c = abList->currentEntry(); 476 OContact c = m_abView -> currentEntry();
508 QString name = c.fileAs(); 477 QString name = c.fileAs();
509 QString email = c.defaultEmail(); 478 QString email = c.defaultEmail();
510 479
511 // I prefer the OPIE-Environment variable before the 480 // I prefer the OPIE-Environment variable before the
512 // QPE-one.. 481 // QPE-one..
513 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 482 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
514 if ( basepath.isEmpty() ) 483 if ( basepath.isEmpty() )
515 basepath = QString::fromLatin1( getenv("QPEDIR") ); 484 basepath = QString::fromLatin1( getenv("QPEDIR") );
516 485
517 // Try to access the preferred. If not possible, try to 486 // Try to access the preferred. If not possible, try to
518 // switch to the other one.. 487 // switch to the other one..
519 if ( m_useQtMail ){ 488 if ( m_config.useQtMail() ){
520 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 489 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
521 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 490 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
522 qWarning ("QCop"); 491 qWarning ("QCop");
523 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 492 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
524 e << name << email; 493 e << name << email;
525 return; 494 return;
526 } else 495 } else
527 m_useOpieMail = true; 496 m_config.setUseOpieMail( true );
528 } 497 }
529 if ( m_useOpieMail ){ 498 if ( m_config.useOpieMail() ){
530 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); 499 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
531 if ( QFile::exists( basepath + "/bin/mail" ) ){ 500 if ( QFile::exists( basepath + "/bin/mail" ) ){
532 qWarning ("QCop"); 501 qWarning ("QCop");
533 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); 502 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)");
534 e << name << email; 503 e << name << email;
535 return; 504 return;
536 } else 505 } else
537 m_useQtMail = true; 506 m_config.setUseQtMail( true );
538 } 507 }
539 508
540} 509}
541 510
542static const char * beamfile = "/tmp/obex/contact.vcf"; 511static const char * beamfile = "/tmp/obex/contact.vcf";
543 512
544void AddressbookWindow::slotBeam() 513void AddressbookWindow::slotBeam()
545{ 514{
546 QString filename; 515 QString filename;
547 OContact c; 516 OContact c;
548 if ( actionPersonal->isOn() ) { 517 if ( actionPersonal->isOn() ) {
549 filename = addressbookPersonalVCardName(); 518 filename = addressbookPersonalVCardName();
550 if (!QFile::exists(filename)) 519 if (!QFile::exists(filename))
551 return; // can't beam a non-existent file 520 return; // can't beam a non-existent file
552 c = OContact::readVCard( filename )[0]; 521 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
522 filename );
523 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
524 OContactAccess::List allList = access->allRecords();
525 OContactAccess::List::Iterator it = allList.begin(); // Just take first
526 c = *it;
527
528 delete access;
553 } else { 529 } else {
554 unlink( beamfile ); // delete if exists 530 unlink( beamfile ); // delete if exists
555 c = abList->currentEntry();
556 mkdir("/tmp/obex/", 0755); 531 mkdir("/tmp/obex/", 0755);
557 OContact::writeVCard( beamfile, c ); 532 c = m_abView -> currentEntry();
533 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
534 beamfile );
535 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
536 access->add( c );
537 access->save();
538 delete access;
539
558 filename = beamfile; 540 filename = beamfile;
559 } 541 }
542
543
560 Ir *ir = new Ir( this ); 544 Ir *ir = new Ir( this );
561 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 545 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
562 QString description = c.fullName(); 546 QString description = c.fullName();
563 ir->send( filename, description, "text/x-vCard" ); 547 ir->send( filename, description, "text/x-vCard" );
564} 548}
565 549
566void AddressbookWindow::beamDone( Ir *ir ) 550void AddressbookWindow::beamDone( Ir *ir )
567{ 551{
568 delete ir; 552 delete ir;
569 unlink( beamfile ); 553 unlink( beamfile );
570} 554}
571 555
572 556
573static void parseName( const QString& name, QString *first, QString *middle, 557static void parseName( const QString& name, QString *first, QString *middle,
574 QString * last ) 558 QString * last )
575{ 559{
576 560
577 int comma = name.find ( "," ); 561 int comma = name.find ( "," );
578 QString rest; 562 QString rest;
579 if ( comma > 0 ) { 563 if ( comma > 0 ) {
580 *last = name.left( comma ); 564 *last = name.left( comma );
581 comma++; 565 comma++;
582 while ( comma < int(name.length()) && name[comma] == ' ' ) 566 while ( comma < int(name.length()) && name[comma] == ' ' )
583 comma++; 567 comma++;
584 rest = name.mid( comma ); 568 rest = name.mid( comma );
585 } else { 569 } else {
586 int space = name.findRev( ' ' ); 570 int space = name.findRev( ' ' );
587 *last = name.mid( space+1 ); 571 *last = name.mid( space+1 );
588 rest = name.left( space ); 572 rest = name.left( space );
589 } 573 }
590 int space = rest.find( ' ' ); 574 int space = rest.find( ' ' );
591 if ( space <= 0 ) { 575 if ( space <= 0 ) {
592 *first = rest; 576 *first = rest;
593 } else { 577 } else {
594 *first = rest.left( space ); 578 *first = rest.left( space );
595 *middle = rest.mid( space+1 ); 579 *middle = rest.mid( space+1 );
596 } 580 }
597 581
598} 582}
599 583
600 584
601void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 585void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
602{ 586{
603 if (msg == "editPersonal()") { 587 if (msg == "editPersonal()") {
604 editPersonal(); 588 editPersonal();
605 } else if (msg == "editPersonalAndClose()") { 589 } else if (msg == "editPersonalAndClose()") {
606 editPersonal(); 590 editPersonal();
607 close(); 591 close();
608 } else if ( msg == "addContact(QString,QString)" ) { 592 } else if ( msg == "addContact(QString,QString)" ) {
609 QDataStream stream(data,IO_ReadOnly); 593 QDataStream stream(data,IO_ReadOnly);
610 QString name, email; 594 QString name, email;
611 stream >> name >> email; 595 stream >> name >> email;
612 596
613 OContact cnt; 597 OContact cnt;
614 QString fn, mn, ln; 598 QString fn, mn, ln;
615 parseName( name, &fn, &mn, &ln ); 599 parseName( name, &fn, &mn, &ln );
616 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 600 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
617 cnt.setFirstName( fn ); 601 cnt.setFirstName( fn );
618 cnt.setMiddleName( mn ); 602 cnt.setMiddleName( mn );
619 cnt.setLastName( ln ); 603 cnt.setLastName( ln );
620 cnt.insertEmails( email ); 604 cnt.insertEmails( email );
621 cnt.setDefaultEmail( email ); 605 cnt.setDefaultEmail( email );
622 cnt.setFileAs(); 606 cnt.setFileAs();
623 607
624 if ( bAbEditFirstTime ) { 608 m_abView -> addEntry( cnt );
625 abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, 609
626 this, "editor" ); 610 // :SXm_abView()->init( cnt );
627 bAbEditFirstTime = FALSE; 611 editEntry( EditEntry );
628 } else {
629 abEditor->setEntry( cnt );
630 }
631 abView()->init( cnt );
632 editEntry( NewEntry );
633 612
634 613
635 614
636 } 615 }
637#if 0 616#if 0
638 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { 617 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
639 QDataStream stream(data,IO_ReadOnly); 618 QDataStream stream(data,IO_ReadOnly);
640 QCString ch,m; 619 QCString ch,m;
641 QStringList types; 620 QStringList types;
642 stream >> ch >> m >> types; 621 stream >> ch >> m >> types;
643 AddressPicker picker(abList,this,0,TRUE); 622 AddressPicker picker(abList,this,0,TRUE);
644 picker.showMaximized(); 623 picker.showMaximized();
645 picker.setChoiceNames(types); 624 picker.setChoiceNames(types);
646 int i=0; 625 int i=0;
647 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 626 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
648 QStringList sel; 627 QStringList sel;
649 stream >> sel; 628 stream >> sel;
650 picker.setSelection(i++,sel); 629 picker.setSelection(i++,sel);
651 } 630 }
652 picker.showMaximized(); 631 picker.showMaximized();
653 picker.exec(); 632 picker.exec();
654 633
655 // ###### note: contacts may have been added - save here! 634 // ###### note: contacts may have been added - save here!
656 635
657 setCentralWidget(abList); 636 setCentralWidget(abList);
658 QCopEnvelope e(ch,m); 637 QCopEnvelope e(ch,m);
659 i=0; 638 i=0;
660 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 639 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
661 QStringList sel = picker.selection(i++); 640 QStringList sel = picker.selection(i++);
662 e << sel; 641 e << sel;
663 } 642 }
664 } 643 }
665#endif 644#endif
666 645
667} 646}
668 647
669void AddressbookWindow::editPersonal() 648void AddressbookWindow::editEntry( EntryMode entryMode )
670{ 649{
671 QString filename = addressbookPersonalVCardName(); 650 OContact entry;
672 OContact me; 651 if ( !abEditor ) {
673 if (QFile::exists(filename)) 652 abEditor = new ContactEditor( entry, this, "editor" );
674 me = OContact::readVCard( filename )[0];
675 if (bAbEditFirstTime) {
676 qWarning("Editing personal data");
677 abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields,
678 this, "editor" );
679 // don't create a new editor every time
680 bAbEditFirstTime = FALSE;
681 } else{
682 abEditor->setEntry( me );
683 } 653 }
684 654 if ( entryMode == EditEntry )
685 abEditor->setPersonalView( true ); 655 abEditor->setEntry( m_abView -> currentEntry() );
656 else if ( entryMode == NewEntry )
657 abEditor->setEntry( entry );
658 // other things may chane the caption.
659 abEditor->setCaption( tr("Edit Address") );
686 660
687 abEditor->setCaption(tr("Edit My Personal Details")); 661#if defined(Q_WS_QWS) || defined(_WS_QWS_)
688 abEditor->showMaximized(); 662 abEditor->showMaximized();
689 663#endif
690 // fix the foxus... 664 // fix the foxus...
691 abEditor->setNameFocus(); 665 abEditor->setNameFocus();
692 if ( abEditor->exec() ) { 666 if ( abEditor->exec() ) {
693 setFocus(); 667 setFocus();
694 OContact new_personal = abEditor->entry(); 668 if ( entryMode == NewEntry ) {
695 QString fname = addressbookPersonalVCardName(); 669 OContact insertEntry = abEditor->entry();
696 OContact::writeVCard( fname, new_personal ); 670 insertEntry.assignUid();
697 abView()->init(new_personal); 671 m_abView -> addEntry( insertEntry );
698 abView()->sync(); 672 } else {
673 OContact replEntry = abEditor->entry();
674
675 if ( !replEntry.isValidUid() )
676 replEntry.assignUid();
677
678 m_abView -> replaceEntry( replEntry );
679 }
699 } 680 }
700 abEditor->setCaption( tr("Edit Address") ); 681 // populateCategories();
701 abEditor->setPersonalView( false ); 682
683}
684
685void AddressbookWindow::editPersonal()
686{
687 OContact entry;
688 if ( !abEditor ) {
689 abEditor = new ContactEditor( entry, this, "editor" );
690 }
691
692 abEditor->setCaption(tr("Edit My Personal Details"));
693 abEditor->setPersonalView( true );
694 editEntry( EditEntry );
695 abEditor->setPersonalView( false );
696
702} 697}
703 698
699
704void AddressbookWindow::slotPersonalView() 700void AddressbookWindow::slotPersonalView()
705{ 701{
706 if (!actionPersonal->isOn()) { 702 if (!actionPersonal->isOn()) {
707 // we just turned it off 703 // we just turned it off
708 setCaption( tr("Contacts") ); 704 setCaption( tr("Contacts") );
709 actionNew->setEnabled(TRUE); 705 actionNew->setEnabled(TRUE);
710 actionTrash->setEnabled(TRUE); 706 actionTrash->setEnabled(TRUE);
711 actionFind->setEnabled(TRUE); 707 actionFind->setEnabled(TRUE);
712 slotUpdateToolbar(); // maybe some of the above could be moved there 708 actionMail->setEnabled(TRUE);
713 showList(); 709 // slotUpdateToolbar();
710
711 m_abView->showPersonal( false );
712
714 return; 713 return;
715 } 714 }
716 715
717 // XXX need to disable some QActions. 716 // XXX need to disable some QActions.
718 actionNew->setEnabled(FALSE); 717 actionNew->setEnabled(FALSE);
719 actionTrash->setEnabled(FALSE); 718 actionTrash->setEnabled(FALSE);
720#ifndef MAKE_FOR_SHARP_ROM
721 actionFind->setEnabled(FALSE); 719 actionFind->setEnabled(FALSE);
722#endif
723 actionMail->setEnabled(FALSE); 720 actionMail->setEnabled(FALSE);
724 721
725 setCaption( tr("Contacts - My Personal Details") ); 722 setCaption( tr("Contacts - My Personal Details") );
726 QString filename = addressbookPersonalVCardName();
727 OContact me;
728 if (QFile::exists(filename))
729 me = OContact::readVCard( filename )[0];
730
731 abView()->init( me );
732 abView()->sync();
733 listContainer->hide();
734 setCentralWidget( abView() );
735 mView->show();
736 mView->setFocus();
737}
738 723
739void AddressbookWindow::editEntry( EntryMode entryMode ) 724 m_abView->showPersonal( true );
740{
741 OContact entry;
742 if ( bAbEditFirstTime ) {
743 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields,
744 this, "editor" );
745 bAbEditFirstTime = FALSE;
746 if ( entryMode == EditEntry )
747 abEditor->setEntry( abList->currentEntry() );
748 }
749 // other things may chane the caption.
750 abEditor->setCaption( tr("Edit Address") );
751 725
752#if defined(Q_WS_QWS) || defined(_WS_QWS_)
753 abEditor->showMaximized();
754#endif
755 // fix the foxus...
756 abEditor->setNameFocus();
757 if ( abEditor->exec() ) {
758 setFocus();
759 if ( entryMode == NewEntry ) {
760 OContact insertEntry = abEditor->entry();
761 insertEntry.assignUid();
762 abList->addEntry( insertEntry );
763 } else {
764 OContact replaceEntry = abEditor->entry();
765 if ( !replaceEntry.isValidUid() )
766 replaceEntry.assignUid();
767 abList->replaceCurrentEntry( replaceEntry );
768 }
769 }
770 populateCategories();
771 showList();
772} 726}
773 727
728
774void AddressbookWindow::listIsEmpty( bool empty ) 729void AddressbookWindow::listIsEmpty( bool empty )
775{ 730{
776 if ( !empty ) { 731 if ( !empty ) {
777 deleteButton->setEnabled( TRUE ); 732 deleteButton->setEnabled( TRUE );
778 } 733 }
779} 734}
780 735
781void AddressbookWindow::reload() 736void AddressbookWindow::reload()
782{ 737{
783 syncing = FALSE; 738 syncing = FALSE;
784 abList->clear(); 739 m_abView->clear();
785 abList->reload(); 740 m_abView->reload();
786} 741}
787 742
788void AddressbookWindow::flush() 743void AddressbookWindow::flush()
789{ 744{
790 syncing = TRUE; 745 syncing = TRUE;
791 abList->save(); 746 m_abView->save();
792} 747}
793 748
794 749
795void AddressbookWindow::closeEvent( QCloseEvent *e ) 750void AddressbookWindow::closeEvent( QCloseEvent *e )
796{ 751{
797 if ( centralWidget() == mView ) {
798 if (actionPersonal->isOn()) {
799 // pretend we clicked it off
800 actionPersonal->setOn(FALSE);
801 slotPersonalView();
802 } else {
803 showList();
804 }
805 e->ignore();
806 return;
807 }
808 752
809 if(syncing) { 753 if(syncing) {
810 /* shouldn't we save, I hear you say? well its already been set 754 /* shouldn't we save, I hear you say? well its already been set
811 so that an edit can not occur during a sync, and we flushed 755 so that an edit can not occur during a sync, and we flushed
812 at the start of the sync, so there is no need to save 756 at the start of the sync, so there is no need to save
813 Saving however itself would cause problems. */ 757 Saving however itself would cause problems. */
814 e->accept(); 758 e->accept();
815 return; 759 return;
816 } 760 }
817 //################## shouldn't always save 761 //################## shouldn't always save
818 // True, but the database handles this automatically ! (se) 762 // True, but the database handles this automatically ! (se)
819 if ( save() ) 763 if ( save() )
820 e->accept(); 764 e->accept();
821 else 765 else
822 e->ignore(); 766 e->ignore();
823} 767}
824 768
825/* 769/*
826 Returns TRUE if it is OK to exit 770 Returns TRUE if it is OK to exit
827*/ 771*/
828 772
829bool AddressbookWindow::save() 773bool AddressbookWindow::save()
830{ 774{
831 if ( !abList->save() ) { 775 if ( !m_abView->save() ) {
832 if ( QMessageBox::critical( 0, tr( "Out of space" ), 776 if ( QMessageBox::critical( 0, tr( "Out of space" ),
833 tr("Unable to save information.\n" 777 tr("Unable to save information.\n"
834 "Free up some space\n" 778 "Free up some space\n"
835 "and try again.\n" 779 "and try again.\n"
836 "\nQuit anyway?"), 780 "\nQuit anyway?"),
837 QMessageBox::Yes|QMessageBox::Escape, 781 QMessageBox::Yes|QMessageBox::Escape,
838 QMessageBox::No|QMessageBox::Default ) 782 QMessageBox::No|QMessageBox::Default )
839 != QMessageBox::No ) 783 != QMessageBox::No )
840 return TRUE; 784 return TRUE;
841 else 785 else
842 return FALSE; 786 return FALSE;
843 } 787 }
844 return TRUE; 788 return TRUE;
845} 789}
846 790
847#ifdef __DEBUG_RELEASE 791#ifdef __DEBUG_RELEASE
848void AddressbookWindow::slotSave() 792void AddressbookWindow::slotSave()
849{ 793{
850 save(); 794 save();
851} 795}
852#endif 796#endif
853 797
854void AddressbookWindow::slotSettings()
855{
856 AddressSettings frmSettings( this );
857#if defined(Q_WS_QWS) || defined(_WS_QWS_)
858 frmSettings.showMaximized();
859#endif
860
861 if ( frmSettings.exec() ) {
862 allFields.clear();
863 orderedFields.clear();
864 slOrderedFields.clear();
865 initFields();
866 if ( abEditor )
867 abEditor->loadFields();
868 abList->refresh();
869 }
870}
871
872
873void AddressbookWindow::initFields()
874{
875 // we really don't need the things from the configuration, anymore
876 // only thing that is important are the important categories. So,
877 // Call the contact functions that correspond to these old functions...
878
879 QStringList xmlFields = OContact::fields();
880 QStringList visibleFields = OContact::untrfields();
881 // QStringList trFields = OContact::trfields();
882
883 xmlFields.remove( "Title" );
884 visibleFields.remove( "Name Title" );
885 visibleFields.remove( "Notes" );
886
887 int i, version;
888 Config cfg( "AddressBook" );
889 QString zn;
890
891 // ### Write a function to keep this from happening again...
892 QStringList::ConstIterator it;
893 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) {
894 allFields.append( i + 3 );
895 }
896
897 cfg.setGroup( "Version" );
898 version = cfg.readNumEntry( "version" );
899 i = 0;
900 startFontSize = 1;
901
902 if ( version >= ADDRESSVERSION ) {
903
904 cfg.setGroup( "ImportantCategory" );
905
906 zn = cfg.readEntry( "Category" + QString::number(i), QString::null );
907 while ( !zn.isNull() ) {
908 if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) {
909 slOrderedFields.clear();
910 break;
911 }
912 slOrderedFields.append( zn );
913 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null );
914 }
915 cfg.setGroup( "Font" );
916 startFontSize = cfg.readNumEntry( "fontSize", 1 );
917
918
919 } else {
920 QString str;
921 str = getenv("HOME");
922 str += "/Settings/AddressBook.conf";
923 QFile::remove( str );
924 }
925
926 if ( slOrderedFields.count() > 0 ) {
927 for( QStringList::ConstIterator it = slOrderedFields.begin();
928 it != slOrderedFields.end(); ++it ) {
929 QValueList<int>::ConstIterator itVl;
930 QStringList::ConstIterator itVis;
931 itVl = allFields.begin();
932 for ( itVis = visibleFields.begin();
933 itVis != visibleFields.end() && itVl != allFields.end();
934 ++itVis, ++itVl ) {
935 if ( *it == *itVis && itVl != allFields.end() ) {
936 orderedFields.append( *itVl );
937 }
938 }
939 }
940 } else {
941 QValueList<int>::ConstIterator it;
942 for ( it = allFields.begin(); it != allFields.end(); ++it )
943 orderedFields.append( *it );
944
945 slOrderedFields = visibleFields;
946 orderedFields.remove( Qtopia::AddressUid );
947 orderedFields.remove( Qtopia::Title );
948 orderedFields.remove( Qtopia::Groups );
949 orderedFields.remove( Qtopia::AddressCategory );
950 orderedFields.remove( Qtopia::FirstName );
951 orderedFields.remove( Qtopia::LastName );
952 orderedFields.remove( Qtopia::DefaultEmail );
953 orderedFields.remove( Qtopia::FileAs );
954 orderedFields.remove( Qtopia::Notes );
955 orderedFields.remove( Qtopia::Gender );
956 slOrderedFields.remove( "Name Title" );
957 slOrderedFields.remove( "First Name" );
958 slOrderedFields.remove( "Last Name" );
959 slOrderedFields.remove( "File As" );
960 slOrderedFields.remove( "Default Email" );
961 slOrderedFields.remove( "Notes" );
962 slOrderedFields.remove( "Gender" );
963
964 }
965}
966
967
968AbLabel *AddressbookWindow::abView()
969{
970 if ( !mView ) {
971 mView = new AbLabel( this, "viewer" );
972 mView->init( OContact() );
973 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
974 }
975 return mView;
976}
977
978void AddressbookWindow::slotFindOpen()
979{
980 searchBar->show();
981 abList -> inSearch();
982 searchEdit->setFocus();
983}
984void AddressbookWindow::slotFindClose()
985{
986 searchBar->hide();
987 abList -> offSearch();
988 abList->setFocus();
989}
990void AddressbookWindow::slotFindNext()
991{
992 if ( centralWidget() == abView() )
993 showList();
994
995 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false);
996
997 searchEdit->clearFocus();
998 abList->setFocus();
999 if ( abList->numSelections() )
1000 abList->clearSelection();
1001
1002}
1003void AddressbookWindow::slotFindPrevious()
1004{
1005 if ( centralWidget() == abView() )
1006 showList();
1007
1008 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true);
1009
1010 if ( abList->numSelections() )
1011 abList->clearSelection();
1012
1013}
1014
1015void AddressbookWindow::slotFind()
1016{
1017
1018 abList->clearFindRow();
1019 slotFindNext();
1020}
1021 798
1022void AddressbookWindow::slotNotFound() 799void AddressbookWindow::slotNotFound()
1023{ 800{
1024 qWarning("Got notfound signal !"); 801 qWarning("Got notfound signal !");
1025 QMessageBox::information( this, tr( "Not Found" ), 802 QMessageBox::information( this, tr( "Not Found" ),
1026 tr( "Unable to find a contact for this" ) + "\n" 803 tr( "Unable to find a contact for this" ) + "\n"
1027 + tr( "search pattern !" ) ); 804 + tr( "search pattern !" ) );
1028 805
1029 806
1030} 807}
1031void AddressbookWindow::slotWrapAround() 808void AddressbookWindow::slotWrapAround()
1032{ 809{
1033 qWarning("Got wrap signal !"); 810 qWarning("Got wrap signal !");
1034 if ( doNotifyWrapAround ) 811 // if ( doNotifyWrapAround )
1035 QMessageBox::information( this, tr( "End of list" ), 812 // QMessageBox::information( this, tr( "End of list" ),
1036 tr( "End of list. Wrap around now.. !" ) + "\n" ); 813 // tr( "End of list. Wrap around now.. !" ) + "\n" );
1037 814
1038} 815}
1039 816
1040void AddressbookWindow::slotSetCategory( int c ) 817void AddressbookWindow::slotSetCategory( int c )
1041{ 818{
819 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
1042 820
1043 QString cat, book; 821 QString cat, book;
822 AbView::Views view = AbView::TableView;
1044 823
1045 if ( c <= 0 ) 824 if ( c <= 0 )
1046 return; 825 return;
1047 826
1048 // Set checkItem for selected one 827 // Checkmark Book Menu Item Selected
1049 for ( unsigned int i = 1; i < catMenu->count(); i++ ) 828 if ( c < 3 )
1050 catMenu->setItemChecked( i, c == (int)i ); 829 for ( unsigned int i = 1; i < 3; i++ )
830 catMenu->setItemChecked( i, c == (int)i );
831 // Checkmark Category Menu Item Selected
832 else
833 for ( unsigned int i = 3; i < catMenu->count(); i++ )
834 catMenu->setItemChecked( i, c == (int)i );
1051 835
1052 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 836 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
1053 if (catMenu->isItemChecked( i )) { 837 if (catMenu->isItemChecked( i )) {
1054 if ( i == 1 ) // default List view 838 if ( i == 1 ){ // default List view
1055 book = QString::null; 839 book = QString::null;
1056 else if ( i == 2 ) 840 view = AbView::TableView;
1057 book = "Phone"; 841 }else if ( i == 2 ){
1058 else if ( i == 3 ) 842 book = tr( "Cards" );
1059 book = "Company"; 843 view = AbView::CardView;
1060 else if ( i == 4 ) 844 // }else if ( i == 3 ){
1061 book = "Email"; 845 // book = tr( "Personal" );
1062 else if ( i == 5 ) 846 // view = AbView:: PersonalView;
1063 book = "Cards"; 847 }else if ( i == 3 ){ // default All Categories
1064 else if ( i == 6 ) // default All Categories
1065 cat = QString::null; 848 cat = QString::null;
1066 else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled 849 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
1067 cat = "Unfiled"; 850 cat = "Unfiled";
1068 else 851 qWarning ("Unfiled selected!!!");
1069 cat = abList->categories()[i - 7]; 852 }else{
853 cat = m_abView->categories()[i - 4];
854 }
1070 } 855 }
1071 } 856 }
1072 857
1073 abList->setShowCategory( book, cat ); 858 slotViewSwitched( view );
1074 859
860 m_abView -> setShowByCategory( view, cat );
861
1075 if ( book.isEmpty() ) 862 if ( book.isEmpty() )
1076 book = "List"; 863 book = "List";
1077 if ( cat.isEmpty() ) 864 if ( cat.isEmpty() )
1078 cat = "All"; 865 cat = "All";
1079 866
1080 setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); 867 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
868}
869
870void AddressbookWindow::slotViewSwitched( int view )
871{
872 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
873 int menu = 0;
874 switch ( view ){
875 case AbView::TableView:
876 menu = 1;
877 m_tableViewButton->setOn(true);
878 m_cardViewButton->setOn(false);
879 break;
880 case AbView::CardView:
881 menu = 2;
882 m_tableViewButton->setOn(false);
883 m_cardViewButton->setOn(true);
884 break;
885 // case AbView::PersonalView:
886 // menu = 3;
887 // break;
888 // case AbView::CompanyBook:
889 // menu = 3;
890 // break;
891 // case AbView::EmailBook:
892 // menu = 4;
893 // break;
894 }
895 for ( unsigned int i = 1; i < 3; i++ ){
896 if ( catMenu )
897 catMenu->setItemChecked( i, menu == (int)i );
898 }
899}
900
901
902void AddressbookWindow::slotListView()
903{
904 emit slotSetCategory( AbView::TableView +1 );
905}
906
907void AddressbookWindow::slotCardView()
908{
909 emit slotSetCategory( AbView::CardView +1 );
1081} 910}
1082 911
1083void AddressbookWindow::slotSetLetter( char c ) { 912void AddressbookWindow::slotSetLetter( char c ) {
1084 913
1085 abList->setShowByLetter( c ); 914 m_abView->setShowByLetter( c );
1086 915
1087} 916}
1088 917
918
1089void AddressbookWindow::populateCategories() 919void AddressbookWindow::populateCategories()
1090{ 920{
1091 catMenu->clear(); 921 catMenu->clear();
1092 922
1093 int id, rememberId; 923 int id, rememberId;
1094 id = 1; 924 id = 1;
1095 rememberId = 0; 925 rememberId = 0;
1096 926
1097 catMenu->insertItem( tr( "List" ), id++ ); 927 catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ );
1098 catMenu->insertItem( tr( "Phone Book" ), id++ ); 928 catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ );
1099 catMenu->insertItem( tr( "Company Book" ), id++ ); 929 // catMenu->insertItem( tr( "Personal" ), id++ );
1100 catMenu->insertItem( tr( "Email Book" ), id++ );
1101 catMenu->insertItem( tr( "Cards" ), id++ );
1102 catMenu->insertSeparator(); 930 catMenu->insertSeparator();
1103 931
1104 catMenu->insertItem( tr( "All" ), id++ ); 932 catMenu->insertItem( tr( "All" ), id++ );
1105 QStringList categories = abList->categories(); 933 QStringList categories = m_abView->categories();
1106 categories.append( tr( "Unfiled" ) ); 934 categories.append( tr( "Unfiled" ) );
1107 for ( QStringList::Iterator it = categories.begin(); 935 for ( QStringList::Iterator it = categories.begin();
1108 it != categories.end(); ++it ) { 936 it != categories.end(); ++it ) {
1109 catMenu->insertItem( *it, id ); 937 catMenu->insertItem( *it, id );
1110 if ( *it == abList->showCategory() ) 938 if ( *it == m_abView -> showCategory() )
1111 rememberId = id; 939 rememberId = id;
1112 ++id; 940 ++id;
1113 } 941 }
1114 942
1115 if ( abList->showBook().isEmpty() ) { 943 // :SX
1116 catMenu->setItemChecked( 1, true ); 944 // if ( abList->showBook().isEmpty() ) {
1117 } else if ( abList->showBook() == "Phone" ) { 945 // catMenu->setItemChecked( 1, true );
1118 catMenu->setItemChecked( 2, true ); 946 // } else if ( abList->showBook() == "Phone" ) {
1119 } else if ( abList->showBook() == "Company" ) { 947 // catMenu->setItemChecked( 2, true );
1120 catMenu->setItemChecked( 3, true ); 948 // } else if ( abList->showBook() == "Company" ) {
1121 } else if ( abList->showBook() == "Email" ) { 949 // catMenu->setItemChecked( 3, true );
1122 catMenu->setItemChecked( 4, true ); 950 // } else if ( abList->showBook() == "Email" ) {
1123 } else if ( abList->showBook() == "Cards" ) { 951 // catMenu->setItemChecked( 4, true );
1124 catMenu->setItemChecked( 5, true ); 952 // } else if ( abList->showBook() == "Cards" ) {
1125 } 953 // catMenu->setItemChecked( 5, true );
1126 954 // }
1127 if ( abList->showCategory().isEmpty() ) { 955
1128 slotSetCategory( 6 ); 956 if ( m_abView -> showCategory().isEmpty() ) {
957 slotSetCategory( 3 );
1129 } 958 }
1130 else { 959 else {
1131 slotSetCategory( rememberId ); 960 slotSetCategory( rememberId );
1132 } 961 }
1133} 962}
1134 963
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 8027ccf..4c1e2f2 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -1,136 +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 <qmainwindow.h>
27#include <qvaluelist.h> 27#include <qvaluelist.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include "ofloatbar.h" 30#include "ofloatbar.h"
31#include "abview.h"
32#include "abconfig.h"
31 33
32class ContactEditor; 34class ContactEditor;
33class AbLabel; 35class AbLabel;
34class AbTable; 36class AbTable;
35class QPEToolBar; 37class QPEToolBar;
36class QPopupMenu; 38class QPopupMenu;
37class QToolButton; 39class QToolButton;
38class QDialog; 40class QDialog;
39class Ir; 41class Ir;
40class QAction; 42class QAction;
41class LetterPicker; 43class LetterPicker;
42 44
43class AddressbookWindow: public QMainWindow 45class AddressbookWindow: public QMainWindow
44{ 46{
45 Q_OBJECT 47 Q_OBJECT
46public: 48public:
49 enum EntryMode { NewEntry=0, EditEntry };
50
47 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 51 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
48 ~AddressbookWindow(); 52 ~AddressbookWindow();
49 53
50protected: 54protected:
51 void resizeEvent( QResizeEvent * e ); 55 void resizeEvent( QResizeEvent * e );
52 void showList(); 56
53 void showView();
54 enum EntryMode { NewEntry=0, EditEntry };
55 void editPersonal(); 57 void editPersonal();
56 void editEntry( EntryMode ); 58 void editEntry( EntryMode );
57 void closeEvent( QCloseEvent *e ); 59 void closeEvent( QCloseEvent *e );
58 bool save(); 60 bool save();
59 61
60public slots: 62public slots:
61 void flush(); 63 void flush();
62 void reload(); 64 void reload();
63 void appMessage(const QCString &, const QByteArray &); 65 void appMessage(const QCString &, const QByteArray &);
64 void setDocument( const QString & ); 66 void setDocument( const QString & );
65 void slotFindNext();
66 void slotFindPrevious();
67#ifdef __DEBUG_RELEASE 67#ifdef __DEBUG_RELEASE
68 void slotSave(); 68 void slotSave();
69#endif 69#endif
70 70
71private slots: 71private slots:
72 void importvCard(); 72 void importvCard();
73 void slotListNew(); 73 void slotListNew();
74 void slotListView(); 74 /* void slotListView(); */
75 void slotListDelete(); 75 void slotListDelete();
76 void slotViewBack(); 76 void slotViewBack();
77 void slotViewEdit(); 77 void slotViewEdit();
78 void slotPersonalView(); 78 void slotPersonalView();
79 void listIsEmpty( bool ); 79 void listIsEmpty( bool );
80 void slotSettings(); 80 /* void slotSettings(); */
81 void writeMail(); 81 void writeMail();
82 void slotBeam(); 82 void slotBeam();
83 void beamDone( Ir * ); 83 void beamDone( Ir * );
84 void slotSetCategory( int ); 84 void slotSetCategory( int );
85 void slotSetLetter( char ); 85 void slotSetLetter( char );
86 void slotUpdateToolbar(); 86 void slotUpdateToolbar();
87 void slotSetFont(int); 87 void slotSetFont(int);
88 88
89 void slotFindOpen(); 89 void slotFindOpen();
90 void slotFindClose(); 90 void slotFindClose();
91 void slotFind(); 91 void slotFind();
92 void slotNotFound(); 92 void slotNotFound();
93 void slotWrapAround(); 93 void slotWrapAround();
94 94
95 void slotViewSwitched( int );
96 void slotListView();
97 void slotCardView();
98
95 void slotConfig(); 99 void slotConfig();
96 100
97private: 101private:
98 void initFields(); // inititialize our fields... 102 //void initFields(); // inititialize our fields...
99 AbLabel *abView(); 103 // AbLabel *abView();
100 void populateCategories(); 104 void populateCategories();
101 105
102 QPopupMenu *catMenu, *fontMenu; 106 QPopupMenu *catMenu;
103 QPEToolBar *listTools; 107 QPEToolBar *listTools;
104 QToolButton *deleteButton; 108 QToolButton *deleteButton;
105 QValueList<int> allFields, orderedFields; 109 //QValueList<int> allFields, orderedFields;
106 QStringList slOrderedFields; 110 //QStringList slOrderedFields;
107 enum Panes { paneList=0, paneView, paneEdit }; 111 enum Panes { paneList=0, paneView, paneEdit };
108 ContactEditor *abEditor; 112 ContactEditor *abEditor;
109 AbLabel *mView;
110 LetterPicker *pLabel; 113 LetterPicker *pLabel;
111 AbTable *abList; 114 AbView* m_abView;
112 QWidget *listContainer; 115 QWidget *listContainer;
113 116
114 // Searching stuff 117 // Searching stuff
115 OFloatBar* searchBar; 118 OFloatBar* searchBar;
116 QLineEdit* searchEdit; 119 QLineEdit* searchEdit;
117 bool useRegExp;
118 bool doNotifyWrapAround;
119 bool caseSensitive;
120
121 bool m_useQtMail;
122 bool m_useOpieMail;
123 120
124 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; 121 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail;
125 122
126 bool bAbEditFirstTime;
127 int viewMargin; 123 int viewMargin;
128 124
129 bool syncing; 125 bool syncing;
130 QFont *defaultFont; 126 QFont *defaultFont;
131 int startFontSize; 127 int m_curFontSize;
132 128
133 bool isLoading; 129 bool isLoading;
130
131 AbConfig m_config;
132
133 QAction* m_tableViewButton;
134 QAction* m_cardViewButton;
134}; 135};
135 136
136#endif 137#endif
diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro
index 9ed2f68..ef49374 100644
--- a/core/pim/addressbook/addressbook.pro
+++ b/core/pim/addressbook/addressbook.pro
@@ -1,41 +1,46 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 #CONFIG = qt warn_on release
3 CONFIG = qt warn_on debug
3 DESTDIR = $(OPIEDIR)/bin 4 DESTDIR = $(OPIEDIR)/bin
4 HEADERS= addressbook.h \ 5 HEADERS= addressbook.h \
5 contacteditor.h \ 6 contacteditor.h \
7 ocontactfields.h \
6 ablabel.h \ 8 ablabel.h \
7 abtable.h \ 9 abtable.h \
8 addresssettings.h \
9 picker.h \ 10 picker.h \
10 ofloatbar.h \ 11 ofloatbar.h \
11 configdlg.h 12 configdlg.h \
13 abconfig.h \
14 abview.h
12 SOURCES= main.cpp \ 15 SOURCES= main.cpp \
13 addressbook.cpp \ 16 addressbook.cpp \
14 contacteditor.cpp \ 17 contacteditor.cpp \
18 ocontactfields.cpp \
15 ablabel.cpp \ 19 ablabel.cpp \
16 abtable.cpp \ 20 abtable.cpp \
17 addresssettings.cpp \
18 picker.cpp \ 21 picker.cpp \
19 configdlg.cpp 22 configdlg.cpp \
23 abconfig.cpp \
24 abview.cpp
20 25
21 INTERFACES= addresssettingsbase.ui configdlg_base.ui 26 INTERFACES= configdlg_base.ui
22 TARGET = addressbook 27 TARGET = addressbook
23INCLUDEPATH += $(OPIEDIR)/include 28INCLUDEPATH += $(OPIEDIR)/include
24 DEPENDPATH+= $(OPIEDIR)/include 29 DEPENDPATH+= $(OPIEDIR)/include
25LIBS += -lqpe -lopie 30LIBS += -lqpe -lopie
26 31
27TRANSLATIONS = ../../../i18n/de/addressbook.ts \ 32TRANSLATIONS = ../../../i18n/de/addressbook.ts \
28 ../../../i18n/en/addressbook.ts \ 33 ../../../i18n/en/addressbook.ts \
29 ../../../i18n/es/addressbook.ts \ 34 ../../../i18n/es/addressbook.ts \
30 ../../../i18n/fr/addressbook.ts \ 35 ../../../i18n/fr/addressbook.ts \
31 ../../../i18n/hu/addressbook.ts \ 36 ../../../i18n/hu/addressbook.ts \
32 ../../../i18n/ja/addressbook.ts \ 37 ../../../i18n/ja/addressbook.ts \
33 ../../../i18n/ko/addressbook.ts \ 38 ../../../i18n/ko/addressbook.ts \
34 ../../../i18n/no/addressbook.ts \ 39 ../../../i18n/no/addressbook.ts \
35 ../../../i18n/pl/addressbook.ts \ 40 ../../../i18n/pl/addressbook.ts \
36 ../../../i18n/pt/addressbook.ts \ 41 ../../../i18n/pt/addressbook.ts \
37 ../../../i18n/pt_BR/addressbook.ts \ 42 ../../../i18n/pt_BR/addressbook.ts \
38 ../../../i18n/sl/addressbook.ts \ 43 ../../../i18n/sl/addressbook.ts \
39 ../../../i18n/zh_CN/addressbook.ts \ 44 ../../../i18n/zh_CN/addressbook.ts \
40 ../../../i18n/it/addressbook.ts \ 45 ../../../i18n/it/addressbook.ts \
41 ../../../i18n/zh_TW/addressbook.ts 46 ../../../i18n/zh_TW/addressbook.ts
diff --git a/core/pim/addressbook/addresssettings.cpp b/core/pim/addressbook/addresssettings.cpp
index e7c2210..2a9413c 100644
--- a/core/pim/addressbook/addresssettings.cpp
+++ b/core/pim/addressbook/addresssettings.cpp
@@ -1,92 +1,92 @@
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 20
21 21
22#include "addresssettings.h" 22#include "addresssettings.h"
23 23
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/contact.h> 25#include <opie/ocontact.h>
26 26
27#include <qfile.h> 27#include <qfile.h>
28#include <qlistbox.h> 28#include <qlistbox.h>
29 29
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32AddressSettings::AddressSettings( QWidget *parent, const char *name ) 32AddressSettings::AddressSettings( QWidget *parent, const char *name )
33 : AddressSettingsBase( parent, name, TRUE ) 33 : AddressSettingsBase( parent, name, TRUE )
34{ 34{
35 init(); 35 init();
36} 36}
37 37
38AddressSettings::~AddressSettings() 38AddressSettings::~AddressSettings()
39{ 39{
40} 40}
41 41
42void AddressSettings::init() 42void AddressSettings::init()
43{ 43{
44 QStringList slFields = Contact::trfields(); 44 QStringList slFields = OContact::trfields();
45 // Make this match what is in initFields 45 // Make this match what is in initFields
46 slFields.remove( tr("Name Title") ); 46 slFields.remove( tr("Name Title") );
47 slFields.remove( tr("First Name") ); 47 slFields.remove( tr("First Name") );
48 slFields.remove( tr("Last Name") ); 48 slFields.remove( tr("Last Name") );
49 slFields.remove( tr("File As") ); 49 slFields.remove( tr("File As") );
50 slFields.remove( tr("Default Email") ); 50 slFields.remove( tr("Default Email") );
51 slFields.remove( tr("Notes") ); 51 slFields.remove( tr("Notes") );
52 slFields.remove( tr("Gender") ); 52 slFields.remove( tr("Gender") );
53 53
54 54
55 for( QStringList::Iterator it = slFields.begin(); 55 for( QStringList::Iterator it = slFields.begin();
56 it != slFields.end(); ++it ) { 56 it != slFields.end(); ++it ) {
57 fieldListBox->insertItem( *it ); 57 fieldListBox->insertItem( *it );
58 } 58 }
59 59
60 Config cfg( "AddressBook" ); 60 Config cfg( "AddressBook" );
61 61
62 cfg.setGroup( "Version" ); 62 cfg.setGroup( "Version" );
63 int version; 63 int version;
64 version = cfg.readNumEntry( "version" ); 64 version = cfg.readNumEntry( "version" );
65 if ( version >= ADDRESSVERSION ) { 65 if ( version >= ADDRESSVERSION ) {
66 int i = 0; 66 int i = 0;
67 int p = 0; 67 int p = 0;
68 cfg.setGroup( "ImportantCategory" ); 68 cfg.setGroup( "ImportantCategory" );
69 QString zn = cfg.readEntry( "Category" + QString::number(i), 69 QString zn = cfg.readEntry( "Category" + QString::number(i),
70 QString::null ); 70 QString::null );
71 while ( !zn.isNull() ) { 71 while ( !zn.isNull() ) {
72 for ( int m = i; m < (int)fieldListBox->count(); m++ ) { 72 for ( int m = i; m < (int)fieldListBox->count(); m++ ) {
73 if ( fieldListBox->text( m ) == zn ) { 73 if ( fieldListBox->text( m ) == zn ) {
74 if ( m != p ) { 74 if ( m != p ) {
75 fieldListBox->removeItem( m ); 75 fieldListBox->removeItem( m );
76 fieldListBox->insertItem( zn, p ); 76 fieldListBox->insertItem( zn, p );
77 } 77 }
78 p++; 78 p++;
79 break; 79 break;
80 } 80 }
81 } 81 }
82 zn = cfg.readEntry( "Category" + QString::number(++i), 82 zn = cfg.readEntry( "Category" + QString::number(++i),
83 QString::null ); 83 QString::null );
84 } 84 }
85 85
86 fieldListBox->setCurrentItem( 0 ); 86 fieldListBox->setCurrentItem( 0 );
87 } else { 87 } else {
88 QString str; 88 QString str;
89 str = getenv("HOME"); 89 str = getenv("HOME");
90 90
91 str += "/Settings/AddressBook.conf"; 91 str += "/Settings/AddressBook.conf";
92 QFile::remove( str ); 92 QFile::remove( str );
diff --git a/core/pim/addressbook/addresssettingsbase.ui b/core/pim/addressbook/addresssettingsbase.ui
index bd3b85b..f0eb7e8 100644
--- a/core/pim/addressbook/addresssettingsbase.ui
+++ b/core/pim/addressbook/addresssettingsbase.ui
@@ -1,83 +1,83 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>AddressSettingsBase</class> 2<class>AddressSettingsBase</class>
3<comment>/********************************************************************** 3<comment>/**********************************************************************
4** Copyright (C) 2001 Trolltech AS. All rights reserved. 4** Copyright (C) 2001 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of Qt Palmtop Environment. 6** This file is part of Qt Palmtop Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21** $Id$ 21** $Id$
22** 22**
23**********************************************************************/</comment> 23**********************************************************************/</comment>
24<widget> 24<widget>
25 <class>QDialog</class> 25 <class>QDialog</class>
26 <property stdset="1"> 26 <property stdset="1">
27 <name>name</name> 27 <name>name</name>
28 <cstring>AddressSettingsBase</cstring> 28 <cstring>AddressSettingsBase</cstring>
29 </property> 29 </property>
30 <property stdset="1"> 30 <property stdset="1">
31 <name>geometry</name> 31 <name>geometry</name>
32 <rect> 32 <rect>
33 <x>0</x> 33 <x>0</x>
34 <y>0</y> 34 <y>0</y>
35 <width>244</width> 35 <width>240</width>
36 <height>207</height> 36 <height>207</height>
37 </rect> 37 </rect>
38 </property> 38 </property>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>caption</name> 40 <name>caption</name>
41 <string>Arrange Edit Fields</string> 41 <string>Arrange Edit Fields</string>
42 </property> 42 </property>
43 <property> 43 <property>
44 <name>layoutMargin</name> 44 <name>layoutMargin</name>
45 </property> 45 </property>
46 <property> 46 <property>
47 <name>layoutSpacing</name> 47 <name>layoutSpacing</name>
48 </property> 48 </property>
49 <grid> 49 <grid>
50 <property stdset="1"> 50 <property stdset="1">
51 <name>margin</name> 51 <name>margin</name>
52 <number>6</number> 52 <number>6</number>
53 </property> 53 </property>
54 <property stdset="1"> 54 <property stdset="1">
55 <name>spacing</name> 55 <name>spacing</name>
56 <number>6</number> 56 <number>6</number>
57 </property> 57 </property>
58 <widget row="1" column="0" rowspan="3" colspan="1" > 58 <widget row="1" column="0" rowspan="3" colspan="1" >
59 <class>QListBox</class> 59 <class>QListBox</class>
60 <property stdset="1"> 60 <property stdset="1">
61 <name>name</name> 61 <name>name</name>
62 <cstring>fieldListBox</cstring> 62 <cstring>fieldListBox</cstring>
63 </property> 63 </property>
64 </widget> 64 </widget>
65 <widget row="0" column="0" rowspan="1" colspan="2" > 65 <widget row="0" column="0" rowspan="1" colspan="2" >
66 <class>QLabel</class> 66 <class>QLabel</class>
67 <property stdset="1"> 67 <property stdset="1">
68 <name>name</name> 68 <name>name</name>
69 <cstring>lblExplain</cstring> 69 <cstring>lblExplain</cstring>
70 </property> 70 </property>
71 <property stdset="1"> 71 <property stdset="1">
72 <name>sizePolicy</name> 72 <name>sizePolicy</name>
73 <sizepolicy> 73 <sizepolicy>
74 <hsizetype>1</hsizetype> 74 <hsizetype>1</hsizetype>
75 <vsizetype>1</vsizetype> 75 <vsizetype>1</vsizetype>
76 </sizepolicy> 76 </sizepolicy>
77 </property> 77 </property>
78 <property stdset="1"> 78 <property stdset="1">
79 <name>frameShape</name> 79 <name>frameShape</name>
80 <enum>MShape</enum> 80 <enum>MShape</enum>
81 </property> 81 </property>
82 <property stdset="1"> 82 <property stdset="1">
83 <name>frameShadow</name> 83 <name>frameShadow</name>
diff --git a/core/pim/addressbook/configdlg.cpp b/core/pim/addressbook/configdlg.cpp
index d1c2ef8..afba688 100644
--- a/core/pim/addressbook/configdlg.cpp
+++ b/core/pim/addressbook/configdlg.cpp
@@ -1,61 +1,137 @@
1#include "configdlg.h" 1#include "configdlg.h"
2#include "ocontactfields.h"
2#include <qcheckbox.h> 3#include <qcheckbox.h>
3#include <qradiobutton.h> 4#include <qradiobutton.h>
5#include <qlistbox.h>
6#include <qpushbutton.h>
7
8#include <opie/ocontact.h>
4 9
5ConfigDlg::ConfigDlg( QWidget *parent, const char *name): 10ConfigDlg::ConfigDlg( QWidget *parent, const char *name):
6 ConfigDlg_Base(parent, name, true ) 11 ConfigDlg_Base(parent, name, true )
7{}
8
9
10bool ConfigDlg::useRegExp() const
11{
12 return m_useRegExp->isOn();
13}
14bool ConfigDlg::useWildCards() const
15{
16 return m_useWildCard->isOn();
17}
18bool ConfigDlg::useQtMail() const
19{
20 return m_useQtMail->isOn();
21}
22bool ConfigDlg::useOpieMail() const
23{ 12{
24 return m_useOpieMail->isOn(); 13 contFields = OContactFields::trfields();
25} 14
26bool ConfigDlg::beCaseSensitive() const 15 // We add all Fields into the Listbox
27{ 16 for (uint i=0; i < contFields.count(); i++) {
28 return m_useCaseSensitive->isChecked(); 17 allFieldListBox->insertItem( contFields[i] );
29} 18 }
30bool ConfigDlg::signalWrapAround() const 19
31{ 20 // Get the translation maps between Field ID and translated strings
32 return m_signalWrapAround->isChecked(); 21 m_mapStrToID = OContactFields::trFieldsToId();
33} 22 m_mapIDToStr = OContactFields::idToTrFields();
34void ConfigDlg::setUseRegExp( bool v ) 23
35{ 24 connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) );
36 m_useRegExp->setChecked( v ); 25 connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) );
26 connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) );
27 connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) );
37} 28}
38void ConfigDlg::setUseWildCards( bool v ) 29
30void ConfigDlg::slotItemUp()
39{ 31{
40 m_useWildCard->setChecked( v ); 32 qWarning( "void ConfigDlg::slotItemUp()" );
33
34 int i = fieldListBox->currentItem();
35 if ( i > 0 ) {
36 QString item = fieldListBox->currentText();
37 fieldListBox->removeItem( i );
38 fieldListBox->insertItem( item, i-1 );
39 fieldListBox->setCurrentItem( i-1 );
40 }
41
41} 42}
42void ConfigDlg::setBeCaseSensitive( bool v ) 43
44void ConfigDlg::slotItemDown()
43{ 45{
44 m_useCaseSensitive->setChecked( v ); 46 qWarning( "void ConfigDlg::slotItemDown()" );
47
48 int i = fieldListBox->currentItem();
49 if ( i < (int)fieldListBox->count() - 1 ) {
50 QString item = fieldListBox->currentText();
51 fieldListBox->removeItem( i );
52 fieldListBox->insertItem( item, i+1 );
53 fieldListBox->setCurrentItem( i+1 );
54 }
45} 55}
46void ConfigDlg::setSignalWrapAround( bool v ) 56
57void ConfigDlg::slotItemAdd()
47{ 58{
48 m_signalWrapAround->setChecked( v ); 59 qWarning( "void ConfigDlg::slotItemAdd()" );
60
61 int i = allFieldListBox->currentItem();
62 if ( i > 0 ) {
63 QString item = allFieldListBox->currentText();
64 qWarning("ADding %s", item.latin1());
65 fieldListBox->insertItem( item );
66 }
49} 67}
50void ConfigDlg::setQtMail( bool v ) 68
69void ConfigDlg::slotItemRemove()
51{ 70{
52 m_useQtMail->setChecked( v ); 71 qWarning( "void ConfigDlg::slotItemRemove()" );
72
73 int i = fieldListBox->currentItem();
74 if ( i > 0 ) {
75 fieldListBox->removeItem( i );
76 }
53} 77}
54void ConfigDlg::setOpieMail( bool v ) 78
55{ 79void ConfigDlg::setConfig( const AbConfig& cnf )
56 m_useOpieMail->setChecked( v ); 80{
81 m_config = cnf;
82
83 m_useRegExp->setChecked( m_config.useRegExp() );
84 m_useWildCard->setChecked( m_config.useWildCards() );
85 m_useQtMail->setChecked( m_config.useQtMail() );
86 m_useOpieMail->setChecked( m_config.useOpieMail() );
87 m_useCaseSensitive->setChecked( m_config.beCaseSensitive() );
88
89 switch( m_config.fontSize() ){
90 case 0:
91 m_smallFont->setChecked( true );
92 m_normalFont->setChecked( false );
93 m_largeFont->setChecked( false );
94 break;
95 case 1:
96 m_smallFont->setChecked( false );
97 m_normalFont->setChecked( true );
98 m_largeFont->setChecked( false );
99 break;
100 case 2:
101 m_smallFont->setChecked( false );
102 m_normalFont->setChecked( false );
103 m_largeFont->setChecked( true );
104 break;
105 }
106
107 for( uint i = 0; i < m_config.orderList().count(); i++ ) {
108 fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] );
109 }
110
111
57} 112}
113
114AbConfig ConfigDlg::getConfig()
115{
116 m_config.setUseRegExp( m_useRegExp->isOn() );
117 m_config.setUseWildCards( m_useWildCard->isOn() );
118 m_config.setUseQtMail( m_useQtMail->isOn() );
119 m_config.setUseOpieMail( m_useOpieMail->isOn() );
120 m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() );
58 121
122 if ( m_smallFont->isChecked() )
123 m_config.setFontSize( 0 );
124 if ( m_normalFont->isChecked() )
125 m_config.setFontSize( 1 );
126 if ( m_largeFont->isChecked() )
127 m_config.setFontSize( 2 );
59 128
129 QValueList<int> orderlist;
130 for( int i = 0; i < (int)fieldListBox->count(); i++ ) {
131 orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] );
132 }
133 m_config.setOrderList( orderlist );
60 134
135 return m_config;
136}
61 137
diff --git a/core/pim/addressbook/configdlg.h b/core/pim/addressbook/configdlg.h
index 34e9718..53d3d01 100644
--- a/core/pim/addressbook/configdlg.h
+++ b/core/pim/addressbook/configdlg.h
@@ -1,29 +1,33 @@
1#ifndef _CONFIGDLG_H_ 1#ifndef _CONFIGDLG_H_
2#define _CONFIGDLG_H_ 2#define _CONFIGDLG_H_
3 3
4#include <qmap.h>
5
4#include "configdlg_base.h" 6#include "configdlg_base.h"
7#include "abconfig.h"
5 8
6class ConfigDlg: public ConfigDlg_Base 9class ConfigDlg: public ConfigDlg_Base
7{ 10{
8 Q_OBJECT 11 Q_OBJECT
9public: 12public:
10 ConfigDlg( QWidget *parent = 0, const char *name = 0 ); 13 ConfigDlg( QWidget *parent = 0, const char *name = 0 );
11 14
12 // Search Settings 15 // Search Settings
13 bool useRegExp() const; 16 void setConfig( const AbConfig& cnf );
14 bool useWildCards() const; 17 AbConfig getConfig();
15 bool beCaseSensitive() const; 18
16 bool signalWrapAround() const; 19protected slots:
17 bool useQtMail() const; 20 void slotItemUp();
18 bool useOpieMail() const; 21 void slotItemDown();
19 22 void slotItemAdd();
20 void setUseRegExp( bool v ); 23 void slotItemRemove();
21 void setUseWildCards( bool v ); 24
22 void setBeCaseSensitive( bool v ); 25protected:
23 void setSignalWrapAround( bool v ); 26 QStringList contFields;
24 void setQtMail( bool v ); 27 AbConfig m_config;
25 void setOpieMail( bool v ); 28 QMap<QString, int> m_mapStrToID;
29 QMap<int, QString> m_mapIDToStr;
26}; 30};
27 31
28 32
29#endif 33#endif
diff --git a/core/pim/addressbook/configdlg_base.ui b/core/pim/addressbook/configdlg_base.ui
index a6fcffa..66414f5 100644
--- a/core/pim/addressbook/configdlg_base.ui
+++ b/core/pim/addressbook/configdlg_base.ui
@@ -1,179 +1,267 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>ConfigDlg_Base</class> 2<class>ConfigDlg_Base</class>
3<author>Stefan Eilers</author> 3<author>Stefan Eilers</author>
4<widget> 4<widget>
5 <class>QDialog</class> 5 <class>QDialog</class>
6 <property stdset="1"> 6 <property stdset="1">
7 <name>name</name> 7 <name>name</name>
8 <cstring>Configuration</cstring> 8 <cstring>Configuration</cstring>
9 </property> 9 </property>
10 <property stdset="1"> 10 <property stdset="1">
11 <name>geometry</name> 11 <name>geometry</name>
12 <rect> 12 <rect>
13 <x>0</x> 13 <x>0</x>
14 <y>0</y> 14 <y>0</y>
15 <width>244</width> 15 <width>276</width>
16 <height>298</height> 16 <height>327</height>
17 </rect> 17 </rect>
18 </property> 18 </property>
19 <property stdset="1"> 19 <property stdset="1">
20 <name>sizePolicy</name>
21 <sizepolicy>
22 <hsizetype>5</hsizetype>
23 <vsizetype>5</vsizetype>
24 </sizepolicy>
25 </property>
26 <property stdset="1">
20 <name>caption</name> 27 <name>caption</name>
21 <string>MyDialog1</string> 28 <string>MyDialog1</string>
22 </property> 29 </property>
23 <property stdset="1"> 30 <property stdset="1">
24 <name>sizeGripEnabled</name> 31 <name>sizeGripEnabled</name>
25 <bool>true</bool> 32 <bool>true</bool>
26 </property> 33 </property>
34 <property>
35 <name>layoutMargin</name>
36 </property>
27 <vbox> 37 <vbox>
28 <property stdset="1"> 38 <property stdset="1">
29 <name>margin</name> 39 <name>margin</name>
30 <number>11</number> 40 <number>1</number>
31 </property> 41 </property>
32 <property stdset="1"> 42 <property stdset="1">
33 <name>spacing</name> 43 <name>spacing</name>
34 <number>6</number> 44 <number>6</number>
35 </property> 45 </property>
36 <widget> 46 <widget>
37 <class>QTabWidget</class> 47 <class>QTabWidget</class>
38 <property stdset="1"> 48 <property stdset="1">
39 <name>name</name> 49 <name>name</name>
40 <cstring>configDlg_base</cstring> 50 <cstring>configDlg_base</cstring>
41 </property> 51 </property>
52 <property stdset="1">
53 <name>sizePolicy</name>
54 <sizepolicy>
55 <hsizetype>7</hsizetype>
56 <vsizetype>7</vsizetype>
57 </sizepolicy>
58 </property>
42 <property> 59 <property>
43 <name>layoutMargin</name> 60 <name>layoutMargin</name>
44 </property> 61 </property>
62 <property>
63 <name>layoutSpacing</name>
64 </property>
45 <widget> 65 <widget>
46 <class>QWidget</class> 66 <class>QWidget</class>
47 <property stdset="1"> 67 <property stdset="1">
48 <name>name</name> 68 <name>name</name>
49 <cstring>Widget5</cstring> 69 <cstring>Widget5</cstring>
50 </property> 70 </property>
51 <attribute> 71 <attribute>
52 <name>title</name> 72 <name>title</name>
53 <string>Search</string> 73 <string>Misc</string>
54 </attribute> 74 </attribute>
55 <vbox> 75 <vbox>
56 <property stdset="1"> 76 <property stdset="1">
57 <name>margin</name> 77 <name>margin</name>
58 <number>5</number> 78 <number>5</number>
59 </property> 79 </property>
60 <property stdset="1"> 80 <property stdset="1">
61 <name>spacing</name> 81 <name>spacing</name>
62 <number>6</number> 82 <number>6</number>
63 </property> 83 </property>
64 <widget> 84 <widget>
65 <class>QButtonGroup</class> 85 <class>QGroupBox</class>
66 <property stdset="1"> 86 <property stdset="1">
67 <name>name</name> 87 <name>name</name>
68 <cstring>ButtonGroup1</cstring> 88 <cstring>GroupBox2</cstring>
69 </property> 89 </property>
70 <property stdset="1"> 90 <property stdset="1">
71 <name>title</name> 91 <name>title</name>
72 <string>Query Style</string> 92 <string>Search Settings</string>
73 </property> 93 </property>
74 <vbox> 94 <vbox>
75 <property stdset="1"> 95 <property stdset="1">
76 <name>margin</name> 96 <name>margin</name>
77 <number>11</number> 97 <number>11</number>
78 </property> 98 </property>
79 <property stdset="1"> 99 <property stdset="1">
80 <name>spacing</name> 100 <name>spacing</name>
81 <number>6</number> 101 <number>6</number>
82 </property> 102 </property>
83 <widget> 103 <widget>
84 <class>QRadioButton</class> 104 <class>QButtonGroup</class>
85 <property stdset="1"> 105 <property stdset="1">
86 <name>name</name> 106 <name>name</name>
87 <cstring>m_useRegExp</cstring> 107 <cstring>ButtonGroup1</cstring>
88 </property> 108 </property>
89 <property stdset="1"> 109 <property stdset="1">
90 <name>text</name> 110 <name>title</name>
91 <string>Use Regular Expressions</string> 111 <string>Query Style</string>
92 </property> 112 </property>
113 <vbox>
114 <property stdset="1">
115 <name>margin</name>
116 <number>11</number>
117 </property>
118 <property stdset="1">
119 <name>spacing</name>
120 <number>6</number>
121 </property>
122 <widget>
123 <class>QRadioButton</class>
124 <property stdset="1">
125 <name>name</name>
126 <cstring>m_useRegExp</cstring>
127 </property>
128 <property stdset="1">
129 <name>text</name>
130 <string>Use Regular Expressions</string>
131 </property>
132 </widget>
133 <widget>
134 <class>QRadioButton</class>
135 <property stdset="1">
136 <name>name</name>
137 <cstring>m_useWildCard</cstring>
138 </property>
139 <property stdset="1">
140 <name>text</name>
141 <string>Use Wildcards (*,?)</string>
142 </property>
143 <property stdset="1">
144 <name>checked</name>
145 <bool>true</bool>
146 </property>
147 </widget>
148 </vbox>
93 </widget> 149 </widget>
94 <widget> 150 <widget>
95 <class>QRadioButton</class> 151 <class>QCheckBox</class>
96 <property stdset="1"> 152 <property stdset="1">
97 <name>name</name> 153 <name>name</name>
98 <cstring>m_useWildCard</cstring> 154 <cstring>m_useCaseSensitive</cstring>
99 </property> 155 </property>
100 <property stdset="1"> 156 <property stdset="1">
101 <name>text</name> 157 <name>text</name>
102 <string>Use Wildcards (*,?)</string> 158 <string>Case Sensitive</string>
103 </property>
104 <property stdset="1">
105 <name>checked</name>
106 <bool>true</bool>
107 </property> 159 </property>
108 </widget> 160 </widget>
109 </vbox> 161 </vbox>
110 </widget> 162 </widget>
111 <widget> 163 <widget>
112 <class>QCheckBox</class> 164 <class>QButtonGroup</class>
113 <property stdset="1">
114 <name>name</name>
115 <cstring>m_useCaseSensitive</cstring>
116 </property>
117 <property stdset="1">
118 <name>text</name>
119 <string>Case Sensitive</string>
120 </property>
121 </widget>
122 <widget>
123 <class>QCheckBox</class>
124 <property stdset="1"> 165 <property stdset="1">
125 <name>name</name> 166 <name>name</name>
126 <cstring>m_signalWrapAround</cstring> 167 <cstring>ButtonGroup3</cstring>
127 </property> 168 </property>
128 <property stdset="1"> 169 <property stdset="1">
129 <name>text</name> 170 <name>title</name>
130 <string>Signal Wrap Around</string> 171 <string>Font</string>
131 </property> 172 </property>
173 <hbox>
174 <property stdset="1">
175 <name>margin</name>
176 <number>11</number>
177 </property>
178 <property stdset="1">
179 <name>spacing</name>
180 <number>6</number>
181 </property>
182 <widget>
183 <class>QRadioButton</class>
184 <property stdset="1">
185 <name>name</name>
186 <cstring>m_smallFont</cstring>
187 </property>
188 <property stdset="1">
189 <name>text</name>
190 <string>Small</string>
191 </property>
192 </widget>
193 <widget>
194 <class>QRadioButton</class>
195 <property stdset="1">
196 <name>name</name>
197 <cstring>m_normalFont</cstring>
198 </property>
199 <property stdset="1">
200 <name>text</name>
201 <string>Normal</string>
202 </property>
203 <property stdset="1">
204 <name>checked</name>
205 <bool>true</bool>
206 </property>
207 </widget>
208 <widget>
209 <class>QRadioButton</class>
210 <property stdset="1">
211 <name>name</name>
212 <cstring>m_largeFont</cstring>
213 </property>
214 <property stdset="1">
215 <name>text</name>
216 <string>Large</string>
217 </property>
218 </widget>
219 </hbox>
132 </widget> 220 </widget>
133 <spacer> 221 <spacer>
134 <property> 222 <property>
135 <name>name</name> 223 <name>name</name>
136 <cstring>Spacer3</cstring> 224 <cstring>Spacer3</cstring>
137 </property> 225 </property>
138 <property stdset="1"> 226 <property stdset="1">
139 <name>orientation</name> 227 <name>orientation</name>
140 <enum>Vertical</enum> 228 <enum>Vertical</enum>
141 </property> 229 </property>
142 <property stdset="1"> 230 <property stdset="1">
143 <name>sizeType</name> 231 <name>sizeType</name>
144 <enum>Expanding</enum> 232 <enum>Expanding</enum>
145 </property> 233 </property>
146 <property> 234 <property>
147 <name>sizeHint</name> 235 <name>sizeHint</name>
148 <size> 236 <size>
149 <width>20</width> 237 <width>20</width>
150 <height>20</height> 238 <height>20</height>
151 </size> 239 </size>
152 </property> 240 </property>
153 </spacer> 241 </spacer>
154 </vbox> 242 </vbox>
155 </widget> 243 </widget>
156 <widget> 244 <widget>
157 <class>QWidget</class> 245 <class>QWidget</class>
158 <property stdset="1"> 246 <property stdset="1">
159 <name>name</name> 247 <name>name</name>
160 <cstring>tab</cstring> 248 <cstring>tab</cstring>
161 </property> 249 </property>
162 <attribute> 250 <attribute>
163 <name>title</name> 251 <name>title</name>
164 <string>Mail</string> 252 <string>Mail</string>
165 </attribute> 253 </attribute>
166 <vbox> 254 <vbox>
167 <property stdset="1"> 255 <property stdset="1">
168 <name>margin</name> 256 <name>margin</name>
169 <number>5</number> 257 <number>5</number>
170 </property> 258 </property>
171 <property stdset="1"> 259 <property stdset="1">
172 <name>spacing</name> 260 <name>spacing</name>
173 <number>6</number> 261 <number>6</number>
174 </property> 262 </property>
175 <widget> 263 <widget>
176 <class>QButtonGroup</class> 264 <class>QButtonGroup</class>
177 <property stdset="1"> 265 <property stdset="1">
178 <name>name</name> 266 <name>name</name>
179 <cstring>ButtonGroup2</cstring> 267 <cstring>ButtonGroup2</cstring>
@@ -211,127 +299,249 @@
211 <property stdset="1"> 299 <property stdset="1">
212 <name>name</name> 300 <name>name</name>
213 <cstring>m_useOpieMail</cstring> 301 <cstring>m_useOpieMail</cstring>
214 </property> 302 </property>
215 <property stdset="1"> 303 <property stdset="1">
216 <name>text</name> 304 <name>text</name>
217 <string>Prefer Opie-Mail</string> 305 <string>Prefer Opie-Mail</string>
218 </property> 306 </property>
219 </widget> 307 </widget>
220 <widget> 308 <widget>
221 <class>QLabel</class> 309 <class>QLabel</class>
222 <property stdset="1"> 310 <property stdset="1">
223 <name>name</name> 311 <name>name</name>
224 <cstring>TextLabel1</cstring> 312 <cstring>TextLabel1</cstring>
225 </property> 313 </property>
226 <property stdset="1"> 314 <property stdset="1">
227 <name>text</name> 315 <name>text</name>
228 <string>Notice: QT-Mail is just 316 <string>Notice: QT-Mail is just
229provided in the SHARP 317provided in the SHARP
230default ROM. Opie-Mail 318default ROM. Opie-Mail
231is provided free !</string> 319is provided free !</string>
232 </property> 320 </property>
233 </widget> 321 </widget>
234 </vbox> 322 </vbox>
235 </widget> 323 </widget>
236 <spacer> 324 <spacer>
237 <property> 325 <property>
238 <name>name</name> 326 <name>name</name>
239 <cstring>Spacer2</cstring> 327 <cstring>Spacer2</cstring>
240 </property> 328 </property>
241 <property stdset="1"> 329 <property stdset="1">
242 <name>orientation</name> 330 <name>orientation</name>
243 <enum>Vertical</enum> 331 <enum>Vertical</enum>
244 </property> 332 </property>
245 <property stdset="1"> 333 <property stdset="1">
246 <name>sizeType</name> 334 <name>sizeType</name>
247 <enum>Expanding</enum> 335 <enum>Expanding</enum>
248 </property> 336 </property>
249 <property> 337 <property>
250 <name>sizeHint</name> 338 <name>sizeHint</name>
251 <size> 339 <size>
252 <width>20</width> 340 <width>20</width>
253 <height>20</height> 341 <height>20</height>
254 </size> 342 </size>
255 </property> 343 </property>
256 </spacer> 344 </spacer>
257 </vbox> 345 </vbox>
258 </widget> 346 </widget>
259 </widget> 347 <widget>
260 <widget> 348 <class>QWidget</class>
261 <class>QLayoutWidget</class>
262 <property stdset="1">
263 <name>name</name>
264 <cstring>Layout1</cstring>
265 </property>
266 <hbox>
267 <property stdset="1">
268 <name>margin</name>
269 <number>0</number>
270 </property>
271 <property stdset="1"> 349 <property stdset="1">
272 <name>spacing</name> 350 <name>name</name>
273 <number>6</number> 351 <cstring>tab</cstring>
274 </property> 352 </property>
275 <widget> 353 <attribute>
276 <class>QPushButton</class> 354 <name>title</name>
277 <property stdset="1"> 355 <string>Order</string>
278 <name>name</name> 356 </attribute>
279 <cstring>buttonOk</cstring> 357 <vbox>
280 </property>
281 <property stdset="1">
282 <name>text</name>
283 <string>&amp;OK</string>
284 </property>
285 <property stdset="1">
286 <name>autoDefault</name>
287 <bool>true</bool>
288 </property>
289 <property stdset="1">
290 <name>default</name>
291 <bool>true</bool>
292 </property>
293 </widget>
294 <widget>
295 <class>QPushButton</class>
296 <property stdset="1">
297 <name>name</name>
298 <cstring>buttonCancel</cstring>
299 </property>
300 <property stdset="1"> 358 <property stdset="1">
301 <name>text</name> 359 <name>margin</name>
302 <string>&amp;Cancel</string> 360 <number>-1</number>
303 </property> 361 </property>
304 <property stdset="1"> 362 <property stdset="1">
305 <name>autoDefault</name> 363 <name>spacing</name>
306 <bool>true</bool> 364 <number>-1</number>
307 </property> 365 </property>
308 </widget> 366 <widget>
309 </hbox> 367 <class>QGroupBox</class>
368 <property stdset="1">
369 <name>name</name>
370 <cstring>GroupBox9</cstring>
371 </property>
372 <property stdset="1">
373 <name>title</name>
374 <string>Select Contact Order:</string>
375 </property>
376 <grid>
377 <property stdset="1">
378 <name>margin</name>
379 <number>11</number>
380 </property>
381 <property stdset="1">
382 <name>spacing</name>
383 <number>6</number>
384 </property>
385 <widget row="0" column="2" >
386 <class>QPushButton</class>
387 <property stdset="1">
388 <name>name</name>
389 <cstring>m_upButton</cstring>
390 </property>
391 <property stdset="1">
392 <name>sizePolicy</name>
393 <sizepolicy>
394 <hsizetype>1</hsizetype>
395 <vsizetype>0</vsizetype>
396 </sizepolicy>
397 </property>
398 <property stdset="1">
399 <name>text</name>
400 <string>Up</string>
401 </property>
402 <property stdset="1">
403 <name>autoRepeat</name>
404 <bool>true</bool>
405 </property>
406 </widget>
407 <widget row="1" column="2" >
408 <class>QPushButton</class>
409 <property stdset="1">
410 <name>name</name>
411 <cstring>m_downButton</cstring>
412 </property>
413 <property stdset="1">
414 <name>sizePolicy</name>
415 <sizepolicy>
416 <hsizetype>1</hsizetype>
417 <vsizetype>0</vsizetype>
418 </sizepolicy>
419 </property>
420 <property stdset="1">
421 <name>text</name>
422 <string>Down</string>
423 </property>
424 <property stdset="1">
425 <name>autoRepeat</name>
426 <bool>true</bool>
427 </property>
428 </widget>
429 <widget row="4" column="0" rowspan="1" colspan="2" >
430 <class>QListBox</class>
431 <property stdset="1">
432 <name>name</name>
433 <cstring>allFieldListBox</cstring>
434 </property>
435 <property stdset="1">
436 <name>sizePolicy</name>
437 <sizepolicy>
438 <hsizetype>7</hsizetype>
439 <vsizetype>7</vsizetype>
440 </sizepolicy>
441 </property>
442 </widget>
443 <widget row="3" column="0" >
444 <class>QPushButton</class>
445 <property stdset="1">
446 <name>name</name>
447 <cstring>m_addButton</cstring>
448 </property>
449 <property stdset="1">
450 <name>sizePolicy</name>
451 <sizepolicy>
452 <hsizetype>1</hsizetype>
453 <vsizetype>0</vsizetype>
454 </sizepolicy>
455 </property>
456 <property stdset="1">
457 <name>text</name>
458 <string>Add</string>
459 </property>
460 </widget>
461 <widget row="3" column="1" >
462 <class>QPushButton</class>
463 <property stdset="1">
464 <name>name</name>
465 <cstring>m_removeButton</cstring>
466 </property>
467 <property stdset="1">
468 <name>sizePolicy</name>
469 <sizepolicy>
470 <hsizetype>1</hsizetype>
471 <vsizetype>0</vsizetype>
472 </sizepolicy>
473 </property>
474 <property stdset="1">
475 <name>text</name>
476 <string>Remove</string>
477 </property>
478 </widget>
479 <spacer row="2" column="2" >
480 <property>
481 <name>name</name>
482 <cstring>Spacer23</cstring>
483 </property>
484 <property stdset="1">
485 <name>orientation</name>
486 <enum>Vertical</enum>
487 </property>
488 <property stdset="1">
489 <name>sizeType</name>
490 <enum>Expanding</enum>
491 </property>
492 <property>
493 <name>sizeHint</name>
494 <size>
495 <width>20</width>
496 <height>20</height>
497 </size>
498 </property>
499 </spacer>
500 <spacer row="3" column="2" rowspan="2" colspan="1" >
501 <property>
502 <name>name</name>
503 <cstring>Spacer2_2</cstring>
504 </property>
505 <property stdset="1">
506 <name>orientation</name>
507 <enum>Vertical</enum>
508 </property>
509 <property stdset="1">
510 <name>sizeType</name>
511 <enum>Expanding</enum>
512 </property>
513 <property>
514 <name>sizeHint</name>
515 <size>
516 <width>20</width>
517 <height>20</height>
518 </size>
519 </property>
520 </spacer>
521 <widget row="0" column="0" rowspan="3" colspan="2" >
522 <class>QListBox</class>
523 <property stdset="1">
524 <name>name</name>
525 <cstring>fieldListBox</cstring>
526 </property>
527 <property stdset="1">
528 <name>sizePolicy</name>
529 <sizepolicy>
530 <hsizetype>7</hsizetype>
531 <vsizetype>7</vsizetype>
532 </sizepolicy>
533 </property>
534 </widget>
535 </grid>
536 </widget>
537 </vbox>
538 </widget>
310 </widget> 539 </widget>
311 </vbox> 540 </vbox>
312</widget> 541</widget>
313<connections>
314 <connection>
315 <sender>buttonOk</sender>
316 <signal>clicked()</signal>
317 <receiver>Configuration</receiver>
318 <slot>accept()</slot>
319 </connection>
320 <connection>
321 <sender>buttonCancel</sender>
322 <signal>clicked()</signal>
323 <receiver>Configuration</receiver>
324 <slot>reject()</slot>
325 </connection>
326</connections>
327<tabstops> 542<tabstops>
328 <tabstop>configDlg_base</tabstop> 543 <tabstop>configDlg_base</tabstop>
329 <tabstop>m_useWildCard</tabstop>
330 <tabstop>m_useCaseSensitive</tabstop>
331 <tabstop>m_signalWrapAround</tabstop>
332 <tabstop>m_useQtMail</tabstop> 544 <tabstop>m_useQtMail</tabstop>
333 <tabstop>m_useOpieMail</tabstop> 545 <tabstop>m_useOpieMail</tabstop>
334 <tabstop>buttonOk</tabstop>
335 <tabstop>buttonCancel</tabstop>
336</tabstops> 546</tabstops>
337</UI> 547</UI>
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index e034b35..5a7bf1a 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,520 +1,239 @@
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 "addresspicker.h" 23#include "addresspicker.h"
24#include "ocontactfields.h"
24 25
25#include <qpe/categoryselect.h> 26#include <qpe/categoryselect.h>
26#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
27#include <qpe/qpedialog.h> 28#include <qpe/qpedialog.h>
28#include <qpe/timeconversion.h> 29#include <qpe/timeconversion.h>
30#include <opie/ocontact.h>
31#include <qpe/resource.h>
29 32
30#include <qcombobox.h> 33#include <qcombobox.h>
31#include <qlabel.h> 34#include <qlabel.h>
32#include <qtabwidget.h> 35#include <qtabwidget.h>
33#include <qlayout.h> 36#include <qlayout.h>
34#include <qlineedit.h> 37#include <qlineedit.h>
35#include <qmultilineedit.h> 38#include <qmultilineedit.h>
36#include <qscrollview.h> 39#include <qscrollview.h>
37#include <qtoolbutton.h> 40#include <qtoolbutton.h>
38#include <qpushbutton.h> 41#include <qpushbutton.h>
39#include <qmainwindow.h> 42#include <qmainwindow.h>
40#include <qvaluelist.h> 43#include <qvaluelist.h>
41#include <qpopupmenu.h> 44#include <qpopupmenu.h>
42#include <qlistbox.h> 45#include <qlistbox.h>
46#include <qhbox.h>
47#include <qaction.h>
48#include <qiconset.h>
43 49
44static inline bool containsAlphaNum( const QString &str ); 50static inline bool containsAlphaNum( const QString &str );
45static inline bool constainsWhiteSpace( const QString &str ); 51static inline bool constainsWhiteSpace( const QString &str );
46 52
47// helper functions, convert our comma delimited list to proper 53// helper functions, convert our comma delimited list to proper
48// file format... 54// file format...
49void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 55void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
50 QString &strAll ); 56 QString &strAll );
51 57
52// helper convert from file format to comma delimited... 58// helper convert from file format to comma delimited...
53void parseEmailTo( const QString &strDefaultEmail, 59void parseEmailTo( const QString &strDefaultEmail,
54 const QString &strOtherEmail, QString &strBack ); 60 const QString &strOtherEmail, QString &strBack );
55 61
56 ContactEditor::ContactEditor(const OContact &entry, 62 ContactEditor::ContactEditor(const OContact &entry,
57 const QValueList<int> *newOrderedValues,
58 QStringList *slNewOrdered,
59 QWidget *parent, 63 QWidget *parent,
60 const char *name, 64 const char *name,
61 WFlags fl ) 65 WFlags fl )
62 : QDialog( parent, name, TRUE, fl ), 66 : QDialog( parent, name, TRUE, fl ),
63 orderedValues( newOrderedValues ),
64 slOrdered( *slNewOrdered ),
65 m_personalView ( false ) 67 m_personalView ( false )
66{ 68{
67 69
68 init(); 70 init();
69 initMap();
70 setEntry( entry ); 71 setEntry( entry );
71 qDebug("finish");
72} 72}
73 73
74ContactEditor::~ContactEditor() { 74ContactEditor::~ContactEditor() {
75} 75}
76 76
77void ContactEditor::init() { 77void ContactEditor::init() {
78 78
79 useFullName = TRUE; 79 useFullName = true;
80 80
81 int i = 0; 81 uint i = 0;
82/** SHut up and stop leaking
83 slHomeAddress = new QStringList;
84 slBusinessAddress = new QStringList;
85 slChooserNames = new QStringList;
86 slChooserValues = new QStringList;
87
88 slDynamicEntries = new QStringList;
89*/
90 //*slDynamicEntries = *slOrdered;
91 82
92 QStringList trlChooserNames; 83 QStringList trlChooserNames;
93 84
94 for (i = 0; i <= 6; i++) { 85 for (i = 0; i <= 6; i++) {
95 slHomeAddress.append( "" ); 86 slHomeAddress.append( "" );
96 slBusinessAddress.append( "" ); 87 slBusinessAddress.append( "" );
97 } 88 }
98 89
99 { 90 trlChooserNames = OContactFields::trphonefields();
100 hasGender = FALSE; 91 slChooserNames = OContactFields::untrphonefields();
101 hasTitle = FALSE; 92 slDynamicEntries = OContactFields::untrdetailsfields();
102 hasCompany = FALSE; 93 trlDynamicEntries = OContactFields::trdetailsfields();
103 hasNotes = FALSE; 94 for (i = 0; i < slChooserNames.count(); i++)
104 hasStreet = FALSE; 95 slChooserValues.append("");
105 hasStreet2 = FALSE;
106 hasPOBox = FALSE;
107 hasCity = FALSE;
108 hasState = FALSE;
109 hasZip = FALSE;
110 hasCountry = FALSE;
111
112 QStringList::ConstIterator it = slOrdered.begin();
113
114 for ( i = 0; it != slOrdered.end(); i++, ++it ) {
115
116 if ( (*it) == "Business Fax" ) {
117 trlChooserNames.append( tr( "Business Fax" ) );
118 slChooserNames.append( *it );
119 slChooserValues.append("" );
120 //slDynamicEntries->remove( it );
121 continue;
122 }
123
124 if ( (*it) == "Home Fax" ) {
125 trlChooserNames.append( tr( "Home Fax" ) );
126 slChooserNames.append( *it );
127 slChooserValues.append("" );
128 //slDynamicEntries->remove( it );
129 continue;
130 }
131
132
133 if ( (*it) == "Business Phone" ) {
134 trlChooserNames.append( tr( "Business Phone" ) );
135 slChooserNames.append( *it );
136 slChooserValues.append( "" );
137 //slDynamicEntries->remove( it );
138 continue;
139 }
140
141 if ( (*it) == "Home Phone" ) {
142 trlChooserNames.append( tr( "Home Phone" ) );
143 slChooserNames.append( *it );
144 slChooserValues.append( "" );
145 //slDynamicEntries->remove( it );
146 continue;
147 }
148 96
149/*
150 if ( (*it).right( 2 ) == tr( "IM" ) ) {
151 slChooserNames.append( *it );
152 slChooserValues.append( "" );
153 //slDynamicEntries->remove( it );
154 continue;
155 } */
156
157 if ( (*it) == "Business Mobile" ) {
158 trlChooserNames.append( tr( "Business Mobile" ) );
159 slChooserNames.append( *it );
160 slChooserValues.append( "" );
161 //slDynamicEntries->remove( it );
162 continue;
163 }
164
165 if ( (*it) == "Home Mobile" ) {
166 trlChooserNames.append( tr( "Home Mobile" ) );
167 slChooserNames.append( *it );
168 slChooserValues.append( "" );
169 //slDynamicEntries->remove( it );
170 continue;
171 }
172
173
174 if ( (*it) == "Business WebPage" ) {
175 trlChooserNames.append( tr( "Business WebPage" ) );
176 slChooserNames.append( *it );
177 slChooserValues.append( "" );
178 //slDynamicEntries->remove( it );
179 continue;
180 }
181
182 if ( (*it) == "Home Web Page" ) {
183 trlChooserNames.append( tr( "Home Web Page" ) );
184 slChooserNames.append( *it );
185 slChooserValues.append( "" );
186 //slDynamicEntries->remove( it );
187 continue;
188 }
189
190 if ( (*it) == "Business Pager" ) {
191 trlChooserNames.append( tr( "Business Pager" ) );
192 slChooserNames.append( *it );
193 slChooserValues.append( "" );
194 //slDynamicEntries->remove( it );
195 continue;
196 }
197
198 if ( *it == "Default Email" ) {
199 trlChooserNames.append( tr( "Default Email" ) );
200 slChooserNames.append( *it );
201 slChooserValues.append( "" );
202 //slDynamicEntries->remove( it );
203 continue;
204 }
205
206 if ( *it == "Emails" ) {
207 trlChooserNames.append( tr( "Emails" ) );
208 slChooserNames.append( *it );
209 slChooserValues.append( "" );
210 //slDynamicEntries->remove( it );
211 continue;
212 }
213
214 if ( *it == "Name Title" ||
215 *it == "First Name" ||
216 *it == "Middle Name" ||
217 *it == "Last Name" ||
218 *it == "File As" ||
219 *it == "Default Email" ||
220 *it == "Emails" ||
221 *it == "Groups" ||
222 *it == "Anniversary" ||
223 *it == "Birthday" )
224 continue;
225
226 if ( *it == "Name Title" ) {
227 //slDynamicEntries->remove( it );
228 continue;
229 }
230
231 if ( *it == "First Name" ) {
232 //slDynamicEntries->remove( it );
233 continue;
234 }
235
236 if ( *it == "Middle Name" ) {
237 //slDynamicEntries->remove( it );
238 continue;
239 }
240
241 if ( *it == "Last Name" ) {
242 //slDynamicEntries->remove( it );
243 continue;
244 }
245
246 if ( *it == "Suffix" ) {
247 //slDynamicEntries->remove( it );
248 continue;
249 }
250
251 if ( *it == "File As" ) {
252 //slDynamicEntries->remove( it );
253 continue;
254 }
255
256 if ( *it == "Gender" ) {
257 hasGender = TRUE;
258 //slDynamicEntries->remove( it );
259 continue;
260 }
261
262 if ( *it == "Job Title" ) {
263 hasTitle = TRUE;
264 //slDynamicEntries->remove( it );
265 continue;
266 }
267
268 if ( ( *it == "Company") || (*it == "Organization" ) ) {
269 hasCompany = TRUE;
270 //slDynamicEntries->remove( it );
271 continue;
272 }
273
274 if ( *it == "Notes" ) {
275 hasNotes = TRUE;
276 //slDynamicEntries->remove( it );
277 continue;
278 }
279
280 if ( *it == "Groups" ) {
281 //slDynamicEntries->remove( it );
282 continue;
283 }
284
285 if ( (*it) == "Business Street" ) {
286 hasStreet = TRUE;
287 //slDynamicEntries->remove( it );
288 continue;
289 }
290
291 if ( (*it) == "Home Street" ) {
292 hasStreet = TRUE;
293 //slDynamicEntries->remove( it );
294 continue;
295 }
296/*
297 if ( (*it).right( 8 ) == tr( "Street 2" ) ) {
298 hasStreet2 = TRUE;
299 //slDynamicEntries->remove( it );
300 continue;
301 }
302
303 if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) {
304 hasPOBox = TRUE;
305 //slDynamicEntries->remove( it );
306 continue;
307 } */
308
309 if ( (*it) == "Business City" ) {
310 hasCity = TRUE;
311 //slDynamicEntries->remove( it );
312 continue;
313 }
314
315 if ( (*it) == "Business State" ) {
316 hasState = TRUE;
317 //slDynamicEntries->remove( it );
318 continue;
319 }
320
321 if ( (*it) == "Business Zip" ) {
322 hasZip = TRUE;
323 //slDynamicEntries->remove( it );
324 continue;
325 }
326
327 if ( (*it) == "Business Country" ) {
328 hasCountry = TRUE;
329 //slDynamicEntries->remove( it );
330 continue;
331 }
332
333 if ( (*it) == "Home City" ) {
334 hasCity = TRUE;
335 //slDynamicEntries->remove( it );
336 continue;
337 }
338
339 if ( (*it) == "Home State" ) {
340 hasState = TRUE;
341 //slDynamicEntries->remove( it );
342 continue;
343 }
344
345 if ( (*it) == "Home Zip" ) {
346 hasZip = TRUE;
347 //slDynamicEntries->remove( it );
348 continue;
349 }
350
351 if ( (*it) == "Home Country" ) {
352 hasCountry = TRUE;
353 //slDynamicEntries->remove( it );
354 continue;
355 }
356
357 slDynamicEntries.append( *it );
358 }
359 }
360 97
361 QVBoxLayout *vb = new QVBoxLayout( this ); 98 QVBoxLayout *vb = new QVBoxLayout( this );
362 99
363 tabMain = new QTabWidget( this ); 100 tabMain = new QTabWidget( this );
364 vb->addWidget( tabMain ); 101 vb->addWidget( tabMain );
365 102
366 QWidget *tabViewport = new QWidget ( tabMain ); 103 QWidget *tabViewport = new QWidget ( tabMain );
367 104
368 vb = new QVBoxLayout( tabViewport ); 105 vb = new QVBoxLayout( tabViewport );
369 106
370 svGeneral = new QScrollView( tabViewport ); 107 svGeneral = new QScrollView( tabViewport );
371 vb->addWidget( svGeneral, 0, 0 ); 108 vb->addWidget( svGeneral, 0, 0 );
372 svGeneral->setResizePolicy( QScrollView::AutoOneFit ); 109 svGeneral->setResizePolicy( QScrollView::AutoOneFit );
373 svGeneral->setFrameStyle( QFrame::NoFrame ); 110 svGeneral->setFrameStyle( QFrame::NoFrame );
374 111
375 QWidget *container = new QWidget( svGeneral->viewport() ); 112 QWidget *container = new QWidget( svGeneral->viewport() );
376 svGeneral->addChild( container ); 113 svGeneral->addChild( container );
377 114
378 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); 115 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 );
379 gl->setResizeMode( QLayout::FreeResize ); 116 gl->setResizeMode( QLayout::FreeResize );
380 117
381 btnFullName = new QPushButton( tr( "Full Name..." ), container ); 118 btnFullName = new QPushButton( tr( "Full Name..." ), container );
382 gl->addWidget( btnFullName, 0, 0 ); 119 gl->addWidget( btnFullName, 0, 0 );
383 txtFullName = new QLineEdit( container ); 120 txtFullName = new QLineEdit( container );
384 gl->addWidget( txtFullName, 0, 1 ); 121 gl->addWidget( txtFullName, 0, 1 );
385 122
386 QLabel *l = new QLabel( tr( "Job Title" ), container ); 123 QLabel *l = new QLabel( tr( "Job Title" ), container );
387 gl->addWidget( l, 1, 0 ); 124 gl->addWidget( l, 1, 0 );
388 txtJobTitle = new QLineEdit( container ); 125 txtJobTitle = new QLineEdit( container );
389 gl->addWidget( txtJobTitle, 1, 1 ); 126 gl->addWidget( txtJobTitle, 1, 1 );
390 127
391 l = new QLabel( tr( "Organization" ), container ); 128 l = new QLabel( tr( "Organization" ), container );
392 gl->addWidget( l, 2, 0 ); 129 gl->addWidget( l, 2, 0 );
393 txtOrganization = new QLineEdit( container ); 130 txtOrganization = new QLineEdit( container );
394 gl->addWidget( txtOrganization, 2, 1 ); 131 gl->addWidget( txtOrganization, 2, 1 );
395 132
396 cmbChooserField1 = new QComboBox( FALSE, container ); 133 cmbChooserField1 = new QComboBox( FALSE, container );
397 cmbChooserField1->setMaximumWidth( 90 ); 134 cmbChooserField1->setMaximumWidth( 90 );
398 gl->addWidget( cmbChooserField1, 3, 0 ); 135 gl->addWidget( cmbChooserField1, 3, 0 );
399 txtChooserField1 = new QLineEdit( container ); 136 txtChooserField1 = new QLineEdit( container );
400 gl->addWidget( txtChooserField1, 3, 1 ); 137 gl->addWidget( txtChooserField1, 3, 1 );
401 138
402 cmbChooserField2 = new QComboBox( FALSE, container ); 139 cmbChooserField2 = new QComboBox( FALSE, container );
403 cmbChooserField2->setMaximumWidth( 90 ); 140 cmbChooserField2->setMaximumWidth( 90 );
404 gl->addWidget( cmbChooserField2, 4, 0 ); 141 gl->addWidget( cmbChooserField2, 4, 0 );
405 txtChooserField2 = new QLineEdit( container ); 142 txtChooserField2 = new QLineEdit( container );
406 gl->addWidget( txtChooserField2, 4, 1 ); 143 gl->addWidget( txtChooserField2, 4, 1 );
407 144
408 cmbChooserField3 = new QComboBox( FALSE, container ); 145 cmbChooserField3 = new QComboBox( FALSE, container );
409 cmbChooserField3->setMaximumWidth( 90 ); 146 cmbChooserField3->setMaximumWidth( 90 );
410 gl->addWidget( cmbChooserField3, 5, 0 ); 147 gl->addWidget( cmbChooserField3, 5, 0 );
411 txtChooserField3 = new QLineEdit( container ); 148 txtChooserField3 = new QLineEdit( container );
412 gl->addWidget( txtChooserField3, 5, 1 ); 149 gl->addWidget( txtChooserField3, 5, 1 );
413 150
414 l = new QLabel( tr( "File As" ), container ); 151 l = new QLabel( tr( "File As" ), container );
415 gl->addWidget( l, 6, 0 ); 152 gl->addWidget( l, 6, 0 );
416 cmbFileAs = new QComboBox( TRUE, container ); 153 cmbFileAs = new QComboBox( TRUE, container );
417 gl->addWidget( cmbFileAs, 6, 1 ); 154 gl->addWidget( cmbFileAs, 6, 1 );
418 155
419 labCat = new QLabel( tr( "Category" ), container ); 156 labCat = new QLabel( tr( "Category" ), container );
420 gl->addWidget( labCat, 7, 0 ); 157 gl->addWidget( labCat, 7, 0 );
421 cmbCat = new CategorySelect( container ); 158 cmbCat = new CategorySelect( container );
422 gl->addWidget( cmbCat, 7, 1 ); 159 gl->addWidget( cmbCat, 7, 1 );
423 160 labCat->show();
424 // We don't need categories for the personal view 161 cmbCat->show();
425 if ( m_personalView ){
426 qWarning("Disable Category..");
427 labCat->hide();
428 cmbCat->hide();
429 } else {
430 labCat->show();
431 cmbCat->show();
432 }
433 162
434 btnNote = new QPushButton( tr( "Notes..." ), container ); 163 btnNote = new QPushButton( tr( "Notes..." ), container );
435 gl->addWidget( btnNote, 8, 1 ); 164 gl->addWidget( btnNote, 8, 1 );
436 165
437 tabMain->insertTab( tabViewport, tr( "General" ) ); 166 tabMain->insertTab( tabViewport, tr( "General" ) );
438 167
439 tabViewport = new QWidget ( tabMain ); 168 tabViewport = new QWidget ( tabMain );
440 169
441 vb = new QVBoxLayout( tabViewport ); 170 vb = new QVBoxLayout( tabViewport );
442 171
443 svAddress = new QScrollView( tabViewport ); 172 svAddress = new QScrollView( tabViewport );
444 vb->addWidget( svAddress, 0, 0 ); 173 vb->addWidget( svAddress, 0, 0 );
445 svAddress->setResizePolicy( QScrollView::AutoOneFit ); 174 svAddress->setResizePolicy( QScrollView::AutoOneFit );
446 svAddress->setFrameStyle( QFrame::NoFrame ); 175 svAddress->setFrameStyle( QFrame::NoFrame );
447 176
448 container = new QWidget( svAddress->viewport() ); 177 container = new QWidget( svAddress->viewport() );
449 svAddress->addChild( container ); 178 svAddress->addChild( container );
450 179
451 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem 180 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem
452 181
453 cmbAddress = new QComboBox( FALSE, container ); 182 cmbAddress = new QComboBox( FALSE, container );
454 cmbAddress->insertItem( tr( "Business" ) ); 183 cmbAddress->insertItem( tr( "Business" ) );
455 cmbAddress->insertItem( tr( "Home" ) ); 184 cmbAddress->insertItem( tr( "Home" ) );
456 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); 185 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 );
457 186
458 l = new QLabel( tr( "Address" ), container ); 187 l = new QLabel( tr( "Address" ), container );
459 gl->addWidget( l, 1, 0 ); 188 gl->addWidget( l, 1, 0 );
460 txtAddress = new QLineEdit( container ); 189 txtAddress = new QLineEdit( container );
461 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); 190 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 );
462/*
463 l = new QLabel( tr( "Address 2" ), container );
464 gl->addWidget( l, 2, 0 );
465 txtAddress2 = new QLineEdit( container );
466 gl->addMultiCellWidget( txtAddress2, 2, 2, 1, 2 );
467 191
468 l = new QLabel( tr( "P.O. Box" ), container );
469 gl->addWidget( l, 3, 0 );
470 txtPOBox = new QLineEdit( container );
471 gl->addMultiCellWidget( txtPOBox, 3, 3, 1, 2 );
472*/
473 l = new QLabel( tr( "City" ), container ); 192 l = new QLabel( tr( "City" ), container );
474 gl->addWidget( l, 2, 0 ); 193 gl->addWidget( l, 2, 0 );
475 txtCity = new QLineEdit( container ); 194 txtCity = new QLineEdit( container );
476 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); 195 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 );
477 196
478 l = new QLabel( tr( "State" ), container ); 197 l = new QLabel( tr( "State" ), container );
479 gl->addWidget( l, 3, 0 ); 198 gl->addWidget( l, 3, 0 );
480 txtState = new QLineEdit( container ); 199 txtState = new QLineEdit( container );
481 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); 200 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 );
482 201
483 l = new QLabel( tr( "Zip Code" ), container ); 202 l = new QLabel( tr( "Zip Code" ), container );
484 gl->addWidget( l, 4, 0 ); 203 gl->addWidget( l, 4, 0 );
485 txtZip = new QLineEdit( container ); 204 txtZip = new QLineEdit( container );
486 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); 205 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 );
487 206
488 l = new QLabel( tr( "Country" ), container ); 207 l = new QLabel( tr( "Country" ), container );
489 gl->addWidget( l, 5, 0 ); 208 gl->addWidget( l, 5, 0 );
490 cmbCountry = new QComboBox( TRUE, container ); 209 cmbCountry = new QComboBox( TRUE, container );
491 cmbCountry->insertItem( tr( "" ) ); 210 cmbCountry->insertItem( tr( "" ) );
492 cmbCountry->insertItem( tr ( "United States" ) ); 211 cmbCountry->insertItem( tr ( "United States" ) );
493 cmbCountry->insertItem( tr ( "United Kingdom" ) ); 212 cmbCountry->insertItem( tr ( "United Kingdom" ) );
494 cmbCountry->insertItem( tr ( "Afganistan" ) ); 213 cmbCountry->insertItem( tr ( "Afganistan" ) );
495 cmbCountry->insertItem( tr ( "Albania" ) ); 214 cmbCountry->insertItem( tr ( "Albania" ) );
496 cmbCountry->insertItem( tr ( "Algeria" ) ); 215 cmbCountry->insertItem( tr ( "Algeria" ) );
497 cmbCountry->insertItem( tr ( "American Samoa" ) ); 216 cmbCountry->insertItem( tr ( "American Samoa" ) );
498 cmbCountry->insertItem( tr ( "Andorra" ) ); 217 cmbCountry->insertItem( tr ( "Andorra" ) );
499 cmbCountry->insertItem( tr ( "Angola" ) ); 218 cmbCountry->insertItem( tr ( "Angola" ) );
500 cmbCountry->insertItem( tr ( "Anguilla" ) ); 219 cmbCountry->insertItem( tr ( "Anguilla" ) );
501 cmbCountry->insertItem( tr ( "Antartica" ) ); 220 cmbCountry->insertItem( tr ( "Antartica" ) );
502 cmbCountry->insertItem( tr ( "Argentina" ) ); 221 cmbCountry->insertItem( tr ( "Argentina" ) );
503 cmbCountry->insertItem( tr ( "Armania" ) ); 222 cmbCountry->insertItem( tr ( "Armania" ) );
504 cmbCountry->insertItem( tr ( "Aruba" ) ); 223 cmbCountry->insertItem( tr ( "Aruba" ) );
505 cmbCountry->insertItem( tr ( "Australia" ) ); 224 cmbCountry->insertItem( tr ( "Australia" ) );
506 cmbCountry->insertItem( tr ( "Austria" ) ); 225 cmbCountry->insertItem( tr ( "Austria" ) );
507 cmbCountry->insertItem( tr ( "Azerbaijan" ) ); 226 cmbCountry->insertItem( tr ( "Azerbaijan" ) );
508 cmbCountry->insertItem( tr ( "Bahamas" ) ); 227 cmbCountry->insertItem( tr ( "Bahamas" ) );
509 cmbCountry->insertItem( tr ( "Bahrain" ) ); 228 cmbCountry->insertItem( tr ( "Bahrain" ) );
510 cmbCountry->insertItem( tr ( "Bangladesh" ) ); 229 cmbCountry->insertItem( tr ( "Bangladesh" ) );
511 cmbCountry->insertItem( tr ( "Barbados" ) ); 230 cmbCountry->insertItem( tr ( "Barbados" ) );
512 cmbCountry->insertItem( tr ( "Belarus" ) ); 231 cmbCountry->insertItem( tr ( "Belarus" ) );
513 cmbCountry->insertItem( tr ( "Belgium" ) ); 232 cmbCountry->insertItem( tr ( "Belgium" ) );
514 cmbCountry->insertItem( tr ( "Belize" ) ); 233 cmbCountry->insertItem( tr ( "Belize" ) );
515 cmbCountry->insertItem( tr ( "Benin" ) ); 234 cmbCountry->insertItem( tr ( "Benin" ) );
516 cmbCountry->insertItem( tr ( "Bermuda" ) ); 235 cmbCountry->insertItem( tr ( "Bermuda" ) );
517 cmbCountry->insertItem( tr ( "Bhutan" ) ); 236 cmbCountry->insertItem( tr ( "Bhutan" ) );
518 cmbCountry->insertItem( tr ( "Boliva" ) ); 237 cmbCountry->insertItem( tr ( "Boliva" ) );
519 cmbCountry->insertItem( tr ( "Botswana" ) ); 238 cmbCountry->insertItem( tr ( "Botswana" ) );
520 cmbCountry->insertItem( tr ( "Bouvet Island" ) ); 239 cmbCountry->insertItem( tr ( "Bouvet Island" ) );
@@ -691,266 +410,260 @@ void ContactEditor::init() {
691 cmbCountry->insertItem( tr ( "Uruguay" ) ); 410 cmbCountry->insertItem( tr ( "Uruguay" ) );
692 cmbCountry->insertItem( tr ( "Uzbekistan" ) ); 411 cmbCountry->insertItem( tr ( "Uzbekistan" ) );
693 cmbCountry->insertItem( tr ( "Vanuatu" ) ); 412 cmbCountry->insertItem( tr ( "Vanuatu" ) );
694 cmbCountry->insertItem( tr ( "Venezuela" ) ); 413 cmbCountry->insertItem( tr ( "Venezuela" ) );
695 cmbCountry->insertItem( tr ( "Viet Nam" ) ); 414 cmbCountry->insertItem( tr ( "Viet Nam" ) );
696 cmbCountry->insertItem( tr ( "Virgin Islands" ) ); 415 cmbCountry->insertItem( tr ( "Virgin Islands" ) );
697 cmbCountry->insertItem( tr ( "Western Sahara" ) ); 416 cmbCountry->insertItem( tr ( "Western Sahara" ) );
698 cmbCountry->insertItem( tr ( "Yemen" ) ); 417 cmbCountry->insertItem( tr ( "Yemen" ) );
699 cmbCountry->insertItem( tr ( "Yugoslavia" ) ); 418 cmbCountry->insertItem( tr ( "Yugoslavia" ) );
700 cmbCountry->insertItem( tr ( "Zambia" ) ); 419 cmbCountry->insertItem( tr ( "Zambia" ) );
701 cmbCountry->insertItem( tr ( "Zimbabwe" ) ); 420 cmbCountry->insertItem( tr ( "Zimbabwe" ) );
702 if (cmbCountry->listBox()!=0) 421 if (cmbCountry->listBox()!=0)
703 cmbCountry->listBox()->sort(); 422 cmbCountry->listBox()->sort();
704 423
705 cmbCountry->setMaximumWidth( 135 ); 424 cmbCountry->setMaximumWidth( 135 );
706 425
707 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); 426 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 );
708 427
709 cmbChooserField4 = new QComboBox( FALSE, container ); 428 cmbChooserField4 = new QComboBox( FALSE, container );
710 cmbChooserField4->setMaximumWidth( 90 ); 429 cmbChooserField4->setMaximumWidth( 90 );
711 gl->addWidget( cmbChooserField4, 6, 0 ); 430 gl->addWidget( cmbChooserField4, 6, 0 );
712 txtChooserField4 = new QLineEdit( container ); 431 txtChooserField4 = new QLineEdit( container );
713 gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 ); 432 gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 );
714 433
715 QSpacerItem *space = new QSpacerItem(1,1, 434 QSpacerItem *space = new QSpacerItem(1,1,
716 QSizePolicy::Maximum, 435 QSizePolicy::Maximum,
717 QSizePolicy::MinimumExpanding ); 436 QSizePolicy::MinimumExpanding );
718 gl->addItem( space, 7, 0 ); 437 gl->addItem( space, 7, 0 );
719 438
720 tabMain->insertTab( tabViewport, tr( "Address" ) ); 439 tabMain->insertTab( tabViewport, tr( "Address" ) );
721 440
722 tabViewport = new QWidget ( tabMain ); 441 tabViewport = new QWidget ( tabMain );
723 442
724 vb = new QVBoxLayout( tabViewport ); 443 vb = new QVBoxLayout( tabViewport );
725 444
726 svDetails = new QScrollView( tabViewport ); 445 svDetails = new QScrollView( tabViewport );
727 vb->addWidget( svDetails, 0, 0 ); 446 vb->addWidget( svDetails, 0, 0 );
728 svDetails->setResizePolicy( QScrollView::AutoOneFit ); 447 svDetails->setResizePolicy( QScrollView::AutoOneFit );
729 svDetails->setFrameStyle( QFrame::NoFrame ); 448 svDetails->setFrameStyle( QFrame::NoFrame );
730 449
731 container = new QWidget( svDetails->viewport() ); 450 container = new QWidget( svDetails->viewport() );
732 svDetails->addChild( container ); 451 svDetails->addChild( container );
733 452
734 gl = new QGridLayout( container, 1, 2, 2, 4 ); 453 gl = new QGridLayout( container, 1, 2, 2, 4 );
735 454
736 int counter = 0; 455 int counter = 0;
737 456
738 // Birthday 457 // Birthday
458 QHBox* hBox = new QHBox( container );
739 l = new QLabel( tr("Birthday"), container ); 459 l = new QLabel( tr("Birthday"), container );
740 gl->addWidget( l, counter, 0 ); 460 gl->addWidget( l, counter, 0 );
741 461
742 QPopupMenu* m1 = new QPopupMenu( container ); 462 QPopupMenu* m1 = new QPopupMenu( container );
743 birthdayPicker = new DateBookMonth( m1, 0, TRUE ); 463 birthdayPicker = new DateBookMonth( m1, 0, TRUE );
744 m1->insertItem( birthdayPicker ); 464 m1->insertItem( birthdayPicker );
745 465
746 birthdayButton= new QToolButton( container, "buttonStart" ); 466 birthdayButton= new QToolButton( hBox, "buttonStart" );
747 birthdayButton->setPopup( m1 ); 467 birthdayButton->setPopup( m1 );
748 birthdayButton->setPopupDelay(0); 468 birthdayButton->setPopupDelay(0);
749 gl->addWidget( birthdayButton, counter , 1 ); 469
470 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
471 tr( "Delete" ),
472 hBox, 0 );
473
474 gl->addWidget( hBox, counter , 1 );
475
750 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), 476 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ),
751 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); 477 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) );
478 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
752 479
753 ++counter; 480 ++counter;
754 481
755 // Anniversary 482 // Anniversary
483 hBox = new QHBox( container );
756 l = new QLabel( tr("Anniversary"), container ); 484 l = new QLabel( tr("Anniversary"), container );
757 gl->addWidget( l, counter, 0 ); 485 gl->addWidget( l, counter, 0 );
758 486
759 m1 = new QPopupMenu( container ); 487 m1 = new QPopupMenu( container );
760 anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); 488 anniversaryPicker = new DateBookMonth( m1, 0, TRUE );
761 m1->insertItem( anniversaryPicker ); 489 m1->insertItem( anniversaryPicker );
762 490
763 anniversaryButton= new QToolButton( container, "buttonStart" ); 491 anniversaryButton= new QToolButton( hBox, "buttonStart" );
764 anniversaryButton->setPopup( m1 ); 492 anniversaryButton->setPopup( m1 );
765 anniversaryButton->setPopupDelay(0); 493 anniversaryButton->setPopupDelay(0);
766 gl->addWidget( anniversaryButton, counter , 1 ); 494
495 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
496 tr( "Delete" ),
497 hBox, 0 );
498 gl->addWidget( hBox, counter , 1 );
499
767 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), 500 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ),
768 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); 501 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) );
502 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) );
769 503
770 ++counter; 504 ++counter;
771 505
772 // Gender 506 // Gender
773 l = new QLabel( tr("Gender"), container ); 507 l = new QLabel( tr("Gender"), container );
774 gl->addWidget( l, counter, 0 ); 508 gl->addWidget( l, counter, 0 );
775 cmbGender = new QComboBox( container ); 509 cmbGender = new QComboBox( container );
776 cmbGender->insertItem( "", 0 ); 510 cmbGender->insertItem( "", 0 );
777 cmbGender->insertItem( tr("Male"), 1); 511 cmbGender->insertItem( tr("Male"), 1);
778 cmbGender->insertItem( tr("Female"), 2); 512 cmbGender->insertItem( tr("Female"), 2);
779 gl->addWidget( cmbGender, counter, 1 ); 513 gl->addWidget( cmbGender, counter, 1 );
780 514
781 ++counter; 515 ++counter;
782 516
783 // Create Labels and lineedit fields for every dynamic entry 517 // Create Labels and lineedit fields for every dynamic entry
784 QStringList::ConstIterator it = slDynamicEntries.begin(); 518 QStringList::ConstIterator it = slDynamicEntries.begin();
785 for (i = counter; it != slDynamicEntries.end(); i++, ++it) { 519 QStringList::ConstIterator trit = trlDynamicEntries.begin();
786 l = new QLabel( QString::null , container ); 520 for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) {
521
522 if (((*it) == "Anniversary") ||
523 ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
524
525 l = new QLabel( (*it).utf8() , container );
787 listName.append( l ); 526 listName.append( l );
788 gl->addWidget( l, i, 0 ); 527 gl->addWidget( l, i, 0 );
789 QLineEdit *e = new QLineEdit( container ); 528 QLineEdit *e = new QLineEdit( container );
790 listValue.append( e ); 529 listValue.append( e );
791 gl->addWidget( e, i, 1); 530 gl->addWidget( e, i, 1);
792 } 531 }
793 // Fill labels with names.. 532 // Fill labels with names..
794 loadFields(); 533 //loadFields();
795 534
796 535
797 tabMain->insertTab( tabViewport, tr( "Details" ) ); 536 tabMain->insertTab( tabViewport, tr( "Details" ) );
798 537
799 dlgNote = new QDialog( this, "Note Dialog", TRUE ); 538 dlgNote = new QDialog( this, "Note Dialog", TRUE );
800 dlgNote->setCaption( tr("Enter Note") ); 539 dlgNote->setCaption( tr("Enter Note") );
801 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); 540 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
802 txtNote = new QMultiLineEdit( dlgNote ); 541 txtNote = new QMultiLineEdit( dlgNote );
803 vbNote->addWidget( txtNote ); 542 vbNote->addWidget( txtNote );
804 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); 543 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
805 544
806 dlgName = new QDialog( this, "Name Dialog", TRUE ); 545 dlgName = new QDialog( this, "Name Dialog", TRUE );
807 dlgName->setCaption( tr("Edit Name") ); 546 dlgName->setCaption( tr("Edit Name") );
808 gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); 547 gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
809 548
810 l = new QLabel( tr("First Name"), dlgName ); 549 l = new QLabel( tr("First Name"), dlgName );
811 gl->addWidget( l, 0, 0 ); 550 gl->addWidget( l, 0, 0 );
812 txtFirstName = new QLineEdit( dlgName ); 551 txtFirstName = new QLineEdit( dlgName );
813 gl->addWidget( txtFirstName, 0, 1 ); 552 gl->addWidget( txtFirstName, 0, 1 );
814 553
815 l = new QLabel( tr("Middle Name"), dlgName ); 554 l = new QLabel( tr("Middle Name"), dlgName );
816 gl->addWidget( l, 1, 0 ); 555 gl->addWidget( l, 1, 0 );
817 txtMiddleName = new QLineEdit( dlgName ); 556 txtMiddleName = new QLineEdit( dlgName );
818 gl->addWidget( txtMiddleName, 1, 1 ); 557 gl->addWidget( txtMiddleName, 1, 1 );
819 558
820 l = new QLabel( tr("Last Name"), dlgName ); 559 l = new QLabel( tr("Last Name"), dlgName );
821 gl->addWidget( l, 2, 0 ); 560 gl->addWidget( l, 2, 0 );
822 txtLastName = new QLineEdit( dlgName ); 561 txtLastName = new QLineEdit( dlgName );
823 gl->addWidget( txtLastName, 2, 1 ); 562 gl->addWidget( txtLastName, 2, 1 );
824 563
825 l = new QLabel( tr("Suffix"), dlgName ); 564 l = new QLabel( tr("Suffix"), dlgName );
826 gl->addWidget( l, 3, 0 ); 565 gl->addWidget( l, 3, 0 );
827 txtSuffix = new QLineEdit( dlgName ); 566 txtSuffix = new QLineEdit( dlgName );
828 gl->addWidget( txtSuffix, 3, 1 ); 567 gl->addWidget( txtSuffix, 3, 1 );
829 space = new QSpacerItem(1,1, 568 space = new QSpacerItem(1,1,
830 QSizePolicy::Maximum, 569 QSizePolicy::Maximum,
831 QSizePolicy::MinimumExpanding ); 570 QSizePolicy::MinimumExpanding );
832 gl->addItem( space, 4, 0 ); 571 gl->addItem( space, 4, 0 );
833 572
834 cmbChooserField1->insertStringList( trlChooserNames ); 573 cmbChooserField1->insertStringList( trlChooserNames );
835 cmbChooserField2->insertStringList( trlChooserNames ); 574 cmbChooserField2->insertStringList( trlChooserNames );
836 cmbChooserField3->insertStringList( trlChooserNames ); 575 cmbChooserField3->insertStringList( trlChooserNames );
837 cmbChooserField4->insertStringList( trlChooserNames ); 576 cmbChooserField4->insertStringList( trlChooserNames );
838 577
839 cmbChooserField1->setCurrentItem( 0 ); 578 cmbChooserField1->setCurrentItem( 0 );
840 cmbChooserField2->setCurrentItem( 1 ); 579 cmbChooserField2->setCurrentItem( 1 );
841 cmbChooserField3->setCurrentItem( 2 ); 580 cmbChooserField3->setCurrentItem( 2 );
842 581
843 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 582 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
844 583
845 connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); 584 connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) );
846 585
847 connect( txtChooserField1, SIGNAL(textChanged(const QString &)), 586 connect( txtChooserField1, SIGNAL(textChanged(const QString &)),
848 this, SLOT(slotChooser1Change(const QString &)) ); 587 this, SLOT(slotChooser1Change(const QString &)) );
849 connect( txtChooserField2, SIGNAL(textChanged(const QString &)), 588 connect( txtChooserField2, SIGNAL(textChanged(const QString &)),
850 this, SLOT(slotChooser2Change(const QString &)) ); 589 this, SLOT(slotChooser2Change(const QString &)) );
851 connect( txtChooserField3, SIGNAL(textChanged(const QString &)), 590 connect( txtChooserField3, SIGNAL(textChanged(const QString &)),
852 this, SLOT(slotChooser3Change(const QString &)) ); 591 this, SLOT(slotChooser3Change(const QString &)) );
853 connect( txtChooserField4, SIGNAL(textChanged(const QString &)), 592 connect( txtChooserField4, SIGNAL(textChanged(const QString &)),
854 this, SLOT(slotChooser4Change(const QString &)) ); 593 this, SLOT(slotChooser4Change(const QString &)) );
855 connect( txtAddress, SIGNAL(textChanged(const QString &)), 594 connect( txtAddress, SIGNAL(textChanged(const QString &)),
856 this, SLOT(slotAddressChange(const QString &)) ); 595 this, SLOT(slotAddressChange(const QString &)) );
857 //connect( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) ); 596 //connect( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) );
858 //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(const QString &)) ); 597 //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(const QString &)) );
859 connect( txtCity, SIGNAL(textChanged(const QString &)), 598 connect( txtCity, SIGNAL(textChanged(const QString &)),
860 this, SLOT(slotCityChange(const QString &)) ); 599 this, SLOT(slotCityChange(const QString &)) );
861 connect( txtState, SIGNAL(textChanged(const QString &)), 600 connect( txtState, SIGNAL(textChanged(const QString &)),
862 this, SLOT(slotStateChange(const QString &)) ); 601 this, SLOT(slotStateChange(const QString &)) );
863 connect( txtZip, SIGNAL(textChanged(const QString &)), 602 connect( txtZip, SIGNAL(textChanged(const QString &)),
864 this, SLOT(slotZipChange(const QString &)) ); 603 this, SLOT(slotZipChange(const QString &)) );
865 connect( cmbCountry, SIGNAL(textChanged(const QString &)), 604 connect( cmbCountry, SIGNAL(textChanged(const QString &)),
866 this, SLOT(slotCountryChange(const QString &)) ); 605 this, SLOT(slotCountryChange(const QString &)) );
867 connect( cmbCountry, SIGNAL(activated(const QString &)), 606 connect( cmbCountry, SIGNAL(activated(const QString &)),
868 this, SLOT(slotCountryChange(const QString &)) ); 607 this, SLOT(slotCountryChange(const QString &)) );
869 connect( cmbChooserField1, SIGNAL(activated(int)), 608 connect( cmbChooserField1, SIGNAL(activated(int)),
870 this, SLOT(slotCmbChooser1Change(int)) ); 609 this, SLOT(slotCmbChooser1Change(int)) );
871 connect( cmbChooserField2, SIGNAL(activated(int)), 610 connect( cmbChooserField2, SIGNAL(activated(int)),
872 this, SLOT(slotCmbChooser2Change(int)) ); 611 this, SLOT(slotCmbChooser2Change(int)) );
873 connect( cmbChooserField3, SIGNAL(activated(int)), 612 connect( cmbChooserField3, SIGNAL(activated(int)),
874 this, SLOT(slotCmbChooser3Change(int)) ); 613 this, SLOT(slotCmbChooser3Change(int)) );
875 connect( cmbChooserField4, SIGNAL(activated(int)), 614 connect( cmbChooserField4, SIGNAL(activated(int)),
876 this, SLOT(slotCmbChooser4Change(int)) ); 615 this, SLOT(slotCmbChooser4Change(int)) );
877 connect( cmbAddress, SIGNAL(activated(int)), 616 connect( cmbAddress, SIGNAL(activated(int)),
878 this, SLOT(slotAddressTypeChange(int)) ); 617 this, SLOT(slotAddressTypeChange(int)) );
879 618
880 new QPEDialogListener(this); 619 new QPEDialogListener(this);
881}
882 620
883void ContactEditor::initMap() 621 setPersonalView ( m_personalView );
884{
885 /*
886 // since the fields and the XML fields exist, create a map
887 // between them...
888 Config cfg1( "AddressBook" );
889 Config cfg2( "AddressBook" );
890 QString strCfg1,
891 strCfg2;
892 int i;
893
894 // This stuff better exist...
895 cfg1.setGroup( "AddressFields" );
896o cfg2.setGroup( "XMLFields" );
897 i = 0;
898 strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null );
899 strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++),
900 QString::null );
901 while ( !strCfg1.isNull() && !strCfg2.isNull() ) {
902 mapField.insert( strCfg1, strCfg2 );
903 strCfg1 = cfg1.readEntry( "Field" + QString::number(i),
904 QString::null );
905 strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++),
906 QString::null );
907 }
908 */
909} 622}
910 623
911void ContactEditor::slotChooser1Change( const QString &textChanged ) { 624void ContactEditor::slotChooser1Change( const QString &textChanged ) {
912 625
913 int index = cmbChooserField1->currentItem(); 626 int index = cmbChooserField1->currentItem();
914 627
915 slChooserValues[index] = textChanged; 628 slChooserValues[index] = textChanged;
916 629
917} 630}
918 631
919void ContactEditor::slotChooser2Change( const QString &textChanged ) { 632void ContactEditor::slotChooser2Change( const QString &textChanged ) {
920 633
921 int index = cmbChooserField2->currentItem(); 634 int index = cmbChooserField2->currentItem();
922 635
923 slChooserValues[index] = textChanged; 636 slChooserValues[index] = textChanged;
924 637
925} 638}
926 639
927void ContactEditor::slotChooser3Change( const QString &textChanged ) { 640void ContactEditor::slotChooser3Change( const QString &textChanged ) {
928 641
929 int index = cmbChooserField3->currentItem(); 642 int index = cmbChooserField3->currentItem();
930 643
931 slChooserValues[index] = textChanged; 644 slChooserValues[index] = textChanged;
932 645
933} 646}
934 647
935void ContactEditor::slotChooser4Change( const QString &textChanged ) { 648void ContactEditor::slotChooser4Change( const QString &textChanged ) {
936 649
937 int index = cmbChooserField4->currentItem(); 650 int index = cmbChooserField4->currentItem();
938 651
939 slChooserValues[index] = textChanged; 652 slChooserValues[index] = textChanged;
940 653
941} 654}
942 655
943void ContactEditor::slotAddressChange( const QString &textChanged ) { 656void ContactEditor::slotAddressChange( const QString &textChanged ) {
944 657
945 if ( cmbAddress->currentItem() == 0 ) { 658 if ( cmbAddress->currentItem() == 0 ) {
946 slBusinessAddress[0] = textChanged; 659 slBusinessAddress[0] = textChanged;
947 } else { 660 } else {
948 slHomeAddress[0] = textChanged; 661 slHomeAddress[0] = textChanged;
949 } 662 }
950} 663}
951 664
952void ContactEditor::slotAddress2Change( const QString &textChanged ) { 665void ContactEditor::slotAddress2Change( const QString &textChanged ) {
953 666
954 if ( cmbAddress->currentItem() == 0 ) { 667 if ( cmbAddress->currentItem() == 0 ) {
955 slBusinessAddress[1] = textChanged; 668 slBusinessAddress[1] = textChanged;
956 } else { 669 } else {
@@ -1026,174 +739,137 @@ void ContactEditor::slotCmbChooser3Change( int index ) {
1026void ContactEditor::slotCmbChooser4Change( int index ) { 739void ContactEditor::slotCmbChooser4Change( int index ) {
1027 740
1028 txtChooserField4->setText( slChooserValues[index] ); 741 txtChooserField4->setText( slChooserValues[index] );
1029 txtChooserField4->setFocus(); 742 txtChooserField4->setFocus();
1030 743
1031} 744}
1032 745
1033void ContactEditor::slotAddressTypeChange( int index ) { 746void ContactEditor::slotAddressTypeChange( int index ) {
1034 747
1035 if ( index == 0 ) { 748 if ( index == 0 ) {
1036 749
1037 txtAddress->setText( slBusinessAddress[0] ); 750 txtAddress->setText( slBusinessAddress[0] );
1038 //txtAddress2->setText( (*slBusinessAddress)[1] ); 751 //txtAddress2->setText( (*slBusinessAddress)[1] );
1039 //txtPOBox->setText( (*slBusinessAddress)[2] ); 752 //txtPOBox->setText( (*slBusinessAddress)[2] );
1040 txtCity->setText( slBusinessAddress[3] ); 753 txtCity->setText( slBusinessAddress[3] );
1041 txtState->setText( slBusinessAddress[4] ); 754 txtState->setText( slBusinessAddress[4] );
1042 txtZip->setText( slBusinessAddress[5] ); 755 txtZip->setText( slBusinessAddress[5] );
1043 QLineEdit *txtTmp = cmbCountry->lineEdit(); 756 QLineEdit *txtTmp = cmbCountry->lineEdit();
1044 txtTmp->setText( slBusinessAddress[6] ); 757 txtTmp->setText( slBusinessAddress[6] );
1045 758
1046 } else { 759 } else {
1047 760
1048 txtAddress->setText( slHomeAddress[0] ); 761 txtAddress->setText( slHomeAddress[0] );
1049 //txtAddress2->setText( (*slHomeAddress)[1] ); 762 //txtAddress2->setText( (*slHomeAddress)[1] );
1050 //txtPOBox->setText( (*slHomeAddress)[2] ); 763 //txtPOBox->setText( (*slHomeAddress)[2] );
1051 txtCity->setText( slHomeAddress[3] ); 764 txtCity->setText( slHomeAddress[3] );
1052 txtState->setText( slHomeAddress[4] ); 765 txtState->setText( slHomeAddress[4] );
1053 txtZip->setText( slHomeAddress[5] ); 766 txtZip->setText( slHomeAddress[5] );
1054 QLineEdit *txtTmp = cmbCountry->lineEdit(); 767 QLineEdit *txtTmp = cmbCountry->lineEdit();
1055 txtTmp->setText( slHomeAddress[6] ); 768 txtTmp->setText( slHomeAddress[6] );
1056 769
1057 } 770 }
1058 771
1059} 772}
1060 773
1061void ContactEditor::slotFullNameChange( const QString &textChanged ) { 774void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1062 775
1063 int index = cmbFileAs->currentItem(); 776 int index = cmbFileAs->currentItem();
1064 777
1065 cmbFileAs->clear(); 778 cmbFileAs->clear();
1066 779
1067 cmbFileAs->insertItem( parseName( textChanged, 0 ) ); 780 cmbFileAs->insertItem( parseName( textChanged, 0 ) );
1068 cmbFileAs->insertItem( parseName( textChanged, 1 ) ); 781 cmbFileAs->insertItem( parseName( textChanged, 1 ) );
1069 cmbFileAs->insertItem( parseName( textChanged, 2 ) ); 782 cmbFileAs->insertItem( parseName( textChanged, 2 ) );
1070 cmbFileAs->insertItem( parseName( textChanged, 3 ) ); 783 cmbFileAs->insertItem( parseName( textChanged, 3 ) );
1071 784
1072 cmbFileAs->setCurrentItem( index ); 785 cmbFileAs->setCurrentItem( index );
1073 786
1074 useFullName = TRUE; 787 useFullName = true;
1075
1076}
1077
1078// Loads the detail fields
1079void ContactEditor::loadFields() {
1080
1081 QStringList::ConstIterator it;
1082 QListIterator<QLabel> lit( listName );
1083 for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) {
1084
1085 if ( *it == "Department" )
1086 (*lit)->setText( tr( "Department" ) );
1087
1088 if ( *it == "Company" )
1089 (*lit)->setText( tr( "Company" ) );
1090
1091 if ( *it == "Office" )
1092 (*lit)->setText( tr( "Office" ) );
1093
1094 if ( *it == "Profession" )
1095 (*lit)->setText( tr( "Profession" ) );
1096
1097 if ( *it == "Assistant" )
1098 (*lit)->setText( tr( "Assistant" ) );
1099
1100 if ( *it == "Manager" )
1101 (*lit)->setText( tr( "Manager" ) );
1102
1103 if ( *it == "Spouse" )
1104 (*lit)->setText( tr( "Spouse" ) );
1105
1106 if ( *it == "Nickname" )
1107 (*lit)->setText( tr( "Nickname" ) );
1108
1109 if ( *it == "Children" )
1110 (*lit)->setText( tr( "Children" ) );
1111 }
1112 788
1113} 789}
1114 790
1115void ContactEditor::accept() { 791void ContactEditor::accept() {
1116 792
1117 if ( isEmpty() ) { 793 if ( isEmpty() ) {
1118 cleanupFields(); 794 cleanupFields();
1119 reject(); 795 reject();
1120 } else { 796 } else {
1121 saveEntry(); 797 saveEntry();
1122 cleanupFields(); 798 cleanupFields();
1123 QDialog::accept(); 799 QDialog::accept();
1124 } 800 }
1125 801
1126} 802}
1127 803
1128void ContactEditor::slotNote() { 804void ContactEditor::slotNote() {
1129 805
1130 dlgNote->showMaximized(); 806 dlgNote->showMaximized();
1131 if ( !dlgNote->exec() ) { 807 if ( !dlgNote->exec() ) {
1132 txtNote->setText( ent.notes() ); 808 txtNote->setText( ent.notes() );
1133 } 809 }
1134} 810}
1135 811
1136void ContactEditor::slotName() { 812void ContactEditor::slotName() {
1137 813
1138 QString tmpName; 814 QString tmpName;
1139 if (useFullName == TRUE) { 815 if (useFullName) {
1140 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 816 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
1141 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 817 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
1142 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 818 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1143 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 819 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1144 } 820 }
1145 dlgName->showMaximized(); 821 dlgName->showMaximized();
1146 if ( dlgName->exec() ) { 822 if ( dlgName->exec() ) {
1147 823
1148 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); 824 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text();
1149 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 825 txtFullName->setText( tmpName.simplifyWhiteSpace() );
1150 slotFullNameChange( txtFullName->text() ); 826 slotFullNameChange( txtFullName->text() );
1151 useFullName = FALSE; 827 useFullName = false;
1152 } 828 }
1153 829
1154} 830}
1155 831
1156void ContactEditor::setNameFocus() { 832void ContactEditor::setNameFocus() {
1157 833
1158 txtFullName->setFocus(); 834 txtFullName->setFocus();
1159 835
1160} 836}
1161 837
1162bool ContactEditor::isEmpty() { 838bool ContactEditor::isEmpty() {
1163 // Test and see if the record should be saved. 839 // Test and see if the record should be saved.
1164 // More strict than the original qtopia, needs name or fileas to save 840 // More strict than the original qtopia, needs name or fileas to save
1165 841
1166 QString t = txtFullName->text(); 842 QString t = txtFullName->text();
1167 if ( !t.isEmpty() && containsAlphaNum( t ) ) 843 if ( !t.isEmpty() && containsAlphaNum( t ) )
1168 return false; 844 return false;
1169 845
1170 t = cmbFileAs->currentText(); 846 t = cmbFileAs->currentText();
1171 if ( !t.isEmpty() && containsAlphaNum( t ) ) 847 if ( !t.isEmpty() && containsAlphaNum( t ) )
1172 return false; 848 return false;
1173 849
1174 return true; 850 return true;
1175 851
1176} 852}
1177 853
1178QString ContactEditor::parseName( const QString fullName, int type ) { 854QString ContactEditor::parseName( const QString fullName, int type ) {
1179 855
1180 QString simplifiedName( fullName.simplifyWhiteSpace() ); 856 QString simplifiedName( fullName.simplifyWhiteSpace() );
1181 QString strFirstName; 857 QString strFirstName;
1182 QString strMiddleName; 858 QString strMiddleName;
1183 QString strLastName; 859 QString strLastName;
1184 QString strSuffix; 860 QString strSuffix;
1185 QString strTitle; 861 QString strTitle;
1186 int commapos; 862 int commapos;
1187 int spCount; 863 int spCount;
1188 int spPos; 864 int spPos;
1189 int spPos2; 865 int spPos2;
1190 866
1191 867
1192 commapos = simplifiedName.find( ',', 0, TRUE); 868 commapos = simplifiedName.find( ',', 0, TRUE);
1193 spCount = simplifiedName.contains( ' ', TRUE ); 869 spCount = simplifiedName.contains( ' ', TRUE );
1194 870
1195 if ( commapos == -1 ) { 871 if ( commapos == -1 ) {
1196 872
1197 switch (spCount) { 873 switch (spCount) {
1198 case 0: 874 case 0:
1199 //return simplifiedName; 875 //return simplifiedName;
@@ -1316,205 +992,190 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1316 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 992 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1317 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 993 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1318 strSuffix = simplifiedName.mid( spPos2 + 1 ); 994 strSuffix = simplifiedName.mid( spPos2 + 1 );
1319 break; 995 break;
1320 996
1321 default: 997 default:
1322 spPos = simplifiedName.find( ' ', 0, TRUE ); 998 spPos = simplifiedName.find( ' ', 0, TRUE );
1323 strLastName = simplifiedName.left( spPos ); 999 strLastName = simplifiedName.left( spPos );
1324 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1000 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1325 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1001 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1326 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1002 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1327 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); 1003 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos );
1328 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1004 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1329 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1005 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1330 strSuffix = simplifiedName.mid( spPos2 + 1 ); 1006 strSuffix = simplifiedName.mid( spPos2 + 1 );
1331 break; 1007 break;
1332 } 1008 }
1333 } 1009 }
1334 switch (type) { 1010 switch (type) {
1335 case NAME_FL: 1011 case NAME_FL:
1336 return strFirstName + " " + strLastName; 1012 return strFirstName + " " + strLastName;
1337 1013
1338 case NAME_LF: 1014 case NAME_LF:
1339 return strLastName + ", " + strFirstName; 1015 return strLastName + ", " + strFirstName;
1340 1016
1341 case NAME_LFM: 1017 case NAME_LFM:
1342 return strLastName + ", " + strFirstName + " " + strMiddleName; 1018 return strLastName + ", " + strFirstName + " " + strMiddleName;
1343 1019
1344 case NAME_FMLS: 1020 case NAME_FMLS:
1345 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; 1021 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix;
1346 1022
1347 case NAME_F: 1023 case NAME_F:
1348 return strFirstName; 1024 return strFirstName;
1349 1025
1350 case NAME_M: 1026 case NAME_M:
1351 return strMiddleName; 1027 return strMiddleName;
1352 1028
1353 case NAME_L: 1029 case NAME_L:
1354 return strLastName; 1030 return strLastName;
1355 1031
1356 case NAME_S: 1032 case NAME_S:
1357 return strSuffix; 1033 return strSuffix;
1358 1034
1359 } 1035 }
1360 return QString::null; 1036 return QString::null;
1361} 1037}
1362 1038
1363void ContactEditor::cleanupFields() { 1039void ContactEditor::cleanupFields() {
1364
1365 QStringList::Iterator it = slChooserValues.begin(); 1040 QStringList::Iterator it = slChooserValues.begin();
1366 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { 1041 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
1367 (*it) = ""; 1042 (*it) = "";
1368 } 1043 }
1369 1044
1370 for ( int i = 0; i < 7; i++ ) { 1045 for ( int i = 0; i < 7; i++ ) {
1371 slHomeAddress[i] = ""; 1046 slHomeAddress[i] = "";
1372 slBusinessAddress[i] = ""; 1047 slBusinessAddress[i] = "";
1373 } 1048 }
1374 1049
1375 QStringList::ConstIterator cit; 1050 QListIterator<QLineEdit> itLV( listValue );
1376 QListIterator<QLineEdit> itLE( listValue ); 1051 for ( ; itLV.current(); ++itLV ) {
1377 for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) { 1052 (*itLV)->setText( "" );
1378 (*itLE)->setText( "" ); 1053 }
1379 } 1054
1380
1381 txtFirstName->setText(""); 1055 txtFirstName->setText("");
1382 txtMiddleName->setText(""); 1056 txtMiddleName->setText("");
1383 txtLastName->setText(""); 1057 txtLastName->setText("");
1384 txtSuffix->setText(""); 1058 txtSuffix->setText("");
1385 txtNote->setText(""); 1059 txtNote->setText("");
1386 txtFullName->setText(""); 1060 txtFullName->setText("");
1387 txtJobTitle->setText(""); 1061 txtJobTitle->setText("");
1388 txtOrganization->setText(""); 1062 txtOrganization->setText("");
1389 txtChooserField1->setText(""); 1063 txtChooserField1->setText("");
1390 txtChooserField2->setText(""); 1064 txtChooserField2->setText("");
1391 txtChooserField3->setText(""); 1065 txtChooserField3->setText("");
1392 txtAddress->setText(""); 1066 txtAddress->setText("");
1393 //txtAddress2->setText("");
1394 txtCity->setText(""); 1067 txtCity->setText("");
1395 //txtPOBox->setText("");
1396 txtState->setText(""); 1068 txtState->setText("");
1397 txtZip->setText(""); 1069 txtZip->setText("");
1398 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1070 QLineEdit *txtTmp = cmbCountry->lineEdit();
1399 txtTmp->setText(""); 1071 txtTmp->setText("");
1400 txtTmp = cmbFileAs->lineEdit(); 1072 txtTmp = cmbFileAs->lineEdit();
1401 txtTmp->setText(""); 1073 txtTmp->setText("");
1402 1074
1403} 1075}
1404 1076
1405void ContactEditor::setEntry( const OContact &entry ) { 1077void ContactEditor::setEntry( const OContact &entry ) {
1406 1078
1407 cleanupFields(); 1079 cleanupFields();
1408 1080
1409
1410 ent = entry; 1081 ent = entry;
1411 1082
1412 useFullName = FALSE; 1083 useFullName = false;
1413 txtFirstName->setText( ent.firstName() ); 1084 txtFirstName->setText( ent.firstName() );
1414 txtMiddleName->setText( ent.middleName() ); 1085 txtMiddleName->setText( ent.middleName() );
1415 txtLastName->setText( ent.lastName() ); 1086 txtLastName->setText( ent.lastName() );
1416 txtSuffix->setText( ent.suffix() ); 1087 txtSuffix->setText( ent.suffix() );
1417 1088
1418 QString *tmpString = new QString; 1089 QString *tmpString = new QString;
1419 *tmpString = ent.firstName() + " " + ent.middleName() + 1090 *tmpString = ent.firstName() + " " + ent.middleName() +
1420 + " " + ent.lastName() + " " + ent.suffix(); 1091 + " " + ent.lastName() + " " + ent.suffix();
1421 1092
1422 txtFullName->setText( tmpString->simplifyWhiteSpace() ); 1093 txtFullName->setText( tmpString->simplifyWhiteSpace() );
1423 1094
1424 cmbFileAs->setEditText( ent.fileAs() ); 1095 cmbFileAs->setEditText( ent.fileAs() );
1425 1096
1426 if (hasTitle) 1097 //if (hasTitle)
1427 txtJobTitle->setText( ent.jobTitle() ); 1098 txtJobTitle->setText( ent.jobTitle() );
1428 1099
1429 if (hasCompany) 1100 //if (hasCompany)
1430 txtOrganization->setText( ent.company() ); 1101 txtOrganization->setText( ent.company() );
1431 1102
1432 if (hasNotes) 1103 //if (hasNotes)
1433 txtNote->setText( ent.notes() ); 1104 txtNote->setText( ent.notes() );
1434 1105
1435 if (hasStreet) { 1106 //if (hasStreet) {
1436 slHomeAddress[0] = ent.homeStreet(); 1107 slHomeAddress[0] = ent.homeStreet();
1437 slBusinessAddress[0] = ent.businessStreet(); 1108 slBusinessAddress[0] = ent.businessStreet();
1438 } 1109 //}
1439/*
1440 if (hasStreet2) {
1441 (*slHomeAddress)[1] = ent.homeStreet2();
1442 (*slBusinessAddress)[1] = ent.businessStreet2();
1443 }
1444 1110
1445 if (hasPOBox) { 1111 //if (hasCity) {
1446 (*slHomeAddress)[2] = ent.homePOBox();
1447 (*slBusinessAddress)[2] = ent.businessPOBox();
1448 }
1449*/
1450 if (hasCity) {
1451 slHomeAddress[3] = ent.homeCity(); 1112 slHomeAddress[3] = ent.homeCity();
1452 slBusinessAddress[3] = ent.businessCity(); 1113 slBusinessAddress[3] = ent.businessCity();
1453 } 1114//}
1454 1115
1455 if (hasState) { 1116//if (hasState) {
1456 slHomeAddress[4] = ent.homeState(); 1117 slHomeAddress[4] = ent.homeState();
1457 slBusinessAddress[4] = ent.businessState(); 1118 slBusinessAddress[4] = ent.businessState();
1458 } 1119//}
1459 1120
1460 if (hasZip) { 1121//if (hasZip) {
1461 slHomeAddress[5] = ent.homeZip(); 1122 slHomeAddress[5] = ent.homeZip();
1462 slBusinessAddress[5] = ent.businessZip(); 1123 slBusinessAddress[5] = ent.businessZip();
1463 } 1124//}
1464 1125
1465 if (hasCountry) { 1126//if (hasCountry) {
1466 slHomeAddress[6] = ent.homeCountry(); 1127 slHomeAddress[6] = ent.homeCountry();
1467 slBusinessAddress[6] = ent.businessCountry(); 1128 slBusinessAddress[6] = ent.businessCountry();
1468 } 1129//}
1469 1130
1470 QStringList::ConstIterator it; 1131 QStringList::ConstIterator it;
1471 QListIterator<QLineEdit> itLE( listValue ); 1132 QListIterator<QLineEdit> itLE( listValue );
1472 for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { 1133 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
1473 if ( *it == "Department" ) 1134 if ( *it == "Department" )
1474 (*itLE)->setText( ent.department() ); 1135 (*itLE)->setText( ent.department() );
1475 1136
1476 if ( *it == "Company" ) 1137 if ( *it == "Company" )
1477 (*itLE)->setText( ent.company() ); 1138 (*itLE)->setText( ent.company() );
1478 1139
1479 if ( *it == "Office" ) 1140 if ( *it == "Office" )
1480 (*itLE)->setText( ent.office() ); 1141 (*itLE)->setText( ent.office() );
1481 1142
1482 if ( *it == "Profession" ) 1143 if ( *it == "Profession" )
1483 (*itLE)->setText( ent.profession() ); 1144 (*itLE)->setText( ent.profession() );
1484 1145
1485 if ( *it == "Assistant" ) 1146 if ( *it == "Assistant" )
1486 (*itLE)->setText( ent.assistant() ); 1147 (*itLE)->setText( ent.assistant() );
1487 1148
1488 if ( *it == "Manager" ) 1149 if ( *it == "Manager" )
1489 (*itLE)->setText( ent.manager() ); 1150 (*itLE)->setText( ent.manager() );
1490 1151
1491 if ( *it == "Spouse" ) 1152 if ( *it == "Spouse" )
1492 (*itLE)->setText( ent.spouse() ); 1153 (*itLE)->setText( ent.spouse() );
1493 1154
1494 if ( *it == "Nickname" ) 1155 if ( *it == "Nickname" )
1495 (*itLE)->setText( ent.nickname() ); 1156 (*itLE)->setText( ent.nickname() );
1496 1157
1497 if ( *it == "Children" ) 1158 if ( *it == "Children" )
1498 (*itLE)->setText( ent.children() ); 1159 (*itLE)->setText( ent.children() );
1499 1160
1500 } 1161 }
1501 1162
1502 QStringList::Iterator itV; 1163 QStringList::Iterator itV;
1503 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1164 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1504 1165
1505 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) 1166 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) )
1506 *itV = ent.businessPhone(); 1167 *itV = ent.businessPhone();
1507/* 1168/*
1508 if ( *it == "Business 2 Phone" ) 1169 if ( *it == "Business 2 Phone" )
1509 *itV = ent.business2Phone(); 1170 *itV = ent.business2Phone();
1510*/ 1171*/
1511 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) 1172 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) )
1512 *itV = ent.businessFax(); 1173 *itV = ent.businessFax();
1513 1174
1514 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) 1175 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) )
1515 *itV = ent.businessMobile(); 1176 *itV = ent.businessMobile();
1516/* 1177/*
1517 if ( *it == "Company Phone" ) 1178 if ( *it == "Company Phone" )
1518 *itV = ent.companyPhone(); 1179 *itV = ent.companyPhone();
1519*/ 1180*/
1520 if ( *it == "Default Email" ) 1181 if ( *it == "Default Email" )
@@ -1544,361 +1205,331 @@ void ContactEditor::setEntry( const OContact &entry ) {
1544 if ( *it == "Other Phone" ) 1205 if ( *it == "Other Phone" )
1545 *itV = ent.otherPhone(); 1206 *itV = ent.otherPhone();
1546*/ 1207*/
1547 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1208 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1548 *itV = ent.businessPager(); 1209 *itV = ent.businessPager();
1549/* 1210/*
1550 if ( *it == "Home Pager") 1211 if ( *it == "Home Pager")
1551 *itV = ent.homePager(); 1212 *itV = ent.homePager();
1552 1213
1553 if ( *it == "AIM IM" ) 1214 if ( *it == "AIM IM" )
1554 *itV = ent.AIMIM(); 1215 *itV = ent.AIMIM();
1555 1216
1556 if ( *it == "ICQ IM" ) 1217 if ( *it == "ICQ IM" )
1557 *itV = ent.ICQIM(); 1218 *itV = ent.ICQIM();
1558 1219
1559 if ( *it == "Jabber IM" ) 1220 if ( *it == "Jabber IM" )
1560 *itV = ent.jabberIM(); 1221 *itV = ent.jabberIM();
1561 1222
1562 if ( *it == "MSN IM" ) 1223 if ( *it == "MSN IM" )
1563 *itV = ent.MSNIM(); 1224 *itV = ent.MSNIM();
1564 1225
1565 if ( *it == "Yahoo IM" ) 1226 if ( *it == "Yahoo IM" )
1566 *itV = ent.yahooIM(); 1227 *itV = ent.yahooIM();
1567*/ 1228*/
1568 if ( *it == "Home Web Page" ) 1229 if ( *it == "Home Web Page" )
1569 *itV = ent.homeWebpage(); 1230 *itV = ent.homeWebpage();
1570 1231
1571 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1232 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1572 *itV = ent.businessWebpage(); 1233 *itV = ent.businessWebpage();
1573 1234
1574 1235
1575 } 1236 }
1576 1237
1577 1238
1578 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); 1239 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
1579 1240
1580 QString gender = ent.gender(); 1241 QString gender = ent.gender();
1581 cmbGender->setCurrentItem( gender.toInt() ); 1242 cmbGender->setCurrentItem( gender.toInt() );
1582 1243
1583 txtNote->setText( ent.notes() ); 1244 txtNote->setText( ent.notes() );
1584 1245
1585 slotCmbChooser1Change( cmbChooserField1->currentItem() ); 1246 slotCmbChooser1Change( cmbChooserField1->currentItem() );
1586 slotCmbChooser2Change( cmbChooserField2->currentItem() ); 1247 slotCmbChooser2Change( cmbChooserField2->currentItem() );
1587 slotCmbChooser3Change( cmbChooserField3->currentItem() ); 1248 slotCmbChooser3Change( cmbChooserField3->currentItem() );
1588 1249
1589 slotAddressTypeChange( cmbAddress->currentItem() ); 1250 slotAddressTypeChange( cmbAddress->currentItem() );
1590 1251
1591 // loadFields(); :SX 1252 // loadFields(); :SX
1592 1253 updateDatePicker();
1254}
1255void ContactEditor::updateDatePicker()
1256{
1593 // Set DatePicker 1257 // Set DatePicker
1594 if ( !ent.birthday().isNull() ){ 1258 if ( !ent.birthday().isNull() ){
1595 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); 1259 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) );
1596 birthdayPicker->setDate( ent.birthday() ); 1260 birthdayPicker->setDate( ent.birthday() );
1597 } else 1261 } else
1598 birthdayButton->setText( tr ("Unknown") ); 1262 birthdayButton->setText( tr ("Unknown") );
1599 1263
1600 if ( !ent.anniversary().isNull() ){ 1264 if ( !ent.anniversary().isNull() ){
1601 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); 1265 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) );
1602 anniversaryPicker->setDate( ent.anniversary() ); 1266 anniversaryPicker->setDate( ent.anniversary() );
1603 } else 1267 } else
1604 anniversaryButton->setText( tr ("Unknown") ); 1268 anniversaryButton->setText( tr ("Unknown") );
1605 1269
1606} 1270}
1607 1271
1608void ContactEditor::saveEntry() { 1272void ContactEditor::saveEntry() {
1609 1273
1610 if ( useFullName == TRUE ) { 1274 if ( useFullName ) {
1611 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); 1275 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) );
1612 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); 1276 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) );
1613 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); 1277 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) );
1614 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); 1278 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) );
1615 1279
1616 useFullName = FALSE; 1280 useFullName = false;
1617} 1281 }
1618
1619 /*if ( ent.firstName() != txtFirstName->text() ||
1620 ent.lastName != txtLastName->text() ||
1621 ent.middleName != txtMiddleName->text() ) {
1622 */
1623 ent.setFirstName( txtFirstName->text() );
1624 ent.setLastName( txtLastName->text() );
1625 ent.setMiddleName( txtMiddleName->text() );
1626 ent.setSuffix( txtSuffix->text() );
1627 1282
1628 //} 1283 ent.setFirstName( txtFirstName->text() );
1284 ent.setLastName( txtLastName->text() );
1285 ent.setMiddleName( txtMiddleName->text() );
1286 ent.setSuffix( txtSuffix->text() );
1629 1287
1630 ent.setFileAs( cmbFileAs->currentText() ); 1288 ent.setFileAs( cmbFileAs->currentText() );
1631 1289
1632 ent.setCategories( cmbCat->currentCategories() ); 1290 ent.setCategories( cmbCat->currentCategories() );
1633 1291
1634 if (hasTitle) 1292
1293 //if (hasTitle)
1635 ent.setJobTitle( txtJobTitle->text() ); 1294 ent.setJobTitle( txtJobTitle->text() );
1636 1295
1637 if (hasCompany) 1296 //if (hasCompany)
1638 ent.setCompany( txtOrganization->text() ); 1297 ent.setCompany( txtOrganization->text() );
1639 1298
1640 if (hasNotes) 1299 //if (hasNotes)
1641 ent.setNotes( txtNote->text() ); 1300 ent.setNotes( txtNote->text() );
1642 1301
1643 if (hasStreet) { 1302 //if (hasStreet) {
1644 ent.setHomeStreet( slHomeAddress[0] ); 1303 ent.setHomeStreet( slHomeAddress[0] );
1645 ent.setBusinessStreet( slBusinessAddress[0] ); 1304 ent.setBusinessStreet( slBusinessAddress[0] );
1646 } 1305 //}
1647/*
1648 if (hasStreet2) {
1649 ent.setHomeStreet2( (*slHomeAddress)[1] );
1650 ent.setBusinessStreet2( (*slBusinessAddress)[1] );
1651 }
1652 1306
1653 if (hasPOBox) { 1307 //if (hasCity) {
1654 ent.setHomePOBox( (*slHomeAddress)[2] );
1655 ent.setBusinessPOBox( (*slBusinessAddress)[2] );
1656 }
1657*/
1658 if (hasCity) {
1659 ent.setHomeCity( slHomeAddress[3] ); 1308 ent.setHomeCity( slHomeAddress[3] );
1660 ent.setBusinessCity( slBusinessAddress[3] ); 1309 ent.setBusinessCity( slBusinessAddress[3] );
1661 } 1310 //}
1662 1311
1663 if (hasState) { 1312 //if (hasState) {
1664 ent.setHomeState( slHomeAddress[4] ); 1313 ent.setHomeState( slHomeAddress[4] );
1665 ent.setBusinessState( slBusinessAddress[4] ); 1314 ent.setBusinessState( slBusinessAddress[4] );
1666 } 1315 //}
1667 1316
1668 if (hasZip) { 1317 //if (hasZip) {
1669 ent.setHomeZip( slHomeAddress[5] ); 1318 ent.setHomeZip( slHomeAddress[5] );
1670 ent.setBusinessZip( slBusinessAddress[5] ); 1319 ent.setBusinessZip( slBusinessAddress[5] );
1671 } 1320 //}
1672 1321
1673 if (hasCountry) { 1322 //if (hasCountry) {
1674 ent.setHomeCountry( slHomeAddress[6] ); 1323 ent.setHomeCountry( slHomeAddress[6] );
1675 ent.setBusinessCountry( slBusinessAddress[6] ); 1324 ent.setBusinessCountry( slBusinessAddress[6] );
1676 } 1325 //}
1677 1326
1678 QStringList::ConstIterator it; 1327 QStringList::ConstIterator it;
1679 QListIterator<QLineEdit> itLE( listValue ); 1328 QListIterator<QLineEdit> itLE( listValue );
1680 for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { 1329 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) {
1330
1681 if ( *it == "Department" ) 1331 if ( *it == "Department" )
1682 ent.setDepartment( (*itLE)->text() ); 1332 ent.setDepartment( (*itLE)->text() );
1683 1333
1684 if ( *it == "Company" ) 1334 if ( *it == "Company" )
1685 ent.setCompany( (*itLE)->text() ); 1335 ent.setCompany( (*itLE)->text() );
1686 1336
1687 if ( *it == "Office" ) 1337 if ( *it == "Office" )
1688 ent.setOffice( (*itLE)->text() ); 1338 ent.setOffice( (*itLE)->text() );
1689 1339
1690 if ( *it == "Profession" ) 1340 if ( *it == "Profession" )
1691 ent.setProfession( (*itLE)->text() ); 1341 ent.setProfession( (*itLE)->text() );
1692 1342
1693 if ( *it == "Assistant" ) 1343 if ( *it == "Assistant" )
1694 ent.setAssistant( (*itLE)->text() ); 1344 ent.setAssistant( (*itLE)->text() );
1695 1345
1696 if ( *it == "Manager" ) 1346 if ( *it == "Manager" )
1697 ent.setManager( (*itLE)->text() ); 1347 ent.setManager( (*itLE)->text() );
1698 1348
1699 if ( *it == "Spouse" ) 1349 if ( *it == "Spouse" )
1700 ent.setSpouse( (*itLE)->text() ); 1350 ent.setSpouse( (*itLE)->text() );
1701 1351
1702 if ( *it == "Nickname" ) 1352 if ( *it == "Nickname" )
1703 ent.setNickname( (*itLE)->text() ); 1353 ent.setNickname( (*itLE)->text() );
1704 1354
1705 if ( *it == "Children" ) 1355 if ( *it == "Children" )
1706 ent.setChildren( (*itLE)->text() ); 1356 ent.setChildren( (*itLE)->text() );
1707 1357
1708 } 1358 }
1709 1359
1360
1710 QStringList::ConstIterator itV; 1361 QStringList::ConstIterator itV;
1711 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1362 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1712 1363
1713 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) 1364 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) )
1714 ent.setBusinessPhone( *itV ); 1365 ent.setBusinessPhone( *itV );
1715/* 1366
1716 if ( *it == tr("Business 2 Phone" )
1717 ent.setBusiness2Phone( *itV );
1718*/
1719 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) 1367 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
1720 ent.setBusinessFax( *itV ); 1368 ent.setBusinessFax( *itV );
1721 1369
1722 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) 1370 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
1723 ent.setBusinessMobile( *itV ); 1371 ent.setBusinessMobile( *itV );
1724/*
1725 if ( *it == "Company Phone" )
1726 ent.setCompanyPhone( *itV );
1727*/
1728 //if ( *it == "Default Email" )
1729 //ent.setDefaultEmail( *itV );
1730 1372
1731 if ( *it == "Emails" ){ 1373 if ( *it == "Emails" ){
1732 QString allemail; 1374 QString allemail;
1733 QString defaultmail; 1375 QString defaultmail;
1734 parseEmailFrom( *itV, defaultmail, allemail ); 1376 parseEmailFrom( *itV, defaultmail, allemail );
1735 // ent.clearEmails(); 1377 // ent.clearEmails();
1736 ent.setDefaultEmail( defaultmail ); 1378 ent.setDefaultEmail( defaultmail );
1737 ent.setEmails( allemail ); 1379 ent.setEmails( allemail );
1738 } 1380 }
1739 1381
1740 if ( *it == "Home Phone" ) 1382 if ( *it == "Home Phone" )
1741 ent.setHomePhone( *itV ); 1383 ent.setHomePhone( *itV );
1742/* 1384
1743 if ( *it == "Home 2 Phone" )
1744 ent.setHome2Phone( *itV );
1745*/
1746 if ( *it == "Home Fax" ) 1385 if ( *it == "Home Fax" )
1747 ent.setHomeFax( *itV ); 1386 ent.setHomeFax( *itV );
1748 1387
1749 if ( *it == "Home Mobile" ) 1388 if ( *it == "Home Mobile" )
1750 ent.setHomeMobile( *itV ); 1389 ent.setHomeMobile( *itV );
1751/*
1752 if ( *it == "Car Phone" )
1753 ent.setCarPhone( *itV );
1754
1755 if ( *it == "ISDN Phone" )
1756 ent.setISDNPhone( *itV );
1757 1390
1758 if ( *it == "Other Phone" )
1759 ent.setOtherPhone( *itV );
1760*/
1761 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1391 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1762 ent.setBusinessPager( *itV ); 1392 ent.setBusinessPager( *itV );
1763/*
1764 if ( *it == "Home Pager" )
1765 ent.setHomePager( *itV );
1766 1393
1767 if ( *it == "AIM IM" )
1768 ent.setAIMIM( *itV );
1769
1770 if ( *it == "ICQ IM" )
1771 ent.setICQIM( *itV );
1772
1773 if ( *it == "Jabber IM" )
1774 ent.setJabberIM( *itV );
1775
1776 if ( *it == "MSN IM" )
1777 ent.setMSNIM( *itV );
1778
1779 if ( *it == "Yahoo IM" )
1780 ent.setYahooIM( *itV );
1781*/
1782 if ( *it == "Home Web Page" ) 1394 if ( *it == "Home Web Page" )
1783 ent.setHomeWebpage( *itV ); 1395 ent.setHomeWebpage( *itV );
1784 1396
1785 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1397 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1786 ent.setBusinessWebpage( *itV ); 1398 ent.setBusinessWebpage( *itV );
1787 1399
1788 1400
1789 } 1401 }
1790 1402
1791 int gender = cmbGender->currentItem(); 1403 int gender = cmbGender->currentItem();
1792 ent.setGender( QString::number( gender ) ); 1404 ent.setGender( QString::number( gender ) );
1793 1405
1794 QString str = txtNote->text(); 1406 QString str = txtNote->text();
1795 if ( !str.isNull() ) 1407 if ( !str.isNull() )
1796 ent.setNotes( str ); 1408 ent.setNotes( str );
1797 1409
1798} 1410}
1799 1411
1800void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 1412void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
1801 QString &strAll ) 1413 QString &strAll )
1802{ 1414{
1803 int where, 1415 int where,
1804 start; 1416 start;
1805 if ( txt.isEmpty() ) 1417 if ( txt.isEmpty() )
1806 return; 1418 return;
1807 // find the first 1419 // find the first
1808 where = txt.find( ',' ); 1420 where = txt.find( ',' );
1809 if ( where < 0 ) { 1421 if ( where < 0 ) {
1810 strDefaultEmail = txt; 1422 strDefaultEmail = txt;
1811 strAll = txt; 1423 strAll = txt;
1812 } else { 1424 } else {
1813 strDefaultEmail = txt.left( where ).stripWhiteSpace(); 1425 strDefaultEmail = txt.left( where ).stripWhiteSpace();
1814 strAll = strDefaultEmail; 1426 strAll = strDefaultEmail;
1815 while ( where > -1 ) { 1427 while ( where > -1 ) {
1816 strAll.append(" "); 1428 strAll.append(" ");
1817 start = where; 1429 start = where;
1818 where = txt.find( ',', where + 1 ); 1430 where = txt.find( ',', where + 1 );
1819 if ( where > - 1 ) 1431 if ( where > - 1 )
1820 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); 1432 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
1821 else // grab until the end... 1433 else // grab until the end...
1822 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); 1434 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
1823 } 1435 }
1824 } 1436 }
1825} 1437}
1826 1438
1827void parseEmailTo( const QString &strDefaultEmail, 1439void parseEmailTo( const QString &strDefaultEmail,
1828 const QString &strOtherEmail, QString &strBack ) 1440 const QString &strOtherEmail, QString &strBack )
1829{ 1441{
1830 // create a comma dilimeted set of emails... 1442 // create a comma dilimeted set of emails...
1831 // use the power of short circuiting... 1443 // use the power of short circuiting...
1832 bool foundDefault = false; 1444 bool foundDefault = false;
1833 QString strTmp; 1445 QString strTmp;
1834 int start = 0; 1446 int start = 0;
1835 int where; 1447 int where;
1836 // start at the beginng. 1448 // start at the beginng.
1837 strBack = strDefaultEmail; 1449 strBack = strDefaultEmail;
1838 where = 0; 1450 where = 0;
1839 while ( where > -1 ) { 1451 while ( where > -1 ) {
1840 start = where; 1452 start = where;
1841 where = strOtherEmail.find( ' ', where + 1 ); 1453 where = strOtherEmail.find( ' ', where + 1 );
1842 if ( where > 0 ) { 1454 if ( where > 0 ) {
1843 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); 1455 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
1844 } else 1456 } else
1845 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); 1457 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
1846 if ( foundDefault || strTmp != strDefaultEmail ) { 1458 if ( foundDefault || strTmp != strDefaultEmail ) {
1847 strBack.append( ", " ); 1459 strBack.append( ", " );
1848 strBack.append( strTmp ); 1460 strBack.append( strTmp );
1849 } else 1461 } else
1850 foundDefault = true; 1462 foundDefault = true;
1851 } 1463 }
1852} 1464}
1853 1465
1854 1466
1855static inline bool containsAlphaNum( const QString &str ) 1467static inline bool containsAlphaNum( const QString &str )
1856{ 1468{
1857 int i, 1469 int i,
1858 count = str.length(); 1470 count = str.length();
1859 for ( i = 0; i < count; i++ ) 1471 for ( i = 0; i < count; i++ )
1860 if ( !str[i].isSpace() ) 1472 if ( !str[i].isSpace() )
1861 return TRUE; 1473 return TRUE;
1862 return FALSE; 1474 return FALSE;
1863} 1475}
1864 1476
1865static inline bool constainsWhiteSpace( const QString &str ) 1477static inline bool constainsWhiteSpace( const QString &str )
1866{ 1478{
1867 int i, 1479 int i,
1868 count = str.length(); 1480 count = str.length();
1869 for (i = 0; i < count; i++ ) 1481 for (i = 0; i < count; i++ )
1870 if ( str[i].isSpace() ) 1482 if ( str[i].isSpace() )
1871 return TRUE; 1483 return TRUE;
1872 return FALSE; 1484 return FALSE;
1873} 1485}
1874 1486
1875void ContactEditor::setPersonalView( bool personal ) 1487void ContactEditor::setPersonalView( bool personal )
1876{ 1488{
1877 m_personalView = personal; 1489 m_personalView = personal;
1490
1491 // Currently disbled due to the fact that
1492 // show will not work...
1493 return;
1494
1878 if ( personal ){ 1495 if ( personal ){
1879 cmbCat->hide(); 1496 cmbCat->hide();
1880 labCat->hide(); 1497 labCat->hide();
1498
1881 } else{ 1499 } else{
1882 cmbCat->show(); 1500 cmbCat->show();
1883 labCat->show(); 1501 labCat->show();
1884
1885 } 1502 }
1886} 1503}
1887 1504
1888void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) 1505void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
1889{ 1506{
1890 QDate date; 1507 QDate date;
1891 date.setYMD( year, month, day ); 1508 date.setYMD( year, month, day );
1892 QString dateString = TimeString::numberDateString( date ); 1509 QString dateString = TimeString::numberDateString( date );
1893 anniversaryButton->setText( dateString ); 1510 anniversaryButton->setText( dateString );
1894 ent.setAnniversary ( date ); 1511 ent.setAnniversary ( date );
1895} 1512}
1896 1513
1897void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) 1514void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
1898{ 1515{
1899 QDate date; 1516 QDate date;
1900 date.setYMD( year, month, day ); 1517 date.setYMD( year, month, day );
1901 QString dateString = TimeString::numberDateString( date ); 1518 QString dateString = TimeString::numberDateString( date );
1902 birthdayButton->setText( dateString ); 1519 birthdayButton->setText( dateString );
1903 ent.setBirthday ( date ); 1520 ent.setBirthday ( date );
1904} 1521}
1522
1523void ContactEditor::slotRemoveBirthday()
1524{
1525 qWarning("void ContactEditor::slotRemoveBirthday()");
1526 ent.setBirthday( QDate() );
1527 updateDatePicker();
1528}
1529
1530void ContactEditor::slotRemoveAnniversary()
1531{
1532 qWarning("void ContactEditor::slotRemoveAnniversary()");
1533 ent.setAnniversary( QDate() );
1534 updateDatePicker();
1535}
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index 40ce864..250b831 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -10,156 +10,156 @@
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 <opie/ocontact.h> 24#include <opie/ocontact.h>
25 25
26#include <qpe/datebookmonth.h> 26#include <qpe/datebookmonth.h>
27 27
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qlist.h> 29#include <qlist.h>
30#include <qmap.h> 30#include <qmap.h>
31#include <qstringlist.h> 31#include <qstringlist.h>
32 32
33const int NAME_LF = 0; 33const int NAME_LF = 0;
34const int NAME_LFM = 1; 34const int NAME_LFM = 1;
35const int NAME_FL = 2; 35const int NAME_FL = 2;
36const int NAME_FMLS = 3; 36const int NAME_FMLS = 3;
37 37
38const int NAME_F = 4; 38const int NAME_F = 4;
39const int NAME_M = 5; 39const int NAME_M = 5;
40const int NAME_L = 6; 40const int NAME_L = 6;
41const int NAME_S = 7; 41const int NAME_S = 7;
42 42
43 43
44class QScrollView; 44class QScrollView;
45class QTabWidget; 45class QTabWidget;
46class QMultiLineEdit; 46class QMultiLineEdit;
47class QLineEdit; 47class QLineEdit;
48class QComboBox; 48class QComboBox;
49class QPushButton; 49class QPushButton;
50class CategorySelect; 50class CategorySelect;
51class QLabel; 51class QLabel;
52 52
53class ContactEditor : public QDialog { 53class ContactEditor : public QDialog {
54 Q_OBJECT 54 Q_OBJECT
55 55
56 public: 56 public:
57 ContactEditor(const OContact &entry, 57 ContactEditor(const OContact &entry,
58 const QValueList<int> *newOrderedValues,
59 QStringList *slNewOrdered,
60 QWidget *parent = 0, 58 QWidget *parent = 0,
61 const char *name = 0, 59 const char *name = 0,
62 WFlags fl = 0 ); 60 WFlags fl = 0 );
63 ~ContactEditor(); 61 ~ContactEditor();
64 void loadFields();
65 void setNameFocus(); 62 void setNameFocus();
66 void setPersonalView( bool personal = true ); 63 void setPersonalView( bool personal = true );
67 OContact entry() const { return ent; } 64 OContact entry() const { return ent; }
68 65
69 public slots: 66 public slots:
70 void slotNote(); 67 void slotNote();
71 void slotName(); 68 void slotName();
72 void setEntry(const OContact &entry); 69 void setEntry(const OContact &entry);
73 70
74 protected slots: 71 protected slots:
75 void accept(); 72 void accept();
76 73
77 private: 74 private:
78 void init(); 75 void init();
79 void initMap();
80 void saveEntry(); 76 void saveEntry();
81 bool isEmpty(); 77 bool isEmpty();
82 void cleanupFields(); 78 void cleanupFields();
79 void updateDatePicker();
83 QString parseName( QString fullName, int type ); 80 QString parseName( QString fullName, int type );
84 private slots: 81 private slots:
85 void slotChooser1Change( const QString &textChanged ); 82 void slotChooser1Change( const QString &textChanged );
86 void slotChooser2Change( const QString &textChanged ); 83 void slotChooser2Change( const QString &textChanged );
87 void slotChooser3Change( const QString &textChanged ); 84 void slotChooser3Change( const QString &textChanged );
88 void slotChooser4Change( const QString &textChanged ); 85 void slotChooser4Change( const QString &textChanged );
89 void slotCmbChooser1Change( int index ); 86 void slotCmbChooser1Change( int index );
90 void slotCmbChooser2Change( int index ); 87 void slotCmbChooser2Change( int index );
91 void slotCmbChooser3Change( int index ); 88 void slotCmbChooser3Change( int index );
92 void slotCmbChooser4Change( int index ); 89 void slotCmbChooser4Change( int index );
93 void slotAddressTypeChange( int index ); 90 void slotAddressTypeChange( int index );
94 void slotAddressChange( const QString &textChanged ); 91 void slotAddressChange( const QString &textChanged );
95 void slotAddress2Change( const QString &textChanged ); 92 void slotAddress2Change( const QString &textChanged );
96 void slotPOBoxChange( const QString &textChanged ); 93 void slotPOBoxChange( const QString &textChanged );
97 void slotCityChange( const QString &textChanged ); 94 void slotCityChange( const QString &textChanged );
98 void slotStateChange( const QString &textChanged ); 95 void slotStateChange( const QString &textChanged );
99 void slotZipChange( const QString &textChanged ); 96 void slotZipChange( const QString &textChanged );
100 void slotCountryChange( const QString &textChanged ); 97 void slotCountryChange( const QString &textChanged );
101 void slotFullNameChange( const QString &textChanged ); 98 void slotFullNameChange( const QString &textChanged );
102 void slotAnniversaryDateChanged( int year, int month, int day); 99 void slotAnniversaryDateChanged( int year, int month, int day);
103 void slotBirthdayDateChanged( int year, int month, int day); 100 void slotBirthdayDateChanged( int year, int month, int day);
101 void slotRemoveBirthday();
102 void slotRemoveAnniversary();
104 103
105 private: 104 private:
106 bool useFullName, hasGender, hasTitle, hasCompany, hasNotes, hasStreet, hasStreet2, hasPOBox, hasCity, hasState, hasZip, hasCountry; 105 bool useFullName;
106 // bool hasGender, hasTitle, hasCompany, hasNotes, hasStreet, hasStreet2, hasPOBox, hasCity, hasState, hasZip, hasCountry;
107 107
108 OContact ent; 108 OContact ent;
109 109
110 QDialog *dlgNote; 110 QDialog *dlgNote;
111 QDialog *dlgName; 111 QDialog *dlgName;
112 112
113 QList<QLineEdit> listValue; 113 QList<QLineEdit> listValue;
114 QList<QLabel> listName; 114 QList<QLabel> listName;
115 const QValueList<int> *orderedValues; 115
116 QStringList slOrdered;
117 QStringList slDynamicEntries; 116 QStringList slDynamicEntries;
117 QStringList trlDynamicEntries;
118 118
119 bool m_personalView; 119 bool m_personalView;
120 120
121 QStringList slHomeAddress; 121 QStringList slHomeAddress;
122 QStringList slBusinessAddress; 122 QStringList slBusinessAddress;
123 QStringList slChooserNames; 123 QStringList slChooserNames;
124 QStringList slChooserValues; 124 QStringList slChooserValues;
125 125
126 QMultiLineEdit *txtNote; 126 QMultiLineEdit *txtNote;
127 QLabel *lblNote; 127 QLabel *lblNote;
128 128
129 //QLineEdit *txtTitle; 129 //QLineEdit *txtTitle;
130 QLineEdit *txtFirstName; 130 QLineEdit *txtFirstName;
131 QLineEdit *txtMiddleName; 131 QLineEdit *txtMiddleName;
132 QLineEdit *txtLastName; 132 QLineEdit *txtLastName;
133 QLineEdit *txtSuffix; 133 QLineEdit *txtSuffix;
134 134
135 QTabWidget *tabMain; 135 QTabWidget *tabMain;
136 QScrollView *svGeneral; 136 QScrollView *svGeneral;
137 QPushButton *btnFullName; 137 QPushButton *btnFullName;
138 QPushButton *btnNote; 138 QPushButton *btnNote;
139 QLineEdit *txtFullName; 139 QLineEdit *txtFullName;
140 QLineEdit *txtJobTitle; 140 QLineEdit *txtJobTitle;
141 QLineEdit *txtOrganization; 141 QLineEdit *txtOrganization;
142 QLineEdit *txtChooserField1; 142 QLineEdit *txtChooserField1;
143 QLineEdit *txtChooserField2; 143 QLineEdit *txtChooserField2;
144 QLineEdit *txtChooserField3; 144 QLineEdit *txtChooserField3;
145 QLineEdit *txtChooserField4; 145 QLineEdit *txtChooserField4;
146 QComboBox *cmbChooserField1; 146 QComboBox *cmbChooserField1;
147 QComboBox *cmbChooserField2; 147 QComboBox *cmbChooserField2;
148 QComboBox *cmbChooserField3; 148 QComboBox *cmbChooserField3;
149 QComboBox *cmbChooserField4; 149 QComboBox *cmbChooserField4;
150 QComboBox *cmbFileAs; 150 QComboBox *cmbFileAs;
151 CategorySelect *cmbCat; 151 CategorySelect *cmbCat;
152 QLabel *labCat; 152 QLabel *labCat;
153 153
154 QScrollView *svAddress; 154 QScrollView *svAddress;
155 QLineEdit *txtAddress; 155 QLineEdit *txtAddress;
156 //QLineEdit *txtAddress2; 156 //QLineEdit *txtAddress2;
157 //QLineEdit *txtPOBox; 157 //QLineEdit *txtPOBox;
158 QLineEdit *txtCity; 158 QLineEdit *txtCity;
159 QLineEdit *txtState; 159 QLineEdit *txtState;
160 QLineEdit *txtZip; 160 QLineEdit *txtZip;
161 QComboBox *cmbAddress; 161 QComboBox *cmbAddress;
162 QComboBox *cmbCountry; 162 QComboBox *cmbCountry;
163 163
164 QScrollView *svDetails; 164 QScrollView *svDetails;
165 QComboBox *cmbGender; 165 QComboBox *cmbGender;
diff --git a/core/pim/addressbook/ocontactfields.cpp b/core/pim/addressbook/ocontactfields.cpp
new file mode 100644
index 0000000..7823a9c
--- a/dev/null
+++ b/core/pim/addressbook/ocontactfields.cpp
@@ -0,0 +1,283 @@
1
2#include "ocontactfields.h"
3
4#include <qstringlist.h>
5#include <qobject.h>
6
7// We should use our own enum in the future ..
8#include <qpe/recordfields.h>
9
10/*!
11 \internal
12 Returns a list of details field names for a contact.
13*/
14QStringList OContactFields::untrdetailsfields( bool sorted )
15{
16 QStringList list;
17
18 list.append( "Office" );
19 list.append( "Profession" );
20 list.append( "Assistant" );
21 list.append( "Manager" );
22 list.append( "Spouse" );
23 list.append( "Gender" );
24 list.append( "Birthday" );
25 list.append( "Anniversary" );
26 list.append( "Nickname" );
27 list.append( "Children" );
28
29 if (sorted) list.sort();
30
31 return list;
32}
33
34/*!
35 \internal
36 Returns a translated list of phone field names for a contact.
37*/
38QStringList OContactFields::trphonefields( bool sorted )
39{
40 QStringList list;
41 list.append( QObject::tr( "Business Phone" ) );
42 list.append( QObject::tr( "Business Fax" ) );
43 list.append( QObject::tr( "Business Mobile" ) );
44
45 list.append( QObject::tr( "Default Email" ) );
46 list.append( QObject::tr( "Emails" ) );
47
48 list.append( QObject::tr( "Home Phone" ) );
49 list.append( QObject::tr( "Home Fax" ) );
50 list.append( QObject::tr( "Home Mobile" ) );
51
52 if (sorted) list.sort();
53
54 return list;
55}
56
57
58/*!
59 \internal
60 Returns a translated list of details field names for a contact.
61*/
62QStringList OContactFields::trdetailsfields( bool sorted )
63{
64 QStringList list;
65
66 list.append( QObject::tr( "Office" ) );
67 list.append( QObject::tr( "Profession" ) );
68 list.append( QObject::tr( "Assistant" ) );
69 list.append( QObject::tr( "Manager" ) );
70
71 list.append( QObject::tr( "Spouse" ) );
72 list.append( QObject::tr( "Gender" ) );
73 list.append( QObject::tr( "Birthday" ) );
74 list.append( QObject::tr( "Anniversary" ) );
75 list.append( QObject::tr( "Nickname" ) );
76 list.append( QObject::tr( "Children" ) );
77
78 if (sorted) list.sort();
79 return list;
80}
81
82
83/*!
84 \internal
85 Returns a translated list of field names for a contact.
86*/
87QStringList OContactFields::trfields( bool sorted )
88{
89 QStringList list;
90
91 list.append( QObject::tr( "Name Title") );
92 list.append( QObject::tr( "First Name" ) );
93 list.append( QObject::tr( "Middle Name" ) );
94 list.append( QObject::tr( "Last Name" ) );
95 list.append( QObject::tr( "Suffix" ) );
96 list.append( QObject::tr( "File As" ) );
97
98 list.append( QObject::tr( "Job Title" ) );
99 list.append( QObject::tr( "Department" ) );
100 list.append( QObject::tr( "Company" ) );
101
102 list += trphonefields( sorted );
103
104 list.append( QObject::tr( "Business Street" ) );
105 list.append( QObject::tr( "Business City" ) );
106 list.append( QObject::tr( "Business State" ) );
107 list.append( QObject::tr( "Business Zip" ) );
108 list.append( QObject::tr( "Business Country" ) );
109 list.append( QObject::tr( "Business Pager" ) );
110 list.append( QObject::tr( "Business WebPage" ) );
111
112 list.append( QObject::tr( "Home Street" ) );
113 list.append( QObject::tr( "Home City" ) );
114 list.append( QObject::tr( "Home State" ) );
115 list.append( QObject::tr( "Home Zip" ) );
116 list.append( QObject::tr( "Home Country" ) );
117 list.append( QObject::tr( "Home Web Page" ) );
118
119 list += trdetailsfields( sorted );
120
121 list.append( QObject::tr( "Notes" ) );
122 list.append( QObject::tr( "Groups" ) );
123
124 if (sorted) list.sort();
125
126 return list;
127}
128
129/*!
130 \internal
131 Returns a list of phone field names for a contact.
132*/
133QStringList OContactFields::untrphonefields( bool sorted )
134{
135 QStringList list;
136
137 list.append( "Business Phone" );
138 list.append( "Business Fax" );
139 list.append( "Business Mobile" );
140
141 list.append( "Default Email" );
142 list.append( "Emails" );
143
144 list.append( "Home Phone" );
145 list.append( "Home Fax" );
146 list.append( "Home Mobile" );
147
148 if (sorted) list.sort();
149
150 return list;
151}
152
153/*!
154 \internal
155 Returns an untranslated list of field names for a contact.
156*/
157QStringList OContactFields::untrfields( bool sorted )
158{
159 QStringList list;
160
161 list.append( "Name Title" );
162 list.append( "First Name" );
163 list.append( "Middle Name" );
164 list.append( "Last Name" );
165 list.append( "Suffix" );
166 list.append( "File As" );
167
168 list.append( "Job Title" );
169 list.append( "Department" );
170 list.append( "Company" );
171
172 list += untrphonefields( sorted );
173
174 list.append( "Business Street" );
175 list.append( "Business City" );
176 list.append( "Business State" );
177 list.append( "Business Zip" );
178 list.append( "Business Country" );
179 list.append( "Business Pager" );
180 list.append( "Business WebPage" );
181
182 list.append( "Office" );
183 list.append( "Profession" );
184 list.append( "Assistant" );
185 list.append( "Manager" );
186
187 list.append( "Home Street" );
188 list.append( "Home City" );
189 list.append( "Home State" );
190 list.append( "Home Zip" );
191 list.append( "Home Country" );
192 list.append( "Home Web Page" );
193
194 list.append( "Spouse" );
195 list.append( "Gender" );
196 list.append( "Birthday" );
197 list.append( "Anniversary" );
198 list.append( "Nickname" );
199 list.append( "Children" );
200
201 list.append( "Notes" );
202 list.append( "Groups" );
203
204 if (sorted) list.sort();
205
206 return list;
207}
208QMap<int, QString> OContactFields::idToTrFields()
209{
210 QMap<int, QString> ret_map;
211
212 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") );
213 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
214 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
215 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
216 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ));
217 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) );
218
219 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) );
220 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) );
221 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) );
222 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) );
223 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) );
224 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ));
225
226 // email
227 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) );
228 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) );
229
230 ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) );
231 ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) );
232 ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) );
233
234 // business
235 ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) );
236 ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) );
237 ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) );
238 ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) );
239 ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) );
240 ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) );
241 ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) );
242
243 ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) );
244 ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) );
245 ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) );
246 ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) );
247
248 // home
249 ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) );
250 ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) );
251 ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) );
252 ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) );
253 ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) );
254 ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) );
255
256 //personal
257 ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) );
258 ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) );
259 ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) );
260 ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) );
261 ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) );
262 ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) );
263
264 // other
265 ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) );
266
267
268 return ret_map;
269}
270
271QMap<QString, int> OContactFields::trFieldsToId()
272{
273 QMap<int, QString> idtostr = idToTrFields();
274 QMap<QString, int> ret_map;
275
276
277 QMap<int, QString>::Iterator it;
278 for( it = idtostr.begin(); it != idtostr.end(); ++it )
279 ret_map.insert( *it, it.key() );
280
281
282 return ret_map;
283}
diff --git a/core/pim/addressbook/ocontactfields.h b/core/pim/addressbook/ocontactfields.h
new file mode 100644
index 0000000..796bc0a
--- a/dev/null
+++ b/core/pim/addressbook/ocontactfields.h
@@ -0,0 +1,24 @@
1#ifndef OPIE_CONTACTS_FIELDS
2#define OPIE_CONTACTS_FIELDS
3
4class QStringList;
5
6#include <qmap.h>
7#include <qstring.h>
8
9class OContactFields{
10
11 public:
12 static QStringList trphonefields( bool sorted = true );
13 static QStringList untrphonefields( bool sorted = true );
14 static QStringList trdetailsfields( bool sorted = true );
15 static QStringList untrdetailsfields( bool sorted = true );
16 static QStringList trfields( bool sorted = true );
17 static QStringList untrfields( bool sorted = true );
18
19 static QMap<int, QString> idToTrFields();
20 static QMap<QString, int> trFieldsToId();
21
22};
23
24#endif
diff --git a/core/pim/addressbook/opie-addressbook.control b/core/pim/addressbook/opie-addressbook.control
index f73ea4a..48542e7 100644
--- a/core/pim/addressbook/opie-addressbook.control
+++ b/core/pim/addressbook/opie-addressbook.control
@@ -1,10 +1,10 @@
1Files: bin/addressbook apps/1Pim/addressbook.desktop 1Files: bin/addressbook apps/1Pim/addressbook.desktop
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Conflicts: qpe-tkcaddressbook 4Conflicts: qpe-tkcaddressbook
5Maintainer: Stefan Eilers <eilers.stefan@epost.de> 5Maintainer: Stefan Eilers <eilers.stefan@epost.de>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Version: $QPE_VERSION-$SUB_VERSION
8Depends: opie-base ($QPE_VERSION) libopie 8Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION)
9Description: Contacts 9Description: Contacts
10 A simple addressbook for the Opie environment. 10 A simple addressbook for the Opie environment.
diff --git a/core/pim/addressbook/picker.cpp b/core/pim/addressbook/picker.cpp
index 2c7dd71..5099d68 100644
--- a/core/pim/addressbook/picker.cpp
+++ b/core/pim/addressbook/picker.cpp
@@ -173,67 +173,72 @@ LetterPicker::LetterPicker( QWidget *parent, const char *name )
173 173
174 lblPQR = new PickerLabel( this ); 174 lblPQR = new PickerLabel( this );
175 l->addWidget( lblPQR ); 175 l->addWidget( lblPQR );
176 176
177 lblSTU = new PickerLabel( this ); 177 lblSTU = new PickerLabel( this );
178 l->addWidget( lblSTU ); 178 l->addWidget( lblSTU );
179 179
180 lblVWX = new PickerLabel( this ); 180 lblVWX = new PickerLabel( this );
181 l->addWidget( lblVWX ); 181 l->addWidget( lblVWX );
182 182
183 lblYZ = new PickerLabel( this ); 183 lblYZ = new PickerLabel( this );
184 l->addWidget( lblYZ ); 184 l->addWidget( lblYZ );
185 185
186 lblABC->setLetters( 'A', 'B', 'C' ); 186 lblABC->setLetters( 'A', 'B', 'C' );
187 lblDEF->setLetters( 'D', 'E', 'F' ); 187 lblDEF->setLetters( 'D', 'E', 'F' );
188 lblGHI->setLetters( 'G', 'H', 'I' ); 188 lblGHI->setLetters( 'G', 'H', 'I' );
189 lblJKL->setLetters( 'J', 'K', 'L' ); 189 lblJKL->setLetters( 'J', 'K', 'L' );
190 lblMNO->setLetters( 'M', 'N', 'O' ); 190 lblMNO->setLetters( 'M', 'N', 'O' );
191 lblPQR->setLetters( 'P', 'Q', 'R' ); 191 lblPQR->setLetters( 'P', 'Q', 'R' );
192 lblSTU->setLetters( 'S', 'T', 'U' ); 192 lblSTU->setLetters( 'S', 'T', 'U' );
193 lblVWX->setLetters( 'V', 'W', 'X' ); 193 lblVWX->setLetters( 'V', 'W', 'X' );
194 lblYZ->setLetters( 'Y', 'Z', '#' ); 194 lblYZ->setLetters( 'Y', 'Z', '#' );
195 195
196 connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 196 connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
197 connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 197 connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
198 connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 198 connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
199 connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 199 connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
200 connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 200 connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
201 connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 201 connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
202 connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 202 connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
203 connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 203 connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
204 connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 204 connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
205 connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear())); 205 connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear()));
206 connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear())); 206 connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear()));
207 connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear())); 207 connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear()));
208 connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear())); 208 connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear()));
209 connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear())); 209 connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear()));
210 connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear())); 210 connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear()));
211 connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear())); 211 connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear()));
212 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear())); 212 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear()));
213 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear())); 213 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear()));
214 214
215} 215}
216 216
217LetterPicker::~LetterPicker() 217LetterPicker::~LetterPicker()
218{ 218{
219} 219}
220 220
221QSizePolicy LetterPicker::sizePolicy () const
222{
223 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum);
224}
225
221void LetterPicker::clear() 226void LetterPicker::clear()
222{ 227{
223 lblABC->clearLetter(); 228 lblABC->clearLetter();
224 lblDEF->clearLetter(); 229 lblDEF->clearLetter();
225 lblGHI->clearLetter(); 230 lblGHI->clearLetter();
226 lblJKL->clearLetter(); 231 lblJKL->clearLetter();
227 lblMNO->clearLetter(); 232 lblMNO->clearLetter();
228 lblPQR->clearLetter(); 233 lblPQR->clearLetter();
229 lblSTU->clearLetter(); 234 lblSTU->clearLetter();
230 lblVWX->clearLetter(); 235 lblVWX->clearLetter();
231 lblYZ->clearLetter(); 236 lblYZ->clearLetter();
232} 237}
233 238
234void LetterPicker::newLetter( char letter ) 239void LetterPicker::newLetter( char letter )
235{ 240{
236 qWarning("LetterClicked"); 241 qWarning("LetterClicked");
237 emit letterClicked( letter ); 242 emit letterClicked( letter );
238 243
239} 244}
diff --git a/core/pim/addressbook/picker.h b/core/pim/addressbook/picker.h
index d76d582..d268983 100644
--- a/core/pim/addressbook/picker.h
+++ b/core/pim/addressbook/picker.h
@@ -1,68 +1,70 @@
1/* 1/*
2 * Letter Chooser Widget. 2 * Letter Chooser Widget.
3 * 3 *
4 * (c) 2002 Mike Crawford 4 * (c) 2002 Mike Crawford
5 * 5 *
6 * This file is FREE SOFTWARE covered under the GUN General Public License. 6 * This file is FREE SOFTWARE covered under the GUN General Public License.
7 * 7 *
8 * 8 *
9*/ 9*/
10#ifndef PICKER_H 10#ifndef PICKER_H
11#define PICKER_H 11#define PICKER_H
12 12
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qframe.h> 14#include <qframe.h>
15#include <qevent.h> 15#include <qevent.h>
16#include <qsizepolicy.h>
16 17
17class PickerLabel: public QLabel { 18class PickerLabel: public QLabel {
18Q_OBJECT 19Q_OBJECT
19 public: 20 public:
20 PickerLabel( QWidget *parent = 0, const char *name = 0 ); 21 PickerLabel( QWidget *parent = 0, const char *name = 0 );
21 ~PickerLabel(); 22 ~PickerLabel();
22 23
23 void setLetters( char ch1, char ch2, char ch3 ); 24 void setLetters( char ch1, char ch2, char ch3 );
24 void clearLetter(); 25 void clearLetter();
25 26
26 signals: 27 signals:
27 28
28 void selectedLetter( char ); 29 void selectedLetter( char );
29 void clearAll(); 30 void clearAll();
30 31
31 protected: 32 protected:
32 33
33 void mouseReleaseEvent( QMouseEvent *e ); 34 void mouseReleaseEvent( QMouseEvent *e );
34 void mousePressEvent( QMouseEvent *e ); 35 void mousePressEvent( QMouseEvent *e );
35 36
36 private: 37 private:
37 38
38 int currentLetter; 39 int currentLetter;
39 static char lastLetter; 40 static char lastLetter;
40 char letter1, letter2, letter3; 41 char letter1, letter2, letter3;
41 42
42 private slots: 43 private slots:
43 44
44 void emitClearSignal(); 45 void emitClearSignal();
45 46
46}; 47};
47class LetterPicker: public QFrame { 48class LetterPicker: public QFrame {
48Q_OBJECT 49Q_OBJECT
49 public: 50 public:
50 LetterPicker( QWidget *parent = 0, const char *name = 0 ); 51 LetterPicker( QWidget *parent = 0, const char *name = 0 );
51 ~LetterPicker(); 52 ~LetterPicker();
52 53
54 QSizePolicy sizePolicy () const;
53 55
54 public slots: 56 public slots:
55 void clear(); 57 void clear();
56 58
57 signals: 59 signals:
58 void letterClicked( char ); 60 void letterClicked( char );
59 61
60 private: 62 private:
61 PickerLabel *lblABC, *lblDEF, *lblGHI, *lblJKL, *lblMNO, *lblPQR, *lblSTU, *lblVWX, *lblYZ; 63 PickerLabel *lblABC, *lblDEF, *lblGHI, *lblJKL, *lblMNO, *lblPQR, *lblSTU, *lblVWX, *lblYZ;
62 PickerLabel *lastLabel; 64 PickerLabel *lastLabel;
63 65
64 private slots: 66 private slots:
65 void newLetter( char letter ); 67 void newLetter( char letter );
66}; 68};
67 69
68#endif 70#endif
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h
new file mode 100644
index 0000000..d96f857
--- a/dev/null
+++ b/core/pim/addressbook/version.h
@@ -0,0 +1,10 @@
1#ifndef _VERSION_H_
2#define _VERSION_H_
3
4#define MAINVERSION "0"
5#define SUBVERSION "1"
6#define PATCHVERSION "0"
7
8#define APPNAME "OPIE_ADDRESSBOOK"
9
10#endif