summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO16
-rw-r--r--core/pim/addressbook/abtable.cpp40
-rw-r--r--core/pim/addressbook/abview.cpp48
-rw-r--r--core/pim/addressbook/contacteditor.cpp75
-rw-r--r--core/pim/addressbook/contacteditor.h5
-rw-r--r--core/pim/addressbook/ocontactfields.cpp101
-rw-r--r--core/pim/addressbook/ocontactfields.h34
-rw-r--r--core/pim/addressbook/version.h4
8 files changed, 251 insertions, 72 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 76247c1..c600d20 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -5,18 +5,19 @@ 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 incase it's installed and there's no mobile
+- 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
-- Plugin for Today for Birthdays and Anniversaries
- Beaming of multiple contacts (current list/ by search or by category)
+- Configure the letter-picker: lastname/fullname search
Known Bugs:
-----------
-
+- Email-button: A lot of problems.. :(
+- Default Email-Button: Sometimes not hiding the textfields completely
Bugs but not in addressbook:
-----------------------------
- VCARD: If umlaut (äöüß) in address, the parser gets confused..
@@ -28,9 +29,8 @@ Urgent:
--------
ContactEditor:
- Contact-Editor is temporarely reenabled. Wait for replacement.
- Redesign of Contacteditor
-- Store last settings of combo-boxes
- 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
@@ -39,26 +39,24 @@ Important:
----------
- If new contact is added (contacteditor closed): focus (table, card) to
this entry !
-- Implement a picker/combo for the default email.
- 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
-- Overview window cleanup needed..
- 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:
+Fixed/Ready:
-------
- Syncing: abtable not reloaded after sync.
- Find widget should be replaced by something like
qpdf has.
@@ -109,4 +107,8 @@ Fixed:
- 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
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 00335ae..aec390d 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -125,18 +125,18 @@ AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name
enablePainting( true ),
columnVisible( true ),
countNested( 0 )
{
- qWarning("C'tor start");
+ // 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");
+ // qWarning("C'tor end");
}
AbTable::~AbTable()
{
@@ -156,9 +156,9 @@ void AbTable::init()
}
void AbTable::setContacts( const OContactAccess::List& viewList )
{
- qWarning("AbTable::setContacts()");
+ // qWarning("AbTable::setContacts()");
clear();
m_viewList = viewList;
@@ -182,9 +182,9 @@ void AbTable::setContacts( const OContactAccess::List& viewList )
}
bool AbTable::selectContact( int UID )
{
- qWarning( "AbTable::selectContact( %d )", UID );
+ // qWarning( "AbTable::selectContact( %d )", UID );
int rows = numRows();
AbTableItem *abi;
OContact* foundContact = 0l;
bool found = false;
@@ -212,9 +212,9 @@ bool AbTable::selectContact( int UID )
}
void AbTable::insertIntoTable( const OContact& cnt, int row )
{
- qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
+ // qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
QString strName,
strContact;
strName = findContactName( cnt );
@@ -253,9 +253,9 @@ void AbTable::columnClicked( int col )
}
void AbTable::resort()
{
- qWarning( "void AbTable::resort()" );
+ // qWarning( "void AbTable::resort()" );
setPaintingEnabled( FALSE );
if ( sorting() ) {
if ( lastSortCol == -1 )
lastSortCol = 0;
@@ -267,9 +267,9 @@ void AbTable::resort()
}
OContact AbTable::currentEntry()
{
- qWarning( "OContact AbTable::currentEntry()" );
+ // qWarning( "OContact AbTable::currentEntry()" );
OContact cnt;
AbTableItem *abItem;
abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
if ( abItem ) {
@@ -285,9 +285,9 @@ int AbTable::currentEntry_UID()
}
void AbTable::clear()
{
- qWarning( "void AbTable::clear()" );
+ // qWarning( "void AbTable::clear()" );
contactList.clear();
setPaintingEnabled( FALSE );
for ( int r = 0; r < numRows(); ++r ) {
@@ -303,9 +303,9 @@ void AbTable::clear()
// Refresh updates column 2 if the contactsettings changed
void AbTable::refresh()
{
- qWarning( "void AbTable::refresh()" );
+ // qWarning( "void AbTable::refresh()" );
int rows = numRows();
QString value;
AbTableItem *abi;
@@ -325,9 +325,9 @@ void AbTable::keyPressEvent( QKeyEvent *e )
if ( key >= 'A' && key <= 'Z' )
moveTo( key );
- qWarning("Received key ..");
+ // qWarning("Received key ..");
switch( e->key() ) {
case Qt::Key_Space:
case Qt::Key_Return:
case Qt::Key_Enter:
@@ -410,9 +410,9 @@ void AbTable::resizeRows() {
void AbTable::realignTable()
{
- qWarning( "void AbTable::realignTable()" );
+ // qWarning( "void AbTable::realignTable()" );
setPaintingEnabled( FALSE );
resizeRows();
@@ -460,9 +460,9 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
void AbTable::fitColumns()
{
- qWarning( "void AbTable::fitColumns()" );
+ // qWarning( "void AbTable::fitColumns()" );
int contentsWidth = visibleWidth() / 2; // :SX Why too low
// Fix to better value
// contentsWidth = 130;
@@ -472,9 +472,9 @@ void AbTable::fitColumns()
showColumn(0);
columnVisible = true;
}
- qWarning("Width: %d", contentsWidth);
+ // qWarning("Width: %d", contentsWidth);
setColumnWidth( 0, contentsWidth );
adjustColumn(1);
if ( columnWidth(1) < contentsWidth )
@@ -484,9 +484,9 @@ void AbTable::fitColumns()
}
void AbTable::show()
{
- qWarning( "void AbTable::show()" );
+ // qWarning( "void AbTable::show()" );
realignTable();
QTable::show();
}
@@ -506,13 +506,13 @@ void AbTable::setChoiceNames( const QStringList& list)
}
void AbTable::itemClicked(int,int col)
{
- qWarning( "AbTable::itemClicked(int, col:%d)", col);
+ // qWarning( "AbTable::itemClicked(int, col:%d)", col);
if ( col == 2 ) {
return;
} else {
- qWarning ("Emitting signalSwitch()");
+ // qWarning ("Emitting signalSwitch()");
emit signalSwitch();
}
}
@@ -547,9 +547,9 @@ QStringList AbTable::choiceSelection(int /*index*/) const
void AbTable::updateVisible()
{
- qWarning("void AbTable::updateVisible()");
+ // qWarning("void AbTable::updateVisible()");
int visible,
totalRows,
row,
@@ -585,9 +585,9 @@ void AbTable::updateVisible()
void AbTable::setPaintingEnabled( bool e )
{
- qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
+ // qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
if ( e ) {
if ( countNested > 0 )
--countNested;
@@ -601,13 +601,13 @@ void AbTable::setPaintingEnabled( bool e )
++countNested;
enablePainting = false;
setUpdatesEnabled( false );
}
- qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
+ // qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
}
void AbTable::viewportPaintEvent( QPaintEvent* e ) {
- qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
+ // qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
if ( enablePainting )
QTable::viewportPaintEvent( e );
}
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 93e57ca..7da0992 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -94,30 +94,30 @@ AbView::~AbView()
void AbView::setView( Views view )
{
- qWarning("AbView::setView( Views view )");
+ // qWarning("AbView::setView( Views view )");
m_curr_View = view;
load();
}
void AbView::addEntry( const OContact &newContact )
{
- qWarning("abview:AddContact");
+ // qWarning("abview:AddContact");
m_contactdb->add ( newContact );
load();
}
void AbView::removeEntry( const int UID )
{
- qWarning("abview:RemoveContact");
+ // qWarning("abview:RemoveContact");
m_contactdb->remove( UID );
load();
}
void AbView::replaceEntry( const OContact &contact )
{
- qWarning("abview:ReplaceContact");
+ // qWarning("abview:ReplaceContact");
m_contactdb->replace( contact );
load();
}
@@ -139,16 +139,16 @@ OContact AbView::currentEntry()
}
bool AbView::save()
{
- qWarning("abView:Save data");
+ // qWarning("abView:Save data");
return m_contactdb->save();
}
void AbView::load()
{
- qWarning("abView:Load data");
+ // qWarning("abView:Load data");
// Letter Search is stopped at this place
emit signalClearLetterPicker();
@@ -159,17 +159,17 @@ void AbView::load()
m_list = m_contactdb->sorted( true, 0, 0, 0 );
clearForCategory();
}
- qWarning ("Number of contacts: %d", m_list.count());
+ // qWarning ("Number of contacts: %d", m_list.count());
updateView( true );
}
void AbView::reload()
{
- qWarning( "void AbView::reload()" );
+ // qWarning( "void AbView::reload()" );
m_contactdb->reload();
load();
}
@@ -180,9 +180,9 @@ void AbView::clear()
}
void AbView::setShowByCategory( const QString& cat )
{
- qWarning("AbView::setShowCategory( const QString& cat )");
+ // qWarning("AbView::setShowCategory( const QString& cat )");
int intCat = 0;
// All (cat == NULL) will be stored as -1
@@ -192,9 +192,9 @@ void AbView::setShowByCategory( const QString& cat )
intCat = mCat.id("Contacts", cat );
// Just do anything if we really change the category
if ( intCat != m_curr_category ){
- qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category);
+ // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category);
m_curr_category = intCat;
emit signalClearLetterPicker();
@@ -204,11 +204,11 @@ void AbView::setShowByCategory( const QString& cat )
}
void AbView::setShowToView( Views view )
{
- qWarning("void AbView::setShowToView( View %d )", view);
+ // qWarning("void AbView::setShowToView( View %d )", view);
- qWarning ("Change the View (Category is: %d)", m_curr_category);
+ // qWarning ("Change the View (Category is: %d)", m_curr_category);
if ( m_curr_View != view ){
m_prev_View = m_curr_View;
m_curr_View = view;
@@ -219,9 +219,9 @@ void AbView::setShowToView( Views view )
}
void AbView::setShowByLetter( char c )
{
- qWarning("void AbView::setShowByLetter( %c )", c );
+ // qWarning("void AbView::setShowByLetter( %c )", c );
OContact query;
if ( c == 0 ){
load();
return;
@@ -253,9 +253,9 @@ QString AbView::showCategory() const
}
void AbView::showPersonal( bool personal )
{
- qWarning ("void AbView::showPersonal( %d )", personal);
+ // qWarning ("void AbView::showPersonal( %d )", personal);
if ( personal ){
if ( m_inPersonal )
@@ -302,9 +302,9 @@ QStringList AbView::categories()
// BEGIN: Slots
void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
bool , QString cat )
{
- qWarning( "void AbView::slotDoFind" );
+ // qWarning( "void AbView::slotDoFind" );
// We reloading the data: Deselect Letterpicker
emit signalClearLetterPicker();
@@ -316,18 +316,18 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
else{
category = mCat.id("Contacts", cat );
}
- qWarning ("Find in Category %d", category);
+ // qWarning ("Find in Category %d", category);
QRegExp r( str );
r.setCaseSensitive( caseSensitive );
r.setWildcard( !useRegExp );
// Get all matching entries out of the database
m_list = m_contactdb->matchRegexp( r );
- qWarning( "found: %d", m_list.count() );
+ // qWarning( "found: %d", m_list.count() );
if ( m_list.count() == 0 ){
emit signalNotFound();
return;
}
@@ -348,9 +348,9 @@ void AbView::offSearch()
load();
}
void AbView::slotSwitch(){
- qWarning("AbView::slotSwitch()");
+ // qWarning("AbView::slotSwitch()");
m_prev_View = m_curr_View;
switch ( (int) m_curr_View ){
case TableView:
@@ -376,9 +376,9 @@ void AbView::clearForCategory()
OContactAccess::List allList = m_list;
if ( m_curr_category != -1 ){
for ( it = allList.begin(); it != allList.end(); ++it ){
if ( !contactCompare( *it, m_curr_category ) ){
- qWarning("Removing %d", (*it).uid());
+ // qWarning("Removing %d", (*it).uid());
m_list.remove( (*it).uid() );
}
}
}
@@ -386,31 +386,31 @@ void AbView::clearForCategory()
}
bool AbView::contactCompare( const OContact &cnt, int category )
{
- qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category);
+ // qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category);
bool returnMe;
QArray<int> cats;
cats = cnt.categories();
- qWarning ("Number of categories: %d", cats.count() );
+ // qWarning ("Number of categories: %d", cats.count() );
returnMe = false;
if ( cats.count() == 0 && category == 0 )
// Contacts with no category will just shown on "All" and "Unfiled"
returnMe = true;
else {
int i;
for ( i = 0; i < int(cats.count()); i++ ) {
- qWarning("Comparing %d with %d",cats[i],category );
+ // qWarning("Comparing %d with %d",cats[i],category );
if ( cats[i] == category ) {
returnMe = true;
break;
}
}
}
- qWarning ("Return: %d", returnMe);
+ // qWarning ("Return: %d", returnMe);
return returnMe;
}
// In Some rare cases we have to update all lists..
@@ -421,9 +421,9 @@ void AbView::updateListinViews()
}
void AbView::updateView( bool newdata )
{
- qWarning("AbView::updateView()");
+ // qWarning("AbView::updateView()");
if ( m_viewStack -> visibleWidget() ){
m_viewStack -> visibleWidget() -> clearFocus();
}
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index d14ac51..d830ad3 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -66,22 +66,29 @@ ContactEditor::ContactEditor( const OContact &entry,
QWidget *parent,
const char *name,
WFlags fl )
: QDialog( parent, name, TRUE, fl ),
- m_personalView ( false )
-
+ defaultEmailChooserPosition( -1 ),
+ m_personalView ( false ),
+ cmbDefaultEmail( 0 ),
+ initializing ( false )
{
+ initializing = true;
+
init();
setEntry( entry );
- cmbDefaultEmail = 0;
- defaultEmailChooserPosition = -1;
+// cmbDefaultEmail = 0;
+// defaultEmailChooserPosition = -1;
+
+ initializing = false;
}
ContactEditor::~ContactEditor() {
}
void ContactEditor::init() {
+ qWarning("init() START");
useFullName = true;
uint i = 0;
@@ -599,11 +606,11 @@ void ContactEditor::init() {
cmbChooserField2->insertStringList( trlChooserNames );
cmbChooserField3->insertStringList( trlChooserNames );
cmbChooserField4->insertStringList( trlChooserNames );
- cmbChooserField1->setCurrentItem( 0 );
- cmbChooserField2->setCurrentItem( 1 );
- cmbChooserField3->setCurrentItem( 2 );
+ 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 &)) );
@@ -641,8 +648,10 @@ void ContactEditor::init() {
new QPEDialogListener(this);
setPersonalView ( m_personalView );
+
+ qWarning("init() END");
}
void ContactEditor::defaultEmailChanged(int i){
qDebug("defaultEmailChanged");
@@ -691,17 +700,20 @@ void ContactEditor::populateDefaultEmailCmb(){
// "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", type.latin1() );
+ 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 ");
+ qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition);
// More than one defaul-email chooser is not allowed !
if ( ( defaultEmailChooserPosition != -1 ) &&
- defaultEmailChooserPosition != widgetPos ){
+ defaultEmailChooserPosition != widgetPos && !initializing){
chooserError( widgetPos );
return true;
}
@@ -709,9 +721,15 @@ bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widget
delete cmbDefaultEmail;
cmbDefaultEmail = 0l;
}
cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
- cmbDefaultEmail->setGeometry(inputWid->frameGeometry());
+ 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) ) );
@@ -943,8 +961,13 @@ void ContactEditor::slotCmbChooser4Change( int index ) {
}
void ContactEditor::slotAddressTypeChange( int index ) {
+
+ if ( !initializing )
+ contactfields.setFieldOrder( 4, index );
+
+
if ( index == 0 ) {
txtAddress->setText( slBusinessAddress[0] );
//txtAddress2->setText( (*slBusinessAddress)[1] );
@@ -1275,14 +1298,14 @@ void ContactEditor::cleanupFields() {
}
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());
@@ -1454,16 +1477,34 @@ void ContactEditor::setEntry( const OContact &entry ) {
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() );
- // loadFields(); :SX
updateDatePicker();
+
+ initializing = false;
}
void ContactEditor::updateDatePicker()
{
// Set DatePicker
@@ -1482,9 +1523,11 @@ void ContactEditor::updateDatePicker()
}
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 ) );
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index 4fa48d1..95f9f2d 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -29,8 +29,10 @@
#include <qlist.h>
#include <qmap.h>
#include <qstringlist.h>
+#include "ocontactfields.h"
+
const int NAME_LF = 0;
const int NAME_LFM = 1;
const int NAME_FL = 2;
const int NAME_FMLS = 3;
@@ -107,8 +109,9 @@ class ContactEditor : public QDialog {
int defaultEmailChooserPosition;
void populateDefaultEmailCmb();
void chooserChange( const QString&, int , QLineEdit*, int );
bool cmbChooserChange( int , QLineEdit*, int );
+ OContactFields contactfields;
bool useFullName;
OContact ent;
@@ -175,7 +178,9 @@ class ContactEditor : public QDialog {
DateBookMonth* birthdayPicker;
QToolButton* birthdayButton;
DateBookMonth* anniversaryPicker;
QToolButton* anniversaryButton;
+
+ bool initializing;
};
#endif
diff --git a/core/pim/addressbook/ocontactfields.cpp b/core/pim/addressbook/ocontactfields.cpp
index 0da6a4f..75a7641 100644
--- a/core/pim/addressbook/ocontactfields.cpp
+++ b/core/pim/addressbook/ocontactfields.cpp
@@ -5,8 +5,10 @@
#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.
@@ -198,9 +200,9 @@ QStringList OContactFields::untrfields( bool sorted )
}
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" ) );
@@ -253,9 +255,9 @@ QMap<int, QString> OContactFields::idToTrFields()
ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) );
// other
ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) );
-
+
return ret_map;
}
@@ -267,8 +269,101 @@ QMap<QString, int> OContactFields::trFieldsToId()
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 796bc0a..bf3a7f5 100644
--- a/core/pim/addressbook/ocontactfields.h
+++ b/core/pim/addressbook/ocontactfields.h
@@ -4,12 +4,46 @@
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 );
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h
index b740326..e716fe4 100644
--- a/core/pim/addressbook/version.h
+++ b/core/pim/addressbook/version.h
@@ -1,10 +1,10 @@
#ifndef _VERSION_H_
#define _VERSION_H_
#define MAINVERSION "0"
-#define SUBVERSION "1"
-#define PATCHVERSION "1"
+#define SUBVERSION "2"
+#define PATCHVERSION "0"
#define APPNAME "OPIE_ADDRESSBOOK"
#endif