author | eilers <eilers> | 2003-01-31 13:51:13 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-01-31 13:51:13 (UTC) |
commit | 6f5a127080c50eb901ac6a332ac76d9948f91bd5 (patch) (side-by-side diff) | |
tree | 8021e7597b9bc8e527b2fddac1e03dc0959434c9 | |
parent | 84bd32181af3922ccba35fcaed9b404d1e4deed8 (diff) | |
download | opie-6f5a127080c50eb901ac6a332ac76d9948f91bd5.zip opie-6f5a127080c50eb901ac6a332ac76d9948f91bd5.tar.gz opie-6f5a127080c50eb901ac6a332ac76d9948f91bd5.tar.bz2 |
Removed a lot of debug output.. Therefore it should speed up..
The settings of the combo-boxes in the contacteditor are now stored globally
and individual for a contact ( I fear this will not survive any synchronizing! ).
Thanks to tille for his assistance !
I hope there isn't any new bug in the contacteditor.. It is very ugly and hard
to debug..
-rw-r--r-- | core/pim/addressbook/TODO | 16 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 40 | ||||
-rw-r--r-- | core/pim/addressbook/abview.cpp | 48 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 75 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 5 | ||||
-rw-r--r-- | core/pim/addressbook/ocontactfields.cpp | 101 | ||||
-rw-r--r-- | core/pim/addressbook/ocontactfields.h | 34 | ||||
-rw-r--r-- | core/pim/addressbook/version.h | 4 |
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 @@ -1,112 +1,114 @@ 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 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.. - 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 -- 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 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. - 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 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 @@ -81,577 +81,577 @@ void AbTableItem::setItem( const QString &txt, const QString &secondKey ) \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"); + // 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() { } 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()"); + // 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 ); + // 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 ); + // qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); QString strName, strContact; strName = findContactName( cnt ); strContact = findContactContact( cnt, row ); AbTableItem *ati; ati = new AbTableItem( this, QTableItem::Never, strName, strContact); contactList.insert( ati, cnt ); setItem( row, 0, ati ); ati = new AbTableItem( this, QTableItem::Never, strContact, strName); 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()" ); + // 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()" ); + // 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()" ); + // 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()" ); + // qWarning( "void AbTable::refresh()" ); int rows = numRows(); QString value; AbTableItem *abi; 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() ); } resort(); setPaintingEnabled( TRUE ); } void AbTable::keyPressEvent( QKeyEvent *e ) { char key = toupper( e->ascii() ); 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: 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()" ); + // 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()" ); + // 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); + // 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()" ); + // 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); + // qWarning( "AbTable::itemClicked(int, col:%d)", col); if ( col == 2 ) { return; } else { - qWarning ("Emitting signalSwitch()"); + // 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()"); + // 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 ); + // 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 ); + // 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 ); } void AbTable::rowHeightChanged( int row ) { if ( enablePainting ) QTable::rowHeightChanged( row ); } QString AbTable::findContactContact( const OContact &entry, int /* row */ ) { QString value; value = ""; for ( QValueList<int>::ConstIterator it = intFields.begin(); it != intFields.end(); ++it ) { switch ( *it ) { default: break; case Qtopia::Title: value = entry.title(); break; case Qtopia::Suffix: value = entry.suffix(); break; case Qtopia::FileAs: value = entry.fileAs(); break; case Qtopia::DefaultEmail: value = entry.defaultEmail(); case Qtopia::Emails: value = entry.emails(); break; case Qtopia::HomeStreet: value = entry.homeStreet(); break; case Qtopia::HomeCity: value = entry.homeCity(); break; case Qtopia::HomeState: value = entry.homeState(); break; case Qtopia::HomeZip: value = entry.homeZip(); break; case Qtopia::HomeCountry: value = entry.homeCountry(); 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 @@ -50,424 +50,424 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): m_orderedFields( ordered ) { // Load default database and handle syncing myself.. ! m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), mCat.load( categoryFileName() ); // Create Layout and put WidgetStack into it. QVBoxLayout *vb = new QVBoxLayout( this ); m_viewStack = new QWidgetStack( this ); vb->addWidget( m_viewStack ); // Creat TableView QVBox* tableBox = new QVBox( m_viewStack ); m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); m_abTable->setCurrentCell( 0, 0 ); m_abTable->setFocus(); // Add TableView to WidgetStack and raise it m_viewStack -> addWidget( tableBox , TableView ); // Create CardView and add it to WidgetStack QVBox* cardBox = new QVBox( m_viewStack ); m_ablabel = new AbLabel( cardBox, "CardView"); m_viewStack -> addWidget( cardBox , CardView ); // Connect views to me connect ( m_abTable, SIGNAL( signalSwitch( void ) ), this, SLOT( slotSwitch( void ) ) ); connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), this, SLOT( slotSwitch( void ) ) ); load(); } AbView::~AbView() { m_contactdb -> save(); delete m_contactdb; if ( m_storedDB ){ m_storedDB -> save(); delete m_storedDB; } } 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(); } OContact AbView::currentEntry() { OContact currentContact; switch ( (int) m_curr_View ) { case TableView: currentContact = m_abTable -> currentEntry(); break; case CardView: currentContact = m_ablabel -> currentEntry(); break; } m_curr_Contact = currentContact.uid(); return currentContact; } 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(); if ( m_inPersonal ) // VCard Backend does not sort.. m_list = m_contactdb->allRecords(); else{ 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(); } void AbView::clear() { // :SX } 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 if ( cat.isNull() ) intCat = -1; else 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(); load(); } } 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; updateView(); } } void AbView::setShowByLetter( char c ) { - qWarning("void AbView::setShowByLetter( %c )", c ); + // qWarning("void AbView::setShowByLetter( %c )", c ); OContact query; if ( c == 0 ){ load(); return; }else{ // If the current Backend is unable to solve the query, we will // ignore the request .. if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ return; } query.setLastName( QString("%1*").arg(c) ); m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); clearForCategory(); m_curr_Contact = 0; } updateView( true ); } void AbView::setListOrder( const QValueList<int>& ordered ) { m_orderedFields = ordered; updateView(); } QString AbView::showCategory() const { return mCat.label( "Contacts", m_curr_category ); } void AbView::showPersonal( bool personal ) { - qWarning ("void AbView::showPersonal( %d )", personal); + // qWarning ("void AbView::showPersonal( %d )", personal); if ( personal ){ if ( m_inPersonal ) return; // Now switch to vCard Backend and load data. // The current default backend will be stored // to avoid unneeded load/stores. m_storedDB = m_contactdb; OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, addressbookPersonalVCardName() ); m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); m_inPersonal = true; m_curr_View = CardView; }else{ if ( !m_inPersonal ) return; // Remove vCard Backend and restore default m_contactdb->save(); delete m_contactdb; m_contactdb = m_storedDB; m_storedDB = 0l; m_curr_View = TableView; m_inPersonal = false; } load(); } QStringList AbView::categories() { mCat.load( categoryFileName() ); QStringList categoryList = mCat.labels( "Contacts" ); return categoryList; } // 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(); // Use the current Category if nothing else selected int category = 0; if ( cat.isEmpty() ) category = m_curr_category; 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; } // Now remove all contacts with wrong category (if any selected) // This algorithm is a litte bit ineffective, but // we will not have a lot of matching entries.. clearForCategory(); // Now show all found entries updateView( true ); } void AbView::offSearch() { m_inSearch = false; load(); } void AbView::slotSwitch(){ - qWarning("AbView::slotSwitch()"); + // qWarning("AbView::slotSwitch()"); m_prev_View = m_curr_View; switch ( (int) m_curr_View ){ case TableView: qWarning("Switching to CardView"); m_curr_View = CardView; break; case CardView: qWarning("Switching to TableView"); m_curr_View = TableView; break; } updateView(); } // END: Slots void AbView::clearForCategory() { OContactAccess::List::Iterator it; // Now remove all contacts with wrong category if any category selected 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() ); } } } } 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.. void AbView::updateListinViews() { m_abTable -> setContacts( m_list ); m_ablabel -> setContacts( m_list ); } void AbView::updateView( bool newdata ) { - qWarning("AbView::updateView()"); + // qWarning("AbView::updateView()"); if ( m_viewStack -> visibleWidget() ){ m_viewStack -> visibleWidget() -> clearFocus(); } // If we switching the view, we have to store some information if ( !newdata ){ if ( m_list.count() ){ switch ( (int) m_prev_View ) { case TableView: m_curr_Contact = m_abTable -> currentEntry_UID(); break; case CardView: m_curr_Contact = m_ablabel -> currentEntry_UID(); break; } }else m_curr_Contact = 0; } // Feed all views with new lists if ( newdata ) updateListinViews(); // Tell the world that the view is changed if ( m_curr_View != m_prev_View ) emit signalViewSwitched ( (int) m_curr_View ); m_prev_View = m_curr_View; // Switch to new View switch ( (int) m_curr_View ) { case TableView: m_abTable -> setChoiceSelection( m_orderedFields ); if ( m_curr_Contact != 0 ) m_abTable -> selectContact ( m_curr_Contact ); m_abTable -> setFocus(); break; case CardView: if ( m_curr_Contact != 0 ) m_ablabel -> selectContact( m_curr_Contact ); m_ablabel -> setFocus(); break; } // Raise the current View m_viewStack -> raiseWidget( m_curr_View ); } 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 @@ -22,110 +22,117 @@ #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 ), - 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; 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 ); @@ -555,207 +562,218 @@ void ContactEditor::init() { 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 ); + 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", 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; } if ( cmbDefaultEmail ){ 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) ) ); 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.. @@ -899,96 +917,101 @@ void ContactEditor::slotCountryChange( const QString &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(); @@ -1231,102 +1254,102 @@ QString ContactEditor::parseName( const QString fullName, int type ) { 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(); //} @@ -1410,125 +1433,145 @@ void ContactEditor::setEntry( const OContact &entry ) { /* 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() ); - // loadFields(); :SX 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/contacteditor.h b/core/pim/addressbook/contacteditor.h index 4fa48d1..95f9f2d 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h @@ -1,181 +1,186 @@ /* * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> * * This file is an add-on for the OPIE Palmtop Environment * * This file may be distributed and/or modified under the terms of the * GNU General Public License version 2 as published by the Free Software * Foundation and appearing in the file LICENSE.GPL included in the pacakaging * of this file. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * This is a rewrite of the abeditor.h file, modified to provide a more * intuitive interface to TrollTech's original Address Book editor. This * is made to operate exactly in interface with the exception of name. * */ #ifndef CONTACTEDITOR_H #define CONTACTEDITOR_H #include <opie/ocontact.h> #include <qpe/datebookmonth.h> #include <qdialog.h> #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; const int NAME_F = 4; const int NAME_M = 5; const int NAME_L = 6; const int NAME_S = 7; class QScrollView; class QTabWidget; class QMultiLineEdit; class QLineEdit; class QComboBox; class QPushButton; class CategorySelect; class QLabel; class ContactEditor : public QDialog { Q_OBJECT public: ContactEditor( const OContact &entry, QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); ~ContactEditor(); void setNameFocus(); void setPersonalView( bool personal = true ); OContact entry() const { return ent; } public slots: void slotNote(); void slotName(); void setEntry(const OContact &entry); protected slots: void accept(); private: void init(); void saveEntry(); bool isEmpty(); void cleanupFields(); void updateDatePicker(); QString parseName( QString fullName, int type ); void chooserError( int index ); private slots: void slotChooser1Change( const QString &textChanged ); void slotChooser2Change( const QString &textChanged ); void slotChooser3Change( const QString &textChanged ); void slotChooser4Change( const QString &textChanged ); void slotCmbChooser1Change( int index ); void slotCmbChooser2Change( int index ); void slotCmbChooser3Change( int index ); void slotCmbChooser4Change( int index ); void slotAddressTypeChange( int index ); void slotAddressChange( const QString &textChanged ); void slotAddress2Change( const QString &textChanged ); void slotPOBoxChange( const QString &textChanged ); void slotCityChange( const QString &textChanged ); void slotStateChange( const QString &textChanged ); void slotZipChange( const QString &textChanged ); void slotCountryChange( const QString &textChanged ); void slotFullNameChange( const QString &textChanged ); void slotAnniversaryDateChanged( int year, int month, int day); void slotBirthdayDateChanged( int year, int month, int day); void slotRemoveBirthday(); void slotRemoveAnniversary(); void defaultEmailChanged(int); private: int defaultEmailChooserPosition; void populateDefaultEmailCmb(); void chooserChange( const QString&, int , QLineEdit*, int ); bool cmbChooserChange( int , QLineEdit*, int ); + OContactFields contactfields; bool useFullName; OContact ent; QDialog *dlgNote; QDialog *dlgName; QList<QLineEdit> listValue; QList<QLabel> listName; QStringList slDynamicEntries; QStringList trlDynamicEntries; bool m_personalView; QStringList slHomeAddress; QStringList slBusinessAddress; QStringList slChooserNames; QStringList slChooserValues; QStringList emails; QString defaultEmail; QMultiLineEdit *txtNote; QLabel *lblNote; //QLineEdit *txtTitle; QLineEdit *txtFirstName; QLineEdit *txtMiddleName; QLineEdit *txtLastName; QLineEdit *txtSuffix; QTabWidget *tabMain; QScrollView *svGeneral; QPushButton *btnFullName; QPushButton *btnNote; QLineEdit *txtFullName; QLineEdit *txtJobTitle; QLineEdit *txtOrganization; QLineEdit *txtChooserField1; QLineEdit *txtChooserField2; QLineEdit *txtChooserField3; QLineEdit *txtChooserField4; QComboBox *cmbChooserField1; QComboBox *cmbChooserField2; QComboBox *cmbChooserField3; QComboBox *cmbChooserField4; QComboBox *cmbDefaultEmail; QComboBox *cmbFileAs; CategorySelect *cmbCat; QLabel *labCat; QScrollView *svAddress; QLineEdit *txtAddress; //QLineEdit *txtAddress2; //QLineEdit *txtPOBox; QLineEdit *txtCity; QLineEdit *txtState; QLineEdit *txtZip; QComboBox *cmbAddress; QComboBox *cmbCountry; QScrollView *svDetails; QComboBox *cmbGender; DateBookMonth* birthdayPicker; QToolButton* birthdayButton; DateBookMonth* anniversaryPicker; QToolButton* anniversaryButton; + + bool initializing; }; #endif 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 @@ -1,56 +1,58 @@ #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; list.append( "Office" ); list.append( "Profession" ); list.append( "Assistant" ); list.append( "Manager" ); list.append( "Spouse" ); list.append( "Gender" ); list.append( "Birthday" ); list.append( "Anniversary" ); list.append( "Nickname" ); list.append( "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; list.append( QObject::tr( "Office" ) ); list.append( QObject::tr( "Profession" ) ); list.append( QObject::tr( "Assistant" ) ); list.append( QObject::tr( "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" ) ); if (sorted) list.sort(); return list; } @@ -154,121 +156,214 @@ QStringList OContactFields::trfields( bool sorted ) /*! \internal Returns an untranslated list of field names for a contact. */ QStringList OContactFields::untrfields( bool sorted ) { QStringList list; 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( "Job Title" ); list.append( "Department" ); list.append( "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 += untrdetailsfields( sorted ); list.append( "Notes" ); list.append( "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<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; } + +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 @@ -1,24 +1,58 @@ #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(); }; #endif 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 |