Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 70 |
1 files changed, 51 insertions, 19 deletions
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 | |||
@@ -69,31 +69,38 @@ static 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 | ||
76 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 76 | AddressbookWindow::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 | ||
@@ -152,25 +159,25 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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, |
@@ -214,25 +221,31 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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(); |
@@ -249,48 +262,41 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 | ||
273 | void AddressbookWindow::slotConfig() | 279 | void 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 | ||
291 | void AddressbookWindow::slotSetFont( int size ) { | 297 | void 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; |
@@ -364,25 +370,25 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e ) | |||
364 | showView(); | 370 | showView(); |
365 | } | 371 | } |
366 | 372 | ||
367 | AddressbookWindow::~AddressbookWindow() | 373 | AddressbookWindow::~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 | ||
379 | void AddressbookWindow::slotUpdateToolbar() | 385 | void 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 | ||
385 | void AddressbookWindow::showList() | 391 | void AddressbookWindow::showList() |
386 | { | 392 | { |
387 | bool visiblemView; | 393 | bool visiblemView; |
388 | 394 | ||
@@ -647,27 +653,25 @@ void AddressbookWindow::editPersonal() | |||
647 | abView()->sync(); | 653 | abView()->sync(); |
648 | } | 654 | } |
649 | abEditor->setCaption( tr("Edit Address") ); | 655 | abEditor->setCaption( tr("Edit Address") ); |
650 | } | 656 | } |
651 | 657 | ||
652 | void AddressbookWindow::slotPersonalView() | 658 | void 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); |
@@ -919,55 +923,83 @@ AbLabel *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 | ||
928 | void AddressbookWindow::slotFindOpen() | 932 | void AddressbookWindow::slotFindOpen() |
929 | { | 933 | { |
930 | searchBar->show(); | 934 | searchBar->show(); |
935 | abList -> inSearch(); | ||
931 | searchEdit->setFocus(); | 936 | searchEdit->setFocus(); |
932 | } | 937 | } |
933 | void AddressbookWindow::slotFindClose() | 938 | void AddressbookWindow::slotFindClose() |
934 | { | 939 | { |
935 | searchBar->hide(); | 940 | searchBar->hide(); |
941 | abList -> offSearch(); | ||
936 | abList->setFocus(); | 942 | abList->setFocus(); |
937 | } | 943 | } |
938 | void AddressbookWindow::slotFindNext() | 944 | void 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 | } | ||
957 | void 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 | ||
955 | void AddressbookWindow::slotFind() | 969 | void AddressbookWindow::slotFind() |
956 | { | 970 | { |
957 | 971 | ||
958 | abList->clearFindRow(); | 972 | abList->clearFindRow(); |
959 | slotFindNext(); | 973 | slotFindNext(); |
960 | } | 974 | } |
961 | 975 | ||
976 | void 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 | } | ||
985 | void 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 | |||
962 | void AddressbookWindow::slotSetCategory( int c ) | 994 | void 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 | ||