summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO8
-rw-r--r--core/pim/addressbook/abtable.cpp21
-rw-r--r--core/pim/addressbook/abtable.h5
-rw-r--r--core/pim/addressbook/addressbook.cpp56
4 files changed, 25 insertions, 65 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 32d2838..7bc906d 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -1,26 +1,28 @@
1Stuff todo: 1Stuff todo:
2 2
3Urgent: 3Urgent:
4- Syncing: abtable not reloaded after sync. 4
5- Font menu is invisible using german translation
5 6
6Important: 7Important:
7 8
8- Finishing of new View functions (List, Phonebook...) 9- Finishing of new View functions (List, Phonebook...)
9- Reload if contacts were changed externally 10- Reload if contacts were changed externally
10- "What's this" should be added 11- "What's this" should be added
11- The names of the countries are sorted by there english names, only.. 12- The names of the countries are sorted by there english names, only..
12 Even if they are translated.. :S 13 Even if they are translated.. :S
13- Store last settings of combo-boxes 14- Store last settings of combo-boxes
14 15
15Less important: 16Less important:
16 17
17- Find widget should be replaced by something like 18- Find widget should be replaced by something like
18 qpdf has. 19 qpdf has.
19- The picker (alphabetical sort widget) should be 20- The picker (alphabetical sort widget) should be
20 placed verticaly or horizontally (configurable) 21 placed verticaly or horizontally (configurable)
21 22
22 23
23Should be Fixed: 24Should be Fixed (not absolute sure, need validation):
24- "Nonenglish" translation bug has to be fixed. 25- "Nonenglish" translation bug has to be fixed.
25 26
26Fixed: \ No newline at end of file 27Fixed:
28- Syncing: abtable not reloaded after sync.
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 70c070f..91a7171 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -449,81 +449,84 @@ void AbTable::addEntry( const OContact &newCnt )
449 int row = numRows(); 449 int row = numRows();
450 450
451 setNumRows( row + 1 ); 451 setNumRows( row + 1 );
452 insertIntoTable( newCnt, row ); 452 insertIntoTable( newCnt, row );
453 453
454 qWarning("abtable:AddContact"); 454 qWarning("abtable:AddContact");
455 m_contactdb.add ( newCnt ); 455 m_contactdb.add ( newCnt );
456 456
457 setCurrentCell( row, 0 ); 457 setCurrentCell( row, 0 );
458 // updateVisible(); 458 // updateVisible();
459} 459}
460 460
461void AbTable::resizeRows() { 461void AbTable::resizeRows() {
462 /* 462 /*
463 if (numRows()) { 463 if (numRows()) {
464 for (int i = 0; i < numRows(); i++) { 464 for (int i = 0; i < numRows(); i++) {
465 setRowHeight( i, size ); 465 setRowHeight( i, size );
466 } 466 }
467 } 467 }
468 updateVisible(); 468 updateVisible();
469 */ 469 */
470} 470}
471 471
472 472
473bool AbTable::save( const QString& /* fn */ ) 473bool AbTable::save()
474{ 474{
475 // QTime t; 475 // QTime t;
476 // t.start(); 476 // t.start();
477 qWarning("abtable:Save data"); 477 qWarning("abtable:Save data");
478 m_contactdb.save(); 478
479 479 return m_contactdb.save();
480 return true;
481} 480}
482 481
483void AbTable::load( const QString& /* fn */ ) 482void AbTable::load()
484{ 483{
485 setSorting( false ); 484 setSorting( false );
486 setUpdatesEnabled( FALSE ); 485 setUpdatesEnabled( FALSE );
487 486
488 qWarning("abtable:Load data"); 487 qWarning("abtable:Load data");
489 488
490 OContactAccess::List list = m_contactdb.allRecords(); 489 OContactAccess::List list = m_contactdb.allRecords();
491 OContactAccess::List::Iterator it; 490 OContactAccess::List::Iterator it;
492 setNumRows( list.count() ); 491 setNumRows( list.count() );
493 int row = 0; 492 int row = 0;
494 for ( it = list.begin(); it != list.end(); ++it ) 493 for ( it = list.begin(); it != list.end(); ++it )
495 insertIntoTable( *it, row++ ); 494 insertIntoTable( *it, row++ );
496 495
497 resort();
498
499 setUpdatesEnabled( TRUE ); 496 setUpdatesEnabled( TRUE );
500 497
501 setSorting( true ); 498 setSorting( true );
502 //resort(); 499 resort();
503} 500}
504 501
505 502
503void AbTable::reload()
504{
505 m_contactdb.reload();
506 load();
507}
508
506void AbTable::realignTable( int row ) 509void AbTable::realignTable( int row )
507{ 510{
508 QTableItem *ti1, 511 QTableItem *ti1,
509 *ti2; 512 *ti2;
510 int totalRows = numRows(); 513 int totalRows = numRows();
511 for ( int curr = row; curr < totalRows - 1; curr++ ) { 514 for ( int curr = row; curr < totalRows - 1; curr++ ) {
512 // the same info from the todo list still applies, but I 515 // the same info from the todo list still applies, but I
513 // don't think it is _too_ bad. 516 // don't think it is _too_ bad.
514 ti1 = item( curr + 1, 0 ); 517 ti1 = item( curr + 1, 0 );
515 ti2 = item( curr + 1, 1 ); 518 ti2 = item( curr + 1, 1 );
516 takeItem( ti1 ); 519 takeItem( ti1 );
517 takeItem( ti2 ); 520 takeItem( ti2 );
518 setItem( curr, 0, ti1 ); 521 setItem( curr, 0, ti1 );
519 setItem( curr, 1, ti2 ); 522 setItem( curr, 1, ti2 );
520 } 523 }
521 setNumRows( totalRows - 1 ); 524 setNumRows( totalRows - 1 );
522 resort(); 525 resort();
523} 526}
524 527
525// Add contact into table. 528// Add contact into table.
526void AbTable::insertIntoTable( const OContact &cnt, int row ) 529void AbTable::insertIntoTable( const OContact &cnt, int row )
527{ 530{
528 QString strName, 531 QString strName,
529 strContact; 532 strContact;
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 84aef1e..80c3ca0 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -56,50 +56,51 @@ public:
56 56
57private: 57private:
58 QGuardedPtr<QComboBox> cb; 58 QGuardedPtr<QComboBox> cb;
59}; 59};
60 60
61class AbTable : public QTable 61class AbTable : public QTable
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 64
65public: 65public:
66 AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); 66 AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 );
67 ~AbTable(); 67 ~AbTable();
68 // NEW 68 // NEW
69 void addEntry( const OContact &newContact ); 69 void addEntry( const OContact &newContact );
70 OContact currentEntry(); 70 OContact currentEntry();
71 void replaceCurrentEntry( const OContact &newContact ); 71 void replaceCurrentEntry( const OContact &newContact );
72 72
73 void init(); 73 void init();
74 74
75 void deleteCurrentEntry(); 75 void deleteCurrentEntry();
76 void clear(); 76 void clear();
77 void clearFindRow() { currFindRow = -2; } 77 void clearFindRow() { currFindRow = -2; }
78 void loadFields(); 78 void loadFields();
79 void refresh(); 79 void refresh();
80 bool save( const QString &fn ); 80 bool save();
81 void load( const QString &fn ); 81 void load();
82 void reload();
82 83
83 // addresspicker mode 84 // addresspicker mode
84 void setChoiceNames( const QStringList& list); 85 void setChoiceNames( const QStringList& list);
85 QStringList choiceNames() const; 86 QStringList choiceNames() const;
86 void setChoiceSelection(int index, const QStringList& list); 87 void setChoiceSelection(int index, const QStringList& list);
87 QStringList choiceSelection(int index) const; 88 QStringList choiceSelection(int index) const;
88 void setShowCategory( const QString &b, const QString &c ); 89 void setShowCategory( const QString &b, const QString &c );
89 void setShowByLetter( char c ); 90 void setShowByLetter( char c );
90 QString showCategory() const; 91 QString showCategory() const;
91 QStringList categories(); 92 QStringList categories();
92 93
93 void resizeRows(); 94 void resizeRows();
94 95
95 void show(); 96 void show();
96 void setPaintingEnabled( bool e ); 97 void setPaintingEnabled( bool e );
97 98
98 QString showBook() const; 99 QString showBook() const;
99 100
100public slots: 101public slots:
101 void slotDoFind( const QString &str, bool caseSensitive, bool backwards, 102 void slotDoFind( const QString &str, bool caseSensitive, bool backwards,
102 int category ); 103 int category );
103signals: 104signals:
104 void empty( bool ); 105 void empty( bool );
105 void details(); 106 void details();
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 2eb9ddf..93581e8 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -46,60 +46,48 @@
46#include <qaction.h> 46#include <qaction.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qdir.h> 48#include <qdir.h>
49#include <qfile.h> 49#include <qfile.h>
50#include <qimage.h> 50#include <qimage.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qpe/qpemenubar.h> 52#include <qpe/qpemenubar.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qpixmap.h> 54#include <qpixmap.h>
55#include <qpopupmenu.h> 55#include <qpopupmenu.h>
56#include <qpe/qpetoolbar.h> 56#include <qpe/qpetoolbar.h>
57#include <qstringlist.h> 57#include <qstringlist.h>
58#include <qtoolbutton.h> 58#include <qtoolbutton.h>
59#include <qwhatsthis.h> 59#include <qwhatsthis.h>
60 60
61#include <stdlib.h> 61#include <stdlib.h>
62#include <sys/stat.h> 62#include <sys/stat.h>
63#include <sys/types.h> 63#include <sys/types.h>
64#include <fcntl.h> 64#include <fcntl.h>
65#include <unistd.h> 65#include <unistd.h>
66 66
67#include <qdatetime.h> 67#include <qdatetime.h>
68 68
69#include "picker.h" 69#include "picker.h"
70static QString addressbookOldXMLFilename()
71{
72 QString filename = QPEApplication::documentDir() + "addressbook.xml";
73 return filename;
74}
75
76static QString addressbookXMLFilename()
77{
78 QString filename = Global::applicationFileName("addressbook",
79 "addressbook.xml");
80 return filename;
81}
82 70
83static QString addressbookPersonalVCardName() 71static QString addressbookPersonalVCardName()
84{ 72{
85 QString filename = Global::applicationFileName("addressbook", 73 QString filename = Global::applicationFileName("addressbook",
86 "businesscard.vcf"); 74 "businesscard.vcf");
87 return filename; 75 return filename;
88} 76}
89 77
90 78
91AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 79AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
92 WFlags f ) 80 WFlags f )
93 : QMainWindow( parent, name, f ), 81 : QMainWindow( parent, name, f ),
94 abEditor(0), 82 abEditor(0),
95 bAbEditFirstTime(TRUE), 83 bAbEditFirstTime(TRUE),
96 syncing(FALSE) 84 syncing(FALSE)
97{ 85{
98 isLoading = true; 86 isLoading = true;
99 87
100 initFields(); 88 initFields();
101 89
102 setCaption( tr("Contacts") ); 90 setCaption( tr("Contacts") );
103 setIcon( Resource::loadPixmap( "AddressBook" ) ); 91 setIcon( Resource::loadPixmap( "AddressBook" ) );
104 92
105 setToolBarsMovable( FALSE ); 93 setToolBarsMovable( FALSE );
@@ -181,81 +169,62 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
181 a->addTo( edit ); 169 a->addTo( edit );
182 a->addTo( listTools ); 170 a->addTo( listTools );
183 } 171 }
184 172
185 edit->insertSeparator(); 173 edit->insertSeparator();
186 174
187 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); 175 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE );
188 actionPersonal = a; 176 actionPersonal = a;
189 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 177 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
190 a->addTo( edit ); 178 a->addTo( edit );
191 179
192 edit->insertSeparator(); 180 edit->insertSeparator();
193 181
194 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 182 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
195 actionPersonal = a; 183 actionPersonal = a;
196 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 184 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
197 a->addTo( edit ); 185 a->addTo( edit );
198 186
199 187
200 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 188 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
201 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 189 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
202 a->addTo( edit ); 190 a->addTo( edit );
203 191
204 // Create Views 192 // Create Views
205
206 // This is safe to call without checking to see if it exists...
207 // not to mention it also does the necessary stuff for the
208 // journaling...
209 QString str = addressbookXMLFilename();
210 if ( str.isNull() ) {
211 QMessageBox::warning(
212 this,
213 tr("Out of Space"),
214 tr("There is not enough space to create\n"
215 "neccessary startup files.\n"
216 "\nFree up some space before\nentering data!")
217 );
218 }
219
220 listContainer = new QWidget( this ); 193 listContainer = new QWidget( this );
221 194
222 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 195 QVBoxLayout *vb = new QVBoxLayout( listContainer );
223 196
224 abList = new AbTable( &orderedFields, listContainer, "table" ); 197 abList = new AbTable( &orderedFields, listContainer, "table" );
225 vb->addWidget(abList); 198 vb->addWidget(abList);
226 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 199 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
227 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); 200 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) );
228 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); 201 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) );
229 connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); 202 connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) );
230 203
231 mView = 0; 204 mView = 0;
232 205
233 abList->load( addressbookXMLFilename() ); 206 abList->load();
234 if ( QFile::exists(addressbookOldXMLFilename()) ) {
235 abList->load( addressbookOldXMLFilename() );
236 QFile::remove(addressbookOldXMLFilename());
237 }
238 207
239 pLabel = new LetterPicker( listContainer ); 208 pLabel = new LetterPicker( listContainer );
240 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 209 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
241 vb->addWidget(pLabel); 210 vb->addWidget(pLabel);
242 catMenu = new QPopupMenu( this ); 211 catMenu = new QPopupMenu( this );
243 catMenu->setCheckable( TRUE ); 212 catMenu->setCheckable( TRUE );
244 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 213 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
245 populateCategories(); 214 populateCategories();
246 215
247 mbList->insertItem( tr("View"), catMenu ); 216 mbList->insertItem( tr("View"), catMenu );
248 // setCentralWidget( listContainer ); 217 // setCentralWidget( listContainer );
249 218
250 fontMenu = new QPopupMenu(this); 219 fontMenu = new QPopupMenu(this);
251 fontMenu->setCheckable( true ); 220 fontMenu->setCheckable( true );
252 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); 221 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
253 222
254 fontMenu->insertItem(tr( "Small" ), 0); 223 fontMenu->insertItem(tr( "Small" ), 0);
255 fontMenu->insertItem(tr( "Normal" ), 1); 224 fontMenu->insertItem(tr( "Normal" ), 1);
256 fontMenu->insertItem(tr( "Large" ), 2); 225 fontMenu->insertItem(tr( "Large" ), 2);
257 226
258 defaultFont = new QFont( abList->font() ); 227 defaultFont = new QFont( abList->font() );
259 228
260 slotSetFont(startFontSize); 229 slotSetFont(startFontSize);
261 230
@@ -688,121 +657,106 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
688 insertEntry.assignUid(); 657 insertEntry.assignUid();
689 abList->addEntry( insertEntry ); 658 abList->addEntry( insertEntry );
690 } else { 659 } else {
691 OContact replaceEntry = abEditor->entry(); 660 OContact replaceEntry = abEditor->entry();
692 if ( !replaceEntry.isValidUid() ) 661 if ( !replaceEntry.isValidUid() )
693 replaceEntry.assignUid(); 662 replaceEntry.assignUid();
694 abList->replaceCurrentEntry( replaceEntry ); 663 abList->replaceCurrentEntry( replaceEntry );
695 } 664 }
696 } 665 }
697 populateCategories(); 666 populateCategories();
698 showList(); 667 showList();
699} 668}
700 669
701void AddressbookWindow::listIsEmpty( bool empty ) 670void AddressbookWindow::listIsEmpty( bool empty )
702{ 671{
703 if ( !empty ) { 672 if ( !empty ) {
704 deleteButton->setEnabled( TRUE ); 673 deleteButton->setEnabled( TRUE );
705 } 674 }
706} 675}
707 676
708void AddressbookWindow::reload() 677void AddressbookWindow::reload()
709{ 678{
710 syncing = FALSE; 679 syncing = FALSE;
711 abList->clear(); 680 abList->clear();
712 abList->load( addressbookXMLFilename() ); 681 abList->reload();
713} 682}
714 683
715void AddressbookWindow::flush() 684void AddressbookWindow::flush()
716{ 685{
717 syncing = TRUE; 686 syncing = TRUE;
718 abList->save( addressbookXMLFilename() ); 687 abList->save();
719} 688}
720 689
721 690
722void AddressbookWindow::closeEvent( QCloseEvent *e ) 691void AddressbookWindow::closeEvent( QCloseEvent *e )
723{ 692{
724 if ( centralWidget() == mView ) { 693 if ( centralWidget() == mView ) {
725 if (actionPersonal->isOn()) { 694 if (actionPersonal->isOn()) {
726 // pretend we clicked it off 695 // pretend we clicked it off
727 actionPersonal->setOn(FALSE); 696 actionPersonal->setOn(FALSE);
728 slotPersonalView(); 697 slotPersonalView();
729 } else { 698 } else {
730 showList(); 699 showList();
731 } 700 }
732 e->ignore(); 701 e->ignore();
733 return; 702 return;
734 } 703 }
735 704
736 if(syncing) { 705 if(syncing) {
737 /* shouldn't we save, I hear you say? well its already been set 706 /* shouldn't we save, I hear you say? well its already been set
738 so that an edit can not occur during a sync, and we flushed 707 so that an edit can not occur during a sync, and we flushed
739 at the start of the sync, so there is no need to save 708 at the start of the sync, so there is no need to save
740 Saving however itself would cause problems. */ 709 Saving however itself would cause problems. */
741 e->accept(); 710 e->accept();
742 return; 711 return;
743 } 712 }
744 //################## shouldn't always save 713 //################## shouldn't always save
745 // True, but the database handles this automatically ! (se) 714 // True, but the database handles this automatically ! (se)
746 if ( save() ) 715 if ( save() )
747 e->accept(); 716 e->accept();
748 else 717 else
749 e->ignore(); 718 e->ignore();
750} 719}
751 720
752/* 721/*
753 Returns TRUE if it is OK to exit 722 Returns TRUE if it is OK to exit
754*/ 723*/
755 724
756bool AddressbookWindow::save() 725bool AddressbookWindow::save()
757{ 726{
758 QString str = addressbookXMLFilename(); 727 if ( !abList->save() ) {
759 if ( str.isNull() ) { 728 if ( QMessageBox::critical( 0, tr( "Out of space" ),
760 if ( QMessageBox::critical( 0, tr("Out of space"),
761 tr("Unable to save information.\n" 729 tr("Unable to save information.\n"
762 "Free up some space\n" 730 "Free up some space\n"
763 "and try again.\n" 731 "and try again.\n"
764 "\nQuit anyway?"), 732 "\nQuit anyway?"),
765 QMessageBox::Yes|QMessageBox::Escape, 733 QMessageBox::Yes|QMessageBox::Escape,
766 QMessageBox::No|QMessageBox::Default ) 734 QMessageBox::No|QMessageBox::Default )
767 != QMessageBox::No ) 735 != QMessageBox::No )
768 return TRUE; 736 return TRUE;
769 else 737 else
770 return FALSE; 738 return FALSE;
771 } else {
772 if ( !abList->save( str ) ) {
773 if ( QMessageBox::critical( 0, tr( "Out of space" ),
774 tr("Unable to save information.\n"
775 "Free up some space\n"
776 "and try again.\n"
777 "\nQuit anyway?"),
778 QMessageBox::Yes|QMessageBox::Escape,
779 QMessageBox::No|QMessageBox::Default )
780 != QMessageBox::No )
781 return TRUE;
782 else
783 return FALSE;
784 }
785 } 739 }
786 return TRUE; 740 return TRUE;
787} 741}
788 742
789void AddressbookWindow::slotSettings() 743void AddressbookWindow::slotSettings()
790{ 744{
791 AddressSettings frmSettings( this ); 745 AddressSettings frmSettings( this );
792#if defined(Q_WS_QWS) || defined(_WS_QWS_) 746#if defined(Q_WS_QWS) || defined(_WS_QWS_)
793 frmSettings.showMaximized(); 747 frmSettings.showMaximized();
794#endif 748#endif
795 749
796 if ( frmSettings.exec() ) { 750 if ( frmSettings.exec() ) {
797 allFields.clear(); 751 allFields.clear();
798 orderedFields.clear(); 752 orderedFields.clear();
799 slOrderedFields.clear(); 753 slOrderedFields.clear();
800 initFields(); 754 initFields();
801 if ( abEditor ) 755 if ( abEditor )
802 abEditor->loadFields(); 756 abEditor->loadFields();
803 abList->refresh(); 757 abList->refresh();
804 } 758 }
805} 759}
806 760
807 761
808void AddressbookWindow::initFields() 762void AddressbookWindow::initFields()