summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp4
-rw-r--r--core/pim/addressbook/ocontactfields.cpp257
-rw-r--r--core/pim/addressbook/ocontactfields.h2
3 files changed, 176 insertions, 87 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index d830ad3..9efb8c0 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -456,198 +456,200 @@ void ContactEditor::init() {
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) {
if (((*it) == "Anniversary") ||
((*it) == "Birthday")|| ((*it) == "Gender")) continue;
- l = new QLabel( (*it).utf8() , container );
+ 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");
diff --git a/core/pim/addressbook/ocontactfields.cpp b/core/pim/addressbook/ocontactfields.cpp
index 75a7641..18b68c4 100644
--- a/core/pim/addressbook/ocontactfields.cpp
+++ b/core/pim/addressbook/ocontactfields.cpp
@@ -1,369 +1,454 @@
#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( "Office" );
- list.append( "Profession" );
- list.append( "Assistant" );
- list.append( "Manager" );
+ list.append( mapIdToStr[ Qtopia::Office ] );
+ list.append( mapIdToStr[ Qtopia::Profession ] );
+ list.append( mapIdToStr[ Qtopia::Assistant ] );
+ list.append( mapIdToStr[ Qtopia::Manager ] );
- list.append( "Spouse" );
- list.append( "Gender" );
- list.append( "Birthday" );
- list.append( "Anniversary" );
- list.append( "Nickname" );
- list.append( "Children" );
+ 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( QObject::tr( "Office" ) );
- list.append( QObject::tr( "Profession" ) );
- list.append( QObject::tr( "Assistant" ) );
- list.append( QObject::tr( "Manager" ) );
+ list.append( mapIdToStr[Qtopia::Office] );
+ list.append( mapIdToStr[Qtopia::Profession] );
+ list.append( mapIdToStr[Qtopia::Assistant] );
+ list.append( mapIdToStr[Qtopia::Manager] );
- list.append( QObject::tr( "Spouse" ) );
- list.append( QObject::tr( "Gender" ) );
- list.append( QObject::tr( "Birthday" ) );
- list.append( QObject::tr( "Anniversary" ) );
- list.append( QObject::tr( "Nickname" ) );
- list.append( QObject::tr( "Children" ) );
+ 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;
- list.append( QObject::tr( "Business Phone" ) );
- list.append( QObject::tr( "Business Fax" ) );
- list.append( QObject::tr( "Business Mobile" ) );
+ QMap<int, QString> mapIdToStr = idToTrFields();
- list.append( QObject::tr( "Default Email" ) );
- list.append( QObject::tr( "Emails" ) );
+ list.append( mapIdToStr[Qtopia::BusinessPhone] );
+ list.append( mapIdToStr[Qtopia::BusinessFax] );
+ list.append( mapIdToStr[Qtopia::BusinessMobile] );
- list.append( QObject::tr( "Home Phone" ) );
- list.append( QObject::tr( "Home Fax" ) );
- list.append( QObject::tr( "Home Mobile" ) );
+ 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] );
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( "Business Phone" );
- list.append( "Business Fax" );
- list.append( "Business Mobile" );
+ list.append( mapIdToStr[ Qtopia::BusinessPhone ] );
+ list.append( mapIdToStr[ Qtopia::BusinessFax ] );
+ list.append( mapIdToStr[ Qtopia::BusinessMobile ] );
- list.append( "Default Email" );
- list.append( "Emails" );
+ list.append( mapIdToStr[ Qtopia::DefaultEmail ] );
+ list.append( mapIdToStr[ Qtopia::Emails ] );
- list.append( "Home Phone" );
- list.append( "Home Fax" );
- list.append( "Home Mobile" );
+ list.append( mapIdToStr[ Qtopia::HomePhone ] );
+ list.append( mapIdToStr[ Qtopia::HomeFax ] );
+ list.append( mapIdToStr[ Qtopia::HomeMobile ] );
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( QObject::tr( "Name Title") );
- list.append( QObject::tr( "First Name" ) );
- list.append( QObject::tr( "Middle Name" ) );
- list.append( QObject::tr( "Last Name" ) );
- list.append( QObject::tr( "Suffix" ) );
- list.append( QObject::tr( "File As" ) );
+ 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( QObject::tr( "Job Title" ) );
- list.append( QObject::tr( "Department" ) );
- list.append( QObject::tr( "Company" ) );
+ list.append( mapIdToStr[Qtopia::JobTitle] );
+ list.append( mapIdToStr[Qtopia::Department] );
+ list.append( mapIdToStr[Qtopia::Company] );
list += trphonefields( sorted );
- list.append( QObject::tr( "Business Street" ) );
- list.append( QObject::tr( "Business City" ) );
- list.append( QObject::tr( "Business State" ) );
- list.append( QObject::tr( "Business Zip" ) );
- list.append( QObject::tr( "Business Country" ) );
- list.append( QObject::tr( "Business Pager" ) );
- list.append( QObject::tr( "Business WebPage" ) );
-
- list.append( QObject::tr( "Home Street" ) );
- list.append( QObject::tr( "Home City" ) );
- list.append( QObject::tr( "Home State" ) );
- list.append( QObject::tr( "Home Zip" ) );
- list.append( QObject::tr( "Home Country" ) );
- list.append( QObject::tr( "Home Web Page" ) );
+ 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( QObject::tr( "Notes" ) );
- list.append( QObject::tr( "Groups" ) );
+ 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( "Name Title" );
- list.append( "First Name" );
- list.append( "Middle Name" );
- list.append( "Last Name" );
- list.append( "Suffix" );
- list.append( "File As" );
+ 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( "Job Title" );
- list.append( "Department" );
- list.append( "Company" );
+ list.append( mapIdToStr[ Qtopia::JobTitle ] );
+ list.append( mapIdToStr[ Qtopia::Department ] );
+ list.append( mapIdToStr[ Qtopia::Company ] );
list += untrphonefields( sorted );
- list.append( "Business Street" );
- list.append( "Business City" );
- list.append( "Business State" );
- list.append( "Business Zip" );
- list.append( "Business Country" );
- list.append( "Business Pager" );
- list.append( "Business WebPage" );
-
- list.append( "Home Street" );
- list.append( "Home City" );
- list.append( "Home State" );
- list.append( "Home Zip" );
- list.append( "Home Country" );
- list.append( "Home Web Page" );
+ 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( "Notes" );
- list.append( "Groups" );
+ 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;
}
diff --git a/core/pim/addressbook/ocontactfields.h b/core/pim/addressbook/ocontactfields.h
index bf3a7f5..9f6171b 100644
--- a/core/pim/addressbook/ocontactfields.h
+++ b/core/pim/addressbook/ocontactfields.h
@@ -1,58 +1,60 @@
#ifndef OPIE_CONTACTS_FIELDS
#define OPIE_CONTACTS_FIELDS
class QStringList;
#include <qmap.h>
#include <qstring.h>
#include <opie/ocontact.h>
#define CONTACT_FIELD_ORDER_NAME "opie-contactfield-order"
#define DEFAULT_FIELD_ORDER "__________"
class OContactFields{
public:
OContactFields();
~OContactFields();
/** Set the index for combo boxes.
* Sets the <b>index</b> of combo <b>num</b>.
* @param num selects the number of the combo
* @param index sets the index in the combo
*/
void setFieldOrder( int num, int index );
/** Get the index for combo boxes.
* Returns the index of combo <b>num</b> or defindex
* if none was defined..
* @param num Selects the number of the combo
* @param defIndex will be returned if none was defined (either
* globally in the config file, nor by the contact which was used
* by loadFromRecord() )
*/
int getFieldOrder( int num, int defIndex);
/** Store fieldorder to contact. */
void saveToRecord( OContact& );
/** Get Fieldorder from contact. */
void loadFromRecord( const OContact& );
private:
QString fieldOrder;
QString globalFieldOrder;
bool changedFieldOrder;
public:
static QStringList trphonefields( bool sorted = true );
static QStringList untrphonefields( bool sorted = true );
static QStringList trdetailsfields( bool sorted = true );
static QStringList untrdetailsfields( bool sorted = true );
static QStringList trfields( bool sorted = true );
static QStringList untrfields( bool sorted = true );
static QMap<int, QString> idToTrFields();
static QMap<QString, int> trFieldsToId();
+ static QMap<int, QString> idToUntrFields();
+ static QMap<QString, int> untrFieldsToId();
};
#endif