summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO5
-rw-r--r--core/pim/addressbook/abtable.cpp137
-rw-r--r--core/pim/addressbook/abtable.h12
-rw-r--r--core/pim/addressbook/addressbook.cpp5
-rw-r--r--core/pim/addressbook/configdlg.cpp11
-rw-r--r--core/pim/addressbook/contacteditor.cpp3
-rw-r--r--core/pim/addressbook/ocontactfields.cpp14
7 files changed, 122 insertions, 65 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index f62b075..906b462 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -1,117 +1,118 @@
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 !
- Cursor-UP/Down: Should additionally scroll cardview if it is too large
(behaviour should be selectable by configuration)
Known Bugs:
-----------
-- Email-button: A lot of problems.. :(
+- 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
Bugs but not in addressbook:
-----------------------------
- VCARD: If umlaut (äöüß) in address, the parser gets confused..
- Exporting and reimporting of Jobtitle was reported to fail (Could not reproduce this ! (se))
Urgent:
--------
ContactEditor:
- Contact-Editor is temporarely reenabled. Wait for replacement.
- Redesign of Contacteditor
- Category is on the wrong position after changing to personal and back to normal
( Temporarily workaround: Category is never deactivated.. :S )
-- Personal and Business Web-page is not editable
Important:
----------
- If new contact is added (contacteditor closed): focus (table, card) to
this entry !
- After search (Started with Return): KeyFocus should be on Tabelle
- "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
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
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index aec390d..55b1ba1 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -1,747 +1,780 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
**
** 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.
**
**********************************************************************/
#include <qpe/categoryselect.h>
#include <qpe/config.h>
#include <qpe/stringutil.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/timestring.h>
+#include <qpe/resource.h>
#include <opie/orecordlist.h>
#include <qasciidict.h>
#include <qdatetime.h>
#include <qfile.h>
#include <qregexp.h>
#include <qmessagebox.h>
#include "abtable.h"
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h> //toupper() for key hack
/*!
\class AbTableItem abtable.h
\brief QTableItem based class for showing a field of an entry
*/
AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s,
const QString &secondSortKey)
: QTableItem( t, et, s )
{
// sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower();
sortKey = Qtopia::buildSortKey( s, secondSortKey );
}
int AbTableItem::alignment() const
{
return AlignLeft|AlignVCenter;
}
QString AbTableItem::key() const
{
return sortKey;
}
// A way to reset the item, without out doing a delete or a new...
void AbTableItem::setItem( const QString &txt, const QString &secondKey )
{
setText( txt );
sortKey = Qtopia::buildSortKey( txt, secondKey );
// sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower();
}
/*!
\class AbPickItem abtable.h
\brief QTableItem based class for showing slection of an entry
*/
AbPickItem::AbPickItem( QTable *t ) :
QTableItem(t, WhenCurrent, "?")
{
}
QWidget *AbPickItem::createEditor() const
{
QComboBox* combo = new QComboBox( table()->viewport() );
( (AbPickItem*)this )->cb = combo;
AbTable* t = static_cast<AbTable*>(table());
QStringList c = t->choiceNames();
int cur = 0;
for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
if ( *it == text() )
cur = combo->count();
combo->insertItem(*it);
}
combo->setCurrentItem(cur);
return combo;
}
void AbPickItem::setContentFromEditor( QWidget *w )
{
if ( w->inherits("QComboBox") )
setText( ( (QComboBox*)w )->currentText() );
else
QTableItem::setContentFromEditor( w );
}
/*!
\class AbTable abtable.h
\brief QTable based class for showing a list of entries
*/
AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
: QTable( parent, name ),
lastSortCol( -1 ),
asc( TRUE ),
intFields( order ),
enablePainting( true ),
columnVisible( true ),
countNested( 0 )
{
// qWarning("C'tor start");
setSelectionMode( NoSelection );
init();
setSorting( TRUE );
connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
this, SLOT(itemClicked(int,int)) );
contactList.clear();
// qWarning("C'tor end");
}
AbTable::~AbTable()
{
}
void AbTable::init()
{
// :SX showChar = '\0';
setNumRows( 0 );
setNumCols( 2 );
horizontalHeader()->setLabel( 0, tr( "Full Name" ));
horizontalHeader()->setLabel( 1, tr( "Contact" ));
setLeftMargin( 0 );
verticalHeader()->hide();
columnVisible = true;
}
void AbTable::setContacts( const OContactAccess::List& viewList )
{
// qWarning("AbTable::setContacts()");
clear();
m_viewList = viewList;
setSorting( false );
setPaintingEnabled( FALSE );
OContactAccess::List::Iterator it;
setNumRows( m_viewList.count() );
int row = 0;
for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
insertIntoTable( *it, row++ );
setSorting( true );
resort();
updateVisible();
setPaintingEnabled( TRUE );
}
bool AbTable::selectContact( int UID )
{
// qWarning( "AbTable::selectContact( %d )", UID );
int rows = numRows();
AbTableItem *abi;
OContact* foundContact = 0l;
bool found = false;
setPaintingEnabled( FALSE );
for ( int r = 0; r < rows; ++r ) {
abi = static_cast<AbTableItem*>( item(r, 0) );
foundContact = &contactList[abi];
if ( foundContact -> uid() == UID ){
ensureCellVisible( r, 0 );
setCurrentCell( r, 0 );
found = true;
break;
}
}
if ( !found ){
ensureCellVisible( 0,0 );
setCurrentCell( 0, 0 );
}
setPaintingEnabled( TRUE );
return true;
}
void AbTable::insertIntoTable( const OContact& cnt, int row )
{
// qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
- QString strName,
- strContact;
+ QString strName;
+ ContactItem contactItem;
strName = findContactName( cnt );
- strContact = findContactContact( cnt, row );
+ contactItem = findContactContact( cnt, row );
AbTableItem *ati;
- ati = new AbTableItem( this, QTableItem::Never, strName, strContact);
+ ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value );
contactList.insert( ati, cnt );
setItem( row, 0, ati );
- ati = new AbTableItem( this, QTableItem::Never, strContact, strName);
+ ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName);
+ if ( !contactItem.icon.isNull() )
+ ati->setPixmap( contactItem.icon );
setItem( row, 1, ati );
//### cannot do this; table only has two columns at this point
// setItem( row, 2, new AbPickItem( this ) );
}
void AbTable::columnClicked( int col )
{
if ( !sorting() )
return;
if ( lastSortCol == -1 )
lastSortCol = col;
if ( col == lastSortCol ) {
asc = !asc;
} else {
lastSortCol = col;
asc = TRUE;
}
//QMessageBox::information( this, "resort", "columnClicked" );
resort();
}
void AbTable::resort()
{
// qWarning( "void AbTable::resort()" );
setPaintingEnabled( FALSE );
if ( sorting() ) {
if ( lastSortCol == -1 )
lastSortCol = 0;
sortColumn( lastSortCol, asc, TRUE );
//QMessageBox::information( this, "resort", "resort" );
updateVisible();
}
setPaintingEnabled( TRUE );
}
OContact AbTable::currentEntry()
{
// qWarning( "OContact AbTable::currentEntry()" );
OContact cnt;
AbTableItem *abItem;
abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
if ( abItem ) {
cnt = contactList[abItem];
//cnt = contactList[currentRow()];
}
return cnt;
}
int AbTable::currentEntry_UID()
{
return ( currentEntry().uid() );
}
void AbTable::clear()
{
// qWarning( "void AbTable::clear()" );
contactList.clear();
setPaintingEnabled( FALSE );
for ( int r = 0; r < numRows(); ++r ) {
for ( int c = 0; c < numCols(); ++c ) {
if ( cellWidget( r, c ) )
clearCellWidget( r, c );
clearCell( r, c );
}
}
setNumRows( 0 );
setPaintingEnabled( TRUE );
}
// Refresh updates column 2 if the contactsettings changed
void AbTable::refresh()
{
// qWarning( "void AbTable::refresh()" );
int rows = numRows();
- QString value;
AbTableItem *abi;
+ ContactItem contactItem;
setPaintingEnabled( FALSE );
for ( int r = 0; r < rows; ++r ) {
abi = static_cast<AbTableItem*>( item(r, 0) );
- value = findContactContact( contactList[abi], r );
- static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() );
+ contactItem = findContactContact( contactList[abi], r );
+ static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() );
+ if ( !contactItem.icon.isNull() )
+ static_cast<AbTableItem*>( item(r, 1) )->
+ setPixmap( contactItem.icon );
+
}
resort();
setPaintingEnabled( TRUE );
}
void AbTable::keyPressEvent( QKeyEvent *e )
{
char key = toupper( e->ascii() );
if ( key >= 'A' && key <= 'Z' )
moveTo( key );
// qWarning("Received key ..");
switch( e->key() ) {
case Qt::Key_Space:
case Qt::Key_Return:
case Qt::Key_Enter:
emit signalSwitch();
break;
// case Qt::Key_Up:
// qWarning("a");
// emit signalKeyUp();
// break;
// case Qt::Key_Down:
// qWarning("b");
// emit signalKeyDown();
// break;
default:
QTable::keyPressEvent( e );
}
}
void AbTable::moveTo( char c )
{
qWarning( "void AbTable::moveTo( char c )" );
int rows = numRows();
QString value;
AbTableItem *abi;
int r;
if ( asc ) {
r = 0;
while ( r < rows-1) {
abi = static_cast<AbTableItem*>( item(r, 0) );
QChar first = abi->key()[0];
//### is there a bug in QChar to char comparison???
if ( first.row() || first.cell() >= c )
break;
r++;
}
} else {
//### should probably disable reverse sorting instead
r = rows - 1;
while ( r > 0 ) {
abi = static_cast<AbTableItem*>( item(r, 0) );
QChar first = abi->key()[0];
//### is there a bug in QChar to char comparison???
if ( first.row() || first.cell() >= c )
break;
r--;
}
}
setCurrentCell( r, currentColumn() );
}
QString AbTable::findContactName( const OContact &entry )
{
// We use the fileAs, then company, defaultEmail
QString str;
str = entry.fileAs();
if ( str.isEmpty() ) {
str = entry.company();
if ( str.isEmpty() ) {
str = entry.defaultEmail();
}
}
return str;
}
void AbTable::resizeRows() {
/*
if (numRows()) {
for (int i = 0; i < numRows(); i++) {
setRowHeight( i, size );
}
}
updateVisible();
*/
}
void AbTable::realignTable()
{
// qWarning( "void AbTable::realignTable()" );
setPaintingEnabled( FALSE );
resizeRows();
fitColumns();
setPaintingEnabled( TRUE );
}
#if QT_VERSION <= 230
#ifndef SINGLE_APP
void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
{
// Region of the rect we should draw
QRegion reg( QRect( cx, cy, cw, ch ) );
// Subtract the table from it
reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
// And draw the rectangles (transformed as needed)
QArray<QRect> r = reg.rects();
for (unsigned int i=0; i<r.count(); i++)
p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
}
#endif
#endif
// int AbTable::rowHeight( int ) const
// {
// return 18;
// }
// int AbTable::rowPos( int row ) const
// {
// return 18*row;
// }
// int AbTable::rowAt( int pos ) const
// {
// return QMIN( pos/18, numRows()-1 );
// }
void AbTable::fitColumns()
{
// qWarning( "void AbTable::fitColumns()" );
int contentsWidth = visibleWidth() / 2; // :SX Why too low
// Fix to better value
// contentsWidth = 130;
setPaintingEnabled( FALSE );
if ( columnVisible == false ){
showColumn(0);
columnVisible = true;
}
// qWarning("Width: %d", contentsWidth);
setColumnWidth( 0, contentsWidth );
adjustColumn(1);
if ( columnWidth(1) < contentsWidth )
setColumnWidth( 1, contentsWidth );
setPaintingEnabled( TRUE );
}
void AbTable::show()
{
// qWarning( "void AbTable::show()" );
realignTable();
QTable::show();
}
void AbTable::setChoiceNames( const QStringList& list)
{
choicenames = list;
if ( choicenames.isEmpty() ) {
// hide pick column
setNumCols( 2 );
} else {
// show pick column
setNumCols( 3 );
setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
horizontalHeader()->setLabel( 2, tr( "Pick" ));
}
fitColumns();
}
void AbTable::itemClicked(int,int col)
{
// qWarning( "AbTable::itemClicked(int, col:%d)", col);
if ( col == 2 ) {
return;
} else {
// qWarning ("Emitting signalSwitch()");
emit signalSwitch();
}
}
QStringList AbTable::choiceNames() const
{
return choicenames;
}
void AbTable::setChoiceSelection( const QValueList<int>& list )
{
intFields = list;
}
QStringList AbTable::choiceSelection(int /*index*/) const
{
QStringList r;
/* ######
QString selname = choicenames.at(index);
for (each row) {
OContact *c = contactForRow(row);
if ( text(row,2) == selname ) {
r.append(c->email);
}
}
*/
return r;
}
void AbTable::updateVisible()
{
// qWarning("void AbTable::updateVisible()");
int visible,
totalRows,
row,
selectedRow = 0;
visible = 0;
setPaintingEnabled( FALSE );
realignTable();
totalRows = numRows();
for ( row = 0; row < totalRows; row++ ) {
if ( rowHeight(row) == 0 ) {
showRow( row );
adjustRow( row );
if ( isSelected( row,0 ) || isSelected( row,1 ) )
selectedRow = row;
}
visible++;
}
if ( selectedRow )
setCurrentCell( selectedRow, 0 );
if ( !visible )
setCurrentCell( -1, 0 );
setPaintingEnabled( TRUE );
}
void AbTable::setPaintingEnabled( bool e )
{
// qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
if ( e ) {
if ( countNested > 0 )
--countNested;
if ( ! countNested ){
setUpdatesEnabled( true );
enablePainting = true;
rowHeightChanged( 0 );
viewport()->update();
}
} else {
++countNested;
enablePainting = false;
setUpdatesEnabled( false );
}
// qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
}
void AbTable::viewportPaintEvent( QPaintEvent* e ) {
// qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
if ( enablePainting )
QTable::viewportPaintEvent( e );
}
void AbTable::rowHeightChanged( int row )
{
if ( enablePainting )
QTable::rowHeightChanged( row );
}
-QString AbTable::findContactContact( const OContact &entry, int /* row */ )
+ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ )
{
- QString value;
- value = "";
+
+ ContactItem item;
+
+ item.value = "";
+
for ( QValueList<int>::ConstIterator it = intFields.begin();
it != intFields.end(); ++it ) {
switch ( *it ) {
default:
break;
case Qtopia::Title:
- value = entry.title();
+ item.value = entry.title();
break;
case Qtopia::Suffix:
- value = entry.suffix();
+ item.value = entry.suffix();
break;
case Qtopia::FileAs:
- value = entry.fileAs();
+ item.value = entry.fileAs();
break;
case Qtopia::DefaultEmail:
- value = entry.defaultEmail();
+ item.value = entry.defaultEmail();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/email" );
+ break;
case Qtopia::Emails:
- value = entry.emails();
+ item.value = entry.emails();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/email" );
break;
case Qtopia::HomeStreet:
- value = entry.homeStreet();
+ item.value = entry.homeStreet();
break;
case Qtopia::HomeCity:
- value = entry.homeCity();
+ item.value = entry.homeCity();
break;
case Qtopia::HomeState:
- value = entry.homeState();
+ item.value = entry.homeState();
break;
case Qtopia::HomeZip:
- value = entry.homeZip();
+ item.value = entry.homeZip();
break;
case Qtopia::HomeCountry:
- value = entry.homeCountry();
+ item.value = entry.homeCountry();
break;
case Qtopia::HomePhone:
- value = entry.homePhone();
+ item.value = entry.homePhone();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/phonehome" );
break;
case Qtopia::HomeFax:
- value = entry.homeFax();
+ item.value = entry.homeFax();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/faxhome" );
break;
case Qtopia::HomeMobile:
- value = entry.homeMobile();
+ item.value = entry.homeMobile();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/mobilehome" );
break;
case Qtopia::HomeWebPage:
- value = entry.homeWebpage();
+ item.value = entry.homeWebpage();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/webpagehome" );
break;
case Qtopia::Company:
- value = entry.company();
+ item.value = entry.company();
break;
case Qtopia::BusinessCity:
- value = entry.businessCity();
+ item.value = entry.businessCity();
break;
case Qtopia::BusinessStreet:
- value = entry.businessStreet();
+ item.value = entry.businessStreet();
break;
case Qtopia::BusinessZip:
- value = entry.businessZip();
+ item.value = entry.businessZip();
break;
case Qtopia::BusinessCountry:
- value = entry.businessCountry();
+ item.value = entry.businessCountry();
break;
case Qtopia::BusinessWebPage:
- value = entry.businessWebpage();
+ item.value = entry.businessWebpage();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/webpagework" );
break;
case Qtopia::JobTitle:
- value = entry.jobTitle();
+ item.value = entry.jobTitle();
break;
case Qtopia::Department:
- value = entry.department();
+ item.value = entry.department();
break;
case Qtopia::Office:
- value = entry.office();
+ item.value = entry.office();
break;
case Qtopia::BusinessPhone:
- value = entry.businessPhone();
+ item.value = entry.businessPhone();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/phonework" );
break;
case Qtopia::BusinessFax:
- value = entry.businessFax();
+ item.value = entry.businessFax();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/faxwork" );
break;
case Qtopia::BusinessMobile:
- value = entry.businessMobile();
+ item.value = entry.businessMobile();
+ if ( !item.value.isEmpty() )
+ item.icon = Resource::loadPixmap( "addressbook/mobilework" );
break;
case Qtopia::BusinessPager:
- value = entry.businessPager();
+ item.value = entry.businessPager();
break;
case Qtopia::Profession:
- value = entry.profession();
+ item.value = entry.profession();
break;
case Qtopia::Assistant:
- value = entry.assistant();
+ item.value = entry.assistant();
break;
case Qtopia::Manager:
- value = entry.manager();
+ item.value = entry.manager();
break;
case Qtopia::Spouse:
- value = entry.spouse();
+ item.value = entry.spouse();
break;
case Qtopia::Gender:
- value = entry.gender();
+ item.value = entry.gender();
break;
case Qtopia::Birthday:
- if ( ! entry.birthday().isNull() )
- value = TimeString::numberDateString( entry.birthday() );
+ if ( ! entry.birthday().isNull() ){
+ item.value = TimeString::numberDateString( entry.birthday() );
+ }
break;
case Qtopia::Anniversary:
- if ( ! entry.anniversary().isNull() )
- value = TimeString::numberDateString( entry.anniversary() );
+ if ( ! entry.anniversary().isNull() ){
+ item.value = TimeString::numberDateString( entry.anniversary() );
+ }
break;
case Qtopia::Nickname:
- value = entry.nickname();
+ item.value = entry.nickname();
break;
case Qtopia::Children:
- value = entry.children();
+ item.value = entry.children();
break;
case Qtopia::Notes:
- value = entry.notes();
+ item.value = entry.notes();
break;
}
- if ( !value.isEmpty() )
+ if ( !item.value.isEmpty() )
break;
}
- return value;
+ return item;
}
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 9825665..092e86f 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -1,137 +1,147 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
**
** 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 ABTABLE_H
#define ABTABLE_H
#include <qpe/categories.h>
#include <opie/ocontact.h>
#include <opie/ocontactaccess.h>
#include <qmap.h>
#include <qtable.h>
#include <qstringlist.h>
#include <qcombobox.h>
+#include <qpixmap.h>
class AbTableItem : public QTableItem
{
public:
AbTableItem( QTable *t, EditType et, const QString &s,
const QString &secondSortKey);
QString entryKey() const;
void setEntryKey( const QString & k );
virtual int alignment() const;
virtual QString key() const;
void setItem( const QString &txt, const QString &secondKey );
private:
QString sortKey;
};
+// This is a simple container, storing all contact
+// information
+class ContactItem
+{
+ public:
+ QPixmap icon;
+ QString value;
+};
+
class AbPickItem : public QTableItem
{
public:
AbPickItem( QTable *t );
QWidget *createEditor() const;
void setContentFromEditor( QWidget *w );
private:
QGuardedPtr<QComboBox> cb;
};
class AbTable : public QTable
{
Q_OBJECT
public:
AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 );
~AbTable();
// Set the contacts shown in the table
void setContacts( const OContactAccess::List& viewList );
// Selects a contact of a specific UID
bool selectContact( int UID );
// Get the current selected entry
OContact currentEntry();
// Get the UID of the current selected Entry
int currentEntry_UID();
QString findContactName( const OContact &entry );
void init();
void clear();
void refresh();
void show();
void setPaintingEnabled( bool e );
void viewportPaintEvent( QPaintEvent* e);
// addresspicker mode (What's that ? se)
void setChoiceNames( const QStringList& list);
QStringList choiceNames() const;
void setChoiceSelection( const QValueList<int>& list );
QStringList choiceSelection(int index) const;
signals:
void signalSwitch();
void signalEditor();
void signalKeyDown();
void signalKeyUp();
protected:
virtual void keyPressEvent( QKeyEvent *e );
// int rowHeight( int ) const;
// int rowPos( int row ) const;
// virtual int rowAt( int pos ) const;
protected slots:
void moveTo( char );
virtual void columnClicked( int col );
void itemClicked(int,int col);
void rowHeightChanged( int row );
private:
void insertIntoTable( const OContact &cnt, int row );
- QString findContactContact( const OContact &entry, int row );
+ ContactItem findContactContact( const OContact &entry, int row );
void fitColumns();
void resizeRows();
void realignTable();
void resort();
void updateVisible();
int lastSortCol;
bool asc;
QMap<AbTableItem*, OContact> contactList;
QValueList<int> intFields;
QStringList choicenames;
bool enablePainting;
bool columnVisible;
int countNested;
OContactAccess::List m_viewList;
};
#endif // ABTABLE_H
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index ad8315d..881b839 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,996 +1,997 @@
/**********************************************************************
** 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( true );
setRightJustification( true );
// Create Toolbar
listTools = new QPEToolBar( this, "list operations" );
listTools->setHorizontalStretchable( true );
addToolBar( listTools );
moveToolBar( listTools, m_config.getToolBarPos() );
QPEMenuBar *mbList = new QPEMenuBar( this );
mbList->setMargin( 0 );
QPopupMenu *edit = new QPopupMenu( mbList );
mbList->insertItem( tr( "Contact" ), edit );
// 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"), QString::null, 0, 0);
actionPersonal = a;
connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
a->addTo( edit );
edit->insertSeparator();
- a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
+ a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ),
+ QString::null, 0, this, 0 );
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( "today/config" ), QString::null,
+ a = new QAction( tr( "Config" ), Resource::loadPixmap( "addressbook/configure" ), 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 );
// Category Menu
catMenu = new QPopupMenu( this );
catMenu->setCheckable( TRUE );
connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
populateCategories();
mbList->insertItem( tr("View"), catMenu );
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::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 filename;
OContact c;
if ( actionPersonal->isOn() ) {
filename = addressbookPersonalVCardName();
if (!QFile::exists(filename))
return; // can't beam a non-existent file
OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
filename );
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;
filename = beamfile;
}
Ir *ir = new Ir( this );
connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
QString description = c.fullName();
ir->send( filename, 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 );
}
#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();
if ( !replEntry.isValidUid() )
replEntry.assignUid();
m_abView -> replaceEntry( replEntry );
}
}
// populateCategories();
}
void AddressbookWindow::editPersonal()
{
OContact entry;
// Switch to personal view if not selected
// but take care of the menu, too
if ( ! actionPersonal->isOn() ){
qWarning("*** ++++");
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()
{
qWarning("slotPersonalView()");
if (!actionPersonal->isOn()) {
// we just turned it off
qWarning("slotPersonalView()-> OFF");
setCaption( tr("Contacts") );
actionNew->setEnabled(TRUE);
actionTrash->setEnabled(TRUE);
actionFind->setEnabled(TRUE);
actionMail->setEnabled(TRUE);
// slotUpdateToolbar();
m_abView->showPersonal( false );
return;
}
qWarning("slotPersonalView()-> ON");
// XXX need to disable some QActions.
actionNew->setEnabled(FALSE);
actionTrash->setEnabled(FALSE);
actionFind->setEnabled(FALSE);
actionMail->setEnabled(FALSE);
setCaption( tr("Contacts - My Personal Details") );
m_abView->showPersonal( true );
}
void AddressbookWindow::listIsEmpty( bool empty )
{
if ( !empty ) {
deleteButton->setEnabled( TRUE );
}
}
void AddressbookWindow::reload()
{
syncing = FALSE;
m_abView->clear();
m_abView->reload();
}
void AddressbookWindow::flush()
{
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
*/
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;
else
return FALSE;
}
return TRUE;
}
#ifdef __DEBUG_RELEASE
void AddressbookWindow::slotSave()
{
save();
}
#endif
void AddressbookWindow::slotNotFound()
{
qWarning("Got notfound signal!");
QMessageBox::information( this, tr( "Not Found" ),
tr( "Unable to find a contact for this \n search pattern!" ) );
}
void AddressbookWindow::slotWrapAround()
{
qWarning("Got wrap signal!");
// if ( doNotifyWrapAround )
// QMessageBox::information( this, tr( "End of list" ),
// tr( "End of list. Wrap around now...!" ) + "\n" );
}
void AddressbookWindow::slotSetCategory( int c )
{
qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
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";
qWarning ("Unfiled selected!!!");
}else{
cat = m_abView->categories()[i - 4];
}
}
}
// Switch to the selected View
slotViewSwitched( view );
// 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 ) );
}
void AddressbookWindow::slotViewSwitched( int view )
{
qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
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 );
}
void AddressbookWindow::populateCategories()
{
catMenu->clear();
int id, rememberId;
id = 1;
rememberId = 0;
catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ );
catMenu->insertItem( Resource::loadPixmap( "day" ), 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/configdlg.cpp b/core/pim/addressbook/configdlg.cpp
index afba688..f5c0c5b 100644
--- a/core/pim/addressbook/configdlg.cpp
+++ b/core/pim/addressbook/configdlg.cpp
@@ -1,137 +1,148 @@
#include "configdlg.h"
#include "ocontactfields.h"
+
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qlistbox.h>
#include <qpushbutton.h>
+#include <qiconset.h>
+
+#include <qpe/resource.h>
#include <opie/ocontact.h>
ConfigDlg::ConfigDlg( QWidget *parent, const char *name):
ConfigDlg_Base(parent, name, true )
{
contFields = OContactFields::trfields();
// We add all Fields into the Listbox
for (uint i=0; i < contFields.count(); i++) {
allFieldListBox->insertItem( contFields[i] );
}
+ // Set Pics to Buttons and Tabs
+ m_upButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/up" ) ) );
+ m_downButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/down" ) ) );
+ m_addButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/add" ) ) );
+ m_removeButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/sub" ) ) );
+
+
// Get the translation maps between Field ID and translated strings
m_mapStrToID = OContactFields::trFieldsToId();
m_mapIDToStr = OContactFields::idToTrFields();
connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) );
connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) );
connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) );
connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) );
}
void ConfigDlg::slotItemUp()
{
qWarning( "void ConfigDlg::slotItemUp()" );
int i = fieldListBox->currentItem();
if ( i > 0 ) {
QString item = fieldListBox->currentText();
fieldListBox->removeItem( i );
fieldListBox->insertItem( item, i-1 );
fieldListBox->setCurrentItem( i-1 );
}
}
void ConfigDlg::slotItemDown()
{
qWarning( "void ConfigDlg::slotItemDown()" );
int i = fieldListBox->currentItem();
if ( i < (int)fieldListBox->count() - 1 ) {
QString item = fieldListBox->currentText();
fieldListBox->removeItem( i );
fieldListBox->insertItem( item, i+1 );
fieldListBox->setCurrentItem( i+1 );
}
}
void ConfigDlg::slotItemAdd()
{
qWarning( "void ConfigDlg::slotItemAdd()" );
int i = allFieldListBox->currentItem();
if ( i > 0 ) {
QString item = allFieldListBox->currentText();
qWarning("ADding %s", item.latin1());
fieldListBox->insertItem( item );
}
}
void ConfigDlg::slotItemRemove()
{
qWarning( "void ConfigDlg::slotItemRemove()" );
int i = fieldListBox->currentItem();
if ( i > 0 ) {
fieldListBox->removeItem( i );
}
}
void ConfigDlg::setConfig( const AbConfig& cnf )
{
m_config = cnf;
m_useRegExp->setChecked( m_config.useRegExp() );
m_useWildCard->setChecked( m_config.useWildCards() );
m_useQtMail->setChecked( m_config.useQtMail() );
m_useOpieMail->setChecked( m_config.useOpieMail() );
m_useCaseSensitive->setChecked( m_config.beCaseSensitive() );
switch( m_config.fontSize() ){
case 0:
m_smallFont->setChecked( true );
m_normalFont->setChecked( false );
m_largeFont->setChecked( false );
break;
case 1:
m_smallFont->setChecked( false );
m_normalFont->setChecked( true );
m_largeFont->setChecked( false );
break;
case 2:
m_smallFont->setChecked( false );
m_normalFont->setChecked( false );
m_largeFont->setChecked( true );
break;
}
for( uint i = 0; i < m_config.orderList().count(); i++ ) {
fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] );
}
}
AbConfig ConfigDlg::getConfig()
{
m_config.setUseRegExp( m_useRegExp->isOn() );
m_config.setUseWildCards( m_useWildCard->isOn() );
m_config.setUseQtMail( m_useQtMail->isOn() );
m_config.setUseOpieMail( m_useOpieMail->isOn() );
m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() );
if ( m_smallFont->isChecked() )
m_config.setFontSize( 0 );
if ( m_normalFont->isChecked() )
m_config.setFontSize( 1 );
if ( m_largeFont->isChecked() )
m_config.setFontSize( 2 );
QValueList<int> orderlist;
for( int i = 0; i < (int)fieldListBox->count(); i++ ) {
orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] );
}
m_config.setOrderList( orderlist );
return m_config;
}
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 9efb8c0..97573af 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,1578 +1,1577 @@
/*
* 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 "addresspicker.h"
#include "ocontactfields.h"
#include <qpe/categoryselect.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpedialog.h>
#include <qpe/timeconversion.h>
#include <opie/ocontact.h>
#include <qpe/resource.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qtabwidget.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qscrollview.h>
#include <qtoolbutton.h>
#include <qpushbutton.h>
#include <qmainwindow.h>
#include <qvaluelist.h>
#include <qpopupmenu.h>
#include <qlistbox.h>
#include <qhbox.h>
#include <qaction.h>
#include <qiconset.h>
#include <qmessagebox.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 OContact &entry,
QWidget *parent,
const char *name,
WFlags fl )
: QDialog( parent, name, TRUE, fl ),
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() {
qWarning("init() START");
useFullName = true;
uint i = 0;
QStringList trlChooserNames;
for (i = 0; i <= 6; i++) {
slHomeAddress.append( "" );
slBusinessAddress.append( "" );
}
trlChooserNames = OContactFields::trphonefields( false );
slChooserNames = OContactFields::untrphonefields( false );
slDynamicEntries = OContactFields::untrdetailsfields( false );
trlDynamicEntries = OContactFields::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 = OContactFields::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 );
vb->addWidget( tabMain );
QWidget *tabViewport = new QWidget ( tabMain );
vb = new QVBoxLayout( tabViewport );
svGeneral = new QScrollView( tabViewport );
vb->addWidget( svGeneral, 0, 0 );
svGeneral->setResizePolicy( QScrollView::AutoOneFit );
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 );
btnFullName = new QPushButton( tr( "Full Name..." ), container );
gl->addWidget( btnFullName, 0, 0 );
txtFullName = new QLineEdit( container );
gl->addWidget( txtFullName, 0, 1 );
QLabel *l = new QLabel( tr( "Job Title" ), container );
gl->addWidget( l, 1, 0 );
txtJobTitle = new QLineEdit( container );
gl->addWidget( txtJobTitle, 1, 1 );
l = new QLabel( tr( "Organization" ), container );
gl->addWidget( l, 2, 0 );
txtOrganization = new QLineEdit( container );
gl->addWidget( txtOrganization, 2, 1 );
cmbChooserField1 = new QComboBox( FALSE, container );
cmbChooserField1->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField1, 3, 0 );
txtChooserField1 = new QLineEdit( container );
gl->addWidget( txtChooserField1, 3, 1 );
cmbChooserField2 = new QComboBox( FALSE, container );
cmbChooserField2->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField2, 4, 0 );
txtChooserField2 = new QLineEdit( container );
gl->addWidget( txtChooserField2, 4, 1 );
cmbChooserField3 = new QComboBox( FALSE, container );
cmbChooserField3->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField3, 5, 0 );
txtChooserField3 = new QLineEdit( container );
gl->addWidget( txtChooserField3, 5, 1 );
l = new QLabel( tr( "File As" ), container );
gl->addWidget( l, 6, 0 );
cmbFileAs = new QComboBox( TRUE, container );
gl->addWidget( cmbFileAs, 6, 1 );
labCat = new QLabel( tr( "Category" ), container );
gl->addWidget( labCat, 7, 0 );
cmbCat = new CategorySelect( container );
gl->addWidget( cmbCat, 7, 1 );
labCat->show();
cmbCat->show();
btnNote = new QPushButton( tr( "Notes..." ), container );
gl->addWidget( btnNote, 8, 1 );
tabMain->insertTab( tabViewport, tr( "General" ) );
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->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->insertItem( tr( "" ) );
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" ) );
cmbCountry->insertItem( tr ( "Ireland" ) );
cmbCountry->insertItem( tr ( "Israel" ) );
cmbCountry->insertItem( tr ( "Italy" ) );
cmbCountry->insertItem( tr ( "Jamaica" ) );
cmbCountry->insertItem( tr ( "Japan" ) );
cmbCountry->insertItem( tr ( "Jordan" ) );
cmbCountry->insertItem( tr ( "Kazakhstan" ) );
cmbCountry->insertItem( tr ( "Kenya" ) );
cmbCountry->insertItem( tr ( "Kiribati" ) );
cmbCountry->insertItem( tr ( "Korea" ) );
cmbCountry->insertItem( tr ( "Kuwait" ) );
cmbCountry->insertItem( tr ( "Kyrgyzstan" ) );
cmbCountry->insertItem( tr ( "Laos" ) );
cmbCountry->insertItem( tr ( "Latvia" ) );
cmbCountry->insertItem( tr ( "Lebanon" ) );
cmbCountry->insertItem( tr ( "Lesotho" ) );
cmbCountry->insertItem( tr ( "Liberia" ) );
cmbCountry->insertItem( tr ( "Liechtenstein" ) );
cmbCountry->insertItem( tr ( "Lithuania" ) );
cmbCountry->insertItem( tr ( "Luxembourg" ) );
cmbCountry->insertItem( tr ( "Macau" ) );
cmbCountry->insertItem( tr ( "Macedonia" ) );
cmbCountry->insertItem( tr ( "Madagascar" ) );
cmbCountry->insertItem( tr ( "Malawi" ) );
cmbCountry->insertItem( tr ( "Malaysia" ) );
cmbCountry->insertItem( tr ( "Maldives" ) );
cmbCountry->insertItem( tr ( "Mali" ) );
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 );
cmbChooserField4 = new QComboBox( FALSE, container );
cmbChooserField4->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField4, 6, 0 );
txtChooserField4 = new QLineEdit( container );
gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 );
QSpacerItem *space = new QSpacerItem(1,1,
QSizePolicy::Maximum,
QSizePolicy::MinimumExpanding );
gl->addItem( space, 7, 0 );
tabMain->insertTab( tabViewport, 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 );
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 );
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();
- QStringList::ConstIterator trit = trlDynamicEntries.begin();
QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId();
QMap<int, QString> mapIdToStr = OContactFields::idToTrFields();
- for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) {
+ for (i = counter; it != slDynamicEntries.end(); i++, ++it ) {
if (((*it) == "Anniversary") ||
((*it) == "Birthday")|| ((*it) == "Gender")) continue;
l = new QLabel( mapIdToStr[mapStrToID[*it]].utf8() , 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" ) );
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->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 QLineEdit( dlgName );
gl->addWidget( txtFirstName, 0, 1 );
l = new QLabel( tr("Middle Name"), dlgName );
gl->addWidget( l, 1, 0 );
txtMiddleName = new QLineEdit( dlgName );
gl->addWidget( txtMiddleName, 1, 1 );
l = new QLabel( tr("Last Name"), dlgName );
gl->addWidget( l, 2, 0 );
txtLastName = new QLineEdit( 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( 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 );
qWarning("init() END");
}
void ContactEditor::defaultEmailChanged(int i){
qDebug("defaultEmailChanged");
// was sollte das ? (se)
// int index = cmbChooserField1->currentItem();
// slChooserValues[index] = cmbDefaultEmail->text(i);
defaultEmail = cmbDefaultEmail->text(i);
qDebug ("Changed to: %s", defaultEmail.latin1());
}
void ContactEditor::populateDefaultEmailCmb(){
// if the default-email combo was not selected and therfore not created
// we get a lot of trouble.. Therfore create an invisible one..
if ( !cmbDefaultEmail ){
cmbDefaultEmail = new QComboBox(this);
cmbDefaultEmail -> hide();
}
cmbDefaultEmail->clear();
cmbDefaultEmail->insertStringList( emails );
// cmbDefaultEmail->show();
// Select default email in combo..
bool found = false;
for ( int i = 0; i < cmbDefaultEmail->count(); i++){
qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",
cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1());
if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
cmbDefaultEmail->setCurrentItem( i );
qDebug("set");
found = true;
}
}
// If the current default email is not found in the list, we choose the
// first one..
if ( !found )
defaultEmail = cmbDefaultEmail->text(0);
}
// Called when any combobox was changed.
// "true" returned if the change was chandled by this function, else it should
// be handled by something else..
bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) {
QString type = slChooserNames[index];
qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos );
if ( !initializing )
contactfields.setFieldOrder( widgetPos-1, index );
// Create and connect combobox for selecting the default email
if ( type == "Default Email"){
qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition);
// More than one defaul-email chooser is not allowed !
if ( ( defaultEmailChooserPosition != -1 ) &&
defaultEmailChooserPosition != widgetPos && !initializing){
chooserError( widgetPos );
return true;
}
if ( cmbDefaultEmail ){
delete cmbDefaultEmail;
cmbDefaultEmail = 0l;
}
cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); /* :SX */
QRect rect = inputWid->frameGeometry();
qWarning("Geometrie: X=%d, Y=%d, Left=%d, Top=%d, Right=%d, Bottom=%d",
rect.x(), rect.y(), rect.left(), rect.top(), rect.right(), rect.bottom());
QPoint pnt = inputWid->pos();
qWarning("Position : X=%d, Y=%d", pnt.x(), pnt.y() );
connect( cmbDefaultEmail,SIGNAL( activated(int) ),
SLOT( defaultEmailChanged(int) ) );
cmbDefaultEmail->clear();
cmbDefaultEmail->insertStringList( emails );
cmbDefaultEmail->show();
defaultEmailChooserPosition = widgetPos;
// Set current default email
populateDefaultEmailCmb();
} else {
// Something else was selected: Hide combo..
qWarning(" Hiding default-email combo" );
if ( defaultEmailChooserPosition == widgetPos ){
defaultEmailChooserPosition = -1;
if ( cmbDefaultEmail )
cmbDefaultEmail->hide();
}
// Caller should initialize the responsible textfield, therefore
// "false" is returned
return false;
}
// Everything is worked off ..
return true;
}
// Currently accessed when we select default-email more than once !
void ContactEditor::chooserError( int index )
{
qWarning("ContactEditor::chooserError( %d )", index);
QMessageBox::warning( this, "Chooser Error",
"Multiple selection of this\n"
"Item is not allowed !\n\n"
"First deselect the previous one !",
"&OK", 0, 0,
0, 0 );
// Reset the selected Chooser. Unfortunately the chooser
// generates no signal, therfore we have to
// call the cmbChooserChange function manually..
switch( index ){
case 1:
cmbChooserField1 -> setCurrentItem( 0 );
slotCmbChooser1Change( 0 );
break;
case 2:
cmbChooserField2 -> setCurrentItem( 0 );
slotCmbChooser2Change( 0 );
break;
case 3:
cmbChooserField3 -> setCurrentItem( 0 );
slotCmbChooser3Change( 0 );
break;
case 4:
cmbChooserField4 -> setCurrentItem( 0 );
slotCmbChooser4Change( 0 );
break;
}
}
// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
void ContactEditor::chooserChange( const QString &textChanged, int index,
QLineEdit* , int widgetPos ) {
QString type = slChooserNames[index];
qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",
type.latin1(),textChanged.latin1(), index, widgetPos );
if ( type == "Default Email"){
qWarning ("??? Wozu??: %s", textChanged.latin1());
defaultEmail = textChanged;
populateDefaultEmailCmb();
}else if (defaultEmailChooserPosition == widgetPos){
qDebug("cmbDefaultEmail->hide()");
if (cmbDefaultEmail) cmbDefaultEmail->hide();
widgetPos=-1;
}else if (type == "Emails"){
qDebug("emails");
QString de;
emails = QStringList::split (",", textChanged );
populateDefaultEmailCmb();
}
slChooserValues[index] = textChanged;
}
void ContactEditor::slotChooser1Change( const QString &textChanged ) {
qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1());
chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
}
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(), txtChooserField1, 1) ){
txtChooserField1->setText( slChooserValues[index] );
txtChooserField1->setFocus();
}
}
void ContactEditor::slotCmbChooser2Change( int index ) {
qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
if ( !cmbChooserChange( cmbChooserField2->currentItem(), txtChooserField2, 2) ){
txtChooserField2->setText( slChooserValues[index] );
txtChooserField2->setFocus();
}
}
void ContactEditor::slotCmbChooser3Change( int index ) {
qWarning("ContactEditor::slotCmbChooser3Change( %d )", index);
if ( !cmbChooserChange( cmbChooserField3->currentItem(), txtChooserField3, 3) ){
txtChooserField3->setText( slChooserValues[index] );
txtChooserField3->setFocus();
}
}
void ContactEditor::slotCmbChooser4Change( int index ) {
qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
if ( !cmbChooserChange( cmbChooserField4->currentItem(), txtChooserField4, 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 ) {
int index = cmbFileAs->currentItem();
cmbFileAs->clear();
cmbFileAs->insertItem( parseName( textChanged, 0 ) );
cmbFileAs->insertItem( parseName( textChanged, 1 ) );
cmbFileAs->insertItem( parseName( textChanged, 2 ) );
cmbFileAs->insertItem( parseName( textChanged, 3 ) );
cmbFileAs->setCurrentItem( index );
useFullName = true;
}
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;
if (useFullName) {
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() ) {
tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text();
txtFullName->setText( tmpName.simplifyWhiteSpace() );
slotFullNameChange( txtFullName->text() );
useFullName = false;
}
}
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 strSuffix;
QString strTitle;
int commapos;
int spCount;
int spPos;
int spPos2;
commapos = simplifiedName.find( ',', 0, TRUE);
spCount = simplifiedName.contains( ' ', TRUE );
if ( commapos == -1 ) {
switch (spCount) {
case 0:
//return simplifiedName;
if (txtLastName->text() != "") {
strLastName = simplifiedName;
break;
}
if (txtMiddleName->text() != "") {
strMiddleName = simplifiedName;
break;
}
if (txtSuffix->text() != "") {
strSuffix = simplifiedName;
break;
}
strFirstName = simplifiedName;
break;
case 1:
spPos = simplifiedName.find( ' ', 0, TRUE );
strFirstName = simplifiedName.left( spPos );
strLastName = simplifiedName.mid( spPos + 1 );
break;
case 2:
spPos = simplifiedName.find( ' ', 0, TRUE );
strFirstName = simplifiedName.left( spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
strLastName = simplifiedName.mid( spPos2 + 1 );
break;
case 3:
spPos = simplifiedName.find( ' ', 0, TRUE );
strFirstName = simplifiedName.left( spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
strSuffix = simplifiedName.mid( spPos + 1 );
break;
case 4:
spPos = simplifiedName.find( ' ', 0, TRUE );
strTitle = simplifiedName.left( spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
strSuffix = simplifiedName.mid( spPos2 + 1 );
break;
default:
spPos = simplifiedName.find( ' ', 0, TRUE );
strTitle = simplifiedName.left( spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
strSuffix = simplifiedName.mid( spPos2 + 1 );
break;
}
} else {
simplifiedName.replace( commapos, 1, " " );
simplifiedName = simplifiedName.simplifyWhiteSpace();
switch (spCount) {
case 0:
//return simplifiedName;
if (txtLastName->text() != "") {
strLastName = simplifiedName;
break;
}
if (txtMiddleName->text() != "") {
strMiddleName = simplifiedName;
break;
}
if (txtSuffix->text() != "") {
strSuffix = simplifiedName;
break;
}
strFirstName = simplifiedName;
break;
case 1:
spPos = simplifiedName.find( ' ', 0, TRUE );
strLastName = simplifiedName.left( spPos );
strFirstName = simplifiedName.mid( spPos + 1 );
break;
case 2:
spPos = simplifiedName.find( ' ', 0, TRUE );
strLastName = simplifiedName.left( spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
strMiddleName = simplifiedName.mid( spPos2 + 1 );
break;
case 3:
spPos = simplifiedName.find( ' ', 0, TRUE );
strLastName = simplifiedName.left( spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
strSuffix = simplifiedName.mid( spPos + 1 );
break;
case 4:
spPos = simplifiedName.find( ' ', 0, TRUE );
strLastName = simplifiedName.left( spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
strSuffix = simplifiedName.mid( spPos2 + 1 );
break;
default:
spPos = simplifiedName.find( ' ', 0, TRUE );
strLastName = simplifiedName.left( spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos );
spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
strSuffix = simplifiedName.mid( spPos2 + 1 );
break;
}
}
switch (type) {
case NAME_FL:
return strFirstName + " " + strLastName;
case NAME_LF:
return strLastName + ", " + strFirstName;
case NAME_LFM:
return strLastName + ", " + strFirstName + " " + strMiddleName;
case NAME_FMLS:
return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix;
case NAME_F:
return strFirstName;
case NAME_M:
return strMiddleName;
case NAME_L:
return strLastName;
case NAME_S:
return strSuffix;
}
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;
cleanupFields();
ent = entry;
emails = QStringList(ent.emailList());
defaultEmail = ent.defaultEmail();
if (defaultEmail.isEmpty()) defaultEmail = emails[0];
qDebug("default email=%s",defaultEmail.latin1());
useFullName = false;
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() );
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() );
// Calling "show()" to arrange all widgets. Otherwise we will get
// a wrong position of the textfields and are unable to put our
// default-email combo over it.. This is very ugly !
// Does anybody has a better solution ?
// Basically we should rethink the strategy to hide
// a textfield with overwriting.. (se)
show();
// Get combo-settings from contact and set preset..
contactfields.loadFromRecord( ent );
cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 0) );
cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 1) );
cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 2) );
cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 5) );
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 );
if ( useFullName ) {
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 ) );
useFullName = false;
}
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] );
// }
diff --git a/core/pim/addressbook/ocontactfields.cpp b/core/pim/addressbook/ocontactfields.cpp
index 18b68c4..ffb88e8 100644
--- a/core/pim/addressbook/ocontactfields.cpp
+++ b/core/pim/addressbook/ocontactfields.cpp
@@ -1,454 +1,456 @@
#include "ocontactfields.h"
#include <qstringlist.h>
#include <qobject.h>
// We should use our own enum in the future ..
#include <qpe/recordfields.h>
#include <qpe/config.h>
#include <opie/ocontact.h>
/*!
\internal
Returns a list of details field names for a contact.
*/
QStringList OContactFields::untrdetailsfields( bool sorted )
{
QStringList list;
QMap<int, QString> mapIdToStr = idToUntrFields();
list.append( mapIdToStr[ Qtopia::Office ] );
list.append( mapIdToStr[ Qtopia::Profession ] );
list.append( mapIdToStr[ Qtopia::Assistant ] );
list.append( mapIdToStr[ Qtopia::Manager ] );
list.append( mapIdToStr[ Qtopia::Spouse ] );
list.append( mapIdToStr[ Qtopia::Gender ] );
list.append( mapIdToStr[ Qtopia::Birthday ] );
list.append( mapIdToStr[ Qtopia::Anniversary ] );
list.append( mapIdToStr[ Qtopia::Nickname ] );
list.append( mapIdToStr[ Qtopia::Children ] );
if (sorted) list.sort();
return list;
}
/*!
\internal
Returns a translated list of details field names for a contact.
*/
QStringList OContactFields::trdetailsfields( bool sorted )
{
QStringList list;
QMap<int, QString> mapIdToStr = idToTrFields();
list.append( mapIdToStr[Qtopia::Office] );
list.append( mapIdToStr[Qtopia::Profession] );
list.append( mapIdToStr[Qtopia::Assistant] );
list.append( mapIdToStr[Qtopia::Manager] );
list.append( mapIdToStr[Qtopia::Spouse] );
list.append( mapIdToStr[Qtopia::Gender] );
list.append( mapIdToStr[Qtopia::Birthday] );
list.append( mapIdToStr[Qtopia::Anniversary] );
list.append( mapIdToStr[Qtopia::Nickname] );
list.append( mapIdToStr[Qtopia::Children] );
if (sorted) list.sort();
return list;
}
/*!
\internal
Returns a translated list of phone field names for a contact.
*/
QStringList OContactFields::trphonefields( bool sorted )
{
QStringList list;
QMap<int, QString> mapIdToStr = idToTrFields();
list.append( mapIdToStr[Qtopia::BusinessPhone] );
list.append( mapIdToStr[Qtopia::BusinessFax] );
list.append( mapIdToStr[Qtopia::BusinessMobile] );
+ list.append( mapIdToStr[Qtopia::BusinessPager] );
+ list.append( mapIdToStr[Qtopia::BusinessWebPage] );
list.append( mapIdToStr[Qtopia::DefaultEmail] );
list.append( mapIdToStr[Qtopia::Emails] );
list.append( mapIdToStr[Qtopia::HomePhone] );
list.append( mapIdToStr[Qtopia::HomeFax] );
list.append( mapIdToStr[Qtopia::HomeMobile] );
+ // list.append( mapIdToStr[Qtopia::HomePager] );
+ list.append( mapIdToStr[Qtopia::HomeWebPage] );
if (sorted) list.sort();
return list;
}
/*!
\internal
Returns a list of phone field names for a contact.
*/
QStringList OContactFields::untrphonefields( bool sorted )
{
QStringList list;
QMap<int, QString> mapIdToStr = idToUntrFields();
list.append( mapIdToStr[ Qtopia::BusinessPhone ] );
list.append( mapIdToStr[ Qtopia::BusinessFax ] );
list.append( mapIdToStr[ Qtopia::BusinessMobile ] );
+ list.append( mapIdToStr[ Qtopia::BusinessPager ] );
+ list.append( mapIdToStr[ Qtopia::BusinessWebPage ] );
list.append( mapIdToStr[ Qtopia::DefaultEmail ] );
list.append( mapIdToStr[ Qtopia::Emails ] );
list.append( mapIdToStr[ Qtopia::HomePhone ] );
list.append( mapIdToStr[ Qtopia::HomeFax ] );
list.append( mapIdToStr[ Qtopia::HomeMobile ] );
+ //list.append( mapIdToStr[Qtopia::HomePager] );
+ list.append( mapIdToStr[Qtopia::HomeWebPage] );
if (sorted) list.sort();
return list;
}
/*!
\internal
Returns a translated list of field names for a contact.
*/
QStringList OContactFields::trfields( bool sorted )
{
QStringList list;
QMap<int, QString> mapIdToStr = idToTrFields();
list.append( mapIdToStr[Qtopia::Title]);
list.append( mapIdToStr[Qtopia::FirstName] );
list.append( mapIdToStr[Qtopia::MiddleName] );
list.append( mapIdToStr[Qtopia::LastName] );
list.append( mapIdToStr[Qtopia::Suffix] );
list.append( mapIdToStr[Qtopia::FileAs] );
list.append( mapIdToStr[Qtopia::JobTitle] );
list.append( mapIdToStr[Qtopia::Department] );
list.append( mapIdToStr[Qtopia::Company] );
list += trphonefields( sorted );
list.append( mapIdToStr[Qtopia::BusinessStreet] );
list.append( mapIdToStr[Qtopia::BusinessCity] );
list.append( mapIdToStr[Qtopia::BusinessState] );
list.append( mapIdToStr[Qtopia::BusinessZip] );
list.append( mapIdToStr[Qtopia::BusinessCountry] );
- list.append( mapIdToStr[Qtopia::BusinessPager] );
- list.append( mapIdToStr[Qtopia::BusinessWebPage] );
list.append( mapIdToStr[Qtopia::HomeStreet] );
list.append( mapIdToStr[Qtopia::HomeCity] );
list.append( mapIdToStr[Qtopia::HomeState] );
list.append( mapIdToStr[Qtopia::HomeZip] );
list.append( mapIdToStr[Qtopia::HomeCountry] );
- list.append( mapIdToStr[Qtopia::HomeWebPage] );
list += trdetailsfields( sorted );
list.append( mapIdToStr[Qtopia::Notes] );
list.append( mapIdToStr[Qtopia::Groups] );
if (sorted) list.sort();
return list;
}
/*!
\internal
Returns an untranslated list of field names for a contact.
*/
QStringList OContactFields::untrfields( bool sorted )
{
QStringList list;
QMap<int, QString> mapIdToStr = idToUntrFields();
list.append( mapIdToStr[ Qtopia::Title ] );
list.append( mapIdToStr[ Qtopia::FirstName ] );
list.append( mapIdToStr[ Qtopia::MiddleName ] );
list.append( mapIdToStr[ Qtopia::LastName ] );
list.append( mapIdToStr[ Qtopia::Suffix ] );
list.append( mapIdToStr[ Qtopia::FileAs ] );
list.append( mapIdToStr[ Qtopia::JobTitle ] );
list.append( mapIdToStr[ Qtopia::Department ] );
list.append( mapIdToStr[ Qtopia::Company ] );
list += untrphonefields( sorted );
list.append( mapIdToStr[ Qtopia::BusinessStreet ] );
list.append( mapIdToStr[ Qtopia::BusinessCity ] );
list.append( mapIdToStr[ Qtopia::BusinessState ] );
list.append( mapIdToStr[ Qtopia::BusinessZip ] );
list.append( mapIdToStr[ Qtopia::BusinessCountry ] );
- list.append( mapIdToStr[ Qtopia::BusinessPager ] );
- list.append( mapIdToStr[ Qtopia::BusinessWebPage ] );
list.append( mapIdToStr[ Qtopia::HomeStreet ] );
list.append( mapIdToStr[ Qtopia::HomeCity ] );
list.append( mapIdToStr[ Qtopia::HomeState ] );
list.append( mapIdToStr[ Qtopia::HomeZip ] );
list.append( mapIdToStr[ Qtopia::HomeCountry ] );
- list.append( mapIdToStr[ Qtopia::HomeWebPage] );
list += untrdetailsfields( sorted );
list.append( mapIdToStr[ Qtopia::Notes ] );
list.append( mapIdToStr[ Qtopia::Groups ] );
if (sorted) list.sort();
return list;
}
QMap<int, QString> OContactFields::idToTrFields()
{
QMap<int, QString> ret_map;
ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") );
ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ));
ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) );
ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) );
ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) );
ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) );
ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) );
ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) );
ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ));
// email
ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) );
ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) );
ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) );
ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) );
ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) );
// business
ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) );
ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) );
ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) );
ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) );
ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) );
ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) );
ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) );
ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) );
ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) );
ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) );
ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) );
// home
ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) );
ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) );
ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) );
ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) );
ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) );
ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) );
//personal
ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) );
ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) );
ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) );
ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) );
ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) );
ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) );
// other
ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) );
return ret_map;
}
QMap<int, QString> OContactFields::idToUntrFields()
{
QMap<int, QString> ret_map;
ret_map.insert( Qtopia::Title, "Name Title" );
ret_map.insert( Qtopia::FirstName, "First Name" );
ret_map.insert( Qtopia::MiddleName, "Middle Name" );
ret_map.insert( Qtopia::LastName, "Last Name" );
ret_map.insert( Qtopia::Suffix, "Suffix" );
ret_map.insert( Qtopia::FileAs, "File As" );
ret_map.insert( Qtopia::JobTitle, "Job Title" );
ret_map.insert( Qtopia::Department, "Department" );
ret_map.insert( Qtopia::Company, "Company" );
ret_map.insert( Qtopia::BusinessPhone, "Business Phone" );
ret_map.insert( Qtopia::BusinessFax, "Business Fax" );
ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" );
// email
ret_map.insert( Qtopia::DefaultEmail, "Default Email" );
ret_map.insert( Qtopia::Emails, "Emails" );
ret_map.insert( Qtopia::HomePhone, "Home Phone" );
ret_map.insert( Qtopia::HomeFax, "Home Fax" );
ret_map.insert( Qtopia::HomeMobile, "Home Mobile" );
// business
ret_map.insert( Qtopia::BusinessStreet, "Business Street" );
ret_map.insert( Qtopia::BusinessCity, "Business City" );
ret_map.insert( Qtopia::BusinessState, "Business State" );
ret_map.insert( Qtopia::BusinessZip, "Business Zip" );
ret_map.insert( Qtopia::BusinessCountry, "Business Country" );
ret_map.insert( Qtopia::BusinessPager, "Business Pager" );
ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" );
ret_map.insert( Qtopia::Office, "Office" );
ret_map.insert( Qtopia::Profession, "Profession" );
ret_map.insert( Qtopia::Assistant, "Assistant" );
ret_map.insert( Qtopia::Manager, "Manager" );
// home
ret_map.insert( Qtopia::HomeStreet, "Home Street" );
ret_map.insert( Qtopia::HomeCity, "Home City" );
ret_map.insert( Qtopia::HomeState, "Home State" );
ret_map.insert( Qtopia::HomeZip, "Home Zip" );
ret_map.insert( Qtopia::HomeCountry, "Home Country" );
ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" );
//personal
ret_map.insert( Qtopia::Spouse, "Spouse" );
ret_map.insert( Qtopia::Gender, "Gender" );
ret_map.insert( Qtopia::Birthday, "Birthday" );
ret_map.insert( Qtopia::Anniversary, "Anniversary" );
ret_map.insert( Qtopia::Nickname, "Nickname" );
ret_map.insert( Qtopia::Children, "Children" );
// other
ret_map.insert( Qtopia::Notes, "Notes" );
return ret_map;
}
QMap<QString, int> OContactFields::trFieldsToId()
{
QMap<int, QString> idtostr = idToTrFields();
QMap<QString, int> ret_map;
QMap<int, QString>::Iterator it;
for( it = idtostr.begin(); it != idtostr.end(); ++it )
ret_map.insert( *it, it.key() );
return ret_map;
}
QMap<QString, int> OContactFields::untrFieldsToId()
{
QMap<int, QString> idtostr = idToUntrFields();
QMap<QString, int> ret_map;
QMap<int, QString>::Iterator it;
for( it = idtostr.begin(); it != idtostr.end(); ++it )
ret_map.insert( *it, it.key() );
return ret_map;
}
OContactFields::OContactFields():
fieldOrder( DEFAULT_FIELD_ORDER ),
changedFieldOrder( false )
{
// Get the global field order from the config file and
// use it as a start pattern
Config cfg ( "AddressBook" );
cfg.setGroup( "ContactFieldOrder" );
globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER );
}
OContactFields::~OContactFields(){
// We will store the fieldorder into the config file
// to reuse it for the future..
if ( changedFieldOrder ){
Config cfg ( "AddressBook" );
cfg.setGroup( "ContactFieldOrder" );
cfg.writeEntry( "General", globalFieldOrder );
}
}
void OContactFields::saveToRecord( OContact &cnt ){
qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1());
// Store fieldorder into this contact.
cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder );
globalFieldOrder = fieldOrder;
changedFieldOrder = true;
}
void OContactFields::loadFromRecord( const OContact &cnt ){
qDebug("ocontactfields loadFromRecord");
qDebug("loading >%s<",cnt.fullName().latin1());
// Get fieldorder for this contact. If none is defined,
// we will use the global one from the config file..
fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME );
qDebug("fieldOrder from contact>%s<",fieldOrder.latin1());
if (fieldOrder.isEmpty()){
fieldOrder = globalFieldOrder;
}
qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1());
}
void OContactFields::setFieldOrder( int num, int index ){
qDebug("qcontactfields setfieldorder pos %i -> %i",num,index);
fieldOrder[num] = QString::number( index )[0];
// We will store this new fieldorder globally to
// remember it for contacts which have none
globalFieldOrder = fieldOrder;
changedFieldOrder = true;
qDebug("fieldOrder >%s<",fieldOrder.latin1());
}
int OContactFields::getFieldOrder( int num, int defIndex ){
qDebug("ocontactfields getFieldOrder");
qDebug("fieldOrder >%s<",fieldOrder.latin1());
// Get index of combo as char..
QChar poschar = fieldOrder[num];
bool ok;
int ret = 0;
// Convert char to number..
if ( !( poschar == QChar::null ) )
ret = QString( poschar ).toInt(&ok, 10);
else
ok = false;
// Return default value if index for
// num was not set or if anything else happened..
if ( !ok ) ret = defIndex;
qDebug("returning >%i<",ret);
return ret;
}