Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 53 |
1 files changed, 53 insertions, 0 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 | |||
@@ -204,26 +204,70 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 | } |
233 | void 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 | ||
219 | void AddressbookWindow::setDocument( const QString &filename ) | 263 | void 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 ); |
@@ -235,24 +279,27 @@ void AddressbookWindow::setDocument( const QString &filename ) | |||
235 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 279 | void 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 | ||
245 | AddressbookWindow::~AddressbookWindow() | 289 | AddressbookWindow::~AddressbookWindow() |
246 | { | 290 | { |
291 | Config cfg("AddressBook"); | ||
292 | cfg.setGroup("Font"); | ||
293 | cfg.writeEntry("fontSize", startFontSize); | ||
247 | } | 294 | } |
248 | 295 | ||
249 | void AddressbookWindow::slotUpdateToolbar() | 296 | void 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 | ||
255 | void AddressbookWindow::showList() | 302 | void AddressbookWindow::showList() |
256 | { | 303 | { |
257 | if ( mView ) mView->hide(); | 304 | if ( mView ) mView->hide(); |
258 | setCentralWidget( abList ); | 305 | setCentralWidget( abList ); |
@@ -704,37 +751,43 @@ void AddressbookWindow::initFields() | |||
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(); |