-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 4fa9253..b4734a4 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp @@ -1,311 +1,311 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) ** ** This file is part of the Open Palmtop Environment (see www.opie.info). ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** **********************************************************************/ #define QTOPIA_INTERNAL_FD // #include "addresssettings.h" #include "addressbook.h" #include <opie2/odebug.h> #include <opie2/ofileselector.h> #include <opie2/ofiledialog.h> #include <opie2/opimcontact.h> #include <opie2/ocontactaccessbackend_vcard.h> #include <opie2/oresource.h> #include <qpe/ir.h> #include <qpe/qpemessagebox.h> #include <qmenubar.h> #include <qpe/qpeapplication.h> #include <qaction.h> #include <qlayout.h> #include <qmessagebox.h> #include <qtoolbutton.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include "picker.h" #include "configdlg.h" extern QString addressbookPersonalVCardName(); AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, WFlags /*f*/ ) : Opie::OPimMainWindow( "Addressbook", "Contacts", tr( "Contact" ), "AddressBook", parent, name, WType_TopLevel | WStyle_ContextHelp ), abEditor(0l), syncing(false) { setCaption( tr( "Contacts" ) ); isLoading = true; m_config.load(); // Create Views m_listContainer = new QWidget( this ); QVBoxLayout *vb = new QVBoxLayout( m_listContainer ); m_abView = new AbView( m_listContainer, m_config.orderList() ); vb->addWidget( m_abView ); connect( m_abView, SIGNAL(signalViewSwitched(int)), this, SLOT(slotViewSwitched(int)) ); QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); // Letter Picker pLabel = new LetterPicker( m_listContainer ); connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); connect(m_abView, SIGNAL(signalClearLetterPicker()), pLabel, SLOT(clear()) ); vb->addWidget( pLabel ); // Quick search bar m_searchBar = new OFloatBar( "Search", this, QMainWindow::Top, true ); m_searchBar->setHorizontalStretchable( true ); m_searchBar->hide(); m_searchEdit = new QLineEdit( m_searchBar, "m_searchEdit" ); m_searchBar->setStretchableWidget( m_searchEdit ); connect( m_searchEdit, SIGNAL(returnPressed()), this, SLOT(slotFind()) ); QAction *a = new QAction( tr( "Start Search" ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 ); connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); a->addTo( m_searchBar ); // Insert Contact menu items QActionGroup *items = new QActionGroup( this, QString::null, false ); m_actionMail = new QAction( tr( "Write Mail To" ), - Opie::Core::OResource::loadPixmap( "addressbook/sendmail" ), + Opie::Core::OResource::loadPixmap( "addressbook/sendmail", Opie::Core::OResource::SmallIcon ), QString::null, 0, items, 0 ); connect( m_actionMail, SIGNAL(activated()), this, SLOT(writeMail()) ); a = new QAction( tr("Import vCard"), - Opie::Core::OResource::loadPixmap( "addressbook/fileimport" ), + Opie::Core::OResource::loadPixmap( "addressbook/fileimport", Opie::Core::OResource::SmallIcon ), QString::null, 0, items, 0 ); connect( a, SIGNAL(activated()), this, SLOT(importvCard()) ); a = new QAction( tr("Export vCard"), - Opie::Core::OResource::loadPixmap( "addressbook/fileexport" ), + Opie::Core::OResource::loadPixmap( "addressbook/fileexport", Opie::Core::OResource::SmallIcon ), QString::null, 0, items, 0 ); connect( a, SIGNAL(activated()), this, SLOT(exportvCard()) ); m_actionPersonal = new QAction( tr("My Personal Details"), - Opie::Core::OResource::loadPixmap( "addressbook/identity" ), + Opie::Core::OResource::loadPixmap( "addressbook/identity", Opie::Core::OResource::SmallIcon ), QString::null, 0, items, 0 , true ); connect( m_actionPersonal, SIGNAL(activated()), this, SLOT(slotPersonalView()) ); insertItemMenuItems( items ); // Insert View menu items items = new QActionGroup( this, QString::null, false ); a = new QAction( tr("Show quick search bar"),QString::null, 0, items, 0, true ); connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowFind(bool)) ); insertViewMenuItems( items ); // Fontsize defaultFont = new QFont( m_abView->font() ); slotSetFont(m_config.fontSize()); m_curFontSize = m_config.fontSize(); setCentralWidget(m_listContainer); // odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; connect( qApp, SIGNAL(flush()), this, SLOT(flush()) ); connect( qApp, SIGNAL(reload()), this, SLOT(reload()) ); connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); isLoading = false; // Handle category selection setViewCategory( m_config.category() ); m_abView->setShowByCategory( m_config.category() ); connect( this, SIGNAL(categorySelected(const QString&)), this, SLOT(slotSetCategory(const QString&)) ); } void AddressbookWindow::slotSetFont( int size ) { odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl; if (size > 2 || size < 0) size = 1; m_config.setFontSize( size ); QFont *currentFont; switch (size) { case 0: m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); currentFont = new QFont (m_abView->font()); // abList->resizeRows(currentFont->pixelSize() + 7); :SX // abList->resizeRows(); break; case 1: m_abView->setFont( *defaultFont ); currentFont = new QFont (m_abView->font()); // // abList->resizeRows(currentFont->pixelSize() + 7); // abList->resizeRows(); break; case 2: m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); currentFont = new QFont (m_abView->font()); // //abList->resizeRows(currentFont->pixelSize() + 7); // abList->resizeRows(); break; } } void AddressbookWindow::importvCard() { QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); if(!str.isEmpty() ){ setDocument((const QString&) str ); } } void AddressbookWindow::exportvCard() { odebug << "void AddressbookWindow::exportvCard()" << oendl; QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; Opie::OPimContact curCont = m_abView->currentEntry(); if ( !curCont.isEmpty() ){ Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, filename ); Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); if ( access ){ access->add( curCont ); access->save(); } delete access; }else QMessageBox::critical( 0, "Export VCard", QString( tr( "You have to select a contact !") ) ); }else QMessageBox::critical( 0, "Export VCard", QString( tr( "You have to set a filename !") ) ); } void AddressbookWindow::setDocument( const QString &filename ) { odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; // Switch to default backend. This should avoid to import into // the personal database accidently. if ( m_actionPersonal->isOn() ){ m_actionPersonal->setOn( false ); slotPersonalView(); } if ( filename.find(".vcf") != int(filename.length()) - 4 ){ switch( QMessageBox::information( this, tr ( "Right file type ?" ), tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), tr( "&Yes" ), tr( "&No" ), QString::null, 0, // Enter == button 0 2 ) ) { // Escape == button 2 case 0: odebug << "YES clicked" << oendl; break; case 1: odebug << "NO clicked" << oendl; return; break; } } Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, filename ); Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); Opie::OPimContactAccess::List allList = access->allRecords(); odebug << "Found number of contacts in File: " << allList.count() << oendl; if ( !allList.count() ) { QMessageBox::information( this, "Import VCard", "It was impossible to import\nthe VCard.\n" "The VCard may be corrupted!" ); } bool doAsk = true; Opie::OPimContactAccess::List::Iterator it; for ( it = allList.begin(); it != allList.end(); ++it ){ odebug << "Adding Contact from: " << (*it).fullName() << oendl; if ( doAsk ){ switch( QMessageBox::information( this, tr ( "Add Contact?" ), tr( "Do you really want add contact for \n%1?" ) .arg( (*it).fullName().latin1() ), tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), 0, // Enter == button 0 2 ) ) { // Escape == button 2 case 0: odebug << "YES clicked" << oendl; m_abView->addEntry( *it ); break; case 1: odebug << "NO clicked" << oendl; break; case 2: odebug << "YesAll clicked" << oendl; doAsk = false; break; } }else m_abView->addEntry( *it ); } delete access; } void AddressbookWindow::resizeEvent( QResizeEvent *e ) { QMainWindow::resizeEvent( e ); } AddressbookWindow::~AddressbookWindow() { ToolBarDock dock; int dummy; bool bDummy; getLocation ( listTools, dock, dummy, bDummy, dummy ); m_config.setToolBarDock( dock ); m_config.save(); } |