summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp53
-rw-r--r--core/pim/addressbook/addressbook.h6
2 files changed, 57 insertions, 2 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 5a8038b..b7b35bc 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -168,127 +168,174 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
168 actionPersonal = a; 168 actionPersonal = a;
169 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 169 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
170 a->addTo( edit ); 170 a->addTo( edit );
171 171
172 172
173 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 173 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
174 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 174 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
175 a->addTo( edit ); 175 a->addTo( edit );
176 176
177 // Create Views 177 // Create Views
178 178
179 // This is safe to call without checking to see if it exists... 179 // This is safe to call without checking to see if it exists...
180 // not to mention it also does the necessary stuff for the 180 // not to mention it also does the necessary stuff for the
181 // journaling... 181 // journaling...
182 QString str = addressbookXMLFilename(); 182 QString str = addressbookXMLFilename();
183 if ( str.isNull() ) { 183 if ( str.isNull() ) {
184 QMessageBox::warning( this, tr("Out of Space"), 184 QMessageBox::warning( this, tr("Out of Space"),
185 tr("There is not enough space to create\n" 185 tr("There is not enough space to create\n"
186 "neccessary startup files.\n" 186 "neccessary startup files.\n"
187 "\nFree up some space before\nentering data!") 187 "\nFree up some space before\nentering data!")
188 ); 188 );
189 } 189 }
190 190
191 abList = new AbTable( &orderedFields, this, "table" ); 191 abList = new AbTable( &orderedFields, this, "table" );
192 abList->setHScrollBarMode( QScrollView::AlwaysOff ); 192 abList->setHScrollBarMode( QScrollView::AlwaysOff );
193 connect( abList, SIGNAL( empty( bool ) ), 193 connect( abList, SIGNAL( empty( bool ) ),
194 this, SLOT( listIsEmpty( bool ) ) ); 194 this, SLOT( listIsEmpty( bool ) ) );
195 connect( abList, SIGNAL( details() ), 195 connect( abList, SIGNAL( details() ),
196 this, SLOT( slotListView() ) ); 196 this, SLOT( slotListView() ) );
197 connect( abList, SIGNAL(currentChanged(int,int)), 197 connect( abList, SIGNAL(currentChanged(int,int)),
198 this, SLOT(slotUpdateToolbar()) ); 198 this, SLOT(slotUpdateToolbar()) );
199 199
200 mView = 0; 200 mView = 0;
201 201
202 abList->load( addressbookXMLFilename() ); 202 abList->load( addressbookXMLFilename() );
203 if ( QFile::exists(addressbookOldXMLFilename()) ) { 203 if ( QFile::exists(addressbookOldXMLFilename()) ) {
204 abList->load( addressbookOldXMLFilename() ); 204 abList->load( addressbookOldXMLFilename() );
205 QFile::remove(addressbookOldXMLFilename()); 205 QFile::remove(addressbookOldXMLFilename());
206 } 206 }
207 207
208 catMenu = new QPopupMenu( this ); 208 catMenu = new QPopupMenu( this );
209 catMenu->setCheckable( TRUE ); 209 catMenu->setCheckable( TRUE );
210 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 210 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
211 populateCategories(); 211 populateCategories();
212 212
213 mbList->insertItem( tr("View"), catMenu ); 213 mbList->insertItem( tr("View"), catMenu );
214 setCentralWidget( abList ); 214 setCentralWidget( abList );
215 215
216 fontMenu = new QPopupMenu(this);
217 fontMenu->setCheckable( true );
218 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
219
220 fontMenu->insertItem("Small", 0);
221 fontMenu->insertItem("Normal", 1);
222 fontMenu->insertItem("Large", 2);
223
224 defaultFont = new QFont( abList->font() );
225
226 slotSetFont(startFontSize);
227
228 mbList->insertItem( tr("Font"), fontMenu);
229 setCentralWidget(abList);
230
216 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 231 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
217} 232}
233void AddressbookWindow::slotSetFont( int size ) {
234
235 if (size > 2 || size < 0)
236 size = 1;
237
238 startFontSize = size;
239
240 switch (size) {
241 case 0:
242 fontMenu->setItemChecked(0, true);
243 fontMenu->setItemChecked(1, false);
244 fontMenu->setItemChecked(2, false);
245 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
246 break;
247 case 1:
248 fontMenu->setItemChecked(0, false);
249 fontMenu->setItemChecked(1, true);
250 fontMenu->setItemChecked(2, false);
251 abList->setFont( *defaultFont );
252 break;
253 case 2:
254 fontMenu->setItemChecked(0, false);
255 fontMenu->setItemChecked(1, false);
256 fontMenu->setItemChecked(2, true);
257 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
258 break;
259 }
260}
261
218 262
219void AddressbookWindow::setDocument( const QString &filename ) 263void AddressbookWindow::setDocument( const QString &filename )
220{ 264{
221 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; 265 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return;
222 266
223 QValueList<Contact> cl = Contact::readVCard( filename ); 267 QValueList<Contact> cl = Contact::readVCard( filename );
224 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { 268 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
225 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") 269 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?")
226 // .arg( (*it).fullName() ); 270 // .arg( (*it).fullName() );
227 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == 271 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) ==
228 // QMessageBox::Ok ) { 272 // QMessageBox::Ok ) {
229 abList->addEntry( *it ); 273 abList->addEntry( *it );
230 // } 274 // }
231 } 275 }
232 276
233} 277}
234 278
235void AddressbookWindow::resizeEvent( QResizeEvent *e ) 279void AddressbookWindow::resizeEvent( QResizeEvent *e )
236{ 280{
237 QMainWindow::resizeEvent( e ); 281 QMainWindow::resizeEvent( e );
238 282
239 if ( centralWidget() == abList ) 283 if ( centralWidget() == abList )
240 showList(); 284 showList();
241 else if ( centralWidget() == mView ) 285 else if ( centralWidget() == mView )
242 showView(); 286 showView();
243} 287}
244 288
245AddressbookWindow::~AddressbookWindow() 289AddressbookWindow::~AddressbookWindow()
246{ 290{
291 Config cfg("AddressBook");
292 cfg.setGroup("Font");
293 cfg.writeEntry("fontSize", startFontSize);
247} 294}
248 295
249void AddressbookWindow::slotUpdateToolbar() 296void AddressbookWindow::slotUpdateToolbar()
250{ 297{
251 Contact ce = abList->currentEntry(); 298 Contact ce = abList->currentEntry();
252 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 299 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
253} 300}
254 301
255void AddressbookWindow::showList() 302void AddressbookWindow::showList()
256{ 303{
257 if ( mView ) mView->hide(); 304 if ( mView ) mView->hide();
258 setCentralWidget( abList ); 305 setCentralWidget( abList );
259 abList->show(); 306 abList->show();
260 // update our focues... (or use a stack widget!); 307 // update our focues... (or use a stack widget!);
261 abList->setFocus(); 308 abList->setFocus();
262} 309}
263 310
264void AddressbookWindow::showView() 311void AddressbookWindow::showView()
265{ 312{
266 if ( abList->numRows() > 0 ) { 313 if ( abList->numRows() > 0 ) {
267 abList->hide(); 314 abList->hide();
268 setCentralWidget( abView() ); 315 setCentralWidget( abView() );
269 mView->show(); 316 mView->show();
270 mView->setFocus(); 317 mView->setFocus();
271 } 318 }
272} 319}
273 320
274void AddressbookWindow::slotListNew() 321void AddressbookWindow::slotListNew()
275{ 322{
276 Contact cnt; 323 Contact cnt;
277 if( !syncing ) { 324 if( !syncing ) {
278 if ( abEditor ) 325 if ( abEditor )
279 abEditor->setEntry( cnt ); 326 abEditor->setEntry( cnt );
280 abView()->init( cnt ); 327 abView()->init( cnt );
281 editEntry( NewEntry ); 328 editEntry( NewEntry );
282 } else { 329 } else {
283 QMessageBox::warning(this, tr("Contacts"), 330 QMessageBox::warning(this, tr("Contacts"),
284 tr("Can not edit data, currently syncing")); 331 tr("Can not edit data, currently syncing"));
285 } 332 }
286} 333}
287 334
288void AddressbookWindow::slotListView() 335void AddressbookWindow::slotListView()
289{ 336{
290 abView()->init( abList->currentEntry() ); 337 abView()->init( abList->currentEntry() );
291 mView->sync(); 338 mView->sync();
292 showView(); 339 showView();
293} 340}
294 341
@@ -668,109 +715,115 @@ bool AddressbookWindow::save()
668 return TRUE; 715 return TRUE;
669} 716}
670 717
671void AddressbookWindow::slotSettings() 718void AddressbookWindow::slotSettings()
672{ 719{
673 AddressSettings frmSettings( this ); 720 AddressSettings frmSettings( this );
674#if defined(Q_WS_QWS) || defined(_WS_QWS_) 721#if defined(Q_WS_QWS) || defined(_WS_QWS_)
675 frmSettings.showMaximized(); 722 frmSettings.showMaximized();
676#endif 723#endif
677 724
678 if ( frmSettings.exec() ) { 725 if ( frmSettings.exec() ) {
679 allFields.clear(); 726 allFields.clear();
680 orderedFields.clear(); 727 orderedFields.clear();
681 slOrderedFields.clear(); 728 slOrderedFields.clear();
682 initFields(); 729 initFields();
683 if ( abEditor ) 730 if ( abEditor )
684 abEditor->loadFields(); 731 abEditor->loadFields();
685 abList->refresh(); 732 abList->refresh();
686 } 733 }
687} 734}
688 735
689 736
690void AddressbookWindow::initFields() 737void AddressbookWindow::initFields()
691{ 738{
692 // we really don't need the things from the configuration, anymore 739 // we really don't need the things from the configuration, anymore
693 // only thing that is important are the important categories. So, 740 // only thing that is important are the important categories. So,
694 // Call the contact functions that correspond to these old functions... 741 // Call the contact functions that correspond to these old functions...
695 742
696 QStringList xmlFields = Contact::fields(); 743 QStringList xmlFields = Contact::fields();
697 QStringList visibleFields = Contact::trfields(); 744 QStringList visibleFields = Contact::trfields();
698 xmlFields.remove( "Title" ); 745 xmlFields.remove( "Title" );
699 visibleFields.remove( tr("Name Title") ); 746 visibleFields.remove( tr("Name Title") );
700 visibleFields.remove( tr("Notes") ); 747 visibleFields.remove( tr("Notes") );
701 748
702 int i, 749 int i,
703 version; 750 version;
704 Config cfg( "AddressBook" ); 751 Config cfg( "AddressBook" );
705 QString zn; 752 QString zn;
706 753
707 // ### Write a function to keep this from happening again... 754 // ### Write a function to keep this from happening again...
708 QStringList::ConstIterator it; 755 QStringList::ConstIterator it;
709 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { 756 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) {
710 allFields.append( i + 3 ); 757 allFields.append( i + 3 );
711 } 758 }
712 759
713 cfg.setGroup( "Version" ); 760 cfg.setGroup( "Version" );
714 version = cfg.readNumEntry( "version" ); 761 version = cfg.readNumEntry( "version" );
715 i = 0; 762 i = 0;
763 startFontSize = 1;
764
716 if ( version >= ADDRESSVERSION ) { 765 if ( version >= ADDRESSVERSION ) {
717 766
718 cfg.setGroup( "ImportantCategory" ); 767 cfg.setGroup( "ImportantCategory" );
719 768
720 zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); 769 zn = cfg.readEntry( "Category" + QString::number(i), QString::null );
721 while ( !zn.isNull() ) { 770 while ( !zn.isNull() ) {
722 if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) { 771 if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) {
723 slOrderedFields.clear(); 772 slOrderedFields.clear();
724 break; 773 break;
725 } 774 }
726 slOrderedFields.append( zn ); 775 slOrderedFields.append( zn );
727 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); 776 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null );
728 } 777 }
778 cfg.setGroup( "Font" );
779 startFontSize = cfg.readNumEntry( "fontSize", 1 );
780
781
729 } else { 782 } else {
730 QString str; 783 QString str;
731 str = getenv("HOME"); 784 str = getenv("HOME");
732 str += "/Settings/AddressBook.conf"; 785 str += "/Settings/AddressBook.conf";
733 QFile::remove( str ); 786 QFile::remove( str );
734 } 787 }
735 if ( slOrderedFields.count() > 0 ) { 788 if ( slOrderedFields.count() > 0 ) {
736 for( QStringList::ConstIterator it = slOrderedFields.begin(); 789 for( QStringList::ConstIterator it = slOrderedFields.begin();
737 it != slOrderedFields.end(); ++it ) { 790 it != slOrderedFields.end(); ++it ) {
738 QValueList<int>::ConstIterator itVl; 791 QValueList<int>::ConstIterator itVl;
739 QStringList::ConstIterator itVis; 792 QStringList::ConstIterator itVis;
740 itVl = allFields.begin(); 793 itVl = allFields.begin();
741 for ( itVis = visibleFields.begin(); 794 for ( itVis = visibleFields.begin();
742 itVis != visibleFields.end() && itVl != allFields.end(); 795 itVis != visibleFields.end() && itVl != allFields.end();
743 ++itVis, ++itVl ) { 796 ++itVis, ++itVl ) {
744 if ( *it == *itVis && itVl != allFields.end() ) { 797 if ( *it == *itVis && itVl != allFields.end() ) {
745 orderedFields.append( *itVl ); 798 orderedFields.append( *itVl );
746 } 799 }
747 } 800 }
748 } 801 }
749 } else { 802 } else {
750 QValueList<int>::ConstIterator it; 803 QValueList<int>::ConstIterator it;
751 for ( it = allFields.begin(); it != allFields.end(); ++it ) 804 for ( it = allFields.begin(); it != allFields.end(); ++it )
752 orderedFields.append( *it ); 805 orderedFields.append( *it );
753 806
754 slOrderedFields = visibleFields; 807 slOrderedFields = visibleFields;
755 orderedFields.remove( Qtopia::AddressUid ); 808 orderedFields.remove( Qtopia::AddressUid );
756 orderedFields.remove( Qtopia::Title ); 809 orderedFields.remove( Qtopia::Title );
757 orderedFields.remove( Qtopia::Groups ); 810 orderedFields.remove( Qtopia::Groups );
758 orderedFields.remove( Qtopia::AddressCategory ); 811 orderedFields.remove( Qtopia::AddressCategory );
759 orderedFields.remove( Qtopia::FirstName ); 812 orderedFields.remove( Qtopia::FirstName );
760 orderedFields.remove( Qtopia::LastName ); 813 orderedFields.remove( Qtopia::LastName );
761 orderedFields.remove( Qtopia::DefaultEmail ); 814 orderedFields.remove( Qtopia::DefaultEmail );
762 orderedFields.remove( Qtopia::FileAs ); 815 orderedFields.remove( Qtopia::FileAs );
763 orderedFields.remove( Qtopia::Notes ); 816 orderedFields.remove( Qtopia::Notes );
764 orderedFields.remove( Qtopia::Gender ); 817 orderedFields.remove( Qtopia::Gender );
765 slOrderedFields.remove( tr("Name Title") ); 818 slOrderedFields.remove( tr("Name Title") );
766 slOrderedFields.remove( tr("First Name") ); 819 slOrderedFields.remove( tr("First Name") );
767 slOrderedFields.remove( tr("Last Name") ); 820 slOrderedFields.remove( tr("Last Name") );
768 slOrderedFields.remove( tr("File As") ); 821 slOrderedFields.remove( tr("File As") );
769 slOrderedFields.remove( tr("Default Email") ); 822 slOrderedFields.remove( tr("Default Email") );
770 slOrderedFields.remove( tr("Notes") ); 823 slOrderedFields.remove( tr("Notes") );
771 slOrderedFields.remove( tr("Gender") ); 824 slOrderedFields.remove( tr("Gender") );
772 825
773 } 826 }
774} 827}
775 828
776 829
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 342077f..e2a7100 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -25,75 +25,77 @@
25class ContactEditor; 25class ContactEditor;
26class AbLabel; 26class AbLabel;
27class AbTable; 27class AbTable;
28class QPEToolBar; 28class QPEToolBar;
29class QPopupMenu; 29class QPopupMenu;
30class QToolButton; 30class QToolButton;
31class QDialog; 31class QDialog;
32class Ir; 32class Ir;
33class QAction; 33class QAction;
34 34
35class AddressbookWindow: public QMainWindow 35class AddressbookWindow: public QMainWindow
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38public: 38public:
39 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 39 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
40 ~AddressbookWindow(); 40 ~AddressbookWindow();
41 41
42protected: 42protected:
43 void resizeEvent( QResizeEvent * e ); 43 void resizeEvent( QResizeEvent * e );
44 void showList(); 44 void showList();
45 void showView(); 45 void showView();
46 enum EntryMode { NewEntry=0, EditEntry }; 46 enum EntryMode { NewEntry=0, EditEntry };
47 void editPersonal(); 47 void editPersonal();
48 void editEntry( EntryMode ); 48 void editEntry( EntryMode );
49 void closeEvent( QCloseEvent *e ); 49 void closeEvent( QCloseEvent *e );
50 bool save(); 50 bool save();
51 51
52public slots: 52public slots:
53 void flush(); 53 void flush();
54 void reload(); 54 void reload();
55 void appMessage(const QCString &, const QByteArray &); 55 void appMessage(const QCString &, const QByteArray &);
56 void setDocument( const QString & ); 56 void setDocument( const QString & );
57 57
58private slots: 58private slots:
59 void slotListNew(); 59 void slotListNew();
60 void slotListView(); 60 void slotListView();
61 void slotListDelete(); 61 void slotListDelete();
62 void slotViewBack(); 62 void slotViewBack();
63 void slotViewEdit(); 63 void slotViewEdit();
64 void slotPersonalView(); 64 void slotPersonalView();
65 void listIsEmpty( bool ); 65 void listIsEmpty( bool );
66 void slotSettings(); 66 void slotSettings();
67 void writeMail(); 67 void writeMail();
68 void slotBeam(); 68 void slotBeam();
69 void beamDone( Ir * ); 69 void beamDone( Ir * );
70 void slotFind(); 70 void slotFind();
71 void slotSetCategory( int ); 71 void slotSetCategory( int );
72 void slotUpdateToolbar(); 72 void slotUpdateToolbar();
73 73 void slotSetFont(int);
74private: 74private:
75 void initFields();// inititialize our fields... 75 void initFields();// inititialize our fields...
76 AbLabel *abView(); 76 AbLabel *abView();
77 void populateCategories(); 77 void populateCategories();
78 78
79 QPopupMenu *catMenu; 79 QPopupMenu *catMenu, *fontMenu;
80 QPEToolBar *listTools; 80 QPEToolBar *listTools;
81 QToolButton *deleteButton; 81 QToolButton *deleteButton;
82 QValueList<int> allFields, 82 QValueList<int> allFields,
83 orderedFields; 83 orderedFields;
84 QStringList slOrderedFields; 84 QStringList slOrderedFields;
85 enum Panes { paneList=0, paneView, paneEdit }; 85 enum Panes { paneList=0, paneView, paneEdit };
86 ContactEditor *abEditor; 86 ContactEditor *abEditor;
87 AbLabel *mView; 87 AbLabel *mView;
88 AbTable *abList; 88 AbTable *abList;
89 89
90 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, 90 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
91 *actionPersonal, *actionMail; 91 *actionPersonal, *actionMail;
92 92
93 bool bAbEditFirstTime; 93 bool bAbEditFirstTime;
94 int viewMargin; 94 int viewMargin;
95 95
96 bool syncing; 96 bool syncing;
97 QFont *defaultFont;
98 int startFontSize;
97}; 99};
98 100
99#endif 101#endif