-rw-r--r-- | core/pim/addressbook/abconfig.cpp | 22 | ||||
-rw-r--r-- | core/pim/addressbook/abconfig.h | 13 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 654 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 52 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 62 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 6 |
6 files changed, 310 insertions, 499 deletions
diff --git a/core/pim/addressbook/abconfig.cpp b/core/pim/addressbook/abconfig.cpp index a3fd222..2583327 100644 --- a/core/pim/addressbook/abconfig.cpp +++ b/core/pim/addressbook/abconfig.cpp @@ -1,213 +1,229 @@ #include "abconfig.h" #include "version.h" #include <qpe/config.h> #include <qpe/recordfields.h> AbConfig::AbConfig( ): m_useQtMail( true ), m_useOpieMail( false ), m_useRegExp( false ), m_beCaseSensitive( false ), m_fontSize( 1 ), m_barPos( QMainWindow::Top ), m_fixedBars( true ), m_lpSearchMode( LastName ), m_changed( false ) { } AbConfig::~AbConfig() { -} +} bool AbConfig::useRegExp() const { return m_useRegExp; } bool AbConfig::useWildCards() const { return !m_useRegExp; } bool AbConfig::useQtMail() const { return m_useQtMail; } bool AbConfig::useOpieMail() const { return m_useOpieMail; } bool AbConfig::beCaseSensitive() const { return m_beCaseSensitive; } int AbConfig::fontSize() const { return m_fontSize; } QValueList<int> AbConfig::orderList() const { return m_ordered; } QMainWindow::ToolBarDock AbConfig::getToolBarPos() const { return (QMainWindow::ToolBarDock) m_barPos; } bool AbConfig::fixedBars() const { return m_fixedBars; } AbConfig::LPSearchMode AbConfig::letterPickerSearch() const { return ( AbConfig::LPSearchMode ) m_lpSearchMode; } +const QString &AbConfig::category() const +{ + return m_category; +} + void AbConfig::setUseRegExp( bool v ) { m_useRegExp = v ; m_changed = true; } void AbConfig::setUseWildCards( bool v ) { m_useRegExp = !v; m_changed = true; } void AbConfig::setBeCaseSensitive( bool v ) { m_beCaseSensitive = v; m_changed = true; } void AbConfig::setUseQtMail( bool v ) { m_useQtMail = v; m_changed = true; } void AbConfig::setUseOpieMail( bool v ) { m_useOpieMail = v; m_changed = true; } void AbConfig::setFontSize( int v ) { m_fontSize = v; m_changed = true; } void AbConfig::setOrderList( const QValueList<int>& list ) { m_ordered = list; m_changed = true; } void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v ) { m_barPos = v; m_changed = true; } void AbConfig::setFixedBars( const bool fixed ) { m_fixedBars = fixed; m_changed = true; } void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode ) { m_lpSearchMode = mode; m_changed = true; } +void AbConfig::setCategory( const QString &cat ) +{ + m_category = cat; +} + void AbConfig::load() { // Read Config settings Config cfg("AddressBook"); + cfg.setGroup( "View" ); + m_category = cfg.readEntry( "Category", "All" ); + cfg.setGroup("Font"); m_fontSize = cfg.readNumEntry( "fontSize", 1 ); cfg.setGroup("Search"); m_useRegExp = cfg.readBoolEntry( "useRegExp", false ); m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive", false ); m_lpSearchMode = cfg.readNumEntry( "lpSearchMode", FileAs ); cfg.setGroup("Mail"); m_useQtMail = cfg.readBoolEntry( "useQtMail", true ); m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); cfg.setGroup("ContactOrder"); int ID = 0; int i = 0; ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); while ( ID != 0 ){ m_ordered.append( ID ); ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); } // If no contact order is defined, we set the default if ( m_ordered.count() == 0 ) { m_ordered.append( Qtopia::DefaultEmail ); m_ordered.append( Qtopia::HomePhone); m_ordered.append( Qtopia::HomeMobile); m_ordered.append( Qtopia::BusinessPhone); } cfg.setGroup("ToolBar"); m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top ); m_fixedBars= cfg.readBoolEntry( "fixedBars", true ); m_changed = false; } void AbConfig::save() { if ( m_changed ){ Config cfg("AddressBook"); + cfg.setGroup( "View" ); + cfg.writeEntry( "Category", m_category ); + cfg.setGroup("Font"); cfg.writeEntry("fontSize", m_fontSize); cfg.setGroup("Search"); cfg.writeEntry("useRegExp", m_useRegExp); cfg.writeEntry("caseSensitive", m_beCaseSensitive); cfg.writeEntry("lpSearchMode", m_lpSearchMode ); cfg.setGroup("Mail"); cfg.writeEntry( "useQtMail", m_useQtMail ); cfg.writeEntry( "useOpieMail", m_useOpieMail); cfg.setGroup("ContactOrder"); cfg.clearGroup(); for ( uint i = 0; i < m_ordered.count(); i++ ){ cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] ); } cfg.setGroup("ToolBar"); cfg.writeEntry( "Position", m_barPos ); cfg.writeEntry( "fixedBars", m_fixedBars ); cfg.setGroup("Version"); cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION); cfg.writeEntry( "Mainversion", MAINVERSION ); cfg.writeEntry( "SubVersion", SUBVERSION ); cfg.writeEntry( "PatchVersion", PATCHVERSION ); - + } - + } void AbConfig::operator= ( const AbConfig& cnf ) { m_useQtMail = cnf.m_useQtMail; m_useOpieMail = cnf.m_useOpieMail; m_useRegExp = cnf.m_useRegExp; m_beCaseSensitive = cnf.m_beCaseSensitive; m_fontSize = cnf.m_fontSize; m_ordered = cnf.m_ordered; m_barPos = cnf.m_barPos; m_fixedBars = cnf.m_fixedBars; m_lpSearchMode = cnf.m_lpSearchMode; } diff --git a/core/pim/addressbook/abconfig.h b/core/pim/addressbook/abconfig.h index c312179..68d087c 100644 --- a/core/pim/addressbook/abconfig.h +++ b/core/pim/addressbook/abconfig.h @@ -1,69 +1,72 @@ #ifndef _ABCONFIG_H_ #define _ABCONFIG_H_ -#include <qstringlist.h> +#include <qstringlist.h> #include <qmainwindow.h> class AbConfig { public: enum LPSearchMode{ LastName = 0, FileAs, LASTELEMENT }; AbConfig(); ~AbConfig(); - + // Search Settings bool useRegExp() const; bool useWildCards() const; bool beCaseSensitive() const; bool useQtMail() const; bool useOpieMail() const; int fontSize() const; QValueList<int> orderList() const; QMainWindow::ToolBarDock getToolBarPos() const; bool fixedBars() const; LPSearchMode letterPickerSearch() const; - + const QString &category() const; + void setUseRegExp( bool v ); void setUseWildCards( bool v ); - void setBeCaseSensitive( bool v ); + void setBeCaseSensitive( bool v ); void setUseQtMail( bool v ); void setUseOpieMail( bool v ); void setFontSize( int v ); void setOrderList( const QValueList<int>& list ); void setToolBarDock( const QMainWindow::ToolBarDock v ); void setFixedBars( const bool fixed ); void setLetterPickerSearch( const LPSearchMode mode ); + void setCategory( const QString &cat ); void operator= ( const AbConfig& cnf ); void load(); void save(); protected: /* virtual void itemUp(); */ /* virtual void itemDown(); */ QStringList contFields; bool m_useQtMail; bool m_useOpieMail; bool m_useRegExp; - bool m_beCaseSensitive; + bool m_beCaseSensitive; int m_fontSize; QValueList<int> m_ordered; int m_barPos; bool m_fixedBars; int m_lpSearchMode; + QString m_category; bool m_changed; }; #endif diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 3f0ac74..a4c2c6e 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp @@ -1,1049 +1,843 @@ /********************************************************************** ** 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 <qpe/resource.h> #include <qpe/ir.h> #include <qpe/qpemessagebox.h> #include <qmenubar.h> // #include <qtoolbar.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 ) - : QMainWindow( parent, name, f ), - catMenu (0l), + WFlags /*f*/ ) + : Opie::OPimMainWindow( "Addressbook", "Contacts", tr( "Contact" ), "AddressBook", + parent, name, WType_TopLevel | WStyle_ContextHelp ), abEditor(0l), - syncing(FALSE), - m_tableViewButton(0l), - m_cardViewButton(0l) + syncing(false) { + setCaption( tr( "Contacts" ) ); + isLoading = true; m_config.load(); - setCaption( tr("Contacts") ); - setIcon( Resource::loadPixmap( "addressbook/AddressBook" ) ); - - // Settings for Main Menu - // setToolBarsMovable( false ); - setToolBarsMovable( !m_config.fixedBars() ); - setRightJustification( true ); - - QToolBar *bar = new QToolBar( this ); - bar->setHorizontalStretchable( TRUE ); - - QMenuBar *mbList = new QMenuBar( bar ); - mbList->setMargin( 0 ); - - QPopupMenu *edit = new QPopupMenu( mbList ); - mbList->insertItem( tr( "Contact" ), edit ); - - // Category Menu - catMenu = new QPopupMenu( this ); - catMenu->setCheckable( TRUE ); - connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); - mbList->insertItem( tr("View"), catMenu ); - - // Create Toolbar - listTools = new QToolBar( this, "list operations" ); - listTools->setHorizontalStretchable( true ); - addToolBar( listTools ); - moveToolBar( listTools, m_config.getToolBarPos() ); - - // View Icons - m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), - QString::null, 0, this, 0 ); - connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); - m_tableViewButton->setToggleAction( true ); - m_tableViewButton->addTo( listTools ); - m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); - connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); - m_cardViewButton->setToggleAction( true ); - m_cardViewButton->addTo( listTools ); - - listTools->addSeparator(); - - // Other Buttons - QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, - 0, this, 0 ); - actionNew = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); - a->addTo( edit ); - a->addTo( listTools ); - - a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, - 0, this, 0 ); - actionEdit = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); - a->addTo( edit ); - a->addTo( listTools ); - - a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, - 0, this, 0 ); - actionTrash = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); - a->addTo( edit ); - a->addTo( listTools ); - - - // make it possible to go directly to businesscard via qcop call - //#if defined(Q_WS_QWS) // Why this ? (se) -#if !defined(QT_NO_COP) - QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); - connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), - this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); -#endif - // #endif - a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), - QString::null, 0, this, 0 ); - actionFind = a; - connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); - a->addTo( edit ); - a->addTo( listTools ); - - // Much better search widget, taken from QTReader.. (se) - searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); - searchBar->setHorizontalStretchable( TRUE ); - searchBar->hide(); - searchEdit = new QLineEdit( searchBar, "searchEdit" ); - -// QFont f("unifont", 16 /*, QFont::Bold*/); -// searchEdit->setFont( f ); - - searchBar->setStretchableWidget( searchEdit ); - connect( searchEdit, SIGNAL( returnPressed() ), - this, SLOT( slotFind() ) ); - - a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); - a->addTo( searchBar ); - - a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); - a->addTo( searchBar ); - - a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), - QString::null, 0, this, 0 ); - //a->setEnabled( FALSE ); we got support for it now :) zecke - actionMail = a; - connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); - a->addTo( edit ); - a->addTo( listTools ); - - if ( Ir::supported() ) { - a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, - 0, this, 0 ); - actionBeam = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); - a->addTo( edit ); - a->addTo( listTools ); - } + // Create Views + m_listContainer = new QWidget( this ); + QVBoxLayout *vb = new QVBoxLayout( m_listContainer ); - edit->insertSeparator(); + m_abView = new AbView( m_listContainer, m_config.orderList() ); + vb->addWidget( m_abView ); + connect( m_abView, SIGNAL(signalViewSwitched(int)), + this, SLOT(slotViewSwitched(int)) ); - a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, - 0, this, 0); - actionPersonal = a; - connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); - a->addTo( edit ); + QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); - a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, - 0, this, 0); - actionPersonal = a; - connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); - a->addTo( edit ); + // Letter Picker + pLabel = new LetterPicker( m_listContainer ); + connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); + connect(m_abView, SIGNAL(signalClearLetterPicker()), pLabel, SLOT(clear()) ); - edit->insertSeparator(); + vb->addWidget( pLabel ); - a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), - QString::null, 0, this, 0 , TRUE ); - actionPersonal = a; - connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); - a->addTo( edit ); + // 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()) ); -#ifdef __DEBUG_RELEASE - // Remove this function for public Release ! This is only - // for debug purposes .. - a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); - connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); - a->addTo( edit ); -#endif - a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, - 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); - a->addTo( edit ); + QAction *a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); + a->addTo( m_searchBar ); - // Create Views - listContainer = new QWidget( this ); - QVBoxLayout *vb = new QVBoxLayout( listContainer ); + // Insert Contact menu items + QActionGroup *items = new QActionGroup( this, QString::null, false ); - m_abView = new AbView( listContainer, m_config.orderList() ); - vb->addWidget( m_abView ); - // abList->setHScrollBarMode( QScrollView::AlwaysOff ); - connect( m_abView, SIGNAL( signalViewSwitched(int) ), - this, SLOT( slotViewSwitched(int) ) ); + m_actionMail = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), + QString::null, 0, items, 0 ); + connect( m_actionMail, SIGNAL(activated()), this, SLOT(writeMail()) ); + a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), + QString::null, 0, items, 0 ); + connect( a, SIGNAL(activated()), this, SLOT(importvCard()) ); - QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); + a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), + QString::null, 0, items, 0 ); + connect( a, SIGNAL(activated()), this, SLOT(exportvCard()) ); - // m_abView->load(); // Already done by c'tor . + m_actionPersonal = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), + QString::null, 0, items, 0 , true ); + connect( m_actionPersonal, SIGNAL(activated()), this, SLOT(slotPersonalView()) ); - // Letter Picker - pLabel = new LetterPicker( listContainer ); - connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); - connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); + insertItemMenuItems( items ); - vb->addWidget( pLabel ); + // 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)) ); - // All Categories into view-menu.. - populateCategories(); + insertViewMenuItems( items ); // Fontsize defaultFont = new QFont( m_abView->font() ); slotSetFont(m_config.fontSize()); m_curFontSize = m_config.fontSize(); - setCentralWidget(listContainer); + 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&) ) ); - + 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; -} - -void AddressbookWindow::slotConfig() -{ - ConfigDlg* dlg = new ConfigDlg( this, "Config" ); - dlg -> setConfig( m_config ); - if ( QPEApplication::execDialog( dlg ) ) { - odebug << "Config Dialog accepted!" << oendl; - m_config = dlg -> getConfig(); - if ( m_curFontSize != m_config.fontSize() ){ - odebug << "Font was changed!" << oendl; - m_curFontSize = m_config.fontSize(); - emit slotSetFont( m_curFontSize ); - } - m_abView -> setListOrder( m_config.orderList() ); - } - - delete dlg; + // 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 ( actionPersonal->isOn() ){ - actionPersonal->setOn( false ); + 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(); } -void AddressbookWindow::slotUpdateToolbar() +int AddressbookWindow::create() +{ + return 0; +} + +bool AddressbookWindow::remove( int /*uid*/ ) +{ + return false; +} + +void AddressbookWindow::beam( int /*uid*/ ) +{ +} + +void AddressbookWindow::show( int /*uid*/ ) +{ +} + +void AddressbookWindow::edit( int /*uid*/ ) { - Opie::OPimContact ce = m_abView->currentEntry(); - actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); } -void AddressbookWindow::slotListNew() +void AddressbookWindow::add( const Opie::OPimRecord& ) +{ +} + +void AddressbookWindow::slotItemNew() { Opie::OPimContact cnt; if( !syncing ) { editEntry( NewEntry ); } else { QMessageBox::warning(this, tr("Contacts"), tr("Can not edit data, currently syncing")); } } -// void AddressbookWindow::slotListView() -// { -// m_abView -> init( abList->currentEntry() ); -// // :SX mView->sync(); -// //:SX showView(); -// } +void AddressbookWindow::slotItemEdit() +{ + if(!syncing) { + if (m_actionPersonal->isOn()) { + editPersonal(); + } else { + editEntry( EditEntry ); + } + } else { + QMessageBox::warning( this, tr("Contacts"), + tr("Can not edit data, currently syncing") ); + } +} + +void AddressbookWindow::slotItemDuplicate() +{ +} -void AddressbookWindow::slotListDelete() +void AddressbookWindow::slotItemDelete() { if(!syncing) { Opie::OPimContact tmpEntry = m_abView ->currentEntry(); // get a name, do the best we can... QString strName = tmpEntry.fullName(); if ( strName.isEmpty() ) { strName = tmpEntry.company(); if ( strName.isEmpty() ) strName = "No Name"; } if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), strName ) ) { m_abView->removeEntry( tmpEntry.uid() ); } } else { QMessageBox::warning( this, tr("Contacts"), tr("Can not edit data, currently syncing") ); } } -void AddressbookWindow::slotFindOpen() +static const char * beamfile = "/tmp/obex/contact.vcf"; + +void AddressbookWindow::slotItemBeam() { - searchBar->show(); - m_abView -> inSearch(); - searchEdit->setFocus(); + QString beamFilename; + Opie::OPimContact c; + if ( m_actionPersonal->isOn() ) { + beamFilename = addressbookPersonalVCardName(); + if ( !QFile::exists( beamFilename ) ) + return; // can't beam a non-existent file + Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, + beamFilename ); + Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); + Opie::OPimContactAccess::List allList = access->allRecords(); + Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first + c = *it; + + delete access; + } else { + unlink( beamfile ); // delete if exists + mkdir("/tmp/obex/", 0755); + c = m_abView -> currentEntry(); + Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, + beamfile ); + Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); + access->add( c ); + access->save(); + delete access; + + beamFilename = beamfile; + } + + odebug << "Beaming: " << beamFilename << oendl; + + Ir *ir = new Ir( this ); + connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); + QString description = c.fullName(); + ir->send( beamFilename, description, "text/x-vCard" ); } -void AddressbookWindow::slotFindClose() + +void AddressbookWindow::slotItemFind() { - searchBar->hide(); - m_abView -> offSearch(); - // m_abView->setFocus(); } +void AddressbookWindow::slotConfigure() +{ + ConfigDlg* dlg = new ConfigDlg( this, "Config" ); + dlg -> setConfig( m_config ); + if ( QPEApplication::execDialog( dlg ) ) { + odebug << "Config Dialog accepted!" << oendl; + m_config = dlg -> getConfig(); + if ( m_curFontSize != m_config.fontSize() ){ + odebug << "Font was changed!" << oendl; + m_curFontSize = m_config.fontSize(); + emit slotSetFont( m_curFontSize ); + } + m_abView -> setListOrder( m_config.orderList() ); + } + + delete dlg; +} + +void AddressbookWindow::slotShowFind( bool show ) +{ + if ( show ) + { + // Display search bar + m_searchBar->show(); + m_abView -> inSearch(); + m_searchEdit->setFocus(); + } + else + { + // Hide search bar + m_searchBar->hide(); + m_abView -> offSearch(); + } +} void AddressbookWindow::slotFind() { - m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); + m_abView->slotDoFind( m_searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); - searchEdit->clearFocus(); + m_searchEdit->clearFocus(); // m_abView->setFocus(); } void AddressbookWindow::slotViewBack() { // :SX showList(); } -void AddressbookWindow::slotViewEdit() -{ - if(!syncing) { - if (actionPersonal->isOn()) { - editPersonal(); - } else { - editEntry( EditEntry ); - } - } else { - QMessageBox::warning( this, tr("Contacts"), - tr("Can not edit data, currently syncing") ); - } -} - - - void AddressbookWindow::writeMail() { Opie::OPimContact c = m_abView -> currentEntry(); QString name = c.fileAs(); QString email = c.defaultEmail(); // I prefer the OPIE-Environment variable before the // QPE-one.. QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); if ( basepath.isEmpty() ) basepath = QString::fromLatin1( getenv("QPEDIR") ); // Try to access the preferred. If not possible, try to // switch to the other one.. if ( m_config.useQtMail() ){ odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl; if ( QFile::exists( basepath + "/bin/qtmail" ) ){ odebug << "QCop" << oendl; QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); e << name << email; return; } else m_config.setUseOpieMail( true ); } if ( m_config.useOpieMail() ){ odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl; if ( QFile::exists( basepath + "/bin/opiemail" ) ){ odebug << "QCop" << oendl; QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); e << name << email; return; } else m_config.setUseQtMail( true ); } } -static const char * beamfile = "/tmp/obex/contact.vcf"; - -void AddressbookWindow::slotBeam() -{ - QString beamFilename; - Opie::OPimContact c; - if ( actionPersonal->isOn() ) { - beamFilename = addressbookPersonalVCardName(); - if ( !QFile::exists( beamFilename ) ) - return; // can't beam a non-existent file - Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, - beamFilename ); - Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); - Opie::OPimContactAccess::List allList = access->allRecords(); - Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first - c = *it; - - delete access; - } else { - unlink( beamfile ); // delete if exists - mkdir("/tmp/obex/", 0755); - c = m_abView -> currentEntry(); - Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, - beamfile ); - Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); - access->add( c ); - access->save(); - delete access; - - beamFilename = beamfile; - } - - odebug << "Beaming: " << beamFilename << oendl; - - Ir *ir = new Ir( this ); - connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); - QString description = c.fullName(); - ir->send( beamFilename, description, "text/x-vCard" ); -} - void AddressbookWindow::beamDone( Ir *ir ) { delete ir; unlink( beamfile ); } static void parseName( const QString& name, QString *first, QString *middle, QString * last ) { int comma = name.find ( "," ); QString rest; if ( comma > 0 ) { *last = name.left( comma ); comma++; while ( comma < int(name.length()) && name[comma] == ' ' ) comma++; rest = name.mid( comma ); } else { int space = name.findRev( ' ' ); *last = name.mid( space+1 ); rest = name.left( space ); } int space = rest.find( ' ' ); if ( space <= 0 ) { *first = rest; } else { *first = rest.left( space ); *middle = rest.mid( space+1 ); } } void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) { - bool needShow = FALSE; + bool needShow = false; odebug << "Receiving QCop-Call with message " << msg << oendl; if (msg == "editPersonal()") { editPersonal(); + + // Categories might have changed, so reload + reloadCategories(); } else if (msg == "editPersonalAndClose()") { editPersonal(); close(); } else if ( msg == "addContact(QString,QString)" ) { QDataStream stream(data,IO_ReadOnly); QString name, email; stream >> name >> email; Opie::OPimContact cnt; QString fn, mn, ln; parseName( name, &fn, &mn, &ln ); // odebug << " " << fn << " - " << mn " - " << ln << oendl; cnt.setFirstName( fn ); cnt.setMiddleName( mn ); cnt.setLastName( ln ); cnt.insertEmails( email ); cnt.setDefaultEmail( email ); cnt.setFileAs(); m_abView -> addEntry( cnt ); // :SXm_abView()->init( cnt ); editEntry( EditEntry ); + + // Categories might have changed, so reload + reloadCategories(); } else if ( msg == "beamBusinessCard()" ) { QString beamFilename = addressbookPersonalVCardName(); if ( !QFile::exists( beamFilename ) ) return; // can't beam a non-existent file Ir *ir = new Ir( this ); connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); QString description = "mycard.vcf"; ir->send( beamFilename, description, "text/x-vCard" ); } else if ( msg == "show(int)" ) { raise(); QDataStream stream(data,IO_ReadOnly); int uid; stream >> uid; odebug << "Showing uid: " << uid << oendl; // Deactivate Personal View.. - if ( actionPersonal->isOn() ){ - actionPersonal->setOn( false ); + if ( m_actionPersonal->isOn() ){ + m_actionPersonal->setOn( false ); slotPersonalView(); } // Reset category and show as card.. m_abView -> setShowByCategory( QString::null ); m_abView -> setCurrentUid( uid ); slotViewSwitched ( AbView::CardView ); needShow = true; } else if ( msg == "edit(int)" ) { QDataStream stream(data,IO_ReadOnly); int uid; stream >> uid; // Deactivate Personal View.. - if ( actionPersonal->isOn() ){ - actionPersonal->setOn( false ); + if ( m_actionPersonal->isOn() ){ + m_actionPersonal->setOn( false ); slotPersonalView(); } // Reset category and edit.. m_abView -> setShowByCategory( QString::null ); m_abView -> setCurrentUid( uid ); - slotViewEdit(); - } + slotItemEdit(); + + // Categories might have changed, so reload + reloadCategories(); + } if (needShow) QPEApplication::setKeepRunning(); - } void AddressbookWindow::editEntry( EntryMode entryMode ) { Opie::OPimContact entry; if ( !abEditor ) { abEditor = new ContactEditor( entry, this, "editor" ); } if ( entryMode == EditEntry ) abEditor->setEntry( m_abView -> currentEntry() ); else if ( entryMode == NewEntry ) abEditor->setEntry( entry ); // other things may change the caption. abEditor->setCaption( tr("Edit Address") ); - // fix the foxus... + // fix the focus... abEditor->setNameFocus(); - if ( QPEApplication::execDialog( abEditor ) ) { + if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) { setFocus(); if ( entryMode == NewEntry ) { Opie::OPimContact insertEntry = abEditor->entry(); insertEntry.assignUid(); m_abView -> addEntry( insertEntry ); m_abView -> setCurrentUid( insertEntry.uid() ); } else { Opie::OPimContact replEntry = abEditor->entry(); if ( !replEntry.isValidUid() ) replEntry.assignUid(); m_abView -> replaceEntry( replEntry ); } - } - // populateCategories(); + // Categories might have changed, so reload + reloadCategories(); + } } void AddressbookWindow::editPersonal() { Opie::OPimContact entry; // Switch to personal view if not selected // but take care of the menu, too - if ( ! actionPersonal->isOn() ){ + if ( ! m_actionPersonal->isOn() ){ odebug << "*** ++++" << oendl; - actionPersonal->setOn( true ); + m_actionPersonal->setOn( true ); slotPersonalView(); } if ( !abEditor ) { abEditor = new ContactEditor( entry, this, "editor" ); } abEditor->setCaption(tr("Edit My Personal Details")); abEditor->setPersonalView( true ); editEntry( EditEntry ); abEditor->setPersonalView( false ); } void AddressbookWindow::slotPersonalView() { - odebug << "slotPersonalView()" << oendl; - if (!actionPersonal->isOn()) { - // we just turned it off - odebug << "slotPersonalView()-> OFF" << oendl; - setCaption( tr("Contacts") ); - actionNew->setEnabled(TRUE); - actionTrash->setEnabled(TRUE); - actionFind->setEnabled(TRUE); - actionMail->setEnabled(TRUE); - // slotUpdateToolbar(); - - m_abView->showPersonal( false ); + odebug << "slotPersonalView()" << oendl; - return; - } - - odebug << "slotPersonalView()-> ON" << oendl; - // XXX need to disable some QActions. - actionNew->setEnabled(FALSE); - actionTrash->setEnabled(FALSE); - actionFind->setEnabled(FALSE); - actionMail->setEnabled(FALSE); + bool personal = m_actionPersonal->isOn(); - setCaption( tr("Contacts - My Personal Details") ); + // Disable certain menu items when showing personal details + setItemNewEnabled( !personal ); + setItemDuplicateEnabled( !personal ); + setItemDeleteEnabled( !personal ); + m_actionMail->setEnabled( !personal ); - m_abView->showPersonal( true ); + // Display appropriate view + m_abView->showPersonal( personal ); -} - - -void AddressbookWindow::listIsEmpty( bool empty ) -{ - if ( !empty ) { - deleteButton->setEnabled( TRUE ); - } + // Set application caption + personal ? setCaption( tr( "Contacts - My Personal Details") ) + : setCaption( tr( "Contacts") ); } void AddressbookWindow::reload() { - syncing = FALSE; + syncing = false; m_abView->clear(); m_abView->reload(); } void AddressbookWindow::flush() { - syncing = TRUE; + syncing = true; m_abView->save(); } void AddressbookWindow::closeEvent( QCloseEvent *e ) { if(active_view == AbView::CardView){ slotViewSwitched( AbView::TableView ); e->ignore(); return; } if(syncing) { /* shouldn't we save, I hear you say? well its already been set so that an edit can not occur during a sync, and we flushed at the start of the sync, so there is no need to save Saving however itself would cause problems. */ e->accept(); return; } //################## shouldn't always save // True, but the database handles this automatically ! (se) if ( save() ) e->accept(); else e->ignore(); } /* - Returns TRUE if it is OK to exit + Returns true if it is OK to exit */ bool AddressbookWindow::save() { if ( !m_abView->save() ) { if ( QMessageBox::critical( 0, tr( "Out of space" ), tr("Unable to save information.\n" "Free up some space\n" "and try again.\n" "\nQuit anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default ) != QMessageBox::No ) - return TRUE; + return true; else - return FALSE; + return false; } - return TRUE; + return true; } #ifdef __DEBUG_RELEASE void AddressbookWindow::slotSave() { save(); } #endif void AddressbookWindow::slotNotFound() { odebug << "Got not found signal!" << oendl; QMessageBox::information( this, tr( "Not Found" ), "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); } void AddressbookWindow::slotWrapAround() { odebug << "Got wrap signal!" << oendl; // if ( doNotifyWrapAround ) // QMessageBox::information( this, tr( "End of list" ), // tr( "End of list. Wrap around now...!" ) + "\n" ); } -void AddressbookWindow::slotSetCategory( int c ) +void AddressbookWindow::slotSetCategory( const QString &category ) { - odebug << "void AddressbookWindow::slotSetCategory( " << c << " ) from " - << catMenu->count() << oendl; - - QString cat, book; - AbView::Views view = AbView::TableView; - - if ( c <= 0 ) - return; - - // Switch view - if ( c < 3 ) - for ( unsigned int i = 1; i < 3; i++ ){ - if ( catMenu ) - catMenu->setItemChecked( i, c == (int)i ); - } - else - // Checkmark Category Menu Item Selected - for ( unsigned int i = 3; i < catMenu->count(); i++ ) - catMenu->setItemChecked( i, c == (int)i ); - - // Now switch to the selected category - for ( unsigned int i = 1; i < catMenu->count(); i++ ) { - if (catMenu->isItemChecked( i )) { - if ( i == 1 ){ // default List view - book = QString::null; - view = AbView::TableView; - }else if ( i == 2 ){ - book = tr( "Cards" ); - view = AbView::CardView; -// }else if ( i == 3 ){ -// book = tr( "Personal" ); -// view = AbView:: PersonalView; - }else if ( i == 3 ){ // default All Categories - cat = QString::null; - }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled - cat = "Unfiled"; - odebug << "Unfiled selected!" << oendl; - }else{ - cat = m_abView->categories()[i - 4]; - } - } - } - - // Switch to the selected View - slotViewSwitched( view ); + odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl; // Tell the view about the selected category - m_abView -> setShowByCategory( cat ); - - if ( book.isEmpty() ) - book = "List"; - if ( cat.isEmpty() ) - cat = "All"; - - setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); + m_config.setCategory( category ); + m_abView -> setShowByCategory( category ); } void AddressbookWindow::slotViewSwitched( int view ) { odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl; - int menu = 0; - - // Switch to selected view - switch ( view ){ - case AbView::TableView: - menu = 1; - m_tableViewButton->setOn(true); - m_cardViewButton->setOn(false); - break; - case AbView::CardView: - menu = 2; - m_tableViewButton->setOn(false); - m_cardViewButton->setOn(true); - break; - } - for ( unsigned int i = 1; i < 3; i++ ){ - if ( catMenu ) - catMenu->setItemChecked( i, menu == (int)i ); - } // Tell the view about the selected view m_abView -> setShowToView ( (AbView::Views) view ); active_view = view; } void AddressbookWindow::slotListView() { slotViewSwitched( AbView::TableView ); } void AddressbookWindow::slotCardView() { slotViewSwitched( AbView::CardView ); } void AddressbookWindow::slotSetLetter( char c ) { m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); } - -void AddressbookWindow::populateCategories() -{ - catMenu->clear(); - - int id, rememberId; - id = 1; - rememberId = 0; - - catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ ); - catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ ); -// catMenu->insertItem( tr( "Personal" ), id++ ); - catMenu->insertSeparator(); - - catMenu->insertItem( tr( "All" ), id++ ); - QStringList categories = m_abView->categories(); - categories.append( tr( "Unfiled" ) ); - for ( QStringList::Iterator it = categories.begin(); - it != categories.end(); ++it ) { - catMenu->insertItem( *it, id ); - if ( *it == m_abView -> showCategory() ) - rememberId = id; - ++id; - } - - - if ( m_abView -> showCategory().isEmpty() ) { - slotSetCategory( 3 ); - } - else { - slotSetCategory( rememberId ); - } -} - diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 7cc61bf..b04e2cc 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h @@ -1,137 +1,137 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qt Palmtop Environment. ** ** 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. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef Addressbook_H #define Addressbook_H // Remove this for OPIE releae 1.0 ! // #define __DEBUG_RELEASE -#include <qmainwindow.h> +#include <opie2/opimmainwindow.h> + #include <qvaluelist.h> #include <qstringlist.h> #include <qlineedit.h> #include "ofloatbar.h" #include "abview.h" #include "abconfig.h" class ContactEditor; class AbLabel; class AbTable; class QToolBar; class QPopupMenu; class QToolButton; class QDialog; class Ir; class QAction; class LetterPicker; +class Opie::OPimRecord; -class AddressbookWindow: public QMainWindow +class AddressbookWindow: public Opie::OPimMainWindow { Q_OBJECT public: enum EntryMode { NewEntry=0, EditEntry }; static QString appName() { return QString::fromLatin1("addressbook"); } AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~AddressbookWindow(); protected: void resizeEvent( QResizeEvent * e ); void editPersonal(); void editEntry( EntryMode ); void closeEvent( QCloseEvent *e ); bool save(); public slots: void flush(); void reload(); void appMessage(const QCString &, const QByteArray &); void setDocument( const QString & ); // Called by obex receiver and internally! #ifdef __DEBUG_RELEASE // void slotSave(); #endif +protected slots: + int create(); + bool remove( int uid ); + void beam( int uid ); + void show( int uid ); + void edit( int uid ); + void add( const Opie::OPimRecord& ); + private slots: + void slotItemNew(); + void slotItemEdit(); + void slotItemDuplicate(); + void slotItemDelete(); + void slotItemBeam(); + void slotItemFind(); + void slotConfigure(); + void importvCard(); void exportvCard(); - void slotListNew(); -/* void slotListView(); */ - void slotListDelete(); void slotViewBack(); - void slotViewEdit(); void slotPersonalView(); - void listIsEmpty( bool ); -/* void slotSettings(); */ void writeMail(); - void slotBeam(); void beamDone( Ir * ); - void slotSetCategory( int ); + void slotSetCategory( const QString &category ); void slotSetLetter( char ); - void slotUpdateToolbar(); void slotSetFont(int); - void slotFindOpen(); - void slotFindClose(); + void slotShowFind( bool show ); void slotFind(); void slotNotFound(); void slotWrapAround(); void slotViewSwitched( int ); void slotListView(); void slotCardView(); - void slotConfig(); - private: - void populateCategories(); - - QPopupMenu *catMenu; QToolBar *listTools; - QToolButton *deleteButton; enum Panes { paneList=0, paneView, paneEdit }; ContactEditor *abEditor; LetterPicker *pLabel; AbView* m_abView; - QWidget *listContainer; + QWidget *m_listContainer; // Searching stuff - OFloatBar* searchBar; - QLineEdit* searchEdit; + OFloatBar* m_searchBar; + QLineEdit* m_searchEdit; - QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; + QAction *m_actionPersonal, *m_actionMail; int viewMargin; bool syncing; QFont *defaultFont; int m_curFontSize; bool isLoading; AbConfig m_config; - QAction* m_tableViewButton; - QAction* m_cardViewButton; - int active_view; }; #endif diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index b078968..dec4c7c 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -1,364 +1,362 @@ /* * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) * * This file is an add-on for the OPIE Palmtop Environment * * 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 pacakaging * 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. * * * This is a rewrite of the abeditor.h file, modified to provide a more * intuitive interface to TrollTech's original Address Book editor. This * is made to operate exactly in interface with the exception of name. * */ #include "contacteditor.h" #include "namelineedit.h" #include <opie2/odebug.h> #include <opie2/opimcontact.h> #include <qpe/categoryselect.h> #include <qpe/qpeapplication.h> #include <qpe/qpedialog.h> #include <qpe/resource.h> #include <qlabel.h> -#include <qtabwidget.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qtoolbutton.h> #include <qlistbox.h> #include <qmessagebox.h> #include <qwhatsthis.h> #include <assert.h> static inline bool containsAlphaNum( const QString &str ); static inline bool constainsWhiteSpace( const QString &str ); // helper functions, convert our comma delimited list to proper // file format... void parseEmailFrom( const QString &txt, QString &strDefaultEmail, QString &strAll ); // helper convert from file format to comma delimited... void parseEmailTo( const QString &strDefaultEmail, const QString &strOtherEmail, QString &strBack ); ContactEditor::ContactEditor( const Opie::OPimContact &entry, QWidget *parent, const char *name, WFlags ) - : QDialog( parent, name, TRUE, WStyle_ContextHelp ), + : QDialog( parent, name, true, WStyle_ContextHelp ), defaultEmailChooserPosition( -1 ), m_personalView ( false ), cmbDefaultEmail( 0 ), initializing ( false ) { initializing = true; init(); setEntry( entry ); // cmbDefaultEmail = 0; // defaultEmailChooserPosition = -1; initializing = false; } ContactEditor::~ContactEditor() { } void ContactEditor::init() { odebug << "init() START" << oendl; uint i = 0; QStringList trlChooserNames; for (i = 0; i <= 6; i++) { slHomeAddress.append( "" ); slBusinessAddress.append( "" ); } trlChooserNames = Opie::OPimContactFields::trphonefields( false ); slChooserNames = Opie::OPimContactFields::untrphonefields( false ); slDynamicEntries = Opie::OPimContactFields::untrdetailsfields( false ); trlDynamicEntries = Opie::OPimContactFields::trdetailsfields( false ); // Ok, we have to remove elements from the list of dynamic entries // which are now stored in special (not dynamic) widgets.. // Otherwise we will get problems with field assignments! (se) slDynamicEntries.remove("Anniversary"); slDynamicEntries.remove("Birthday"); slDynamicEntries.remove("Gender"); // The same with translated fields.. But I will // use the translation map to avoid mismatches.. QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields(); trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); trlDynamicEntries.remove( translMap[Qtopia::Gender] ); // Last Check to be sure.. assert( slDynamicEntries.count() == trlDynamicEntries.count() ); assert( slChooserNames.count() == trlChooserNames.count() ); for (i = 0; i < slChooserNames.count(); i++) slChooserValues.append(""); QVBoxLayout *vb = new QVBoxLayout( this ); - tabMain = new QTabWidget( this ); + tabMain = new Opie::Ui::OTabWidget( this ); vb->addWidget( tabMain ); - QWidget *tabViewport = new QWidget ( tabMain ); + m_generalWidget = new QWidget ( tabMain ); - vb = new QVBoxLayout( tabViewport ); + vb = new QVBoxLayout( m_generalWidget ); - svGeneral = new QScrollView( tabViewport ); + svGeneral = new QScrollView( m_generalWidget ); vb->addWidget( svGeneral, 0, 0 ); svGeneral->setResizePolicy( QScrollView::AutoOneFit ); // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); svGeneral->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( svGeneral->viewport() ); svGeneral->addChild( container ); - QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); - gl->setResizeMode( QLayout::FreeResize ); + QGridLayout *gl = new QGridLayout( container, 10, 2, 2, 4 ); btnFullName = new QPushButton( tr( "Full Name..." ), container ); QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); gl->addWidget( btnFullName, 0, 0 ); txtFullName = new ABOOK::NameLineEdit( container ); QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) ); gl->addWidget( txtFullName, 0, 1 ); QLabel *l = new QLabel( tr( "Job Title" ), container ); QWhatsThis::add( l, tr( "The jobtitle.." ) ); gl->addWidget( l, 1, 0 ); txtJobTitle = new QLineEdit( container ); QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) ); gl->addWidget( txtJobTitle, 1, 1 ); l = new QLabel( tr("Suffix"), container ); QWhatsThis::add( l, tr( "Something like \"jr.\".." ) ); gl->addWidget( l, 2, 0 ); txtSuffix = new QLineEdit( container ); QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) ); gl->addWidget( txtSuffix, 2, 1 ); l = new QLabel( tr( "Organization" ), container ); QWhatsThis::add( l, tr( "The working place of the contact" ) ); gl->addWidget( l, 3, 0 ); txtOrganization = new QLineEdit( container ); QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); gl->addWidget( txtOrganization, 3, 1 ); // Chooser 1 - cmbChooserField1 = new QComboBox( FALSE, container ); + cmbChooserField1 = new QComboBox( false, container ); QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); cmbChooserField1->setMaximumWidth( 90 ); gl->addWidget( cmbChooserField1, 4, 0 ); // Textfield for chooser 1. // Now use Widgetstack to contain the textfield and the default-email combo ! m_widgetStack1 = new QWidgetStack( container ); txtChooserField1 = new QLineEdit( m_widgetStack1 ); m_widgetStack1 -> addWidget( txtChooserField1, TextField ); gl->addWidget( m_widgetStack1, 4, 1 ); m_widgetStack1 -> raiseWidget( TextField ); // Chooser 2 - cmbChooserField2 = new QComboBox( FALSE, container ); + cmbChooserField2 = new QComboBox( false, container ); QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); cmbChooserField2->setMaximumWidth( 90 ); gl->addWidget( cmbChooserField2, 5, 0 ); // Textfield for chooser 2 // Now use WidgetStack to contain the textfield and the default-email combo! m_widgetStack2 = new QWidgetStack( container ); txtChooserField2 = new QLineEdit( m_widgetStack2 ); m_widgetStack2 -> addWidget( txtChooserField2, TextField ); gl->addWidget( m_widgetStack2, 5, 1 ); m_widgetStack2 -> raiseWidget( TextField ); // Chooser 3 - cmbChooserField3 = new QComboBox( FALSE, container ); + cmbChooserField3 = new QComboBox( false, container ); QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); cmbChooserField3->setMaximumWidth( 90 ); gl->addWidget( cmbChooserField3, 6, 0 ); // Textfield for chooser 2 // Now use WidgetStack to contain the textfield and the default-email combo! m_widgetStack3 = new QWidgetStack( container ); txtChooserField3 = new QLineEdit( m_widgetStack3 ); m_widgetStack3 -> addWidget( txtChooserField3, TextField ); gl->addWidget( m_widgetStack3, 6, 1 ); m_widgetStack3 -> raiseWidget( TextField ); l = new QLabel( tr( "File As" ), container ); QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) ); gl->addWidget( l, 7, 0 ); - cmbFileAs = new QComboBox( TRUE, container ); + cmbFileAs = new QComboBox( true, container ); gl->addWidget( cmbFileAs, 7, 1 ); labCat = new QLabel( tr( "Category" ), container ); gl->addWidget( labCat, 8, 0 ); cmbCat = new CategorySelect( container ); gl->addWidget( cmbCat, 8, 1 ); labCat->show(); cmbCat->show(); - btnNote = new QPushButton( tr( "Notes..." ), container ); + btnNote = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Notes..." ), container ); gl->addWidget( btnNote, 9, 1 ); - tabMain->insertTab( tabViewport, tr( "General" ) ); + tabMain->addTab( m_generalWidget, "addressbook/AddressBookSmall", tr( "General" ) ); - tabViewport = new QWidget ( tabMain ); + QWidget *tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); svAddress = new QScrollView( tabViewport ); vb->addWidget( svAddress, 0, 0 ); svAddress->setResizePolicy( QScrollView::AutoOneFit ); svAddress->setFrameStyle( QFrame::NoFrame ); container = new QWidget( svAddress->viewport() ); svAddress->addChild( container ); gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem - cmbAddress = new QComboBox( FALSE, container ); + cmbAddress = new QComboBox( false, container ); cmbAddress->insertItem( tr( "Business" ) ); cmbAddress->insertItem( tr( "Home" ) ); gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); l = new QLabel( tr( "Address" ), container ); gl->addWidget( l, 1, 0 ); txtAddress = new QLineEdit( container ); gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); l = new QLabel( tr( "City" ), container ); gl->addWidget( l, 2, 0 ); txtCity = new QLineEdit( container ); gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); l = new QLabel( tr( "State" ), container ); gl->addWidget( l, 3, 0 ); txtState = new QLineEdit( container ); gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); l = new QLabel( tr( "Zip Code" ), container ); gl->addWidget( l, 4, 0 ); txtZip = new QLineEdit( container ); gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); l = new QLabel( tr( "Country" ), container ); gl->addWidget( l, 5, 0 ); - cmbCountry = new QComboBox( TRUE, container ); + cmbCountry = new QComboBox( true, container ); cmbCountry->insertItem( "" ); cmbCountry->insertItem( tr ( "United States" ) ); cmbCountry->insertItem( tr ( "United Kingdom" ) ); cmbCountry->insertItem( tr ( "Afghanistan" ) ); cmbCountry->insertItem( tr ( "Albania" ) ); cmbCountry->insertItem( tr ( "Algeria" ) ); cmbCountry->insertItem( tr ( "American Samoa" ) ); cmbCountry->insertItem( tr ( "Andorra" ) ); cmbCountry->insertItem( tr ( "Angola" ) ); cmbCountry->insertItem( tr ( "Anguilla" ) ); cmbCountry->insertItem( tr ( "Antarctica" ) ); cmbCountry->insertItem( tr ( "Argentina" ) ); cmbCountry->insertItem( tr ( "Armenia" ) ); cmbCountry->insertItem( tr ( "Aruba" ) ); cmbCountry->insertItem( tr ( "Australia" ) ); cmbCountry->insertItem( tr ( "Austria" ) ); cmbCountry->insertItem( tr ( "Azerbaijan" ) ); cmbCountry->insertItem( tr ( "Bahamas" ) ); cmbCountry->insertItem( tr ( "Bahrain" ) ); cmbCountry->insertItem( tr ( "Bangladesh" ) ); cmbCountry->insertItem( tr ( "Barbados" ) ); cmbCountry->insertItem( tr ( "Belarus" ) ); cmbCountry->insertItem( tr ( "Belgium" ) ); cmbCountry->insertItem( tr ( "Belize" ) ); cmbCountry->insertItem( tr ( "Benin" ) ); cmbCountry->insertItem( tr ( "Bermuda" ) ); cmbCountry->insertItem( tr ( "Bhutan" ) ); cmbCountry->insertItem( tr ( "Bolivia" ) ); cmbCountry->insertItem( tr ( "Botswana" ) ); cmbCountry->insertItem( tr ( "Bouvet Island" ) ); cmbCountry->insertItem( tr ( "Brazil" ) ); cmbCountry->insertItem( tr ( "Brunei Darussalam" ) ); cmbCountry->insertItem( tr ( "Bulgaria" ) ); cmbCountry->insertItem( tr ( "Burkina Faso" ) ); cmbCountry->insertItem( tr ( "Burundi" ) ); cmbCountry->insertItem( tr ( "Cambodia" ) ); cmbCountry->insertItem( tr ( "Cameroon" ) ); cmbCountry->insertItem( tr ( "Canada" ) ); cmbCountry->insertItem( tr ( "Cape Verde" ) ); cmbCountry->insertItem( tr ( "Cayman Islands" ) ); cmbCountry->insertItem( tr ( "Chad" ) ); cmbCountry->insertItem( tr ( "Chile" ) ); cmbCountry->insertItem( tr ( "China" ) ); cmbCountry->insertItem( tr ( "Christmas Island" ) ); cmbCountry->insertItem( tr ( "Colombia" ) ); cmbCountry->insertItem( tr ( "Comoros" ) ); cmbCountry->insertItem( tr ( "Congo" ) ); cmbCountry->insertItem( tr ( "Cook Island" ) ); cmbCountry->insertItem( tr ( "Costa Rica" ) ); cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) ); cmbCountry->insertItem( tr ( "Croatia" ) ); cmbCountry->insertItem( tr ( "Cuba" ) ); cmbCountry->insertItem( tr ( "Cyprus" ) ); cmbCountry->insertItem( tr ( "Czech Republic" ) ); cmbCountry->insertItem( tr ( "Denmark" ) ); cmbCountry->insertItem( tr ( "Djibouti" ) ); cmbCountry->insertItem( tr ( "Dominica" ) ); cmbCountry->insertItem( tr ( "Dominican Republic" ) ); cmbCountry->insertItem( tr ( "East Timor" ) ); cmbCountry->insertItem( tr ( "Ecuador" ) ); cmbCountry->insertItem( tr ( "Egypt" ) ); cmbCountry->insertItem( tr ( "El Salvador" ) ); cmbCountry->insertItem( tr ( "Equatorial Guinea" ) ); cmbCountry->insertItem( tr ( "Eritrea" ) ); cmbCountry->insertItem( tr ( "Estonia" ) ); cmbCountry->insertItem( tr ( "Ethiopia" ) ); cmbCountry->insertItem( tr ( "Falkland Islands" ) ); cmbCountry->insertItem( tr ( "Faroe Islands" ) ); cmbCountry->insertItem( tr ( "Fiji" ) ); cmbCountry->insertItem( tr ( "Finland" ) ); cmbCountry->insertItem( tr ( "France" ) ); cmbCountry->insertItem( tr ( "French Guiana" ) ); cmbCountry->insertItem( tr ( "French Polynesia" ) ); cmbCountry->insertItem( tr ( "Gabon" ) ); cmbCountry->insertItem( tr ( "Gambia" ) ); cmbCountry->insertItem( tr ( "Georgia" ) ); cmbCountry->insertItem( tr ( "Germany" ) ); cmbCountry->insertItem( tr ( "Ghana" ) ); cmbCountry->insertItem( tr ( "Gibraltar" ) ); cmbCountry->insertItem( tr ( "Greece" ) ); cmbCountry->insertItem( tr ( "Greenland" ) ); cmbCountry->insertItem( tr ( "Grenada" ) ); cmbCountry->insertItem( tr ( "Guadeloupe" ) ); cmbCountry->insertItem( tr ( "Guam" ) ); cmbCountry->insertItem( tr ( "Guatemala" ) ); cmbCountry->insertItem( tr ( "Guinea" ) ); cmbCountry->insertItem( tr ( "Guinea-Bissau" ) ); cmbCountry->insertItem( tr ( "Guyana" ) ); cmbCountry->insertItem( tr ( "Haiti" ) ); cmbCountry->insertItem( tr ( "Holy See" ) ); cmbCountry->insertItem( tr ( "Honduras" ) ); cmbCountry->insertItem( tr ( "Hong Kong" ) ); cmbCountry->insertItem( tr ( "Hungary" ) ); cmbCountry->insertItem( tr ( "Iceland" ) ); cmbCountry->insertItem( tr ( "India" ) ); cmbCountry->insertItem( tr ( "Indonesia" ) ); @@ -392,316 +390,316 @@ void ContactEditor::init() { cmbCountry->insertItem( tr ( "Malta" ) ); cmbCountry->insertItem( tr ( "Martinique" ) ); cmbCountry->insertItem( tr ( "Mauritania" ) ); cmbCountry->insertItem( tr ( "Mauritius" ) ); cmbCountry->insertItem( tr ( "Mayotte" ) ); cmbCountry->insertItem( tr ( "Mexico" ) ); cmbCountry->insertItem( tr ( "Micronesia" ) ); cmbCountry->insertItem( tr ( "Moldova" ) ); cmbCountry->insertItem( tr ( "Monaco" ) ); cmbCountry->insertItem( tr ( "Mongolia" ) ); cmbCountry->insertItem( tr ( "Montserrat" ) ); cmbCountry->insertItem( tr ( "Morocco" ) ); cmbCountry->insertItem( tr ( "Mozambique" ) ); cmbCountry->insertItem( tr ( "Myanmar" ) ); cmbCountry->insertItem( tr ( "Namibia" ) ); cmbCountry->insertItem( tr ( "Nauru" ) ); cmbCountry->insertItem( tr ( "Nepal" ) ); cmbCountry->insertItem( tr ( "Netherlands" ) ); cmbCountry->insertItem( tr ( "New Caledonia" ) ); cmbCountry->insertItem( tr ( "New Zealand" ) ); cmbCountry->insertItem( tr ( "Nicaragua" ) ); cmbCountry->insertItem( tr ( "Niger" ) ); cmbCountry->insertItem( tr ( "Nigeria" ) ); cmbCountry->insertItem( tr ( "Niue" ) ); cmbCountry->insertItem( tr ( "Norway" ) ); cmbCountry->insertItem( tr ( "Oman" ) ); cmbCountry->insertItem( tr ( "Pakistan" ) ); cmbCountry->insertItem( tr ( "Palau" ) ); cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) ); cmbCountry->insertItem( tr ( "Panama" ) ); cmbCountry->insertItem( tr ( "Papua New Guinea" ) ); cmbCountry->insertItem( tr ( "Paraguay" ) ); cmbCountry->insertItem( tr ( "Peru" ) ); cmbCountry->insertItem( tr ( "Philippines" ) ); cmbCountry->insertItem( tr ( "Pitcairn Islands" ) ); cmbCountry->insertItem( tr ( "Poland" ) ); cmbCountry->insertItem( tr ( "Portugal" ) ); cmbCountry->insertItem( tr ( "Puerto Rico" ) ); cmbCountry->insertItem( tr ( "Qatar" ) ); cmbCountry->insertItem( tr ( "Reunion" ) ); cmbCountry->insertItem( tr ( "Romania" ) ); cmbCountry->insertItem( tr ( "Russia" ) ); cmbCountry->insertItem( tr ( "Rwanda" ) ); cmbCountry->insertItem( tr ( "Saint Lucia" ) ); cmbCountry->insertItem( tr ( "Samoa" ) ); cmbCountry->insertItem( tr ( "San Marino" ) ); cmbCountry->insertItem( tr ( "Saudi Arabia" ) ); cmbCountry->insertItem( tr ( "Senegal" ) ); cmbCountry->insertItem( tr ( "Seychelles" ) ); cmbCountry->insertItem( tr ( "Sierra Leone" ) ); cmbCountry->insertItem( tr ( "Singapore" ) ); cmbCountry->insertItem( tr ( "Slovakia" ) ); cmbCountry->insertItem( tr ( "Slovenia" ) ); cmbCountry->insertItem( tr ( "Solomon Islands" ) ); cmbCountry->insertItem( tr ( "Somalia" ) ); cmbCountry->insertItem( tr ( "South Africa" ) ); cmbCountry->insertItem( tr ( "Spain" ) ); cmbCountry->insertItem( tr ( "Sri Lanka" ) ); cmbCountry->insertItem( tr ( "St. Helena" ) ); cmbCountry->insertItem( tr ( "Sudan" ) ); cmbCountry->insertItem( tr ( "Suriname" ) ); cmbCountry->insertItem( tr ( "Swaziland" ) ); cmbCountry->insertItem( tr ( "Sweden" ) ); cmbCountry->insertItem( tr ( "Switzerland" ) ); cmbCountry->insertItem( tr ( "Taiwan" ) ); cmbCountry->insertItem( tr ( "Tajikistan" ) ); cmbCountry->insertItem( tr ( "Tanzania" ) ); cmbCountry->insertItem( tr ( "Thailand" ) ); cmbCountry->insertItem( tr ( "Togo" ) ); cmbCountry->insertItem( tr ( "Tokelau" ) ); cmbCountry->insertItem( tr ( "Tonga" ) ); cmbCountry->insertItem( tr ( "Tunisia" ) ); cmbCountry->insertItem( tr ( "Turkey" ) ); cmbCountry->insertItem( tr ( "Turkmenistan" ) ); cmbCountry->insertItem( tr ( "Tuvalu" ) ); cmbCountry->insertItem( tr ( "Uganda" ) ); cmbCountry->insertItem( tr ( "Ukraine" ) ); cmbCountry->insertItem( tr ( "Uruguay" ) ); cmbCountry->insertItem( tr ( "Uzbekistan" ) ); cmbCountry->insertItem( tr ( "Vanuatu" ) ); cmbCountry->insertItem( tr ( "Venezuela" ) ); cmbCountry->insertItem( tr ( "Vietnam" ) ); cmbCountry->insertItem( tr ( "Virgin Islands" ) ); cmbCountry->insertItem( tr ( "Western Sahara" ) ); cmbCountry->insertItem( tr ( "Yemen" ) ); cmbCountry->insertItem( tr ( "Yugoslavia" ) ); cmbCountry->insertItem( tr ( "Zambia" ) ); cmbCountry->insertItem( tr ( "Zimbabwe" ) ); if (cmbCountry->listBox()!=0) cmbCountry->listBox()->sort(); cmbCountry->setMaximumWidth( 135 ); gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); // Chooser 4 - cmbChooserField4 = new QComboBox( FALSE, container ); + cmbChooserField4 = new QComboBox( false, container ); cmbChooserField4->setMaximumWidth( 90 ); gl->addWidget( cmbChooserField4, 6, 0 ); // Textfield for chooser 2 // Now use WidgetStack to contain the textfield and the default-email combo! m_widgetStack4 = new QWidgetStack( container ); txtChooserField4 = new QLineEdit( m_widgetStack4 ); m_widgetStack4 -> addWidget( txtChooserField4, TextField ); gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); m_widgetStack4 -> raiseWidget( TextField ); QSpacerItem *space = new QSpacerItem(1,1, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ); gl->addItem( space, 7, 0 ); - tabMain->insertTab( tabViewport, tr( "Address" ) ); + tabMain->addTab( tabViewport, "home", tr( "Address" ) ); tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); svDetails = new QScrollView( tabViewport ); vb->addWidget( svDetails, 0, 0 ); svDetails->setResizePolicy( QScrollView::AutoOneFit ); svDetails->setFrameStyle( QFrame::NoFrame ); container = new QWidget( svDetails->viewport() ); svDetails->addChild( container ); gl = new QGridLayout( container, 1, 2, 2, 4 ); int counter = 0; // Birthday QHBox* hBox = new QHBox( container ); l = new QLabel( tr("Birthday"), container ); gl->addWidget( l, counter, 0 ); QPopupMenu* m1 = new QPopupMenu( container ); - birthdayPicker = new DateBookMonth( m1, 0, TRUE ); + birthdayPicker = new DateBookMonth( m1, 0, true ); m1->insertItem( birthdayPicker ); birthdayButton= new QToolButton( hBox, "buttonStart" ); birthdayButton->setPopup( m1 ); birthdayButton->setPopupDelay(0); QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), tr( "Delete" ), hBox, 0 ); gl->addWidget( hBox, counter , 1 ); connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( slotBirthdayDateChanged(int,int,int) ) ); connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); ++counter; // Anniversary hBox = new QHBox( container ); l = new QLabel( tr("Anniversary"), container ); gl->addWidget( l, counter, 0 ); m1 = new QPopupMenu( container ); - anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); + anniversaryPicker = new DateBookMonth( m1, 0, true ); m1->insertItem( anniversaryPicker ); anniversaryButton= new QToolButton( hBox, "buttonStart" ); anniversaryButton->setPopup( m1 ); anniversaryButton->setPopupDelay(0); deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), tr( "Delete" ), hBox, 0 ); gl->addWidget( hBox, counter , 1 ); connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); ++counter; // Gender l = new QLabel( tr("Gender"), container ); gl->addWidget( l, counter, 0 ); cmbGender = new QComboBox( container ); cmbGender->insertItem( "", 0 ); cmbGender->insertItem( tr("Male"), 1); cmbGender->insertItem( tr("Female"), 2); gl->addWidget( cmbGender, counter, 1 ); ++counter; // Create Labels and lineedit fields for every dynamic entry QStringList::ConstIterator it = slDynamicEntries.begin(); QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId(); QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields(); for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { if (((*it) == "Anniversary") || ((*it) == "Birthday")|| ((*it) == "Gender")) continue; l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); listName.append( l ); gl->addWidget( l, i, 0 ); QLineEdit *e = new QLineEdit( container ); listValue.append( e ); gl->addWidget( e, i, 1); } // Fill labels with names.. // loadFields(); - tabMain->insertTab( tabViewport, tr( "Details" ) ); + tabMain->addTab( tabViewport, "UtilsIcon", tr( "Details" ) ); - dlgNote = new QDialog( this, "Note Dialog", TRUE ); + dlgNote = new QDialog( this, "Note Dialog", true ); dlgNote->setCaption( tr("Enter Note") ); QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); txtNote = new QMultiLineEdit( dlgNote ); vbNote->addWidget( txtNote ); connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); - dlgName = new QDialog( this, "Name Dialog", TRUE ); + dlgName = new QDialog( this, "Name Dialog", true ); dlgName->setCaption( tr("Edit Name") ); gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); l = new QLabel( tr("First Name"), dlgName ); gl->addWidget( l, 0, 0 ); txtFirstName = new ABOOK::NameLineEdit( dlgName ); gl->addWidget( txtFirstName, 0, 1 ); l = new QLabel( tr("Middle Name"), dlgName ); gl->addWidget( l, 1, 0 ); txtMiddleName = new ABOOK::NameLineEdit( dlgName ); gl->addWidget( txtMiddleName, 1, 1 ); l = new QLabel( tr("Last Name"), dlgName ); gl->addWidget( l, 2, 0 ); txtLastName = new ABOOK::NameLineEdit( dlgName ); gl->addWidget( txtLastName, 2, 1 ); // l = new QLabel( tr("Suffix"), dlgName ); // gl->addWidget( l, 3, 0 ); // txtSuffix = new QLineEdit( dlgName ); // gl->addWidget( txtSuffix, 3, 1 ); space = new QSpacerItem(1,1, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ); gl->addItem( space, 4, 0 ); cmbChooserField1->insertStringList( trlChooserNames ); cmbChooserField2->insertStringList( trlChooserNames ); cmbChooserField3->insertStringList( trlChooserNames ); cmbChooserField4->insertStringList( trlChooserNames ); cmbChooserField1->setCurrentItem( 0 ); cmbChooserField2->setCurrentItem( 1 ); cmbChooserField3->setCurrentItem( 2 ); connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); connect( txtFullName, SIGNAL(textChanged(const QString&)), this, SLOT(slotFullNameChange(const QString&)) ); connect( txtSuffix, SIGNAL(textChanged(const QString&)), this, SLOT(slotSuffixChange(const QString&)) ); connect( txtOrganization, SIGNAL(textChanged(const QString&)), this, SLOT(slotOrganizationChange(const QString&)) ); connect( txtChooserField1, SIGNAL(textChanged(const QString&)), this, SLOT(slotChooser1Change(const QString&)) ); connect( txtChooserField2, SIGNAL(textChanged(const QString&)), this, SLOT(slotChooser2Change(const QString&)) ); connect( txtChooserField3, SIGNAL(textChanged(const QString&)), this, SLOT(slotChooser3Change(const QString&)) ); connect( txtChooserField4, SIGNAL(textChanged(const QString&)), this, SLOT(slotChooser4Change(const QString&)) ); connect( txtAddress, SIGNAL(textChanged(const QString&)), this, SLOT(slotAddressChange(const QString&)) ); connect( txtCity, SIGNAL(textChanged(const QString&)), this, SLOT(slotCityChange(const QString&)) ); connect( txtState, SIGNAL(textChanged(const QString&)), this, SLOT(slotStateChange(const QString&)) ); connect( txtZip, SIGNAL(textChanged(const QString&)), this, SLOT(slotZipChange(const QString&)) ); connect( cmbCountry, SIGNAL(textChanged(const QString&)), this, SLOT(slotCountryChange(const QString&)) ); connect( cmbCountry, SIGNAL(activated(const QString&)), this, SLOT(slotCountryChange(const QString&)) ); connect( cmbChooserField1, SIGNAL(activated(int)), this, SLOT(slotCmbChooser1Change(int)) ); connect( cmbChooserField2, SIGNAL(activated(int)), this, SLOT(slotCmbChooser2Change(int)) ); connect( cmbChooserField3, SIGNAL(activated(int)), this, SLOT(slotCmbChooser3Change(int)) ); connect( cmbChooserField4, SIGNAL(activated(int)), this, SLOT(slotCmbChooser4Change(int)) ); connect( cmbAddress, SIGNAL(activated(int)), this, SLOT(slotAddressTypeChange(int)) ); new QPEDialogListener(this); setPersonalView ( m_personalView ); odebug << "init() END" << oendl; } void ContactEditor::defaultEmailChanged(int i){ odebug << "defaultEmailChanged" << oendl; // was sollte das ? (se) // int index = cmbChooserField1->currentItem(); // slChooserValues[index] = cmbDefaultEmail->text(i); defaultEmail = cmbDefaultEmail->text(i); odebug << "Changed to: " << defaultEmail << oendl; } void ContactEditor::populateDefaultEmailCmb(){ @@ -1000,383 +998,383 @@ void ContactEditor::slotAddressTypeChange( int index ) { if ( !initializing ) contactfields.setFieldOrder( 4, index ); if ( index == 0 ) { txtAddress->setText( slBusinessAddress[0] ); //txtAddress2->setText( (*slBusinessAddress)[1] ); //txtPOBox->setText( (*slBusinessAddress)[2] ); txtCity->setText( slBusinessAddress[3] ); txtState->setText( slBusinessAddress[4] ); txtZip->setText( slBusinessAddress[5] ); QLineEdit *txtTmp = cmbCountry->lineEdit(); txtTmp->setText( slBusinessAddress[6] ); } else { txtAddress->setText( slHomeAddress[0] ); //txtAddress2->setText( (*slHomeAddress)[1] ); //txtPOBox->setText( (*slHomeAddress)[2] ); txtCity->setText( slHomeAddress[3] ); txtState->setText( slHomeAddress[4] ); txtZip->setText( slHomeAddress[5] ); QLineEdit *txtTmp = cmbCountry->lineEdit(); txtTmp->setText( slHomeAddress[6] ); } } void ContactEditor::slotFullNameChange( const QString &textChanged ) { odebug << "ContactEditor::slotFullNameChange( " << textChanged << " )" << oendl; int index = cmbFileAs->currentItem(); cmbFileAs->clear(); cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) ); cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) ); cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) ); if ( ! txtSuffix->text().isEmpty() ) cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() ); cmbFileAs->setCurrentItem( index ); } void ContactEditor::slotSuffixChange( const QString& ) { // Just want to update the FileAs combo if the suffix was changed.. slotFullNameChange( txtFullName->text() ); } void ContactEditor::slotOrganizationChange( const QString &textChanged ){ odebug << "ContactEditor::slotOrganizationChange( " << textChanged << " )" << oendl; // Special handling for storing Companies: // If no Fullname is given, we store the Company-Name as lastname // to handle it like a person.. if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) ) txtFullName->setText( textChanged ); } void ContactEditor::accept() { if ( isEmpty() ) { cleanupFields(); reject(); } else { saveEntry(); cleanupFields(); QDialog::accept(); } } void ContactEditor::slotNote() { if ( ! QPEApplication::execDialog( dlgNote ) ) { txtNote->setText( ent.notes() ); } } void ContactEditor::slotName() { QString tmpName; txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); if ( QPEApplication::execDialog( dlgName ) ) { - if ( txtLastName->text().contains( ' ', TRUE ) ) + if ( txtLastName->text().contains( ' ', true ) ) tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); else tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); txtFullName->setText( tmpName.simplifyWhiteSpace() ); slotFullNameChange( txtFullName->text() ); } } void ContactEditor::setNameFocus() { txtFullName->setFocus(); } bool ContactEditor::isEmpty() { // Test and see if the record should be saved. // More strict than the original qtopia, needs name or fileas to save QString t = txtFullName->text(); if ( !t.isEmpty() && containsAlphaNum( t ) ) return false; t = cmbFileAs->currentText(); if ( !t.isEmpty() && containsAlphaNum( t ) ) return false; return true; } QString ContactEditor::parseName( const QString fullName, int type ) { QString simplifiedName( fullName.simplifyWhiteSpace() ); QString strFirstName; QString strMiddleName; QString strLastName; QString strTitle; int commapos; bool haveLastName = false; odebug << "Fullname: " << simplifiedName << oendl; - commapos = simplifiedName.find( ',', 0, TRUE); + commapos = simplifiedName.find( ',', 0, true); if ( commapos >= 0 ) { odebug << " Commapos: " << commapos << oendl; // A comma (",") separates the lastname from one or // many first names. Thus, remove the lastname from the // String and parse the firstnames. strLastName = simplifiedName.left( commapos ); simplifiedName= simplifiedName.mid( commapos + 1 ); haveLastName = true; odebug << "Fullname without ',': " << simplifiedName << oendl; // If we have any lastname, we should now split all first names. // The first one will be the used as first, the rest as "middle names" QStringList allFirstNames = QStringList::split(" ", simplifiedName); QStringList::Iterator it = allFirstNames.begin(); strFirstName = *it++; QStringList allSecondNames; for ( ; it != allFirstNames.end(); ++it ) allSecondNames.append( *it ); strMiddleName = allSecondNames.join(" "); } else { // No comma separator used: We use the first word as firstname, the // last as second/lastname and everything in the middle as middlename QStringList allNames = QStringList::split(" ", simplifiedName); QStringList::Iterator it = allNames.begin(); strFirstName = *it++; QStringList allSecondNames; for ( ; it != --allNames.end(); ++it ) allSecondNames.append( *it ); strMiddleName = allSecondNames.join(" "); strLastName = *(--allNames.end()); } if ( strFirstName == strLastName ) strFirstName = ""; odebug << "strFirstName: " << strFirstName << oendl; odebug << "strMiddletName: " << strMiddleName << oendl; odebug << "strLastName: " << strLastName << oendl; odebug << "strTitle: " << strTitle << oendl; switch (type) { case NAME_FL: return strFirstName + " " + strLastName; case NAME_LF: return strLastName + ", " + strFirstName; case NAME_LFM: return strLastName + ", " + strFirstName + " " + strMiddleName; case NAME_FML: return strFirstName + " " + strMiddleName + " " + strLastName ; case NAME_F: return strFirstName; case NAME_M: return strMiddleName; case NAME_L: return strLastName; case NAME_S: return txtSuffix->text(); } return QString::null; } void ContactEditor::cleanupFields() { QStringList::Iterator it = slChooserValues.begin(); for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { (*it) = ""; } for ( int i = 0; i < 7; i++ ) { slHomeAddress[i] = ""; slBusinessAddress[i] = ""; } QListIterator<QLineEdit> itLV( listValue ); for ( ; itLV.current(); ++itLV ) { (*itLV)->setText( "" ); } txtFirstName->setText(""); txtMiddleName->setText(""); txtLastName->setText(""); txtSuffix->setText(""); txtNote->setText(""); txtFullName->setText(""); txtJobTitle->setText(""); txtOrganization->setText(""); txtChooserField1->setText(""); txtChooserField2->setText(""); txtChooserField3->setText(""); txtAddress->setText(""); txtCity->setText(""); txtState->setText(""); txtZip->setText(""); QLineEdit *txtTmp = cmbCountry->lineEdit(); txtTmp->setText(""); txtTmp = cmbFileAs->lineEdit(); txtTmp->setText(""); } void ContactEditor::setEntry( const Opie::OPimContact &entry ) { initializing = true; // Cleanup and activate the general Page .. cleanupFields(); - tabMain->setCurrentPage( 0 ); + tabMain->setCurrentTab( m_generalWidget ); ent = entry; emails = QStringList(ent.emailList()); defaultEmail = ent.defaultEmail(); if (defaultEmail.isEmpty()) defaultEmail = emails[0]; odebug << "default email=" << defaultEmail << oendl; txtFirstName->setText( ent.firstName() ); txtMiddleName->setText( ent.middleName() ); txtLastName->setText( ent.lastName() ); txtSuffix->setText( ent.suffix() ); // QString *tmpString = new QString; // *tmpString = ent.firstName() + " " + ent.middleName() + // + " " + ent.lastName() + " " + ent.suffix(); // txtFullName->setText( tmpString->simplifyWhiteSpace() ); if ( !ent.isEmpty() ){ // Lastnames with multiple words need to be protected by a comma ! - if ( ent.lastName().contains( ' ', TRUE ) ) + if ( ent.lastName().contains( ' ', true ) ) txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); else txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); } cmbFileAs->setEditText( ent.fileAs() ); // if (hasTitle) txtJobTitle->setText( ent.jobTitle() ); // if (hasCompany) txtOrganization->setText( ent.company() ); // if (hasNotes) txtNote->setText( ent.notes() ); // if (hasStreet) { slHomeAddress[0] = ent.homeStreet(); slBusinessAddress[0] = ent.businessStreet(); // } // if (hasCity) { slHomeAddress[3] = ent.homeCity(); slBusinessAddress[3] = ent.businessCity(); //} //if (hasState) { slHomeAddress[4] = ent.homeState(); slBusinessAddress[4] = ent.businessState(); //} //if (hasZip) { slHomeAddress[5] = ent.homeZip(); slBusinessAddress[5] = ent.businessZip(); //} //if (hasCountry) { slHomeAddress[6] = ent.homeCountry(); slBusinessAddress[6] = ent.businessCountry(); //} QStringList::ConstIterator it; QListIterator<QLineEdit> itLE( listValue ); for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { odebug << " Filling dynamic Field: " << (*it) << oendl; if ( *it == "Department" ) (*itLE)->setText( ent.department() ); if ( *it == "Company" ) (*itLE)->setText( ent.company() ); if ( *it == "Office" ) (*itLE)->setText( ent.office() ); if ( *it == "Profession" ) (*itLE)->setText( ent.profession() ); if ( *it == "Assistant" ) (*itLE)->setText( ent.assistant() ); if ( *it == "Manager" ) (*itLE)->setText( ent.manager() ); if ( *it == "Spouse" ) (*itLE)->setText( ent.spouse() ); if ( *it == "Nickname" ){ odebug << "**** Nichname: " << ent.nickname() << oendl; (*itLE)->setText( ent.nickname() ); } if ( *it == "Children" ) (*itLE)->setText( ent.children() ); } QStringList::Iterator itV; for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) *itV = ent.businessPhone(); /* if ( *it == "Business 2 Phone" ) *itV = ent.business2Phone(); */ if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) *itV = ent.businessFax(); if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) *itV = ent.businessMobile(); /* if ( *it == "Company Phone" ) *itV = ent.companyPhone(); */ @@ -1594,159 +1592,159 @@ void ContactEditor::saveEntry() { } if ( *it == "Default Email") ent.setDefaultEmail( defaultEmail /* *itV */ ); if ( *it == "Home Phone" ) ent.setHomePhone( *itV ); if ( *it == "Home Fax" ) ent.setHomeFax( *itV ); if ( *it == "Home Mobile" ) ent.setHomeMobile( *itV ); if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) ent.setBusinessPager( *itV ); if ( *it == "Home Web Page" ) ent.setHomeWebpage( *itV ); if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) ent.setBusinessWebpage( *itV ); } int gender = cmbGender->currentItem(); ent.setGender( QString::number( gender ) ); QString str = txtNote->text(); if ( !str.isNull() ) ent.setNotes( str ); } void parseEmailFrom( const QString &txt, QString &strDefaultEmail, QString &strAll ) { int where, start; if ( txt.isEmpty() ) return; // find the first where = txt.find( ',' ); if ( where < 0 ) { strDefaultEmail = txt; strAll = txt; } else { strDefaultEmail = txt.left( where ).stripWhiteSpace(); strAll = strDefaultEmail; while ( where > -1 ) { strAll.append(" "); start = where; where = txt.find( ',', where + 1 ); if ( where > - 1 ) strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); else // grab until the end... strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); } } } void parseEmailTo( const QString &strDefaultEmail, const QString &strOtherEmail, QString &strBack ) { // create a comma dilimeted set of emails... // use the power of short circuiting... bool foundDefault = false; QString strTmp; int start = 0; int where; // start at the beginng. strBack = strDefaultEmail; where = 0; while ( where > -1 ) { start = where; where = strOtherEmail.find( ' ', where + 1 ); if ( where > 0 ) { strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); } else strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); if ( foundDefault || strTmp != strDefaultEmail ) { strBack.append( ", " ); strBack.append( strTmp ); } else foundDefault = true; } } static inline bool containsAlphaNum( const QString &str ) { int i, count = str.length(); for ( i = 0; i < count; i++ ) if ( !str[i].isSpace() ) - return TRUE; - return FALSE; + return true; + return false; } static inline bool constainsWhiteSpace( const QString &str ) { int i, count = str.length(); for (i = 0; i < count; i++ ) if ( str[i].isSpace() ) - return TRUE; - return FALSE; + return true; + return false; } void ContactEditor::setPersonalView( bool personal ) { m_personalView = personal; // Currently disbled due to the fact that // show will not work... return; if ( personal ){ cmbCat->hide(); labCat->hide(); } else{ cmbCat->show(); labCat->show(); } } void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) { QDate date; date.setYMD( year, month, day ); QString dateString = TimeString::numberDateString( date ); anniversaryButton->setText( dateString ); ent.setAnniversary ( date ); } void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) { QDate date; date.setYMD( year, month, day ); QString dateString = TimeString::numberDateString( date ); birthdayButton->setText( dateString ); ent.setBirthday ( date ); } void ContactEditor::slotRemoveBirthday() { odebug << "void ContactEditor::slotRemoveBirthday()" << oendl; ent.setBirthday( QDate() ); updateDatePicker(); } void ContactEditor::slotRemoveAnniversary() { odebug << "void ContactEditor::slotRemoveAnniversary()" << oendl; ent.setAnniversary( QDate() ); updateDatePicker(); } diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index 1b86e6f..f3cbbd4 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h @@ -1,191 +1,191 @@ /* * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> * * This file is an add-on for the OPIE Palmtop Environment * * 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 pacakaging * 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. * * * This is a rewrite of the abeditor.h file, modified to provide a more * intuitive interface to TrollTech's original Address Book editor. This * is made to operate exactly in interface with the exception of name. * */ #ifndef CONTACTEDITOR_H #define CONTACTEDITOR_H #include <opie2/opimcontact.h> #include <opie2/opimcontactfields.h> +#include <opie2/otabwidget.h> #include <qpe/datebookmonth.h> #include <qdialog.h> #include <qlist.h> #include <qmap.h> #include <qstringlist.h> #include <qwidgetstack.h> const int NAME_LF = 0; const int NAME_LFM = 1; const int NAME_FL = 2; const int NAME_FML = 3; const int NAME_F = 4; const int NAME_M = 5; const int NAME_L = 6; const int NAME_S = 7; - class QScrollView; -class QTabWidget; class QMultiLineEdit; class QLineEdit; class QComboBox; class QPushButton; class CategorySelect; class QLabel; class ContactEditor : public QDialog { Q_OBJECT public: ContactEditor( const Opie::OPimContact &entry, QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); ~ContactEditor(); void setNameFocus(); void setPersonalView( bool personal = true ); Opie::OPimContact entry() const { return ent; } public slots: void slotNote(); void slotName(); void setEntry(const Opie::OPimContact &entry); protected slots: void accept(); private: void init(); void saveEntry(); bool isEmpty(); void cleanupFields(); void updateDatePicker(); QString parseName( QString fullName, int type ); void chooserError( int index ); private slots: void slotChooser1Change( const QString &textChanged ); void slotChooser2Change( const QString &textChanged ); void slotChooser3Change( const QString &textChanged ); void slotChooser4Change( const QString &textChanged ); void slotCmbChooser1Change( int index ); void slotCmbChooser2Change( int index ); void slotCmbChooser3Change( int index ); void slotCmbChooser4Change( int index ); void slotAddressTypeChange( int index ); void slotAddressChange( const QString &textChanged ); void slotAddress2Change( const QString &textChanged ); void slotPOBoxChange( const QString &textChanged ); void slotCityChange( const QString &textChanged ); void slotStateChange( const QString &textChanged ); void slotZipChange( const QString &textChanged ); void slotCountryChange( const QString &textChanged ); void slotFullNameChange( const QString &textChanged ); void slotSuffixChange( const QString &textChanged ); void slotOrganizationChange( const QString &textChanged ); void slotAnniversaryDateChanged( int year, int month, int day); void slotBirthdayDateChanged( int year, int month, int day); void slotRemoveBirthday(); void slotRemoveAnniversary(); void defaultEmailChanged(int); private: enum StackWidgets { TextField = 1, Combo }; int defaultEmailChooserPosition; void populateDefaultEmailCmb(); void chooserChange( const QString&, int , QLineEdit*, int ); bool cmbChooserChange( int , QWidgetStack*, int ); Opie::OPimContactFields contactfields; Opie::OPimContact ent; QDialog *dlgNote; QDialog *dlgName; QList<QLineEdit> listValue; QList<QLabel> listName; QStringList slDynamicEntries; QStringList trlDynamicEntries; bool m_personalView; QStringList slHomeAddress; QStringList slBusinessAddress; QStringList slChooserNames; QStringList slChooserValues; QStringList emails; QString defaultEmail; QMultiLineEdit *txtNote; QLabel *lblNote; //QLineEdit *txtTitle; QLineEdit *txtFirstName; QLineEdit *txtMiddleName; QLineEdit *txtLastName; QLineEdit *txtSuffix; - QTabWidget *tabMain; + Opie::Ui::OTabWidget *tabMain; + QWidget *m_generalWidget; QScrollView *svGeneral; QPushButton *btnFullName; QPushButton *btnNote; QLineEdit *txtFullName; QLineEdit *txtJobTitle; QLineEdit *txtOrganization; QLineEdit *txtChooserField1; QLineEdit *txtChooserField2; QLineEdit *txtChooserField3; QLineEdit *txtChooserField4; QWidgetStack* m_widgetStack1; QWidgetStack* m_widgetStack2; QWidgetStack* m_widgetStack3; QWidgetStack* m_widgetStack4; QComboBox *cmbChooserField1; QComboBox *cmbChooserField2; QComboBox *cmbChooserField3; QComboBox *cmbChooserField4; QComboBox *cmbDefaultEmail; QComboBox *cmbFileAs; CategorySelect *cmbCat; QLabel *labCat; QScrollView *svAddress; QLineEdit *txtAddress; //QLineEdit *txtAddress2; //QLineEdit *txtPOBox; QLineEdit *txtCity; QLineEdit *txtState; QLineEdit *txtZip; QComboBox *cmbAddress; QComboBox *cmbCountry; QScrollView *svDetails; QComboBox *cmbGender; DateBookMonth* birthdayPicker; QToolButton* birthdayButton; DateBookMonth* anniversaryPicker; QToolButton* anniversaryButton; bool initializing; }; #endif |