summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO7
-rw-r--r--core/pim/addressbook/ablabel.cpp43
-rw-r--r--core/pim/addressbook/abtable.cpp45
-rw-r--r--core/pim/addressbook/abtable.h7
-rw-r--r--core/pim/addressbook/addressbook.cpp70
-rw-r--r--core/pim/addressbook/addressbook.h7
-rw-r--r--core/pim/addressbook/picker.cpp24
-rw-r--r--core/pim/addressbook/picker.h3
8 files changed, 164 insertions, 42 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 4daa2a8..796dc49 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -1,33 +1,36 @@
1Stuff todo until OPIE 1.0 : 1Stuff todo until OPIE 1.0 :
2 2
3Urgent: 3Urgent:
4 4
5- Font menu is invisible using german translation 5- Font menu is invisible using german translation
6 6
7Important: 7Important:
8 8
9- Picker: Activated letter schould be more visible 9- Cursor keys should work in detail-view (ablabel)
10- "What's this" should be added 10- "What's this" should be added
11- Store last settings of combo-boxes 11- Store last settings of combo-boxes
12- Mail-Icon is missing 12- Mail-Icon is missing
13- Overview window cleanup needed..
13- Finishing of new View functions (List, Phonebook...) 14- Finishing of new View functions (List, Phonebook...)
14- The names of the countries are sorted by there english names, only.. 15- The names of the countries are sorted by there english names, only..
15 Even if they are translated.. :S 16 Even if they are translated.. :S
16- Reload if contacts were changed externally 17- Reload if contacts were changed externally
17 18
18Less important: 19Less important:
19 20
20- The picker (alphabetical sort widget) should be 21- The picker (alphabetical sort widget) should be
21 placed verticaly or horizontally (configurable) 22 placed verticaly or horizontally (configurable)
22- Use advanced database functions in abtable to decrease 23- Use advanced database functions in abtable to decrease
23 memory footprint and to make everything more easy ! 24 memory footprint and to make everything more easy !
24 (abtable should store Iterator for selected Category) 25 (abtable should store Iterator for selected Category)
25 26
26Should be Fixed (not absolute sure, need further validation): 27Should be Fixed (not absolute sure, need further validation):
27- "Nonenglish" translation bug has to be fixed. 28- "Nonenglish" translation bug has to be fixed.
28 29
29Fixed: 30Fixed:
30- Syncing: abtable not reloaded after sync. 31- Syncing: abtable not reloaded after sync.
31- Find widget should be replaced by something like 32- Find widget should be replaced by something like
32 qpdf has. 33 qpdf has.
33- Adding a configuration dialog \ No newline at end of file 34- Adding a configuration dialog
35- Picker: Activated letter schould be more visible
36- Advanced handling of cursor keys (search..)
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp
index cf1e39f..ea80700 100644
--- a/core/pim/addressbook/ablabel.cpp
+++ b/core/pim/addressbook/ablabel.cpp
@@ -26,28 +26,65 @@
26#include <qstylesheet.h> 26#include <qstylesheet.h>
27 27
28AbLabel::AbLabel( QWidget *parent, const char *name ) 28AbLabel::AbLabel( QWidget *parent, const char *name )
29 : QTextView( parent, name ) 29 : QTextView( parent, name )
30{ 30{
31} 31}
32 32
33AbLabel::~AbLabel() 33AbLabel::~AbLabel()
34{ 34{
35} 35}
36 36
37void AbLabel::init( const OContact &entry ) 37void AbLabel::init( const OContact &entry )
38{ 38{
39 ent = entry; 39 ent = entry;
40} 40}
41 41
42void AbLabel::sync() 42void AbLabel::sync()
43{ 43{
44 QString text = ent.toRichText(); 44 QString text = ent.toRichText();
45 setText( text ); 45 setText( text );
46} 46}
47 47
48void AbLabel::keyPressEvent( QKeyEvent *e ) 48void AbLabel::keyPressEvent( QKeyEvent *e )
49{ 49{
50 if ( e->key() == Qt::Key_F33 ) { 50 // Commonly handled keys
51 emit okPressed(); 51 switch( e->key() ) {
52 } 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() ) {
66 case Qt::Key_Up:
67 qWarning("a");
68 // emit signalSearchBackward();
69 break;
70 case Qt::Key_Down:
71 qWarning("b");
72 // emit signalSearchNext();
73 break;
74 }
75
76 } else {
77 qWarning("Received key in NON search mode");
78
79 switch( e->key() ) {
80 case Qt::Key_Up:
81 qWarning("a");
82 // emit signalSearchBackward();
83 break;
84 case Qt::Key_Down:
85 qWarning("b");
86 // emit signalSearchNext();
87 break;
88 }
89 }
53} 90}
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index d4dcf7b..97b26db 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -109,48 +109,49 @@ void AbPickItem::setContentFromEditor( QWidget *w )
109{ 109{
110 if ( w->inherits("QComboBox") ) 110 if ( w->inherits("QComboBox") )
111 setText( ( (QComboBox*)w )->currentText() ); 111 setText( ( (QComboBox*)w )->currentText() );
112 else 112 else
113 QTableItem::setContentFromEditor( w ); 113 QTableItem::setContentFromEditor( w );
114} 114}
115 115
116/*! 116/*!
117 \class AbTable abtable.h 117 \class AbTable abtable.h
118 118
119 \brief QTable based class for showing a list of entries 119 \brief QTable based class for showing a list of entries
120*/ 120*/
121 121
122AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) 122AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name )
123 // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR 123 // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
124 // : QTable( 0, 0, parent, name, TRUE ), 124 // : QTable( 0, 0, parent, name, TRUE ),
125 // #else 125 // #else
126 : QTable( parent, name ), 126 : QTable( parent, name ),
127 // #endif 127 // #endif
128 lastSortCol( -1 ), 128 lastSortCol( -1 ),
129 asc( TRUE ), 129 asc( TRUE ),
130 intFields( order ), 130 intFields( order ),
131 currFindRow( -1 ), 131 currFindRow( -1 ),
132 mCat( 0 ), 132 mCat( 0 ),
133 m_inSearch (false),
133 m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! 134 m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. !
134{ 135{
135 mCat.load( categoryFileName() ); 136 mCat.load( categoryFileName() );
136 setSelectionMode( NoSelection ); 137 setSelectionMode( NoSelection );
137 init(); 138 init();
138 setSorting( TRUE ); 139 setSorting( TRUE );
139 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), 140 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
140 this, SLOT(itemClicked(int,int)) ); 141 this, SLOT(itemClicked(int,int)) );
141} 142}
142 143
143AbTable::~AbTable() 144AbTable::~AbTable()
144{ 145{
145} 146}
146 147
147void AbTable::init() 148void AbTable::init()
148{ 149{
149 showChar = '\0'; 150 showChar = '\0';
150 setNumRows( 0 ); 151 setNumRows( 0 );
151 setNumCols( 2 ); 152 setNumCols( 2 );
152 153
153 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 154 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
154 horizontalHeader()->setLabel( 1, tr( "Contact" )); 155 horizontalHeader()->setLabel( 1, tr( "Contact" ));
155 setLeftMargin( 0 ); 156 setLeftMargin( 0 );
156 verticalHeader()->hide(); 157 verticalHeader()->hide();
@@ -239,56 +240,82 @@ void AbTable::refresh()
239 int rows = numRows(); 240 int rows = numRows();
240 QString value; 241 QString value;
241 AbTableItem *abi; 242 AbTableItem *abi;
242 243
243 // hide columns so no flashing ? 244 // hide columns so no flashing ?
244 if ( showBk == "Cards" ) { 245 if ( showBk == "Cards" ) {
245 hideColumn(0); 246 hideColumn(0);
246 hideColumn(1); 247 hideColumn(1);
247 } 248 }
248 for ( int r = 0; r < rows; ++r ) { 249 for ( int r = 0; r < rows; ++r ) {
249 abi = static_cast<AbTableItem*>( item(r, 0) ); 250 abi = static_cast<AbTableItem*>( item(r, 0) );
250 value = findContactContact( contactList[abi], r ); 251 value = findContactContact( contactList[abi], r );
251 static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); 252 static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() );
252 } 253 }
253 resort(); 254 resort();
254} 255}
255 256
256void AbTable::keyPressEvent( QKeyEvent *e ) 257void AbTable::keyPressEvent( QKeyEvent *e )
257{ 258{
258 char key = toupper( e->ascii() ); 259 char key = toupper( e->ascii() );
259 260
260 if ( key >= 'A' && key <= 'Z' ) 261 if ( key >= 'A' && key <= 'Z' )
261 moveTo( key ); 262 moveTo( key );
262 263
263 switch( e->key() ) { 264 if ( m_inSearch ) {
264 case Qt::Key_Space: 265 // Running in seach-mode, therefore we will interprete
265 case Qt::Key_Return: 266 // some key differently
266 case Qt::Key_Enter: 267 qWarning("Received key in search mode");
267 emit details(); 268 switch( e->key() ) {
268 break; 269 case Qt::Key_Space:
269 default: 270 case Qt::Key_Return:
270 QTable::keyPressEvent( e ); 271 case Qt::Key_Enter:
272 emit details();
273 break;
274 case Qt::Key_Up:
275 qWarning("a");
276 emit signalSearchBackward();
277 break;
278 case Qt::Key_Down:
279 qWarning("b");
280 emit signalSearchNext();
281 break;
282 default:
283 QTable::keyPressEvent( e );
284 }
285
286 } else {
287 qWarning("Received key in NON search mode");
288
289 switch( e->key() ) {
290 case Qt::Key_Space:
291 case Qt::Key_Return:
292 case Qt::Key_Enter:
293 emit details();
294 break;
295 default:
296 QTable::keyPressEvent( e );
297 }
271 } 298 }
272} 299}
273 300
274void AbTable::moveTo( char c ) 301void AbTable::moveTo( char c )
275{ 302{
276 303
277 int rows = numRows(); 304 int rows = numRows();
278 QString value; 305 QString value;
279 AbTableItem *abi; 306 AbTableItem *abi;
280 int r; 307 int r;
281 if ( asc ) { 308 if ( asc ) {
282 r = 0; 309 r = 0;
283 while ( r < rows-1) { 310 while ( r < rows-1) {
284 abi = static_cast<AbTableItem*>( item(r, 0) ); 311 abi = static_cast<AbTableItem*>( item(r, 0) );
285 QChar first = abi->key()[0]; 312 QChar first = abi->key()[0];
286 //### is there a bug in QChar to char comparison??? 313 //### is there a bug in QChar to char comparison???
287 if ( first.row() || first.cell() >= c ) 314 if ( first.row() || first.cell() >= c )
288 break; 315 break;
289 r++; 316 r++;
290 } 317 }
291 } else { 318 } else {
292 //### should probably disable reverse sorting instead 319 //### should probably disable reverse sorting instead
293 r = rows - 1; 320 r = rows - 1;
294 while ( r > 0 ) { 321 while ( r > 0 ) {
@@ -662,49 +689,49 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool us
662 689
663 if ( !backwards ) { 690 if ( !backwards ) {
664 for ( row = currFindRow + 1; row < rows; row++ ) { 691 for ( row = currFindRow + 1; row < rows; row++ ) {
665 ati = static_cast<AbTableItem*>( item(row, 0) ); 692 ati = static_cast<AbTableItem*>( item(row, 0) );
666 if ( contactCompare( contactList[ati], r, category ) ) 693 if ( contactCompare( contactList[ati], r, category ) )
667 break; 694 break;
668 } 695 }
669 } else { 696 } else {
670 for ( row = currFindRow - 1; row > -1; row-- ) { 697 for ( row = currFindRow - 1; row > -1; row-- ) {
671 ati = static_cast<AbTableItem*>( item(row, 0) ); 698 ati = static_cast<AbTableItem*>( item(row, 0) );
672 if ( contactCompare( contactList[ati], r, category ) ) 699 if ( contactCompare( contactList[ati], r, category ) )
673 break; 700 break;
674 } 701 }
675 } 702 }
676 if ( row >= rows || row < 0 ) { 703 if ( row >= rows || row < 0 ) {
677 if ( row < 0 ) 704 if ( row < 0 )
678 currFindRow = rows; 705 currFindRow = rows;
679 else 706 else
680 currFindRow = -1; 707 currFindRow = -1;
681 708
682 if ( wrapAround ) 709 if ( wrapAround )
683 emit signalWrapAround(); 710 emit signalWrapAround();
684 else 711 else
685 emit signalNotFound(); 712 emit signalNotFound();
686 713
687 wrapAround = !wrapAround; 714 wrapAround = !wrapAround;
688 } else { 715 } else {
689 currFindRow = row; 716 currFindRow = row;
690 QTableSelection foundSelection; 717 QTableSelection foundSelection;
691 foundSelection.init( currFindRow, 0 ); 718 foundSelection.init( currFindRow, 0 );
692 foundSelection.expandTo( currFindRow, numCols() - 1 ); 719 foundSelection.expandTo( currFindRow, numCols() - 1 );
693 addSelection( foundSelection ); 720 addSelection( foundSelection );
694 setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); 721 setCurrentCell( currFindRow, 0 /* numCols() - 1 */ );
695 wrapAround = true; 722 wrapAround = true;
696 } 723 }
697} 724}
698 725
699static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) 726static bool contactCompare( const OContact &cnt, const QRegExp &r, int category )
700{ 727{
701 bool returnMe; 728 bool returnMe;
702 QArray<int> cats; 729 QArray<int> cats;
703 cats = cnt.categories(); 730 cats = cnt.categories();
704 731
705 returnMe = false; 732 returnMe = false;
706 if ( (cats.count() == 0) || (category == 0) ) 733 if ( (cats.count() == 0) || (category == 0) )
707 returnMe = cnt.match( r ); 734 returnMe = cnt.match( r );
708 else { 735 else {
709 int i; 736 int i;
710 for ( i = 0; i < int(cats.count()); i++ ) { 737 for ( i = 0; i < int(cats.count()); i++ ) {
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index b445874..35a1e9e 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -77,78 +77,85 @@ public:
77 void clearFindRow() { currFindRow = -1; } 77 void clearFindRow() { currFindRow = -1; }
78 void loadFields(); 78 void loadFields();
79 void refresh(); 79 void refresh();
80 bool save(); 80 bool save();
81 void load(); 81 void load();
82 void reload(); 82 void reload();
83 83
84 // addresspicker mode 84 // addresspicker mode
85 void setChoiceNames( const QStringList& list); 85 void setChoiceNames( const QStringList& list);
86 QStringList choiceNames() const; 86 QStringList choiceNames() const;
87 void setChoiceSelection(int index, const QStringList& list); 87 void setChoiceSelection(int index, const QStringList& list);
88 QStringList choiceSelection(int index) const; 88 QStringList choiceSelection(int index) const;
89 void setShowCategory( const QString &b, const QString &c ); 89 void setShowCategory( const QString &b, const QString &c );
90 void setShowByLetter( char c ); 90 void setShowByLetter( char c );
91 QString showCategory() const; 91 QString showCategory() const;
92 QStringList categories(); 92 QStringList categories();
93 93
94 void resizeRows(); 94 void resizeRows();
95 95
96 void show(); 96 void show();
97 void setPaintingEnabled( bool e ); 97 void setPaintingEnabled( bool e );
98 98
99 QString showBook() const; 99 QString showBook() const;
100 100
101 void inSearch() { m_inSearch = true; }
102 void offSearch() { m_inSearch = false; }
103
101public slots: 104public slots:
102 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, bool backwards, 105 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, bool backwards,
103 QString category = QString::null ); 106 QString category = QString::null );
104signals: 107signals:
105 void empty( bool ); 108 void empty( bool );
106 void details(); 109 void details();
107 void signalNotFound(); 110 void signalNotFound();
108 void signalWrapAround(); 111 void signalWrapAround();
112 void signalSearchBackward(); // Signalled if backward search is requested
113 void signalSearchNext(); // Singalled if forward search is requested
109 114
110protected: 115protected:
111 virtual void keyPressEvent( QKeyEvent *e ); 116 virtual void keyPressEvent( QKeyEvent *e );
112 117
113// int rowHeight( int ) const; 118// int rowHeight( int ) const;
114// int rowPos( int row ) const; 119// int rowPos( int row ) const;
115// virtual int rowAt( int pos ) const; 120// virtual int rowAt( int pos ) const;
116 121
117 122
118protected slots: 123protected slots:
119 void moveTo( char ); 124 void moveTo( char );
120 virtual void columnClicked( int col ); 125 virtual void columnClicked( int col );
121 void itemClicked(int,int col); 126 void itemClicked(int,int col);
122 void rowHeightChanged( int row ); 127 void rowHeightChanged( int row );
123 128
124private: 129private:
125 void loadFile( const QString &strFile, bool journalFile ); 130 void loadFile( const QString &strFile, bool journalFile );
126 void fitColumns(); 131 void fitColumns();
127 void resort(); 132 void resort();
128 void updateJournal( const OContact &contact, OContact::journal_action action, 133 void updateJournal( const OContact &contact, OContact::journal_action action,
129 int row = -1 ); 134 int row = -1 );
130 void insertIntoTable( const OContact &contact, int row ); 135 void insertIntoTable( const OContact &contact, int row );
131 QString findContactName( const OContact &entry ); 136 QString findContactName( const OContact &entry );
132 QString findContactContact( const OContact &entry, int row ); 137 QString findContactContact( const OContact &entry, int row );
133 void journalFreeReplace( const OContact &cnt, int row ); 138 void journalFreeReplace( const OContact &cnt, int row );
134 void journalFreeRemove( int row ); 139 void journalFreeRemove( int row );
135 void realignTable( int ); 140 void realignTable( int );
136 void updateVisible(); 141 void updateVisible();
137 int lastSortCol; 142 int lastSortCol;
138 bool asc; 143 bool asc;
139 char showChar; 144 char showChar;
140 QMap<AbTableItem*, OContact> contactList; 145 QMap<AbTableItem*, OContact> contactList;
141 const QValueList<int> *intFields; 146 const QValueList<int> *intFields;
142 int currFindRow; 147 int currFindRow;
143 QString showCat; 148 QString showCat;
144 QStringList choicenames; 149 QStringList choicenames;
145 bool enablePainting; 150 bool enablePainting;
146 Categories mCat; 151 Categories mCat;
147 152
148 QString showBk; 153 QString showBk;
149 bool columnVisible; 154 bool columnVisible;
150 155
156 bool m_inSearch;
157
151 OContactAccess m_contactdb; 158 OContactAccess m_contactdb;
152 159
153}; 160};
154#endif // ABTABLE_H 161#endif // ABTABLE_H
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index f7e4c95..3466801 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -57,55 +57,62 @@
57#include <stdlib.h> 57#include <stdlib.h>
58#include <sys/stat.h> 58#include <sys/stat.h>
59#include <sys/types.h> 59#include <sys/types.h>
60#include <fcntl.h> 60#include <fcntl.h>
61#include <unistd.h> 61#include <unistd.h>
62 62
63#include <qdatetime.h> 63#include <qdatetime.h>
64 64
65#include "picker.h" 65#include "picker.h"
66#include "configdlg.h" 66#include "configdlg.h"
67 67
68static QString addressbookPersonalVCardName() 68static QString addressbookPersonalVCardName()
69{ 69{
70 QString filename = Global::applicationFileName("addressbook", 70 QString filename = Global::applicationFileName("addressbook",
71 "businesscard.vcf"); 71 "businesscard.vcf");
72 return filename; 72 return filename;
73} 73}
74 74
75 75
76AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 76AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
77 WFlags f ) 77 WFlags f )
78 : QMainWindow( parent, name, f ), 78 : QMainWindow( parent, name, f ),
79 abEditor(0), 79 abEditor(0),
80 useRegExp(false), 80 useRegExp(false),
81 DoSignalWrapAround(false), 81 doNotifyWrapAround(true),
82 caseSensitive(false), 82 caseSensitive(false),
83 bAbEditFirstTime(TRUE), 83 bAbEditFirstTime(TRUE),
84 syncing(FALSE) 84 syncing(FALSE)
85{ 85{
86 isLoading = true; 86 isLoading = true;
87 87
88 // Read Config settings
89 Config cfg("AddressBook");
90 cfg.setGroup("Search");
91 useRegExp = cfg.readBoolEntry( "useRegExp" );
92 caseSensitive = cfg.readBoolEntry( "caseSensitive" );
93 doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" );
94
88 initFields(); 95 initFields();
89 96
90 setCaption( tr("Contacts") ); 97 setCaption( tr("Contacts") );
91 setIcon( Resource::loadPixmap( "AddressBook" ) ); 98 setIcon( Resource::loadPixmap( "AddressBook" ) );
92 99
93 setToolBarsMovable( FALSE ); 100 setToolBarsMovable( FALSE );
94 101
95 // Create Toolbars 102 // Create Toolbars
96 103
97 QPEToolBar *bar = new QPEToolBar( this ); 104 QPEToolBar *bar = new QPEToolBar( this );
98 bar->setHorizontalStretchable( TRUE ); 105 bar->setHorizontalStretchable( TRUE );
99 106
100 QPEMenuBar *mbList = new QPEMenuBar( bar ); 107 QPEMenuBar *mbList = new QPEMenuBar( bar );
101 mbList->setMargin( 0 ); 108 mbList->setMargin( 0 );
102 109
103 QPopupMenu *edit = new QPopupMenu( this ); 110 QPopupMenu *edit = new QPopupMenu( this );
104 mbList->insertItem( tr( "Contact" ), edit ); 111 mbList->insertItem( tr( "Contact" ), edit );
105 112
106 listTools = new QPEToolBar( this, "list operations" ); 113 listTools = new QPEToolBar( this, "list operations" );
107 114
108 115
109 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 116 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
110 0, this, 0 ); 117 0, this, 0 );
111 actionNew = a; 118 actionNew = a;
@@ -140,49 +147,49 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
140 QString::null, 0, this, 0 ); 147 QString::null, 0, this, 0 );
141 actionFind = a; 148 actionFind = a;
142 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); 149 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
143 a->addTo( edit ); 150 a->addTo( edit );
144 a->addTo( listTools ); 151 a->addTo( listTools );
145 152
146 // Much better search widget, taken from QTReader.. (se) 153 // Much better search widget, taken from QTReader.. (se)
147 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); 154 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
148 searchBar->setHorizontalStretchable( TRUE ); 155 searchBar->setHorizontalStretchable( TRUE );
149 searchBar->hide(); 156 searchBar->hide();
150 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 157 searchEdit = new QLineEdit( searchBar, "searchEdit" );
151// QFont f("unifont", 16 /*, QFont::Bold*/); 158// QFont f("unifont", 16 /*, QFont::Bold*/);
152// searchEdit->setFont( f ); 159// searchEdit->setFont( f );
153 searchBar->setStretchableWidget( searchEdit ); 160 searchBar->setStretchableWidget( searchEdit );
154 connect( searchEdit, SIGNAL( returnPressed( ) ), 161 connect( searchEdit, SIGNAL( returnPressed( ) ),
155 this, SLOT( slotFind( ) ) ); 162 this, SLOT( slotFind( ) ) );
156 163
157 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 164 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
158 connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); 165 connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) );
159 a->addTo( searchBar ); 166 a->addTo( searchBar );
160 167
161 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 168 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
162 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); 169 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
163 a->addTo( searchBar ); 170 a->addTo( searchBar );
164 171
165 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), 172 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
166 QString::null, 0, this, 0 ); 173 QString::null, 0, this, 0 );
167 //a->setEnabled( FALSE ); we got support for it now :) zecke 174 //a->setEnabled( FALSE ); we got support for it now :) zecke
168 actionMail = a; 175 actionMail = a;
169 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 176 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
170 a->addTo( edit ); 177 a->addTo( edit );
171 a->addTo( listTools ); 178 a->addTo( listTools );
172 179
173 180
174 181
175 if ( Ir::supported() ) { 182 if ( Ir::supported() ) {
176 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 183 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
177 0, this, 0 ); 184 0, this, 0 );
178 actionBeam = a; 185 actionBeam = a;
179 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 186 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
180 a->addTo( edit ); 187 a->addTo( edit );
181 a->addTo( listTools ); 188 a->addTo( listTools );
182 } 189 }
183 190
184 edit->insertSeparator(); 191 edit->insertSeparator();
185 192
186 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); 193 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE );
187 actionPersonal = a; 194 actionPersonal = a;
188 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 195 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
@@ -202,107 +209,106 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
202 209
203 210
204#ifdef __DEBUG_RELEASE 211#ifdef __DEBUG_RELEASE
205 // Remove this function for public Release ! This is only 212 // Remove this function for public Release ! This is only
206 // for debug purposes .. 213 // for debug purposes ..
207 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 214 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
208 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 215 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
209 a->addTo( edit ); 216 a->addTo( edit );
210#endif 217#endif
211 a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 218 a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null,
212 0, this, 0 ); 219 0, this, 0 );
213 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 220 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
214 a->addTo( edit ); 221 a->addTo( edit );
215 222
216 // Create Views 223 // Create Views
217 listContainer = new QWidget( this ); 224 listContainer = new QWidget( this );
218 225
219 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 226 QVBoxLayout *vb = new QVBoxLayout( listContainer );
220 227
221 abList = new AbTable( &orderedFields, listContainer, "table" ); 228 abList = new AbTable( &orderedFields, listContainer, "table" );
222 vb->addWidget(abList); 229 vb->addWidget(abList);
223 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 230 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
224 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); 231 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) );
225 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); 232 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) );
226 connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); 233 connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) );
234 connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) );
235 connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) );
236
237 // Maybe we should react on Wraparound and notfound ?
238 QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
239 QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) );
227 240
228 mView = 0; 241 mView = 0;
229 242
230 abList->load(); 243 abList->load();
231 244
232 pLabel = new LetterPicker( listContainer ); 245 pLabel = new LetterPicker( listContainer );
233 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 246 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
234 vb->addWidget(pLabel); 247 vb->addWidget(pLabel);
235 catMenu = new QPopupMenu( this ); 248 catMenu = new QPopupMenu( this );
236 catMenu->setCheckable( TRUE ); 249 catMenu->setCheckable( TRUE );
237 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 250 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
238 populateCategories(); 251 populateCategories();
239 252
240 mbList->insertItem( tr("View"), catMenu ); 253 mbList->insertItem( tr("View"), catMenu );
241 // setCentralWidget( listContainer ); 254 // setCentralWidget( listContainer );
242 255
243 fontMenu = new QPopupMenu(this); 256 fontMenu = new QPopupMenu(this);
244 fontMenu->setCheckable( true ); 257 fontMenu->setCheckable( true );
245 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); 258 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
246 259
247 fontMenu->insertItem(tr( "Small" ), 0); 260 fontMenu->insertItem(tr( "Small" ), 0);
248 fontMenu->insertItem(tr( "Normal" ), 1); 261 fontMenu->insertItem(tr( "Normal" ), 1);
249 fontMenu->insertItem(tr( "Large" ), 2); 262 fontMenu->insertItem(tr( "Large" ), 2);
250 263
251 defaultFont = new QFont( abList->font() ); 264 defaultFont = new QFont( abList->font() );
252 265
253 slotSetFont(startFontSize); 266 slotSetFont(startFontSize);
254 267
255 mbList->insertItem( tr("Font"), fontMenu); 268 mbList->insertItem( tr("Font"), fontMenu);
256 setCentralWidget(listContainer); 269 setCentralWidget(listContainer);
257 270
258 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 271 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
259 272
260 abList->setCurrentCell( 0, 0 ); 273 abList->setCurrentCell( 0, 0 );
261
262 // Read Config settings
263 Config cfg("AddressBook");
264 cfg.setGroup("Search");
265 useRegExp = cfg.readBoolEntry( "useRegExp" );
266 caseSensitive = cfg.readBoolEntry( "caseSensitive" );
267 DoSignalWrapAround = cfg.readBoolEntry( "signalWrapAround" );
268 274
269 isLoading = false; 275 isLoading = false;
270} 276}
271 277
272 278
273void AddressbookWindow::slotConfig() 279void AddressbookWindow::slotConfig()
274{ 280{
275 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 281 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
276 dlg -> setUseRegExp ( useRegExp ); 282 dlg -> setUseRegExp ( useRegExp );
277 dlg -> setBeCaseSensitive( caseSensitive ); 283 dlg -> setBeCaseSensitive( caseSensitive );
278 dlg -> setSignalWrapAround( DoSignalWrapAround ); 284 dlg -> setSignalWrapAround( doNotifyWrapAround );
279 dlg -> showMaximized(); 285 dlg -> showMaximized();
280 if ( dlg -> exec() ) { 286 if ( dlg -> exec() ) {
281 qWarning ("Config Dialog accepted !"); 287 qWarning ("Config Dialog accepted !");
282 useRegExp = dlg -> useRegExp(); 288 useRegExp = dlg -> useRegExp();
283 caseSensitive = dlg -> beCaseSensitive(); 289 caseSensitive = dlg -> beCaseSensitive();
284 DoSignalWrapAround = dlg -> signalWrapAround(); 290 doNotifyWrapAround = dlg -> signalWrapAround();
285 } 291 }
286 292
287 delete dlg; 293 delete dlg;
288} 294}
289 295
290 296
291void AddressbookWindow::slotSetFont( int size ) { 297void AddressbookWindow::slotSetFont( int size ) {
292 298
293 if (size > 2 || size < 0) 299 if (size > 2 || size < 0)
294 size = 1; 300 size = 1;
295 301
296 startFontSize = size; 302 startFontSize = size;
297 303
298 QFont *currentFont; 304 QFont *currentFont;
299 305
300 switch (size) { 306 switch (size) {
301 case 0: 307 case 0:
302 fontMenu->setItemChecked(0, true); 308 fontMenu->setItemChecked(0, true);
303 fontMenu->setItemChecked(1, false); 309 fontMenu->setItemChecked(1, false);
304 fontMenu->setItemChecked(2, false); 310 fontMenu->setItemChecked(2, false);
305 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 311 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
306 currentFont = new QFont (abList->font()); 312 currentFont = new QFont (abList->font());
307 // abList->resizeRows(currentFont->pixelSize() + 7); 313 // abList->resizeRows(currentFont->pixelSize() + 7);
308 abList->resizeRows(); 314 abList->resizeRows();
@@ -352,49 +358,49 @@ void AddressbookWindow::setDocument( const QString &filename )
352 // } 358 // }
353 } 359 }
354 360
355} 361}
356 362
357void AddressbookWindow::resizeEvent( QResizeEvent *e ) 363void AddressbookWindow::resizeEvent( QResizeEvent *e )
358{ 364{
359 QMainWindow::resizeEvent( e ); 365 QMainWindow::resizeEvent( e );
360 366
361 if ( centralWidget() == listContainer ) 367 if ( centralWidget() == listContainer )
362 showList(); 368 showList();
363 else if ( centralWidget() == mView ) 369 else if ( centralWidget() == mView )
364 showView(); 370 showView();
365} 371}
366 372
367AddressbookWindow::~AddressbookWindow() 373AddressbookWindow::~AddressbookWindow()
368{ 374{
369 Config cfg("AddressBook"); 375 Config cfg("AddressBook");
370 cfg.setGroup("Font"); 376 cfg.setGroup("Font");
371 cfg.writeEntry("fontSize", startFontSize); 377 cfg.writeEntry("fontSize", startFontSize);
372 378
373 cfg.setGroup("Search"); 379 cfg.setGroup("Search");
374 cfg.writeEntry("useRegExp", useRegExp); 380 cfg.writeEntry("useRegExp", useRegExp);
375 cfg.writeEntry("caseSensitive", caseSensitive); 381 cfg.writeEntry("caseSensitive", caseSensitive);
376 cfg.writeEntry("signalWrapAround", DoSignalWrapAround); 382 cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround);
377} 383}
378 384
379void AddressbookWindow::slotUpdateToolbar() 385void AddressbookWindow::slotUpdateToolbar()
380{ 386{
381 OContact ce = abList->currentEntry(); 387 OContact ce = abList->currentEntry();
382 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 388 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
383} 389}
384 390
385void AddressbookWindow::showList() 391void AddressbookWindow::showList()
386{ 392{
387 bool visiblemView; 393 bool visiblemView;
388 394
389 visiblemView = false; 395 visiblemView = false;
390 if ( mView ) { 396 if ( mView ) {
391 mView->hide(); 397 mView->hide();
392 visiblemView = true; 398 visiblemView = true;
393 } 399 }
394 setCentralWidget( listContainer ); 400 setCentralWidget( listContainer );
395 listContainer->show(); 401 listContainer->show();
396 // update our focues... (or use a stack widget!); 402 // update our focues... (or use a stack widget!);
397 abList->setFocus(); 403 abList->setFocus();
398 404
399 // This makes sure we are scrolled all the way to the left 405 // This makes sure we are scrolled all the way to the left
400 abList->setContentsPos( 0, abList->contentsY() ); 406 abList->setContentsPos( 0, abList->contentsY() );
@@ -635,51 +641,49 @@ void AddressbookWindow::editPersonal()
635 641
636 abEditor->setCaption(tr("Edit My Personal Details")); 642 abEditor->setCaption(tr("Edit My Personal Details"));
637 abEditor->showMaximized(); 643 abEditor->showMaximized();
638 644
639 // fix the foxus... 645 // fix the foxus...
640 abEditor->setNameFocus(); 646 abEditor->setNameFocus();
641 if ( abEditor->exec() ) { 647 if ( abEditor->exec() ) {
642 setFocus(); 648 setFocus();
643 OContact new_personal = abEditor->entry(); 649 OContact new_personal = abEditor->entry();
644 QString fname = addressbookPersonalVCardName(); 650 QString fname = addressbookPersonalVCardName();
645 OContact::writeVCard( fname, new_personal ); 651 OContact::writeVCard( fname, new_personal );
646 abView()->init(new_personal); 652 abView()->init(new_personal);
647 abView()->sync(); 653 abView()->sync();
648 } 654 }
649 abEditor->setCaption( tr("Edit Address") ); 655 abEditor->setCaption( tr("Edit Address") );
650} 656}
651 657
652void AddressbookWindow::slotPersonalView() 658void AddressbookWindow::slotPersonalView()
653{ 659{
654 if (!actionPersonal->isOn()) { 660 if (!actionPersonal->isOn()) {
655 // we just turned it off 661 // we just turned it off
656 setCaption( tr("Contacts") ); 662 setCaption( tr("Contacts") );
657 actionNew->setEnabled(TRUE); 663 actionNew->setEnabled(TRUE);
658 actionTrash->setEnabled(TRUE); 664 actionTrash->setEnabled(TRUE);
659#ifndef MAKE_FOR_SHARP_ROM
660 actionFind->setEnabled(TRUE); 665 actionFind->setEnabled(TRUE);
661#endif
662 slotUpdateToolbar(); // maybe some of the above could be moved there 666 slotUpdateToolbar(); // maybe some of the above could be moved there
663 showList(); 667 showList();
664 return; 668 return;
665 } 669 }
666 670
667 // XXX need to disable some QActions. 671 // XXX need to disable some QActions.
668 actionNew->setEnabled(FALSE); 672 actionNew->setEnabled(FALSE);
669 actionTrash->setEnabled(FALSE); 673 actionTrash->setEnabled(FALSE);
670#ifndef MAKE_FOR_SHARP_ROM 674#ifndef MAKE_FOR_SHARP_ROM
671 actionFind->setEnabled(FALSE); 675 actionFind->setEnabled(FALSE);
672#endif 676#endif
673 actionMail->setEnabled(FALSE); 677 actionMail->setEnabled(FALSE);
674 678
675 setCaption( tr("Contacts - My Personal Details") ); 679 setCaption( tr("Contacts - My Personal Details") );
676 QString filename = addressbookPersonalVCardName(); 680 QString filename = addressbookPersonalVCardName();
677 OContact me; 681 OContact me;
678 if (QFile::exists(filename)) 682 if (QFile::exists(filename))
679 me = OContact::readVCard( filename )[0]; 683 me = OContact::readVCard( filename )[0];
680 684
681 abView()->init( me ); 685 abView()->init( me );
682 abView()->sync(); 686 abView()->sync();
683 listContainer->hide(); 687 listContainer->hide();
684 setCentralWidget( abView() ); 688 setCentralWidget( abView() );
685 mView->show(); 689 mView->show();
@@ -907,79 +911,107 @@ void AddressbookWindow::initFields()
907 slOrderedFields.remove( "First Name" ); 911 slOrderedFields.remove( "First Name" );
908 slOrderedFields.remove( "Last Name" ); 912 slOrderedFields.remove( "Last Name" );
909 slOrderedFields.remove( "File As" ); 913 slOrderedFields.remove( "File As" );
910 slOrderedFields.remove( "Default Email" ); 914 slOrderedFields.remove( "Default Email" );
911 slOrderedFields.remove( "Notes" ); 915 slOrderedFields.remove( "Notes" );
912 slOrderedFields.remove( "Gender" ); 916 slOrderedFields.remove( "Gender" );
913 917
914 } 918 }
915} 919}
916 920
917 921
918AbLabel *AddressbookWindow::abView() 922AbLabel *AddressbookWindow::abView()
919{ 923{
920 if ( !mView ) { 924 if ( !mView ) {
921 mView = new AbLabel( this, "viewer" ); 925 mView = new AbLabel( this, "viewer" );
922 mView->init( OContact() ); 926 mView->init( OContact() );
923 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); 927 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
924 } 928 }
925 return mView; 929 return mView;
926} 930}
927 931
928void AddressbookWindow::slotFindOpen() 932void AddressbookWindow::slotFindOpen()
929{ 933{
930 searchBar->show(); 934 searchBar->show();
935 abList -> inSearch();
931 searchEdit->setFocus(); 936 searchEdit->setFocus();
932} 937}
933void AddressbookWindow::slotFindClose() 938void AddressbookWindow::slotFindClose()
934{ 939{
935 searchBar->hide(); 940 searchBar->hide();
941 abList -> offSearch();
936 abList->setFocus(); 942 abList->setFocus();
937} 943}
938void AddressbookWindow::slotFindNext() 944void AddressbookWindow::slotFindNext()
939{ 945{
940 if ( centralWidget() == abView() ) 946 if ( centralWidget() == abView() )
941 showList(); 947 showList();
942 948
943 // Maybe we should react on Wraparound and notfound ?
944 // QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
945 // QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
946
947 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false); 949 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false);
948 950
951 searchEdit->clearFocus();
952 abList->setFocus();
953 if ( abList->numSelections() )
954 abList->clearSelection();
955
956}
957void AddressbookWindow::slotFindPrevious()
958{
959 if ( centralWidget() == abView() )
960 showList();
961
962 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true);
949 963
950 if ( abList->numSelections() ) 964 if ( abList->numSelections() )
951 abList->clearSelection(); 965 abList->clearSelection();
952 966
953} 967}
954 968
955void AddressbookWindow::slotFind() 969void AddressbookWindow::slotFind()
956{ 970{
957 971
958 abList->clearFindRow(); 972 abList->clearFindRow();
959 slotFindNext(); 973 slotFindNext();
960} 974}
961 975
976void AddressbookWindow::slotNotFound()
977{
978 qWarning("Got notfound signal !");
979 QMessageBox::information( this, tr( "Not Found" ),
980 tr( "Unable to find a contact for this" ) + "\n"
981 + tr( "search pattern !" ) );
982
983
984}
985void AddressbookWindow::slotWrapAround()
986{
987 qWarning("Got wrap signal !");
988 if ( doNotifyWrapAround )
989 QMessageBox::information( this, tr( "End of list" ),
990 tr( "End of list. Wrap around now.. !" ) + "\n" );
991
992}
993
962void AddressbookWindow::slotSetCategory( int c ) 994void AddressbookWindow::slotSetCategory( int c )
963{ 995{
964 996
965 QString cat, book; 997 QString cat, book;
966 998
967 if ( c <= 0 ) 999 if ( c <= 0 )
968 return; 1000 return;
969 1001
970 // Set checkItem for selected one 1002 // Set checkItem for selected one
971 for ( unsigned int i = 1; i < catMenu->count(); i++ ) 1003 for ( unsigned int i = 1; i < catMenu->count(); i++ )
972 catMenu->setItemChecked( i, c == (int)i ); 1004 catMenu->setItemChecked( i, c == (int)i );
973 1005
974 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 1006 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
975 if (catMenu->isItemChecked( i )) { 1007 if (catMenu->isItemChecked( i )) {
976 if ( i == 1 ) // default List view 1008 if ( i == 1 ) // default List view
977 book = QString::null; 1009 book = QString::null;
978 else if ( i == 2 ) 1010 else if ( i == 2 )
979 book = "Phone"; 1011 book = "Phone";
980 else if ( i == 3 ) 1012 else if ( i == 3 )
981 book = "Company"; 1013 book = "Company";
982 else if ( i == 4 ) 1014 else if ( i == 4 )
983 book = "Email"; 1015 book = "Email";
984 else if ( i == 5 ) 1016 else if ( i == 5 )
985 book = "Cards"; 1017 book = "Cards";
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 18b083f..299ed70 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -41,90 +41,93 @@ class QAction;
41class LetterPicker; 41class LetterPicker;
42 42
43class AddressbookWindow: public QMainWindow 43class AddressbookWindow: public QMainWindow
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
47 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 47 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
48 ~AddressbookWindow(); 48 ~AddressbookWindow();
49 49
50protected: 50protected:
51 void resizeEvent( QResizeEvent * e ); 51 void resizeEvent( QResizeEvent * e );
52 void showList(); 52 void showList();
53 void showView(); 53 void showView();
54 enum EntryMode { NewEntry=0, EditEntry }; 54 enum EntryMode { NewEntry=0, EditEntry };
55 void editPersonal(); 55 void editPersonal();
56 void editEntry( EntryMode ); 56 void editEntry( EntryMode );
57 void closeEvent( QCloseEvent *e ); 57 void closeEvent( QCloseEvent *e );
58 bool save(); 58 bool save();
59 59
60public slots: 60public slots:
61 void flush(); 61 void flush();
62 void reload(); 62 void reload();
63 void appMessage(const QCString &, const QByteArray &); 63 void appMessage(const QCString &, const QByteArray &);
64 void setDocument( const QString & ); 64 void setDocument( const QString & );
65 void slotFindNext();
66 void slotFindPrevious();
65#ifdef __DEBUG_RELEASE 67#ifdef __DEBUG_RELEASE
66 void slotSave(); 68 void slotSave();
67#endif 69#endif
68 70
69private slots: 71private slots:
70 void importvCard(); 72 void importvCard();
71 void slotListNew(); 73 void slotListNew();
72 void slotListView(); 74 void slotListView();
73 void slotListDelete(); 75 void slotListDelete();
74 void slotViewBack(); 76 void slotViewBack();
75 void slotViewEdit(); 77 void slotViewEdit();
76 void slotPersonalView(); 78 void slotPersonalView();
77 void listIsEmpty( bool ); 79 void listIsEmpty( bool );
78 void slotSettings(); 80 void slotSettings();
79 void writeMail(); 81 void writeMail();
80 void slotBeam(); 82 void slotBeam();
81 void beamDone( Ir * ); 83 void beamDone( Ir * );
82 void slotSetCategory( int ); 84 void slotSetCategory( int );
83 void slotSetLetter( char ); 85 void slotSetLetter( char );
84 void slotUpdateToolbar(); 86 void slotUpdateToolbar();
85 void slotSetFont(int); 87 void slotSetFont(int);
86 88
87 void slotFindOpen(); 89 void slotFindOpen();
88 void slotFindClose(); 90 void slotFindClose();
89 void slotFind(); 91 void slotFind();
90 void slotFindNext(); 92 void slotNotFound();
93 void slotWrapAround();
91 94
92 void slotConfig(); 95 void slotConfig();
93 96
94private: 97private:
95 void initFields(); // inititialize our fields... 98 void initFields(); // inititialize our fields...
96 AbLabel *abView(); 99 AbLabel *abView();
97 void populateCategories(); 100 void populateCategories();
98 101
99 QPopupMenu *catMenu, *fontMenu; 102 QPopupMenu *catMenu, *fontMenu;
100 QPEToolBar *listTools; 103 QPEToolBar *listTools;
101 QToolButton *deleteButton; 104 QToolButton *deleteButton;
102 QValueList<int> allFields, orderedFields; 105 QValueList<int> allFields, orderedFields;
103 QStringList slOrderedFields; 106 QStringList slOrderedFields;
104 enum Panes { paneList=0, paneView, paneEdit }; 107 enum Panes { paneList=0, paneView, paneEdit };
105 ContactEditor *abEditor; 108 ContactEditor *abEditor;
106 AbLabel *mView; 109 AbLabel *mView;
107 LetterPicker *pLabel; 110 LetterPicker *pLabel;
108 AbTable *abList; 111 AbTable *abList;
109 QWidget *listContainer; 112 QWidget *listContainer;
110 113
111 // Searching stuff 114 // Searching stuff
112 OFloatBar* searchBar; 115 OFloatBar* searchBar;
113 QLineEdit* searchEdit; 116 QLineEdit* searchEdit;
114 bool useRegExp; 117 bool useRegExp;
115 bool DoSignalWrapAround; 118 bool doNotifyWrapAround;
116 bool caseSensitive; 119 bool caseSensitive;
117 120
118 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; 121 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail;
119 122
120 bool bAbEditFirstTime; 123 bool bAbEditFirstTime;
121 int viewMargin; 124 int viewMargin;
122 125
123 bool syncing; 126 bool syncing;
124 QFont *defaultFont; 127 QFont *defaultFont;
125 int startFontSize; 128 int startFontSize;
126 129
127 bool isLoading; 130 bool isLoading;
128}; 131};
129 132
130#endif 133#endif
diff --git a/core/pim/addressbook/picker.cpp b/core/pim/addressbook/picker.cpp
index a165451..7f4acb0 100644
--- a/core/pim/addressbook/picker.cpp
+++ b/core/pim/addressbook/picker.cpp
@@ -54,94 +54,103 @@ void PickerLabel::setLetters( char ch1, char ch2, char ch3 )
54 54
55 setText(tmpStr); 55 setText(tmpStr);
56 56
57 currentLetter = 0; 57 currentLetter = 0;
58 58
59} 59}
60 60
61void PickerLabel::clearLetter() 61void PickerLabel::clearLetter()
62{ 62{
63 63
64 QString tmpStr; 64 QString tmpStr;
65 65
66 tmpStr = "<qt>"; 66 tmpStr = "<qt>";
67 tmpStr += letter1; 67 tmpStr += letter1;
68 tmpStr += letter2; 68 tmpStr += letter2;
69 tmpStr += letter3; 69 tmpStr += letter3;
70 tmpStr += "</qt>"; 70 tmpStr += "</qt>";
71 71
72 setText(tmpStr); 72 setText(tmpStr);
73 73
74 currentLetter = 0; 74 currentLetter = 0;
75 75
76} 76}
77 77
78void PickerLabel::mouseReleaseEvent( QMouseEvent *e ) 78void PickerLabel::mousePressEvent( QMouseEvent* e )
79{
80 // If one pickerlabel is was, and an other is now selected, we
81 // have to simulate the releaseevent.. Otherwise the new label
82 // will not get a highlighted letter..
83 // Maybe there is a more intelligent solution, but this works and I am tired.. (se)
84 if ( ( currentLetter == 0 ) && ( lastLetter != '\0' ) ) mouseReleaseEvent( e );
85}
86
87void PickerLabel::mouseReleaseEvent( QMouseEvent* /* e */ )
79{ 88{
80 QString tmpStr; 89 QString tmpStr;
81 90
82 if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3 && lastLetter != '\0') 91 if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3 && lastLetter != '\0')
83 QTimer::singleShot( 0, this, SLOT(emitClearSignal()) ); 92 QTimer::singleShot( 0, this, SLOT(emitClearSignal()) );
84 93
85 switch (currentLetter) { 94 switch (currentLetter) {
86 case 0: 95 case 0:
87 tmpStr = "<qt><font color=\"#7F0000\">"; 96 tmpStr = "<qt><u><font color=\"#7F0000\">";
88 tmpStr += letter1; 97 tmpStr += letter1;
89 tmpStr += "</font>"; 98 tmpStr += "</font></u>";
90 tmpStr += letter2; 99 tmpStr += letter2;
91 tmpStr += letter3; 100 tmpStr += letter3;
92 tmpStr += "</qt>"; 101 tmpStr += "</qt>";
93 102
94 setText(tmpStr); 103 setText(tmpStr);
95 104
96 currentLetter++; 105 currentLetter++;
97 lastLetter = letter1; 106 lastLetter = letter1;
98 emit selectedLetter( letter1 ); 107 emit selectedLetter( letter1 );
99 break; 108 break;
100 109
101 case 1: 110 case 1:
102 tmpStr = "<qt>"; 111 tmpStr = "<qt>";
103 tmpStr += letter1; 112 tmpStr += letter1;
104 tmpStr += "<font color=\"#7F0000\">"; 113 tmpStr += "<u><font color=\"#7F0000\">";
105 tmpStr += letter2; 114 tmpStr += letter2;
106 tmpStr += "</font>"; 115 tmpStr += "</font></u>";
107 tmpStr += letter3; 116 tmpStr += letter3;
108 tmpStr += "</qt>"; 117 tmpStr += "</qt>";
109 118
110 setText(tmpStr); 119 setText(tmpStr);
111 120
112 currentLetter++; 121 currentLetter++;
113 lastLetter = letter2; 122 lastLetter = letter2;
114 emit selectedLetter( letter2 ); 123 emit selectedLetter( letter2 );
115 break; 124 break;
116 125
117 case 2: 126 case 2:
118 tmpStr = "<qt>"; 127 tmpStr = "<qt>";
119 tmpStr += letter1; 128 tmpStr += letter1;
120 tmpStr += letter2; 129 tmpStr += letter2;
121 tmpStr += "<font color=\"#7F0000\">"; 130 tmpStr += "<u><font color=\"#7F0000\">";
122 tmpStr += letter3; 131 tmpStr += letter3;
123 tmpStr += "</font></qt>"; 132 tmpStr += "</font></u></qt>";
124 133
125 setText(tmpStr); 134 setText(tmpStr);
126 135
127 currentLetter++; 136 currentLetter++;
128 lastLetter = letter3; 137 lastLetter = letter3;
129 emit selectedLetter( letter3 ); 138 emit selectedLetter( letter3 );
130 break; 139 break;
131 140
132 default: 141 default:
133 clearLetter(); 142 clearLetter();
134 lastLetter = '\0'; 143 lastLetter = '\0';
135 emit selectedLetter( '\0' ); 144 emit selectedLetter( '\0' );
136 145
137 146
138 } 147 }
139} 148}
140 149
141void PickerLabel::emitClearSignal() { 150void PickerLabel::emitClearSignal() {
142 emit clearAll(); 151 emit clearAll();
143} 152}
144 153
145LetterPicker::LetterPicker( QWidget *parent, const char *name ) 154LetterPicker::LetterPicker( QWidget *parent, const char *name )
146 : QFrame( parent, name ) 155 : QFrame( parent, name )
147{ 156{
@@ -203,27 +212,28 @@ LetterPicker::LetterPicker( QWidget *parent, const char *name )
203 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear())); 212 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear()));
204 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear())); 213 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear()));
205 214
206} 215}
207 216
208LetterPicker::~LetterPicker() 217LetterPicker::~LetterPicker()
209{ 218{
210} 219}
211 220
212void LetterPicker::clear() 221void LetterPicker::clear()
213{ 222{
214 lblABC->clearLetter(); 223 lblABC->clearLetter();
215 lblDEF->clearLetter(); 224 lblDEF->clearLetter();
216 lblGHI->clearLetter(); 225 lblGHI->clearLetter();
217 lblJKL->clearLetter(); 226 lblJKL->clearLetter();
218 lblMNO->clearLetter(); 227 lblMNO->clearLetter();
219 lblPQR->clearLetter(); 228 lblPQR->clearLetter();
220 lblSTU->clearLetter(); 229 lblSTU->clearLetter();
221 lblVWX->clearLetter(); 230 lblVWX->clearLetter();
222 lblYZ->clearLetter(); 231 lblYZ->clearLetter();
223} 232}
224 233
225void LetterPicker::newLetter( char letter ) 234void LetterPicker::newLetter( char letter )
226{ 235{
236 qWarning("LetterClicked");
227 emit letterClicked( letter ); 237 emit letterClicked( letter );
228 238
229} 239}
diff --git a/core/pim/addressbook/picker.h b/core/pim/addressbook/picker.h
index de5bd9d..d76d582 100644
--- a/core/pim/addressbook/picker.h
+++ b/core/pim/addressbook/picker.h
@@ -10,56 +10,59 @@
10#ifndef PICKER_H 10#ifndef PICKER_H
11#define PICKER_H 11#define PICKER_H
12 12
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qframe.h> 14#include <qframe.h>
15#include <qevent.h> 15#include <qevent.h>
16 16
17class PickerLabel: public QLabel { 17class PickerLabel: public QLabel {
18Q_OBJECT 18Q_OBJECT
19 public: 19 public:
20 PickerLabel( QWidget *parent = 0, const char *name = 0 ); 20 PickerLabel( QWidget *parent = 0, const char *name = 0 );
21 ~PickerLabel(); 21 ~PickerLabel();
22 22
23 void setLetters( char ch1, char ch2, char ch3 ); 23 void setLetters( char ch1, char ch2, char ch3 );
24 void clearLetter(); 24 void clearLetter();
25 25
26 signals: 26 signals:
27 27
28 void selectedLetter( char ); 28 void selectedLetter( char );
29 void clearAll(); 29 void clearAll();
30 30
31 protected: 31 protected:
32 32
33 void mouseReleaseEvent( QMouseEvent *e ); 33 void mouseReleaseEvent( QMouseEvent *e );
34 void mousePressEvent( QMouseEvent *e );
34 35
35 private: 36 private:
36 37
37 int currentLetter; 38 int currentLetter;
38 static char lastLetter; 39 static char lastLetter;
39 char letter1, letter2, letter3; 40 char letter1, letter2, letter3;
40 41
41 private slots: 42 private slots:
42 43
43 void emitClearSignal(); 44 void emitClearSignal();
44 45
45}; 46};
46class LetterPicker: public QFrame { 47class LetterPicker: public QFrame {
47Q_OBJECT 48Q_OBJECT
48 public: 49 public:
49 LetterPicker( QWidget *parent = 0, const char *name = 0 ); 50 LetterPicker( QWidget *parent = 0, const char *name = 0 );
50 ~LetterPicker(); 51 ~LetterPicker();
52
51 53
52 public slots: 54 public slots:
53 void clear(); 55 void clear();
54 56
55 signals: 57 signals:
56 void letterClicked( char ); 58 void letterClicked( char );
57 59
58 private: 60 private:
59 PickerLabel *lblABC, *lblDEF, *lblGHI, *lblJKL, *lblMNO, *lblPQR, *lblSTU, *lblVWX, *lblYZ; 61 PickerLabel *lblABC, *lblDEF, *lblGHI, *lblJKL, *lblMNO, *lblPQR, *lblSTU, *lblVWX, *lblYZ;
62 PickerLabel *lastLabel;
60 63
61 private slots: 64 private slots:
62 void newLetter( char letter ); 65 void newLetter( char letter );
63}; 66};
64 67
65#endif 68#endif