summaryrefslogtreecommitdiff
path: root/core/pim
Unidiff
Diffstat (limited to 'core/pim') (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,12 +1,33 @@
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
@@ -14,23 +35,24 @@ Urgent:
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
@@ -38,2 +60,3 @@ Should be Fixed (not absolute sure, need further validation):
38Fixed: 60Fixed:
61-------
39- Syncing: abtable not reloaded after sync. 62- Syncing: abtable not reloaded after sync.
@@ -52 +75,19 @@ Fixed:
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
@@ -27,4 +27,5 @@
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{
@@ -36,10 +37,44 @@ AbLabel::~AbLabel()
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 );
@@ -50,38 +85,28 @@ void AbLabel::keyPressEvent( QKeyEvent *e )
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;
@@ -89,2 +114,3 @@ void AbLabel::keyPressEvent( QKeyEvent *e )
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
@@ -25,2 +25,4 @@
25 25
26#include <opie/ocontactaccess.h>
27
26class AbLabel : public QTextView 28class AbLabel : public QTextView
@@ -33,10 +35,19 @@ public:
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 * );
@@ -44,3 +55,6 @@ protected:
44private: 55private:
45 OContact ent; 56 OContactAccess::List m_viewList;
57 OContactAccess::List::Iterator m_itCurContact;
58
59 bool m_empty;
46 60
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
@@ -2,2 +2,3 @@
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**
@@ -20,3 +21,2 @@
20 21
21#define QTOPIA_INTERNAL_CONTACT_MRE
22 22
@@ -45,5 +45,2 @@
45 45
46static bool contactCompare( const OContact &cnt, const QRegExp &r, int category );
47
48
49/*! 46/*!
@@ -122,17 +119,12 @@ void AbPickItem::setContentFromEditor( QWidget *w )
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 );
@@ -142,2 +134,5 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam
142 this, SLOT(itemClicked(int,int)) ); 134 this, SLOT(itemClicked(int,int)) );
135
136 contactList.clear();
137 qWarning("C'tor end");
143} 138}
@@ -150,3 +145,3 @@ void AbTable::init()
150{ 145{
151 showChar = '\0'; 146 // :SX showChar = '\0';
152 setNumRows( 0 ); 147 setNumRows( 0 );
@@ -161,2 +156,78 @@ void AbTable::init()
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 )
@@ -181,2 +252,3 @@ void AbTable::resort()
181{ 252{
253 qWarning( "void AbTable::resort()" );
182 if ( sorting() ) { 254 if ( sorting() ) {
@@ -192,2 +264,3 @@ OContact AbTable::currentEntry()
192{ 264{
265 qWarning( "OContact AbTable::currentEntry()" );
193 OContact cnt; 266 OContact cnt;
@@ -202,23 +275,5 @@ OContact AbTable::currentEntry()
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}
@@ -227,2 +282,3 @@ void AbTable::clear()
227{ 282{
283 qWarning( "void AbTable::clear()" );
228 contactList.clear(); 284 contactList.clear();
@@ -238,4 +294,6 @@ void AbTable::clear()
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();
@@ -243,8 +301,3 @@ void AbTable::refresh()
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 ) {
@@ -264,37 +317,21 @@ void AbTable::keyPressEvent( QKeyEvent *e )
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}
@@ -303,2 +340,3 @@ void AbTable::moveTo( char c )
303{ 340{
341 qWarning( "void AbTable::moveTo( char c )" );
304 342
@@ -348,141 +386,3 @@ QString AbTable::findContactName( const OContact &entry )
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
@@ -500,133 +400,17 @@ void AbTable::resizeRows() {
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
@@ -664,117 +448,22 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
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}
@@ -783,3 +472,4 @@ void AbTable::show()
783{ 472{
784 fitColumns(); 473 qWarning( "void AbTable::show()" );
474 realignTable();
785 QTable::show(); 475 QTable::show();
@@ -804,2 +494,3 @@ void AbTable::itemClicked(int,int col)
804{ 494{
495 qWarning( "AbTable::itemClicked(int, col:%d)", col);
805 if ( col == 2 ) { 496 if ( col == 2 ) {
@@ -807,3 +498,4 @@ void AbTable::itemClicked(int,int col)
807 } else { 498 } else {
808 emit details(); 499 qWarning ("Emitting signalSwitch()");
500 emit signalSwitch();
809 } 501 }
@@ -816,20 +508,5 @@ QStringList AbTable::choiceNames() const
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}
@@ -853,35 +530,4 @@ QStringList AbTable::choiceSelection(int /*index*/) const
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
@@ -891,142 +537,25 @@ void AbTable::updateVisible()
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 )
@@ -1035,2 +564,4 @@ void AbTable::updateVisible()
1035 setPaintingEnabled( TRUE ); 564 setPaintingEnabled( TRUE );
565
566
1036} 567}
@@ -1056 +587,126 @@ void AbTable::rowHeightChanged( int 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
@@ -2,2 +2,3 @@
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**
@@ -25,2 +26,3 @@
25#include <opie/ocontact.h> 26#include <opie/ocontact.h>
27#include <opie/ocontactaccess.h>
26 28
@@ -31,4 +33,2 @@
31 33
32#include <opie/ocontactaccess.h>
33
34class AbTableItem : public QTableItem 34class AbTableItem : public QTableItem
@@ -65,31 +65,21 @@ class AbTable : public QTable
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
@@ -98,17 +88,13 @@ public:
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
@@ -129,31 +115,20 @@ protected slots:
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
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
@@ -2,2 +2,9 @@
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
@@ -5,5 +12,11 @@ extern 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),
@@ -11,3 +24,4 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL
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 ),
@@ -15,8 +29,10 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL
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() );
@@ -30,3 +46,3 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL
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 );
@@ -51,2 +67,14 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL
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 )
@@ -61,3 +89,3 @@ void AbView::addEntry( const OContact &newContact )
61 qWarning("abview:AddContact"); 89 qWarning("abview:AddContact");
62 m_contactdb.add ( newContact ); 90 m_contactdb->add ( newContact );
63 load(); 91 load();
@@ -68,3 +96,3 @@ void AbView::removeEntry( const int UID )
68 qWarning("abview:RemoveContact"); 96 qWarning("abview:RemoveContact");
69 m_contactdb.remove( UID ); 97 m_contactdb->remove( UID );
70 load(); 98 load();
@@ -75,3 +103,3 @@ void AbView::replaceEntry( const OContact &contact )
75 qWarning("abview:ReplaceContact"); 103 qWarning("abview:ReplaceContact");
76 m_contactdb.replace( contact ); 104 m_contactdb->replace( contact );
77 load(); 105 load();
@@ -97,6 +125,5 @@ bool AbView::save()
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()
@@ -105,5 +132,11 @@ void AbView::load()
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
@@ -117,3 +150,5 @@ void AbView::reload()
117{ 150{
118 m_contactdb.reload(); 151 qWarning( "void AbView::reload()" );
152
153 m_contactdb->reload();
119 load(); 154 load();
@@ -129,14 +164,39 @@ void AbView::setShowByCategory( Views view, const QString& cat )
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
@@ -152,3 +212,3 @@ void AbView::setShowByLetter( char c )
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();
@@ -159,2 +219,9 @@ void AbView::setShowByLetter( char c )
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
@@ -164,6 +231,40 @@ QString AbView::showCategory() const
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}
@@ -182,4 +283,7 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
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;
@@ -199,3 +303,3 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
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
@@ -247,5 +351,6 @@ void AbView::clearForCategory()
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 ) ){
@@ -253,3 +358,2 @@ void AbView::clearForCategory()
253 m_list.remove( (*it).uid() ); 358 m_list.remove( (*it).uid() );
254 it = m_list.begin();
255 } 359 }
@@ -257,2 +361,3 @@ void AbView::clearForCategory()
257 } 361 }
362
258} 363}
@@ -270,3 +375,4 @@ bool AbView::contactCompare( const OContact &cnt, int category )
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;
@@ -286,2 +392,9 @@ bool AbView::contactCompare( const OContact &cnt, int category )
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()
@@ -295,3 +408,3 @@ void AbView::updateView()
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 ) {
@@ -304,3 +417,5 @@ void AbView::updateView()
304 } 417 }
305 } 418 emit signalViewSwitched ( (int) m_curr_View );
419 }else
420 m_curr_Contact = 0;
306 421
@@ -311,2 +426,3 @@ void AbView::updateView()
311 case TableView: 426 case TableView:
427 m_abTable -> setChoiceSelection( m_orderedFields );
312 m_abTable -> setContacts( m_list ); 428 m_abTable -> setContacts( m_list );
@@ -315,3 +431,2 @@ void AbView::updateView()
315 m_abTable -> setFocus(); 431 m_abTable -> setFocus();
316 emit signalViewSwitched ( (int) m_curr_View );
317 break; 432 break;
@@ -322,3 +437,2 @@ void AbView::updateView()
322 m_ablabel -> setFocus(); 437 m_ablabel -> setFocus();
323 emit signalViewSwitched ( (int) m_curr_View );
324 break; 438 break;
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
@@ -19,5 +19,6 @@ class AbView: public QWidget
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
@@ -29,5 +30,7 @@ public:
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
@@ -55,2 +58,3 @@ public slots:
55private: 58private:
59 void updateListinViews();
56 void updateView(); 60 void updateView();
@@ -63,2 +67,3 @@ private:
63 bool m_inSearch; 67 bool m_inSearch;
68 bool m_inPersonal;
64 int m_curr_category; 69 int m_curr_category;
@@ -68,3 +73,4 @@ private:
68 73
69 OContactAccess m_contactdb; 74 OContactAccess* m_contactdb;
75 OContactAccess* m_storedDB;
70 OContactAccess::List m_list; 76 OContactAccess::List m_list;
@@ -76,3 +82,2 @@ private:
76 QValueList<int> m_orderedFields; 82 QValueList<int> m_orderedFields;
77 QStringList m_slOrderedFields;
78}; 83};
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
@@ -24,4 +24,5 @@
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"
@@ -31,7 +32,5 @@
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>
@@ -40,2 +39,8 @@
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
@@ -47,3 +52,2 @@
47#include <qlayout.h> 52#include <qlayout.h>
48#include <qpe/qpemenubar.h>
49#include <qmessagebox.h> 53#include <qmessagebox.h>
@@ -51,3 +55,2 @@
51#include <qpopupmenu.h> 55#include <qpopupmenu.h>
52#include <qpe/qpetoolbar.h>
53#include <qstringlist.h> 56#include <qstringlist.h>
@@ -55,2 +58,3 @@
55#include <qwhatsthis.h> 58#include <qwhatsthis.h>
59#include <qdatetime.h>
56 60
@@ -62,3 +66,2 @@
62 66
63#include <qdatetime.h>
64 67
@@ -67,9 +70,3 @@
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
@@ -78,10 +75,7 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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{
@@ -89,34 +83,38 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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,
@@ -163,4 +161,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 );
@@ -169,4 +169,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 );
@@ -185,4 +185,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
185 185
186
187
188 if ( Ir::supported() ) { 186 if ( Ir::supported() ) {
@@ -198,3 +196,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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;
@@ -210,7 +208,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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
@@ -230,25 +223,23 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 );
@@ -257,19 +248,8 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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);
@@ -278,3 +258,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
278 258
279 abList->setCurrentCell( 0, 0 );
280 259
@@ -287,7 +266,3 @@ void AddressbookWindow::slotConfig()
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();
@@ -295,7 +270,9 @@ void AddressbookWindow::slotConfig()
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 }
@@ -306,3 +283,5 @@ void AddressbookWindow::slotConfig()
306 283
307void AddressbookWindow::slotSetFont( int size ) { 284void AddressbookWindow::slotSetFont( int size )
285{
286 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
308 287
@@ -311,3 +290,3 @@ void AddressbookWindow::slotSetFont( int size ) {
311 290
312 startFontSize = size; 291 m_config.setFontSize( size );
313 292
@@ -317,27 +296,18 @@ void AddressbookWindow::slotSetFont( int 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;
@@ -350,4 +320,5 @@ void 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
@@ -357,15 +328,36 @@ void 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}
@@ -376,6 +368,3 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e )
376 368
377 if ( centralWidget() == listContainer ) 369
378 showList();
379 else if ( centralWidget() == mView )
380 showView();
381} 370}
@@ -384,13 +373,8 @@ AddressbookWindow::~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}
@@ -399,3 +383,3 @@ void 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() );
@@ -403,34 +387,2 @@ void AddressbookWindow::slotUpdateToolbar()
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()
@@ -439,5 +391,2 @@ void AddressbookWindow::slotListNew()
439 if( !syncing ) { 391 if( !syncing ) {
440 if ( abEditor )
441 abEditor->setEntry( cnt );
442 abView()->init( cnt );
443 editEntry( NewEntry ); 392 editEntry( NewEntry );
@@ -449,8 +398,8 @@ void AddressbookWindow::slotListNew()
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
@@ -459,3 +408,3 @@ void AddressbookWindow::slotListDelete()
459 if(!syncing) { 408 if(!syncing) {
460 OContact tmpEntry = abList->currentEntry(); 409 OContact tmpEntry = m_abView ->currentEntry();
461 410
@@ -472,4 +421,3 @@ void AddressbookWindow::slotListDelete()
472 strName ) ) { 421 strName ) ) {
473 abList->deleteCurrentEntry(); 422 m_abView->removeEntry( tmpEntry.uid() );
474 showList();
475 } 423 }
@@ -481,5 +429,28 @@ void AddressbookWindow::slotListDelete()
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}
@@ -492,4 +463,2 @@ void AddressbookWindow::slotViewEdit()
492 } else { 463 } else {
493 if ( !bAbEditFirstTime )
494 abEditor->setEntry( abList->currentEntry() );
495 editEntry( EditEntry ); 464 editEntry( EditEntry );
@@ -506,3 +475,3 @@ void 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();
@@ -518,3 +487,3 @@ void AddressbookWindow::writeMail()
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());
@@ -526,5 +495,5 @@ void AddressbookWindow::writeMail()
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());
@@ -536,3 +505,3 @@ void AddressbookWindow::writeMail()
536 } else 505 } else
537 m_useQtMail = true; 506 m_config.setUseQtMail( true );
538 } 507 }
@@ -551,10 +520,25 @@ void AddressbookWindow::slotBeam()
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 );
@@ -623,11 +607,6 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
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
@@ -668,23 +647,18 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
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...
@@ -693,12 +667,34 @@ void AddressbookWindow::editPersonal()
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()
@@ -711,4 +707,7 @@ void AddressbookWindow::slotPersonalView()
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;
@@ -719,5 +718,3 @@ void AddressbookWindow::slotPersonalView()
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);
@@ -725,50 +722,8 @@ void AddressbookWindow::slotPersonalView()
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 )
@@ -783,4 +738,4 @@ void AddressbookWindow::reload()
783 syncing = FALSE; 738 syncing = FALSE;
784 abList->clear(); 739 m_abView->clear();
785 abList->reload(); 740 m_abView->reload();
786} 741}
@@ -790,3 +745,3 @@ void AddressbookWindow::flush()
790 syncing = TRUE; 745 syncing = TRUE;
791 abList->save(); 746 m_abView->save();
792} 747}
@@ -796,13 +751,2 @@ void 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
@@ -830,3 +774,3 @@ bool 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" ),
@@ -853,169 +797,2 @@ void AddressbookWindow::slotSave()
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
@@ -1033,5 +810,5 @@ void AddressbookWindow::slotWrapAround()
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
@@ -1041,4 +818,6 @@ void 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
@@ -1047,5 +826,10 @@ void AddressbookWindow::slotSetCategory( int c )
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
@@ -1053,18 +837,19 @@ void AddressbookWindow::slotSetCategory( int c )
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 }
@@ -1072,4 +857,6 @@ void AddressbookWindow::slotSetCategory( int c )
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() )
@@ -1079,3 +866,45 @@ void AddressbookWindow::slotSetCategory( int c )
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}
@@ -1084,3 +913,3 @@ void AddressbookWindow::slotSetLetter( char c ) {
1084 913
1085 abList->setShowByLetter( c ); 914 m_abView->setShowByLetter( c );
1086 915
@@ -1088,2 +917,3 @@ void AddressbookWindow::slotSetLetter( char c ) {
1088 917
918
1089void AddressbookWindow::populateCategories() 919void AddressbookWindow::populateCategories()
@@ -1096,7 +926,5 @@ void AddressbookWindow::populateCategories()
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();
@@ -1104,3 +932,3 @@ void AddressbookWindow::populateCategories()
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" ) );
@@ -1109,3 +937,3 @@ void AddressbookWindow::populateCategories()
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;
@@ -1114,16 +942,17 @@ void AddressbookWindow::populateCategories()
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 }
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
@@ -30,2 +30,4 @@
30#include "ofloatbar.h" 30#include "ofloatbar.h"
31#include "abview.h"
32#include "abconfig.h"
31 33
@@ -46,2 +48,4 @@ class AddressbookWindow: public QMainWindow
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 );
@@ -51,5 +55,3 @@ protected:
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();
@@ -64,4 +66,2 @@ public slots:
64 void setDocument( const QString & ); 66 void setDocument( const QString & );
65 void slotFindNext();
66 void slotFindPrevious();
67#ifdef __DEBUG_RELEASE 67#ifdef __DEBUG_RELEASE
@@ -73,3 +73,3 @@ private slots:
73 void slotListNew(); 73 void slotListNew();
74 void slotListView(); 74 /* void slotListView(); */
75 void slotListDelete(); 75 void slotListDelete();
@@ -79,3 +79,3 @@ private slots:
79 void listIsEmpty( bool ); 79 void listIsEmpty( bool );
80 void slotSettings(); 80 /* void slotSettings(); */
81 void writeMail(); 81 void writeMail();
@@ -94,2 +94,6 @@ private slots:
94 94
95 void slotViewSwitched( int );
96 void slotListView();
97 void slotCardView();
98
95 void slotConfig(); 99 void slotConfig();
@@ -97,16 +101,15 @@ private slots:
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;
@@ -116,8 +119,2 @@ private:
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
@@ -125,3 +122,2 @@ private:
125 122
126 bool bAbEditFirstTime;
127 int viewMargin; 123 int viewMargin;
@@ -130,5 +126,10 @@ private:
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};
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,3 +1,4 @@
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
@@ -5,8 +6,10 @@ 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 \
@@ -14,9 +17,11 @@ SOURCES = main.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
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
@@ -24,3 +24,3 @@
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/contact.h> 25#include <opie/ocontact.h>
26 26
@@ -43,3 +43,3 @@ void 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
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
@@ -34,3 +34,3 @@
34 <y>0</y> 34 <y>0</y>
35 <width>244</width> 35 <width>240</width>
36 <height>207</height> 36 <height>207</height>
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,4 +1,9 @@
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
@@ -6,56 +11,127 @@ ConfigDlg::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
@@ -3,3 +3,6 @@
3 3
4#include <qmap.h>
5
4#include "configdlg_base.h" 6#include "configdlg_base.h"
7#include "abconfig.h"
5 8
@@ -12,15 +15,16 @@ public:
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};
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
@@ -14,4 +14,4 @@
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>
@@ -19,2 +19,9 @@
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>
@@ -26,2 +33,5 @@
26 </property> 33 </property>
34 <property>
35 <name>layoutMargin</name>
36 </property>
27 <vbox> 37 <vbox>
@@ -29,3 +39,3 @@
29 <name>margin</name> 39 <name>margin</name>
30 <number>11</number> 40 <number>1</number>
31 </property> 41 </property>
@@ -41,2 +51,9 @@
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>
@@ -44,2 +61,5 @@
44 </property> 61 </property>
62 <property>
63 <name>layoutSpacing</name>
64 </property>
45 <widget> 65 <widget>
@@ -52,3 +72,3 @@
52 <name>title</name> 72 <name>title</name>
53 <string>Search</string> 73 <string>Misc</string>
54 </attribute> 74 </attribute>
@@ -64,6 +84,6 @@
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>
@@ -71,3 +91,3 @@
71 <name>title</name> 91 <name>title</name>
72 <string>Query Style</string> 92 <string>Search Settings</string>
73 </property> 93 </property>
@@ -83,17 +103,53 @@
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>
@@ -101,7 +157,3 @@
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>
@@ -111,22 +163,58 @@
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>
@@ -258,53 +346,194 @@ is provided free !</string>
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>
@@ -312,25 +541,6 @@ is provided free !</string>
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>
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
@@ -23,2 +23,3 @@
23#include "addresspicker.h" 23#include "addresspicker.h"
24#include "ocontactfields.h"
24 25
@@ -28,2 +29,4 @@
28#include <qpe/timeconversion.h> 29#include <qpe/timeconversion.h>
30#include <opie/ocontact.h>
31#include <qpe/resource.h>
29 32
@@ -42,2 +45,5 @@
42#include <qlistbox.h> 45#include <qlistbox.h>
46#include <qhbox.h>
47#include <qaction.h>
48#include <qiconset.h>
43 49
@@ -56,4 +62,2 @@ void parseEmailTo( const QString &strDefaultEmail,
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,
@@ -62,4 +66,2 @@ ContactEditor::ContactEditor( const OContact &entry,
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 )
@@ -68,5 +70,3 @@ ContactEditor::ContactEditor( const OContact &entry,
68 init(); 70 init();
69 initMap();
70 setEntry( entry ); 71 setEntry( entry );
71 qDebug("finish");
72} 72}
@@ -78,14 +78,5 @@ void 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
@@ -98,263 +89,9 @@ void ContactEditor::init() {
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
@@ -422,12 +159,4 @@ void ContactEditor::init() {
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
@@ -461,13 +190,3 @@ void ContactEditor::init() {
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 );
@@ -738,2 +457,3 @@ void ContactEditor::init() {
738 // Birthday 457 // Birthday
458 QHBox* hBox = new QHBox( container );
739 l = new QLabel( tr("Birthday"), container ); 459 l = new QLabel( tr("Birthday"), container );
@@ -745,8 +465,15 @@ void ContactEditor::init() {
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
@@ -755,2 +482,3 @@ void ContactEditor::init() {
755 // Anniversary 482 // Anniversary
483 hBox = new QHBox( container );
756 l = new QLabel( tr("Anniversary"), container ); 484 l = new QLabel( tr("Anniversary"), container );
@@ -762,8 +490,14 @@ void ContactEditor::init() {
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
@@ -784,4 +518,9 @@ void ContactEditor::init() {
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 );
@@ -793,3 +532,3 @@ void ContactEditor::init() {
793 // Fill labels with names.. 532 // Fill labels with names..
794 loadFields(); 533 //loadFields();
795 534
@@ -880,30 +619,4 @@ void ContactEditor::init() {
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}
@@ -1073,40 +786,3 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) {
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
@@ -1138,3 +814,3 @@ void ContactEditor::slotName() {
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) );
@@ -1150,3 +826,3 @@ void ContactEditor::slotName() {
1150 slotFullNameChange( txtFullName->text() ); 826 slotFullNameChange( txtFullName->text() );
1151 useFullName = FALSE; 827 useFullName = false;
1152 } 828 }
@@ -1363,3 +1039,2 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1363void ContactEditor::cleanupFields() { 1039void ContactEditor::cleanupFields() {
1364
1365 QStringList::Iterator it = slChooserValues.begin(); 1040 QStringList::Iterator it = slChooserValues.begin();
@@ -1374,8 +1049,7 @@ void ContactEditor::cleanupFields() {
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("");
@@ -1392,5 +1066,3 @@ void ContactEditor::cleanupFields() {
1392 txtAddress->setText(""); 1066 txtAddress->setText("");
1393 //txtAddress2->setText("");
1394 txtCity->setText(""); 1067 txtCity->setText("");
1395 //txtPOBox->setText("");
1396 txtState->setText(""); 1068 txtState->setText("");
@@ -1408,6 +1080,5 @@ void ContactEditor::setEntry( const OContact &entry ) {
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() );
@@ -1425,45 +1096,35 @@ void ContactEditor::setEntry( const OContact &entry ) {
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
@@ -1471,3 +1132,3 @@ void ContactEditor::setEntry( const OContact &entry ) {
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" )
@@ -1591,3 +1252,6 @@ void ContactEditor::setEntry( const OContact &entry ) {
1591 // loadFields(); :SX 1252 // loadFields(); :SX
1592 1253 updateDatePicker();
1254}
1255void ContactEditor::updateDatePicker()
1256{
1593 // Set DatePicker 1257 // Set DatePicker
@@ -1609,3 +1273,3 @@ void 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 ) );
@@ -1615,15 +1279,9 @@ void ContactEditor::saveEntry() {
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
@@ -1633,45 +1291,36 @@ void ContactEditor::saveEntry() {
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
@@ -1679,3 +1328,4 @@ void ContactEditor::saveEntry() {
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" )
@@ -1709,2 +1359,3 @@ void ContactEditor::saveEntry() {
1709 1359
1360
1710 QStringList::ConstIterator itV; 1361 QStringList::ConstIterator itV;
@@ -1714,6 +1365,3 @@ void ContactEditor::saveEntry() {
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" ) )
@@ -1723,8 +1371,2 @@ void ContactEditor::saveEntry() {
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
@@ -1741,6 +1383,3 @@ void ContactEditor::saveEntry() {
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" )
@@ -1750,33 +1389,6 @@ void ContactEditor::saveEntry() {
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" )
@@ -1877,2 +1489,7 @@ void ContactEditor::setPersonalView( bool personal )
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 ){
@@ -1880,6 +1497,6 @@ void ContactEditor::setPersonalView( bool personal )
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 }
@@ -1904 +1521,15 @@ void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
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
@@ -57,4 +57,2 @@ class ContactEditor : public QDialog {
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,
@@ -63,3 +61,2 @@ class ContactEditor : public QDialog {
63 ~ContactEditor(); 61 ~ContactEditor();
64 void loadFields();
65 void setNameFocus(); 62 void setNameFocus();
@@ -78,3 +75,2 @@ class ContactEditor : public QDialog {
78 void init(); 75 void init();
79 void initMap();
80 void saveEntry(); 76 void saveEntry();
@@ -82,2 +78,3 @@ class ContactEditor : public QDialog {
82 void cleanupFields(); 78 void cleanupFields();
79 void updateDatePicker();
83 QString parseName( QString fullName, int type ); 80 QString parseName( QString fullName, int type );
@@ -103,5 +100,8 @@ class ContactEditor : public QDialog {
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
@@ -114,5 +114,5 @@ class ContactEditor : public QDialog {
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
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
@@ -7,3 +7,3 @@ Architecture: 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
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
@@ -220,2 +220,7 @@ LetterPicker::~LetterPicker()
220 220
221QSizePolicy LetterPicker::sizePolicy () const
222{
223 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum);
224}
225
221void LetterPicker::clear() 226void LetterPicker::clear()
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
@@ -15,2 +15,3 @@
15#include <qevent.h> 15#include <qevent.h>
16#include <qsizepolicy.h>
16 17
@@ -51,3 +52,4 @@ Q_OBJECT
51 ~LetterPicker(); 52 ~LetterPicker();
52 53
54 QSizePolicy sizePolicy () const;
53 55
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