summaryrefslogtreecommitdiff
authoreilers <eilers>2003-04-02 14:22:18 (UTC)
committer eilers <eilers>2003-04-02 14:22:18 (UTC)
commitf0d3ff51dde49f994783827051464920529024af (patch) (side-by-side diff)
tree7d306530f14d020a85b332482fa549e8006f3148
parent617523539b2ac77a97db427ba218b5951267410d (diff)
downloadopie-f0d3ff51dde49f994783827051464920529024af.zip
opie-f0d3ff51dde49f994783827051464920529024af.tar.gz
opie-f0d3ff51dde49f994783827051464920529024af.tar.bz2
Fix bug #791 (Misbehaviour of contacteditor: The main tab is active for every new
entry) Export to VCard added. Edit:Save removed (Was just for testing purposes)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO8
-rw-r--r--core/pim/addressbook/addressbook.cpp30
-rw-r--r--core/pim/addressbook/addressbook.h5
-rw-r--r--core/pim/addressbook/contacteditor.cpp2
-rw-r--r--core/pim/addressbook/version.h2
5 files changed, 38 insertions, 9 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index da9b9c2..a3cffa7 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -1,116 +1,112 @@
Stuff todo until OPIE 1.0 :
===========================
Feature requests:
-----------------
- Dial by mobile phone by tapping the number..
(Maybe using gsmtool. And we may
add a library class for this)
- dial with dtmfdial in case it's installed and there's no mobile
- 3rd column for 2. Contact
- Implementing additional Views (Phonebook, ...)
- Birthday & Anniversary Reminder
- Beaming of multiple contacts (current list/ by search or by category)
- Configure the letter-picker: lastname/fullname search
-- User center of the joypad to switch back from card to listview !
+- Optionally put scrollbars left.
Known Bugs:
-----------
-Bugs but not in addressbook:
------------------------------
-- VCARD: If umlaut (äöüß) in address, the parser gets confused..
-
-
Urgent:
--------
- Category is on the wrong position after changing to personal and back to normal
( Temporarily workaround: Category is never deactivated.. :S )
Important:
----------
- "What's this" should be added (Deleyed after Feature Freeze)
Less important:
---------------
- Reload if contacts were changed externally
- The picker (alphabetical sort widget) should be
placed verticaly or horizontally (configurable)
- Find a smart solution for activating/deactivating the "send email" event
- If new contact is added (contacteditor closed): focus (table, card) to
this entry !
- After search (Started with Return): KeyFocus should be on Tabelle
ContactEditor:
- Redesign of Contacteditor
Should be Fixed (not absolute sure, need further validation):
-------------------------------------------------------------
Fixed/Ready:
-------
- Syncing: abtable not reloaded after sync.
- Find widget should be replaced by something like
qpdf has.
- Adding a configuration dialog
- Picker: Activated letter schould be more visible
- Advanced handling of cursor keys (search..)
- Mail-Icon is missing
- Use opie-mail insted of qt-mail if possible.
- Font menu is invisible using german translation
- Personal contact editor: Disable categories
- "Nonenglish" translation bug has to be fixed.
- contacteditor: Birthday, annyversary, ... : Use Dateselector
- The names of the countries are sorted by there english names, only..
Even if they are translated.. :S
- Cursor keys should work in detail-view (ablabel)
-> Ablabel should be removed and Abtable should be increased with
different views (as started by darwin zins)..
- Use advanced database functions in abtable to decrease
memory footprint and to make everything more easy !
(abtable should store Iterator for selected Category)
- Abtable: Configure Contact column (internally already available,
need configuration)
- Select of primary contact (see #274 on mantis)
- Category-select does not work completely: "Unfiled" is always in listview ..
- Return from Contacteditor: Category resettet to all
- Personal Details not working
- If category changed, the letterpicker should be resetted
- There should be some icons for List and Cardview
- If in Cardview and a category change removes all entries:
There are already entries in Cardview after up/down
- Personal Details: Anniversary zeigt Fantasie-Werte
- Unfiled shown just in Category "All" and "Unfiled".
- After finising search and after Edit: Clear Picker
- After Edit: Table position back to edited entry.
- Optimize Table Update...
- Change MyDialog to Config
- Store position and state of toolbar
- Searchwidget closed: Selected user is jumping
- Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist)
zu lange..
- VCARD: Import of Anniversary does not work correctly (currently disabled)
- Name order selected in "contacteditor" not used in list view.
- OK-Key does not switch from Detailview (ablable) to Listview
- Receiving of beams should open a dialog
- Fix start of opie-mail
- Implement Button Pics
- Add a dialog to accept and optionally edit received contacts by IRDA.
- Language not English (tested with german opie-translation):
1. Configure nicht übersetzt (alles leer).
2. Contacteditor nur teilweise übersetzt.
3. Kategorie-Picker geht nicht.
- Plugin for Today for Birthdays and Anniversaries
- Implement a picker/combo for the default email.
- Overview window cleanup needed..
- Store last settings of combo-boxes
- Personal and Business Web-page is not editable
- Default Email-button: A lot of problems:
If on second tab: The combo chooser is on the top left of the screen ! :(
- Default Email-Button: Sometimes not hiding the textfields completely
- Fix handling of 3 Firstnames
- Cursor-UP/Down: Should additionally scroll cardview if it is too large
(behaviour should be selectable by configuration)
+- User center of the joypad to switch back from card to listview !
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index a5bf19b..89a3312 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,717 +1,747 @@
/**********************************************************************
** 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.
**
** OContact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#define QTOPIA_INTERNAL_FD
#include "contacteditor.h"
#include "ablabel.h"
#include "abview.h"
#include "abtable.h"
// #include "addresssettings.h"
#include "addressbook.h"
#include <opie/ofileselector.h>
#include <opie/ofiledialog.h>
#include <opie/ocontact.h>
#include <opie/ocontactaccessbackend_vcard.h>
#include <qpe/resource.h>
#include <qpe/ir.h>
#include <qpe/qpemessagebox.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpetoolbar.h>
#include <qpe/qpemenubar.h>
// #include <qtoolbar.h>
// #include <qmenubar.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qaction.h>
#include <qdialog.h>
#include <qdir.h>
#include <qfile.h>
#include <qimage.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qpixmap.h>
#include <qpopupmenu.h>
#include <qstringlist.h>
#include <qtoolbutton.h>
#include <qwhatsthis.h>
#include <qdatetime.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),
abEditor(0l),
syncing(FALSE),
m_tableViewButton(0l),
m_cardViewButton(0l)
{
isLoading = true;
m_config.load();
setCaption( tr("Contacts") );
setIcon( Resource::loadPixmap( "AddressBook" ) );
// Settings for Main Menu
// setToolBarsMovable( false );
setToolBarsMovable( !m_config.fixedBars() );
setRightJustification( true );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
QPEMenuBar *mbList = new QPEMenuBar( 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 QPEToolBar( this, "list operations" );
listTools->setHorizontalStretchable( true );
addToolBar( listTools );
moveToolBar( listTools, m_config.getToolBarPos() );
// View Icons
m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/weeklst" ),
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( "day" ), 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 );
}
edit->insertSeparator();
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 );
+ 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 );
+
edit->insertSeparator();
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 );
#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 );
// Create Views
listContainer = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( listContainer );
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 ) ) );
QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
m_abView->load();
// Letter Picker
pLabel = new LetterPicker( listContainer );
connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
vb->addWidget( pLabel );
// All Categories into view-menu..
populateCategories();
// Fontsize
defaultFont = new QFont( m_abView->font() );
slotSetFont(m_config.fontSize());
m_curFontSize = m_config.fontSize();
setCentralWidget(listContainer);
// qDebug("adressbook contrsuction: t=%d", t.elapsed() );
isLoading = false;
}
void AddressbookWindow::slotConfig()
{
ConfigDlg* dlg = new ConfigDlg( this, "Config" );
dlg -> setConfig( m_config );
dlg -> showMaximized();
if ( dlg -> exec() ) {
qWarning ("Config Dialog accepted!");
m_config = dlg -> getConfig();
if ( m_curFontSize != m_config.fontSize() ){
qWarning("Font was changed!");
m_curFontSize = m_config.fontSize();
emit slotSetFont( m_curFontSize );
}
m_abView -> setListOrder( m_config.orderList() );
}
delete dlg;
}
void AddressbookWindow::slotSetFont( int size )
{
qWarning("void AddressbookWindow::slotSetFont( %d )", size);
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 = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
if(!str.isEmpty() ){
setDocument((const QString&) str );
}
}
+void AddressbookWindow::exportvCard()
+{
+ qWarning(" void AddressbookWindow::exportvCard()");
+ QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this );
+ if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){
+ qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 );
+ OContact curCont = m_abView->currentEntry();
+ if ( !curCont.isEmpty() ){
+ OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
+ filename );
+ OContactAccess* access = new OContactAccess ( "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 )
{
qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
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:
qWarning("YES clicked");
break;
case 1:
qWarning("NO clicked");
return;
break;
}
}
OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
filename );
OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
OContactAccess::List allList = access->allRecords();
qWarning( "Found number of contacts in File: %d", allList.count() );
if ( !allList.count() ) {
QMessageBox::information( this, "Import VCard",
"It was impossible to import\nthe VCard.\n"
"The VCard may be corrupted!" );
}
bool doAsk = true;
OContactAccess::List::Iterator it;
for ( it = allList.begin(); it != allList.end(); ++it ){
qWarning("Adding Contact from: %s", (*it).fullName().latin1() );
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:
qWarning("YES clicked");
m_abView->addEntry( *it );
break;
case 1:
qWarning("NO clicked");
break;
case 2:
qWarning("YesAll clicked");
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()
{
OContact ce = m_abView->currentEntry();
actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
}
void AddressbookWindow::slotListNew()
{
OContact 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::slotListDelete()
{
if(!syncing) {
OContact 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()
{
searchBar->show();
m_abView -> inSearch();
searchEdit->setFocus();
}
void AddressbookWindow::slotFindClose()
{
searchBar->hide();
m_abView -> offSearch();
// m_abView->setFocus();
}
void AddressbookWindow::slotFind()
{
m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
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()
{
OContact 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() ){
qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
if ( QFile::exists( basepath + "/bin/qtmail" ) ){
qWarning ("QCop");
QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
e << name << email;
return;
} else
m_config.setUseOpieMail( true );
}
if ( m_config.useOpieMail() ){
qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
if ( QFile::exists( basepath + "/bin/mail" ) ){
qWarning ("QCop");
QCopEnvelope e("QPE/Application/mail", "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;
OContact c;
if ( actionPersonal->isOn() ) {
beamFilename = addressbookPersonalVCardName();
if ( !QFile::exists( beamFilename ) )
return; // can't beam a non-existent file
OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
beamFilename );
OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
OContactAccess::List allList = access->allRecords();
OContactAccess::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();
OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
beamfile );
OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
access->add( c );
access->save();
delete access;
beamFilename = beamfile;
}
qWarning("Beaming: %s", beamFilename.latin1() );
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)
{
if (msg == "editPersonal()") {
editPersonal();
} else if (msg == "editPersonalAndClose()") {
editPersonal();
close();
} else if ( msg == "addContact(QString,QString)" ) {
QDataStream stream(data,IO_ReadOnly);
QString name, email;
stream >> name >> email;
OContact cnt;
QString fn, mn, ln;
parseName( name, &fn, &mn, &ln );
// qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
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 );
} 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" );
}
#if 0
else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
QDataStream stream(data,IO_ReadOnly);
QCString ch,m;
QStringList types;
stream >> ch >> m >> types;
AddressPicker picker(abList,this,0,TRUE);
picker.showMaximized();
picker.setChoiceNames(types);
int i=0;
for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
QStringList sel;
stream >> sel;
picker.setSelection(i++,sel);
}
picker.showMaximized();
picker.exec();
// ###### note: contacts may have been added - save here!
setCentralWidget(abList);
QCopEnvelope e(ch,m);
i=0;
for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
QStringList sel = picker.selection(i++);
e << sel;
}
}
#endif
}
void AddressbookWindow::editEntry( EntryMode entryMode )
{
OContact 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") );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
abEditor->showMaximized();
#endif
// fix the foxus...
abEditor->setNameFocus();
if ( abEditor->exec() ) {
setFocus();
if ( entryMode == NewEntry ) {
OContact insertEntry = abEditor->entry();
insertEntry.assignUid();
m_abView -> addEntry( insertEntry );
} else {
OContact replEntry = abEditor->entry();
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 69fe2f8..f7a560a 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -1,135 +1,136 @@
/**********************************************************************
** 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
+// #define __DEBUG_RELEASE
#include <qmainwindow.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 QPEToolBar;
class QPopupMenu;
class QToolButton;
class QDialog;
class Ir;
class QAction;
class LetterPicker;
class AddressbookWindow: public QMainWindow
{
Q_OBJECT
public:
enum EntryMode { NewEntry=0, EditEntry };
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 & );
#ifdef __DEBUG_RELEASE
- void slotSave();
+ // void slotSave();
#endif
private slots:
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 slotSetLetter( char );
void slotUpdateToolbar();
void slotSetFont(int);
void slotFindOpen();
void slotFindClose();
void slotFind();
void slotNotFound();
void slotWrapAround();
void slotViewSwitched( int );
void slotListView();
void slotCardView();
void slotConfig();
private:
void populateCategories();
QPopupMenu *catMenu;
QPEToolBar *listTools;
QToolButton *deleteButton;
enum Panes { paneList=0, paneView, paneEdit };
ContactEditor *abEditor;
LetterPicker *pLabel;
AbView* m_abView;
QWidget *listContainer;
// Searching stuff
OFloatBar* searchBar;
QLineEdit* searchEdit;
QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *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 df97b85..f33ee0a 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -875,769 +875,771 @@ void ContactEditor::slotChooser1Change( const QString &textChanged ) {
}
void ContactEditor::slotChooser2Change( const QString &textChanged ) {
qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1());
chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
}
void ContactEditor::slotChooser3Change( const QString &textChanged ) {
qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1());
chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
}
void ContactEditor::slotChooser4Change( const QString &textChanged ) {
qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1());
chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4);
}
void ContactEditor::slotAddressChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[0] = textChanged;
} else {
slHomeAddress[0] = textChanged;
}
}
void ContactEditor::slotAddress2Change( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[1] = textChanged;
} else {
slHomeAddress[1] = textChanged;
}
}
void ContactEditor::slotPOBoxChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[2] = textChanged;
} else {
slHomeAddress[2] = textChanged;
}
}
void ContactEditor::slotCityChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[3] = textChanged;
} else {
slHomeAddress[3] = textChanged;
}
}
void ContactEditor::slotStateChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[4] = textChanged;
} else {
slHomeAddress[4] = textChanged;
}
}
void ContactEditor::slotZipChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[5] = textChanged;
} else {
slHomeAddress[5] = textChanged;
}
}
void ContactEditor::slotCountryChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[6] = textChanged;
} else {
slHomeAddress[6] = textChanged;
}
}
void ContactEditor::slotCmbChooser1Change( int index ) {
qWarning("ContactEditor::slotCmbChooser1Change( %d )", index);
if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){
txtChooserField1->setText( slChooserValues[index] );
txtChooserField1->setFocus();
}
}
void ContactEditor::slotCmbChooser2Change( int index ) {
qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){
txtChooserField2->setText( slChooserValues[index] );
txtChooserField2->setFocus();
}
}
void ContactEditor::slotCmbChooser3Change( int index ) {
qWarning("ContactEditor::slotCmbChooser3Change( %d )", index);
if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){
txtChooserField3->setText( slChooserValues[index] );
txtChooserField3->setFocus();
}
}
void ContactEditor::slotCmbChooser4Change( int index ) {
qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){
txtChooserField4->setText( slChooserValues[index] );
txtChooserField4->setFocus();
}
}
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 ) {
qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() );
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::accept() {
if ( isEmpty() ) {
cleanupFields();
reject();
} else {
saveEntry();
cleanupFields();
QDialog::accept();
}
}
void ContactEditor::slotNote() {
dlgNote->showMaximized();
if ( !dlgNote->exec() ) {
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) );
dlgName->showMaximized();
if ( dlgName->exec() ) {
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;
qWarning("Fullname: %s", simplifiedName.latin1());
commapos = simplifiedName.find( ',', 0, TRUE);
if ( commapos >= 0 ) {
qWarning(" Commapos: %d", commapos );
// 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;
qWarning("Fullname without ',': %s", simplifiedName.latin1());
// 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 = "";
qWarning(" strFirstName: %s", strFirstName.latin1());
qWarning(" strMiddleName: %s", strMiddleName.latin1());
qWarning(" strLastName: %s", strLastName.latin1());
qWarning(" strTitle: %s", strTitle.latin1());
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 OContact &entry ) {
initializing = true;
+ // Cleanup and activate the general Page ..
cleanupFields();
+ tabMain->setCurrentPage( 0 );
ent = entry;
emails = QStringList(ent.emailList());
defaultEmail = ent.defaultEmail();
if (defaultEmail.isEmpty()) defaultEmail = emails[0];
qDebug("default email=%s",defaultEmail.latin1());
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 ) )
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) {
qWarning(" Filling dynamic Field: %s", (*it).latin1() );
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" ){
qWarning("**** Nichname: %s", ent.nickname().latin1() );
(*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();
*/
if ( *it == "Default Email" )
*itV = ent.defaultEmail();
if ( *it == "Emails" )
*itV = ent.emailList().join(", "); // :SX
if ( *it == "Home Phone" )
*itV = ent.homePhone();
/*
if ( *it == "Home 2 Phone" )
*itV = ent.home2Phone();
*/
if ( *it == "Home Fax" )
*itV = ent.homeFax();
if ( *it == "Home Mobile" )
*itV = ent.homeMobile();
/*
if ( *it == "Car Phone" )
*itV = ent.carPhone();
if ( *it == "ISDN Phone" )
*itV = ent.ISDNPhone();
if ( *it == "Other Phone" )
*itV = ent.otherPhone();
*/
if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
*itV = ent.businessPager();
/*
if ( *it == "Home Pager")
*itV = ent.homePager();
if ( *it == "AIM IM" )
*itV = ent.AIMIM();
if ( *it == "ICQ IM" )
*itV = ent.ICQIM();
if ( *it == "Jabber IM" )
*itV = ent.jabberIM();
if ( *it == "MSN IM" )
*itV = ent.MSNIM();
if ( *it == "Yahoo IM" )
*itV = ent.yahooIM();
*/
if ( *it == "Home Web Page" )
*itV = ent.homeWebpage();
if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
*itV = ent.businessWebpage();
}
cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
QString gender = ent.gender();
cmbGender->setCurrentItem( gender.toInt() );
txtNote->setText( ent.notes() );
slotAddressTypeChange( cmbAddress->currentItem() );
// Get combo-settings from contact and set preset..
contactfields.loadFromRecord( ent );
cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) );
cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) );
cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) );
cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) );
cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) );
slotCmbChooser1Change( cmbChooserField1->currentItem() );
slotCmbChooser2Change( cmbChooserField2->currentItem() );
slotCmbChooser3Change( cmbChooserField3->currentItem() );
slotCmbChooser4Change( cmbChooserField4->currentItem() );
slotAddressTypeChange( cmbAddress->currentItem() );
updateDatePicker();
initializing = false;
}
void ContactEditor::updateDatePicker()
{
// Set DatePicker
if ( !ent.birthday().isNull() ){
birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) );
birthdayPicker->setDate( ent.birthday() );
} else
birthdayButton->setText( tr ("Unknown") );
if ( !ent.anniversary().isNull() ){
anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) );
anniversaryPicker->setDate( ent.anniversary() );
} else
anniversaryButton->setText( tr ("Unknown") );
}
void ContactEditor::saveEntry() {
// Store current combo into contact
contactfields.saveToRecord( ent );
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 ) );
ent.setFirstName( txtFirstName->text() );
ent.setLastName( txtLastName->text() );
ent.setMiddleName( txtMiddleName->text() );
ent.setSuffix( txtSuffix->text() );
ent.setFileAs( cmbFileAs->currentText() );
ent.setCategories( cmbCat->currentCategories() );
//if (hasTitle)
ent.setJobTitle( txtJobTitle->text() );
//if (hasCompany)
ent.setCompany( txtOrganization->text() );
// if (hasNotes)
ent.setNotes( txtNote->text() );
//if (hasStreet) {
ent.setHomeStreet( slHomeAddress[0] );
ent.setBusinessStreet( slBusinessAddress[0] );
// }
// if (hasCity) {
ent.setHomeCity( slHomeAddress[3] );
ent.setBusinessCity( slBusinessAddress[3] );
// }
// if (hasState) {
ent.setHomeState( slHomeAddress[4] );
ent.setBusinessState( slBusinessAddress[4] );
// }
// if (hasZip) {
ent.setHomeZip( slHomeAddress[5] );
ent.setBusinessZip( slBusinessAddress[5] );
// }
// if (hasCountry) {
ent.setHomeCountry( slHomeAddress[6] );
ent.setBusinessCountry( slBusinessAddress[6] );
// }
QStringList::ConstIterator it;
QListIterator<QLineEdit> itLE( listValue );
for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) {
if ( *it == "Department" )
ent.setDepartment( (*itLE)->text() );
if ( *it == "Company" )
ent.setCompany( (*itLE)->text() );
if ( *it == "Office" )
ent.setOffice( (*itLE)->text() );
if ( *it == "Profession" )
ent.setProfession( (*itLE)->text() );
if ( *it == "Assistant" )
ent.setAssistant( (*itLE)->text() );
if ( *it == "Manager" )
ent.setManager( (*itLE)->text() );
if ( *it == "Spouse" )
ent.setSpouse( (*itLE)->text() );
if ( *it == "Nickname" )
ent.setNickname( (*itLE)->text() );
if ( *it == "Children" )
ent.setChildren( (*itLE)->text() );
}
QStringList::ConstIterator itV;
for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) )
ent.setBusinessPhone( *itV );
if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
ent.setBusinessFax( *itV );
if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
ent.setBusinessMobile( *itV );
if ( *it == "Emails" ){
QString allemail;
QString defaultmail;
parseEmailFrom( emails.join(","), defaultmail, allemail );
if ( defaultEmail.isEmpty() ){
qWarning("Default email was not set by user!");
qWarning("Using first email in list: %s", defaultmail.latin1());
ent.setDefaultEmail( defaultmail );
}
ent.setEmails( allemail );
}
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() );
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h
index d590a86..c0465b5 100644
--- a/core/pim/addressbook/version.h
+++ b/core/pim/addressbook/version.h
@@ -1,10 +1,10 @@
#ifndef _VERSION_H_
#define _VERSION_H_
#define MAINVERSION "0"
#define SUBVERSION "9"
-#define PATCHVERSION "3"
+#define PATCHVERSION "4"
#define APPNAME "OPIE_ADDRESSBOOK"
#endif