25 files changed, 2122 insertions, 1972 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO index 517d702..0380fa3 100644 --- a/core/pim/addressbook/TODO +++ b/core/pim/addressbook/TODO @@ -1,12 +1,33 @@ Stuff todo until OPIE 1.0 : +=========================== -----> This main branch ist currently stable enough for -----> snapshots.. To avoid corrupted snapshots, we currently -----> working on a different branch.. -----> YOU FIND THE CURRENT WORK IN THE BRANCH "GO_FOR_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 +- 3rd column for 2. Contact +- Implementing additional Views (Phonebook, ...) +- Birthday & Anniversary Reminder +- Plugin for Today for Birthdays and Anniversaries +Known Bugs: +----------- +- OK-Key does not switch from Detailview (ablable) to Listview + +Bugs but not in addressbook: +----------------------------- +- VCARD: Import of Anniversary does not work correctly (currently disabled) +- VCARD: If umlaut (äöüß) in address, the parser gets confused.. -Pending bugfixes from previous work: Urgent: +-------- +- Contact-Editor is temporarely reanabled. Wait for replacement. +- Redesign of Contacteditor +- Store last settings of combo-boxes +- Name order selected in "contacteditor" not used in list view. +- Category is on the wrong position after changing to personal and back to normal + ( Temporarily workaround: Category is never deactivated.. :S ) @@ -14,23 +35,24 @@ Urgent: Important: +---------- -- Name order selected in "contacteditor" not used in list view. +- After search (Started with Return): KeyFocus should be on Tabelle +- Searchwidget closed: Selected user is jumping +- Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist) + zu lange.. -- Overview window cleanup needed.. -- 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).. -- Store last settings of combo-boxes -- Finishing of new View functions (List, Phonebook...) -- Reload if contacts were changed externally -- "What's this" should be added +- Store position and state of toolbar -Less important: +- IRDA Receive: Contact is added, but start of editor with new entry expected.. +- "What's this" should be added (Deleyed after Feature Freeze) -- The picker (alphabetical sort widget) should be +Less important: +--------------- +- Reload if contacts were changed externally +- Overview window cleanup needed.. +- The picker (alphabetical sort widget) should be placed verticaly or horizontally (configurable) -- Use advanced database functions in abtable to decrease - memory footprint and to make everything more easy ! - (abtable should store Iterator for selected Category) +- Find a smart solution for activating/deactivating the "send email" event Should be Fixed (not absolute sure, need further validation): +------------------------------------------------------------- @@ -38,2 +60,3 @@ Should be Fixed (not absolute sure, need further validation): Fixed: +------- - Syncing: abtable not reloaded after sync. @@ -52 +75,19 @@ Fixed: 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". diff --git a/core/pim/addressbook/abconfig.cpp b/core/pim/addressbook/abconfig.cpp new file mode 100644 index 0000000..703faac --- a/dev/null +++ b/core/pim/addressbook/abconfig.cpp @@ -0,0 +1,184 @@ +#include "abconfig.h" +#include "version.h" + +#include <qpe/config.h> +#include <qpe/recordfields.h> + +AbConfig::AbConfig( ): + m_useQtMail( true ), + m_useOpieMail( false ), + m_useRegExp( false ), + m_beCaseSensitive( false ), + m_fontSize( 1 ), + m_barPos( QMainWindow::Top ), + m_changed( false ) +{ +} + +AbConfig::~AbConfig() +{ +} + +bool AbConfig::useRegExp() const +{ + return m_useRegExp; +} +bool AbConfig::useWildCards() const +{ + return !m_useRegExp; +} +bool AbConfig::useQtMail() const +{ + return m_useQtMail; +} +bool AbConfig::useOpieMail() const +{ + return m_useOpieMail; +} +bool AbConfig::beCaseSensitive() const +{ + return m_beCaseSensitive; +} +int AbConfig::fontSize() const +{ + return m_fontSize; +} + +QValueList<int> AbConfig::orderList() const +{ + return m_ordered; +} + +QMainWindow::ToolBarDock AbConfig::getToolBarPos() const +{ + return (QMainWindow::ToolBarDock) m_barPos; +} + + +void AbConfig::setUseRegExp( bool v ) +{ + m_useRegExp = v ; + m_changed = true; +} +void AbConfig::setUseWildCards( bool v ) +{ + m_useRegExp = !v; + m_changed = true; +} +void AbConfig::setBeCaseSensitive( bool v ) +{ + m_beCaseSensitive = v; + m_changed = true; +} +void AbConfig::setUseQtMail( bool v ) +{ + m_useQtMail = v; + m_changed = true; +} +void AbConfig::setUseOpieMail( bool v ) +{ + m_useOpieMail = v; + m_changed = true; +} +void AbConfig::setFontSize( int v ) +{ + m_fontSize = v; + m_changed = true; +} + +void AbConfig::setOrderList( const QValueList<int>& list ) +{ + m_ordered = list; + m_changed = true; +} + +void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v ) +{ + m_barPos = v; + m_changed = true; +} + +void AbConfig::load() +{ + // Read Config settings + Config cfg("AddressBook"); + + cfg.setGroup("Font"); + m_fontSize = cfg.readNumEntry( "fontSize", 1 ); + + cfg.setGroup("Search"); + m_useRegExp = cfg.readBoolEntry( "useRegExp" ); + m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive" ); + + cfg.setGroup("Mail"); + m_useQtMail = cfg.readBoolEntry( "useQtMail", true ); + m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); + + cfg.setGroup("ContactOrder"); + int ID = 0; + int i = 0; + ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); + while ( ID != 0 ){ + m_ordered.append( ID ); + ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); + } + + // If no contact order is defined, we set the default + if ( m_ordered.count() == 0 ) { + m_ordered.append( Qtopia::DefaultEmail ); + m_ordered.append( Qtopia::HomePhone); + m_ordered.append( Qtopia::HomeMobile); + m_ordered.append( Qtopia::BusinessPhone); + } + + cfg.setGroup("ToolBar"); + m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top ); + + m_changed = false; +} + +void AbConfig::save() +{ + if ( m_changed ){ + Config cfg("AddressBook"); + cfg.setGroup("Font"); + cfg.writeEntry("fontSize", m_fontSize); + + cfg.setGroup("Search"); + cfg.writeEntry("useRegExp", m_useRegExp); + cfg.writeEntry("caseSensitive", m_beCaseSensitive); + + cfg.setGroup("Mail"); + cfg.writeEntry( "useQtMail", m_useQtMail ); + cfg.writeEntry( "useOpieMail", m_useOpieMail); + + cfg.setGroup("ContactOrder"); + cfg.clearGroup(); + for ( uint i = 0; i < m_ordered.count(); i++ ){ + cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] ); + } + + cfg.setGroup("ToolBar"); + cfg.writeEntry( "Position", m_barPos ); + + cfg.setGroup("Version"); + cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION); + cfg.writeEntry( "Mainversion", MAINVERSION ); + cfg.writeEntry( "SubVersion", SUBVERSION ); + cfg.writeEntry( "PatchVersion", PATCHVERSION ); + + } + +} + +void AbConfig::operator= ( const AbConfig& cnf ) +{ + m_useQtMail = cnf.m_useQtMail; + m_useOpieMail = cnf.m_useOpieMail; + m_useRegExp = cnf.m_useRegExp; + m_beCaseSensitive = cnf.m_beCaseSensitive; + m_fontSize = cnf.m_fontSize; + m_ordered = cnf.m_ordered; + +} + diff --git a/core/pim/addressbook/abconfig.h b/core/pim/addressbook/abconfig.h new file mode 100644 index 0000000..b8460d7 --- a/dev/null +++ b/core/pim/addressbook/abconfig.h @@ -0,0 +1,55 @@ +#ifndef _ABCONFIG_H_ +#define _ABCONFIG_H_ + +#include <qstringlist.h> +#include <qmainwindow.h> + +class AbConfig +{ +public: + AbConfig(); + ~AbConfig(); + + // Search Settings + bool useRegExp() const; + bool useWildCards() const; + bool beCaseSensitive() const; + bool useQtMail() const; + bool useOpieMail() const; + int fontSize() const; + QValueList<int> orderList() const; + QMainWindow::ToolBarDock getToolBarPos() const; + + void setUseRegExp( bool v ); + void setUseWildCards( bool v ); + void setBeCaseSensitive( bool v ); + void setUseQtMail( bool v ); + void setUseOpieMail( bool v ); + void setFontSize( int v ); + void setOrderList( const QValueList<int>& list ); + void setToolBarDock( const QMainWindow::ToolBarDock v ); + + void operator= ( const AbConfig& cnf ); + + void load(); + void save(); + +protected: +/* virtual void itemUp(); */ +/* virtual void itemDown(); */ + + QStringList contFields; + + bool m_useQtMail; + bool m_useOpieMail; + bool m_useRegExp; + bool m_beCaseSensitive; + int m_fontSize; + QValueList<int> m_ordered; + int m_barPos; + + bool m_changed; +}; + + +#endif diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp index ea80700..5b40dc1 100644 --- a/core/pim/addressbook/ablabel.cpp +++ b/core/pim/addressbook/ablabel.cpp @@ -27,4 +27,5 @@ -AbLabel::AbLabel( QWidget *parent, const char *name ) - : QTextView( parent, name ) +AbLabel::AbLabel( QWidget *parent, const char *name ): + QTextView( parent, name ), + m_empty( false ) { @@ -36,10 +37,44 @@ AbLabel::~AbLabel() -void AbLabel::init( const OContact &entry ) +void AbLabel::setContacts( const OContactAccess::List& viewList ) { - ent = entry; + m_viewList = viewList; + if (m_viewList.count() != 0){ + m_empty = false; + m_itCurContact = m_viewList.begin(); + sync(); + }else{ + // m_itCurContact.clear(); + m_empty = true; + setText( "" ); + } +} + +int AbLabel::currentEntry_UID() +{ + return ( (*m_itCurContact).uid() ); +} + +OContact AbLabel::currentEntry() +{ + return ( *m_itCurContact ); } + +bool AbLabel::selectContact( int UID ) +{ + + for ( m_itCurContact = m_viewList.begin(); m_itCurContact != m_viewList.end(); ++m_itCurContact){ + if ( (*m_itCurContact).uid() == UID ) + break; + } + sync(); + + return true; +} + + + void AbLabel::sync() { - QString text = ent.toRichText(); + QString text = (*m_itCurContact).toRichText(); setText( text ); @@ -50,38 +85,28 @@ void AbLabel::keyPressEvent( QKeyEvent *e ) // Commonly handled keys - switch( e->key() ) { - case Qt::Key_Left: - qWarning( "Left.."); - case Qt::Key_F33: - qWarning( "OK.."); - emit okPressed(); - break; - } - - - if ( /* m_inSearch */ false ) { - // Running in seach-mode, therefore we will interprete - // some key differently - qWarning("Received key in search mode"); + if ( !m_empty ){ switch( e->key() ) { - case Qt::Key_Up: - qWarning("a"); - // emit signalSearchBackward(); - break; - case Qt::Key_Down: - qWarning("b"); - // emit signalSearchNext(); + case Qt::Key_Left: + qWarning( "Left.."); + case Qt::Key_Right: + qWarning( "Right.."); + case Qt::Key_F33: + qWarning( "OK.."); + emit signalOkPressed(); break; - } - - } else { - qWarning("Received key in NON search mode"); - - switch( e->key() ) { case Qt::Key_Up: - qWarning("a"); - // emit signalSearchBackward(); + qWarning( "UP.."); + --m_itCurContact; + if ( *m_itCurContact != OContact() ) + sync(); + else + m_itCurContact = m_viewList.end(); + break; case Qt::Key_Down: - qWarning("b"); - // emit signalSearchNext(); + qWarning( "DOWN.."); + ++m_itCurContact; + if ( *m_itCurContact != OContact() ) + sync(); + else + m_itCurContact = m_viewList.begin(); break; @@ -89,2 +114,3 @@ void AbLabel::keyPressEvent( QKeyEvent *e ) } + } diff --git a/core/pim/addressbook/ablabel.h b/core/pim/addressbook/ablabel.h index 9086c4a..b1e35de 100644 --- a/core/pim/addressbook/ablabel.h +++ b/core/pim/addressbook/ablabel.h @@ -25,2 +25,4 @@ +#include <opie/ocontactaccess.h> + class AbLabel : public QTextView @@ -33,10 +35,19 @@ public: -public slots: - void init( const OContact &entry ); - void sync(); + // Set the contacts + void setContacts( const OContactAccess::List& viewList ); + + // Selects a contact + bool selectContact( int UID ); + + // Get the UID of the current selected Entry + int currentEntry_UID(); + + // + OContact currentEntry(); signals: - void okPressed(); + void signalOkPressed(); protected: + void sync(); void keyPressEvent( QKeyEvent * ); @@ -44,3 +55,6 @@ protected: private: - OContact ent; + OContactAccess::List m_viewList; + OContactAccess::List::Iterator m_itCurContact; + + bool m_empty; diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 5222f16..b8127e9 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp @@ -2,2 +2,3 @@ ** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) ** @@ -20,3 +21,2 @@ -#define QTOPIA_INTERNAL_CONTACT_MRE @@ -45,5 +45,2 @@ -static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); - - /*! @@ -122,17 +119,12 @@ void AbPickItem::setContentFromEditor( QWidget *w ) -AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) - // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR - // : QTable( 0, 0, parent, name, TRUE ), - // #else +AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) : QTable( parent, name ), - // #endif - lastSortCol( -1 ), - asc( TRUE ), - intFields( order ), - currFindRow( -1 ), - mCat( 0 ), - m_inSearch (false), - m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! + lastSortCol( -1 ), + asc( TRUE ), + intFields( order ), + enablePainting( true ), + columnVisible( true ) { - mCat.load( categoryFileName() ); + qWarning("C'tor start"); + setSelectionMode( NoSelection ); @@ -142,2 +134,5 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam this, SLOT(itemClicked(int,int)) ); + + contactList.clear(); + qWarning("C'tor end"); } @@ -150,3 +145,3 @@ void AbTable::init() { - showChar = '\0'; + // :SX showChar = '\0'; setNumRows( 0 ); @@ -161,2 +156,78 @@ void AbTable::init() +void AbTable::setContacts( const OContactAccess::List& viewList ) +{ + qWarning("AbTable::setContacts()"); + + clear(); + m_viewList = viewList; + + setSorting( false ); + setUpdatesEnabled( 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++ ); + + setUpdatesEnabled( TRUE ); + + setSorting( true ); + + resort(); + + updateVisible(); + +} + +bool AbTable::selectContact( int UID ) +{ + qWarning( "AbTable::selectContact( %d )", UID ); + int rows = numRows(); + AbTableItem *abi; + OContact* foundContact = 0l; + bool found = 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 ); + } + + return true; +} + +void AbTable::insertIntoTable( const OContact& cnt, int 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 ) @@ -181,2 +252,3 @@ void AbTable::resort() { + qWarning( "void AbTable::resort()" ); if ( sorting() ) { @@ -192,2 +264,3 @@ OContact AbTable::currentEntry() { + qWarning( "OContact AbTable::currentEntry()" ); OContact cnt; @@ -202,23 +275,5 @@ OContact AbTable::currentEntry() -void AbTable::replaceCurrentEntry( const OContact &newContact ) +int AbTable::currentEntry_UID() { - int row = currentRow(); - updateVisible(); - - journalFreeReplace( newContact, row ); - -} - -void AbTable::deleteCurrentEntry() -{ - int row = currentRow(); - - // a little wasteful, but it ensure's there is only one place - // where we delete. - journalFreeRemove( row ); - updateVisible(); - - if ( numRows() == 0 ) - emit empty( TRUE ); - + return ( currentEntry().uid() ); } @@ -227,2 +282,3 @@ void AbTable::clear() { + qWarning( "void AbTable::clear()" ); contactList.clear(); @@ -238,4 +294,6 @@ void AbTable::clear() +// Refresh updates column 2 if the contactsettings changed void AbTable::refresh() { + qWarning( "void AbTable::refresh()" ); int rows = numRows(); @@ -243,8 +301,3 @@ void AbTable::refresh() AbTableItem *abi; - - // hide columns so no flashing ? - if ( showBk == "Cards" ) { - hideColumn(0); - hideColumn(1); - } + for ( int r = 0; r < rows; ++r ) { @@ -264,37 +317,21 @@ void AbTable::keyPressEvent( QKeyEvent *e ) - if ( m_inSearch ) { - // Running in seach-mode, therefore we will interprete - // some key differently - qWarning("Received key in search mode"); - switch( e->key() ) { - case Qt::Key_Space: - case Qt::Key_Return: - case Qt::Key_Enter: - emit details(); - break; - case Qt::Key_Up: - qWarning("a"); - emit signalSearchBackward(); - break; - case Qt::Key_Down: - qWarning("b"); - emit signalSearchNext(); - break; - default: - QTable::keyPressEvent( e ); - } - - } else { - qWarning("Received key in NON search mode"); - - switch( e->key() ) { - case Qt::Key_Space: - case Qt::Key_Return: - case Qt::Key_Enter: - emit details(); - break; - default: - QTable::keyPressEvent( e ); - } + 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 ); } + } @@ -303,2 +340,3 @@ void AbTable::moveTo( char c ) { + qWarning( "void AbTable::moveTo( char c )" ); @@ -348,141 +386,3 @@ QString AbTable::findContactName( const OContact &entry ) -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(); - break; - case Qtopia::HomePhone: - value = entry.homePhone(); - break; - case Qtopia::HomeFax: - value = entry.homeFax(); - break; - case Qtopia::HomeMobile: - value = entry.homeMobile(); - break; - case Qtopia::HomeWebPage: - value = entry.homeWebpage(); - break; - case Qtopia::Company: - value = entry.company(); - break; - case Qtopia::BusinessCity: - value = entry.businessCity(); - break; - case Qtopia::BusinessStreet: - value = entry.businessStreet(); - break; - case Qtopia::BusinessZip: - value = entry.businessZip(); - break; - case Qtopia::BusinessCountry: - value = entry.businessCountry(); - break; - case Qtopia::BusinessWebPage: - value = entry.businessWebpage(); - break; - case Qtopia::JobTitle: - value = entry.jobTitle(); - break; - case Qtopia::Department: - value = entry.department(); - break; - case Qtopia::Office: - value = entry.office(); - break; - case Qtopia::BusinessPhone: - value = entry.businessPhone(); - break; - case Qtopia::BusinessFax: - value = entry.businessFax(); - break; - case Qtopia::BusinessMobile: - value = entry.businessMobile(); - break; - case Qtopia::BusinessPager: - value = entry.businessPager(); - break; - case Qtopia::Profession: - value = entry.profession(); - break; - case Qtopia::Assistant: - value = entry.assistant(); - break; - case Qtopia::Manager: - value = entry.manager(); - break; - case Qtopia::Spouse: - value = entry.spouse(); - break; - case Qtopia::Gender: - value = entry.gender(); - break; - case Qtopia::Birthday: - value = TimeString::numberDateString( entry.birthday() ); - break; - case Qtopia::Anniversary: - value = TimeString::numberDateString( entry.anniversary() ); - break; - case Qtopia::Nickname: - value = entry.nickname(); - break; - case Qtopia::Children: - value = entry.children(); - break; - case Qtopia::Notes: - value = entry.notes(); - break; - } - if ( !value.isEmpty() ) - break; - } - return value; -} -void AbTable::addEntry( const OContact &newCnt ) -{ - int row = numRows(); - - setNumRows( row + 1 ); - insertIntoTable( newCnt, row ); - - qWarning("abtable:AddContact"); - m_contactdb.add ( newCnt ); - - setCurrentCell( row, 0 ); - // updateVisible(); -} @@ -500,133 +400,17 @@ void AbTable::resizeRows() { -bool AbTable::save() -{ - // QTime t; - // t.start(); - qWarning("abtable:Save data"); - - return m_contactdb.save(); -} - -void AbTable::load() +void AbTable::realignTable() { - setSorting( false ); - setUpdatesEnabled( FALSE ); - - qWarning("abtable:Load data"); - - OContactAccess::List list = m_contactdb.allRecords(); - OContactAccess::List::Iterator it; - setNumRows( list.count() ); - int row = 0; - for ( it = list.begin(); it != list.end(); ++it ) - insertIntoTable( *it, row++ ); - - setUpdatesEnabled( TRUE ); + qWarning( "void AbTable::realignTable()" ); - setSorting( true ); - resort(); -} + setPaintingEnabled( FALSE ); + resizeRows(); + fitColumns(); -void AbTable::reload() -{ - m_contactdb.reload(); - load(); -} + setPaintingEnabled( TRUE ); -void AbTable::realignTable( int row ) -{ - QTableItem *ti1, - *ti2; - int totalRows = numRows(); - for ( int curr = row; curr < totalRows - 1; curr++ ) { - // the same info from the todo list still applies, but I - // don't think it is _too_ bad. - ti1 = item( curr + 1, 0 ); - ti2 = item( curr + 1, 1 ); - takeItem( ti1 ); - takeItem( ti2 ); - setItem( curr, 0, ti1 ); - setItem( curr, 1, ti2 ); - } - setNumRows( totalRows - 1 ); - resort(); } -// Add contact into table. -void AbTable::insertIntoTable( const OContact &cnt, int 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 ) ); - - // resort at some point? -} -// Replace or add an entry -void AbTable::journalFreeReplace( const OContact &cnt, int row ) -{ - QString strName, - strContact; - AbTableItem *ati = 0l; - - strName = findContactName( cnt ); - strContact = findContactContact( cnt, row ); - ati = static_cast<AbTableItem*>(item(row, 0)); - - // Replace element if found in row "row" - // or add this element if not. - if ( ati != 0 ) { // replace - // :SX db access -> replace - qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); - m_contactdb.replace ( cnt ); - - contactList.remove( ati ); - ati->setItem( strName, strContact ); - contactList.insert( ati, cnt ); - - ati = static_cast<AbTableItem*>(item(row, 1)); - ati->setItem( strContact, strName ); - - }else{ // add - int myrows = numRows(); - setNumRows( myrows + 1 ); - insertIntoTable( cnt, myrows ); - // gets deleted when returning -- Why ? (se) - // :SX db access -> add - qWarning ("Are you sure to add to database ? -> Currently disabled !!"); - // m_contactdb.add( cnt ); - } -} - -// Remove entry -void AbTable::journalFreeRemove( int row ) -{ - AbTableItem *ati; - ati = static_cast<AbTableItem*>(item(row, 0)); - if ( !ati ) - return; - - // :SX db access -> remove - qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); - m_contactdb.remove( contactList[ati].uid() ); - - contactList.remove( ati ); - - realignTable( row ); - -} @@ -664,117 +448,22 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) -void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool useRegExp, - bool backwards, QString cat /* int category */ ) -{ - int category = 0; - - // Use the current Category if nothing else selected - if ( cat.isEmpty() ) - category = mCat.id( "Contacts", showCat ); - else{ - category = mCat.id("Contacts", cat ); - } - - qWarning ("Found in Category %d", category); - - if ( currFindRow < -1 ) - currFindRow = - 1; - clearSelection( TRUE ); - int rows, row; - AbTableItem *ati; - QRegExp r( findString ); - r.setCaseSensitive( caseSensitive ); - r.setWildcard( !useRegExp ); - rows = numRows(); - static bool wrapAround = true; - bool try_again = false; - - // We will loop until we found an entry or found nothing. - do { - if ( !backwards ) { - for ( row = currFindRow + 1; row < rows; row++ ) { - ati = static_cast<AbTableItem*>( item(row, 0) ); - if ( contactCompare( contactList[ati], r, category ) ){ - try_again = false; - break; - } - } - } else { - for ( row = currFindRow - 1; row > -1; row-- ) { - ati = static_cast<AbTableItem*>( item(row, 0) ); - if ( contactCompare( contactList[ati], r, category ) ){ - try_again = false; - break; - } - } - } - if ( row >= rows || row < 0 ) { - if ( row < 0 ) - currFindRow = rows; - else - currFindRow = -1; - - if ( wrapAround ){ - emit signalWrapAround(); - try_again = true; - }else{ - emit signalNotFound(); - try_again = false; - } - - wrapAround = !wrapAround; - } else { - currFindRow = row; - QTableSelection foundSelection; - foundSelection.init( currFindRow, 0 ); - foundSelection.expandTo( currFindRow, numCols() - 1 ); - addSelection( foundSelection ); - setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); - wrapAround = true; - try_again = false; - } - } while ( try_again ); -} -static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) +void AbTable::fitColumns() { - bool returnMe; - QArray<int> cats; - cats = cnt.categories(); + qWarning( "void AbTable::fitColumns()" ); + int contentsWidth = visibleWidth() / 2; // :SX Why too low + // Fix to better value + // contentsWidth = 130; - returnMe = false; - if ( (cats.count() == 0) || (category == 0) ) - returnMe = cnt.match( r ); - else { - int i; - for ( i = 0; i < int(cats.count()); i++ ) { - if ( cats[i] == category ) { - returnMe = cnt.match( r ); - break; - } - } + if ( columnVisible == false ){ + showColumn(0); + columnVisible = true; } - return returnMe; -} + qWarning("Width: %d", contentsWidth); -void AbTable::fitColumns() -{ - int contentsWidth = visibleWidth() / 2; - - if ( showBk == "Cards" ) { - showColumn(1); - //adjustColumn(1); - setColumnWidth( 1, visibleWidth() ); - columnVisible = false; - } else { - if ( columnVisible == false ){ - showColumn(0); - columnVisible = true; - } - setColumnWidth( 0, contentsWidth ); - adjustColumn(1); - if ( columnWidth(1) < contentsWidth ) - setColumnWidth( 1, contentsWidth ); - } + setColumnWidth( 0, contentsWidth ); + adjustColumn(1); + if ( columnWidth(1) < contentsWidth ) + setColumnWidth( 1, contentsWidth ); } @@ -783,3 +472,4 @@ void AbTable::show() { - fitColumns(); + qWarning( "void AbTable::show()" ); + realignTable(); QTable::show(); @@ -804,2 +494,3 @@ void AbTable::itemClicked(int,int col) { + qWarning( "AbTable::itemClicked(int, col:%d)", col); if ( col == 2 ) { @@ -807,3 +498,4 @@ void AbTable::itemClicked(int,int col) } else { - emit details(); + qWarning ("Emitting signalSwitch()"); + emit signalSwitch(); } @@ -816,20 +508,5 @@ QStringList AbTable::choiceNames() const -void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) +void AbTable::setChoiceSelection( const QValueList<int>& list ) { - /* ###### - - QString selname = choicenames.at(index); - for (each row) { - OContact *c = contactForRow(row); - if ( list.contains(c->email) ) { - list.remove(c->email); - setText(row, 2, selname); - } - } - for (remaining list items) { - OContact *c = new contact(item); - setText(newrow, 2, selname); - } - - */ + intFields = list; } @@ -853,35 +530,4 @@ QStringList AbTable::choiceSelection(int /*index*/) const -void AbTable::setShowCategory( const QString &b, const QString &c ) -{ - showBk = b; - showCat = c; - //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); - //updateVisible(); - refresh(); - ensureCellVisible( currentRow(), 0 ); - updateVisible(); // :SX -} -void AbTable::setShowByLetter( char c ) -{ - showChar = tolower(c); - updateVisible(); -} -QString AbTable::showCategory() const -{ - return showCat; -} - -QString AbTable::showBook() const -{ - return showBk; -} - -QStringList AbTable::categories() -{ - mCat.load( categoryFileName() ); - QStringList categoryList = mCat.labels( "Contacts" ); - return categoryList; -} @@ -891,142 +537,25 @@ void AbTable::updateVisible() totalRows, - id, - totalCats, - it, - row; - bool hide; - AbTableItem *ati; - OContact *cnt; - QString fileAsName; - QString tmpStr; + row, + selectedRow = 0; + visible = 0; + realignTable(); + setPaintingEnabled( FALSE ); - + totalRows = numRows(); - id = mCat.id( "Contacts", showCat ); - QArray<int> cats; for ( row = 0; row < totalRows; row++ ) { - ati = static_cast<AbTableItem*>( item(row, 0) ); - cnt = &contactList[ati]; - cats = cnt->categories(); - fileAsName = cnt->fileAs(); - hide = false; - if ( !showCat.isEmpty() ) { - if ( showCat == tr( "Unfiled" ) ) { - if ( cats.count() > 0 ) - hide = true; - } else { - // do some comparing - if ( !hide ) { - hide = true; - totalCats = int(cats.count()); - for ( it = 0; it < totalCats; it++ ) { - if ( cats[it] == id ) { - hide = false; - break; - } - } - } - } - } - if ( showChar != '\0' ) { - tmpStr = fileAsName.left(1); - tmpStr = tmpStr.lower(); - if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) { - hide = true; - } - if ( showChar == '#' ) { - if (tmpStr == "a") - hide = true; - - if (tmpStr == "b") - hide = true; - - if (tmpStr == "c") - hide = true; - - if (tmpStr == "d") - hide = true; - - if (tmpStr == "e") - hide = true; - - if (tmpStr == "f") - hide = true; - - if (tmpStr == "g") - hide = true; - - if (tmpStr == "h") - hide = true; - - if (tmpStr == "i") - hide = true; - - if (tmpStr == "j") - hide = true; - - if (tmpStr == "k") - hide = true; - - if (tmpStr == "l") - hide = true; - - if (tmpStr == "m") - hide = true; - - if (tmpStr == "n") - hide = true; - - if (tmpStr == "o") - hide = true; - - if (tmpStr == "p") - hide = true; - - if (tmpStr == "q") - hide = true; - - if (tmpStr == "r") - hide = true; - - if (tmpStr == "s") - hide = true; - - if (tmpStr == "t") - hide = true; - - if (tmpStr == "u") - hide = true; - - if (tmpStr == "v") - hide = true; - - if (tmpStr == "w") - hide = true; - - if (tmpStr == "x") - hide = true; - - if (tmpStr == "y") - hide = true; - - if (tmpStr == "z") - hide = true; - } - - } - if ( hide ) { - if ( currentRow() == row ) - setCurrentCell( -1, 0 ); - if ( rowHeight(row) > 0 ) - hideRow( row ); - } else { - if ( rowHeight(row) == 0 ) { - showRow( row ); - adjustRow( row ); - } - visible++; + 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 ) @@ -1035,2 +564,4 @@ void AbTable::updateVisible() setPaintingEnabled( TRUE ); + + } @@ -1056 +587,126 @@ void AbTable::rowHeightChanged( int 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(); + break; + case Qtopia::HomePhone: + value = entry.homePhone(); + break; + case Qtopia::HomeFax: + value = entry.homeFax(); + break; + case Qtopia::HomeMobile: + value = entry.homeMobile(); + break; + case Qtopia::HomeWebPage: + value = entry.homeWebpage(); + break; + case Qtopia::Company: + value = entry.company(); + break; + case Qtopia::BusinessCity: + value = entry.businessCity(); + break; + case Qtopia::BusinessStreet: + value = entry.businessStreet(); + break; + case Qtopia::BusinessZip: + value = entry.businessZip(); + break; + case Qtopia::BusinessCountry: + value = entry.businessCountry(); + break; + case Qtopia::BusinessWebPage: + value = entry.businessWebpage(); + break; + case Qtopia::JobTitle: + value = entry.jobTitle(); + break; + case Qtopia::Department: + value = entry.department(); + break; + case Qtopia::Office: + value = entry.office(); + break; + case Qtopia::BusinessPhone: + value = entry.businessPhone(); + break; + case Qtopia::BusinessFax: + value = entry.businessFax(); + break; + case Qtopia::BusinessMobile: + value = entry.businessMobile(); + break; + case Qtopia::BusinessPager: + value = entry.businessPager(); + break; + case Qtopia::Profession: + value = entry.profession(); + break; + case Qtopia::Assistant: + value = entry.assistant(); + break; + case Qtopia::Manager: + value = entry.manager(); + break; + case Qtopia::Spouse: + value = entry.spouse(); + break; + case Qtopia::Gender: + value = entry.gender(); + break; + case Qtopia::Birthday: + value = TimeString::numberDateString( entry.birthday() ); + break; + case Qtopia::Anniversary: + value = TimeString::numberDateString( entry.anniversary() ); + break; + case Qtopia::Nickname: + value = entry.nickname(); + break; + case Qtopia::Children: + value = entry.children(); + break; + case Qtopia::Notes: + value = entry.notes(); + break; + } + if ( !value.isEmpty() ) + break; + } + return value; +} diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index 35a1e9e..83bd5a7 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h @@ -2,2 +2,3 @@ ** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) ** @@ -25,2 +26,3 @@ #include <opie/ocontact.h> +#include <opie/ocontactaccess.h> @@ -31,4 +33,2 @@ -#include <opie/ocontactaccess.h> - class AbTableItem : public QTableItem @@ -65,31 +65,21 @@ class AbTable : public QTable public: - AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); + AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 ); ~AbTable(); - // NEW - void addEntry( const OContact &newContact ); + + // Set the contacts shown in the table + void setContacts( const OContactAccess::List& viewList ); + // Selects a contact of a specific UID + bool selectContact( int UID ); + + // Get the current selected entry OContact currentEntry(); - void replaceCurrentEntry( const OContact &newContact ); - void init(); + // Get the UID of the current selected Entry + int currentEntry_UID(); + + QString findContactName( const OContact &entry ); - void deleteCurrentEntry(); + void init(); void clear(); - void clearFindRow() { currFindRow = -1; } - void loadFields(); void refresh(); - bool save(); - void load(); - void reload(); - - // addresspicker mode - void setChoiceNames( const QStringList& list); - QStringList choiceNames() const; - void setChoiceSelection(int index, const QStringList& list); - QStringList choiceSelection(int index) const; - void setShowCategory( const QString &b, const QString &c ); - void setShowByLetter( char c ); - QString showCategory() const; - QStringList categories(); - - void resizeRows(); @@ -98,17 +88,13 @@ public: - QString showBook() const; - - void inSearch() { m_inSearch = true; } - void offSearch() { m_inSearch = false; } + // addresspicker mode (What's that ? se) + void setChoiceNames( const QStringList& list); + QStringList choiceNames() const; + void setChoiceSelection( const QValueList<int>& list ); + QStringList choiceSelection(int index) const; -public slots: - void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, bool backwards, - QString category = QString::null ); signals: - void empty( bool ); - void details(); - void signalNotFound(); - void signalWrapAround(); - void signalSearchBackward(); // Signalled if backward search is requested - void signalSearchNext(); // Singalled if forward search is requested + void signalSwitch(); + void signalEditor(); + void signalKeyDown(); + void signalKeyUp(); @@ -129,31 +115,20 @@ protected slots: private: - void loadFile( const QString &strFile, bool journalFile ); + void insertIntoTable( const OContact &cnt, int row ); + QString findContactContact( const OContact &entry, int row ); void fitColumns(); + void resizeRows(); + void realignTable(); void resort(); - void updateJournal( const OContact &contact, OContact::journal_action action, - int row = -1 ); - void insertIntoTable( const OContact &contact, int row ); - QString findContactName( const OContact &entry ); - QString findContactContact( const OContact &entry, int row ); - void journalFreeReplace( const OContact &cnt, int row ); - void journalFreeRemove( int row ); - void realignTable( int ); void updateVisible(); + int lastSortCol; bool asc; - char showChar; QMap<AbTableItem*, OContact> contactList; - const QValueList<int> *intFields; - int currFindRow; - QString showCat; + QValueList<int> intFields; QStringList choicenames; bool enablePainting; - Categories mCat; - QString showBk; bool columnVisible; - bool m_inSearch; - - OContactAccess m_contactdb; + OContactAccess::List m_viewList; diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index d35e392..8d22129 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp @@ -2,2 +2,9 @@ +#include <qlayout.h> + +#include <qpe/global.h> + +#include <opie/ocontactaccessbackend_vcard.h> + + // Is defined in LibQPE @@ -5,5 +12,11 @@ extern QString categoryFileName(); -#include <qlayout.h> +QString addressbookPersonalVCardName() +{ + QString filename = Global::applicationFileName("addressbook", + "businesscard.vcf"); + return filename; +} -AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringList& slOrderedFields ): + +AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): QWidget(parent), @@ -11,3 +24,4 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL m_inSearch( false ), - m_curr_category( 0 ), + m_inPersonal( false ), + m_curr_category( -1 ), m_curr_View( TableView ), @@ -15,8 +29,10 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL m_curr_Contact ( 0 ), - m_contactdb ( "addressbook", 0l, 0l, false ), // Handle syncing myself.. ! + m_contactdb ( 0l ), + m_storedDB ( 0l ), m_viewStack( 0l ), m_abTable( 0l ), - m_orderedFields( ordered ), - m_slOrderedFields( slOrderedFields ) + m_orderedFields( ordered ) { + // Load default database and handle syncing myself.. ! + m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), mCat.load( categoryFileName() ); @@ -30,3 +46,3 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL QVBox* tableBox = new QVBox( m_viewStack ); - m_abTable = new AbTable( &m_orderedFields, tableBox, "table" ); + m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); m_abTable->setCurrentCell( 0, 0 ); @@ -51,2 +67,14 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL +AbView::~AbView() +{ + m_contactdb -> save(); + delete m_contactdb; + + if ( m_storedDB ){ + m_storedDB -> save(); + delete m_storedDB; + } +} + + void AbView::setView( Views view ) @@ -61,3 +89,3 @@ void AbView::addEntry( const OContact &newContact ) qWarning("abview:AddContact"); - m_contactdb.add ( newContact ); + m_contactdb->add ( newContact ); load(); @@ -68,3 +96,3 @@ void AbView::removeEntry( const int UID ) qWarning("abview:RemoveContact"); - m_contactdb.remove( UID ); + m_contactdb->remove( UID ); load(); @@ -75,3 +103,3 @@ void AbView::replaceEntry( const OContact &contact ) qWarning("abview:ReplaceContact"); - m_contactdb.replace( contact ); + m_contactdb->replace( contact ); load(); @@ -97,6 +125,5 @@ bool AbView::save() - return m_contactdb.save(); + return m_contactdb->save(); } -// :SX Add: Just load for specific Category void AbView::load() @@ -105,5 +132,11 @@ void AbView::load() - m_list = m_contactdb.allRecords(); + if ( m_inPersonal ) + m_list = m_contactdb->allRecords(); + else + m_list = m_contactdb->sorted( true, 0, 0, 0 ); + clearForCategory(); - m_curr_Contact = 0; + + // Feed all views with new lists + updateListinViews(); @@ -117,3 +150,5 @@ void AbView::reload() { - m_contactdb.reload(); + qWarning( "void AbView::reload()" ); + + m_contactdb->reload(); load(); @@ -129,14 +164,39 @@ void AbView::setShowByCategory( Views view, const QString& cat ) qWarning("AbView::setShowCategory( Views view, const QString& cat )"); - m_curr_View = view; - emit signalClearLetterPicker(); +// if ( view == PersonalView ){ +// if ( ! m_inPersonal ) +// showPersonal( true ); + +// }else{ +// if ( m_inPersonal ) +// showPersonal( false ); - if ( !cat.isNull() ) - m_curr_category = mCat.id("Contacts", cat ); +// m_curr_View = view; +// } + + int intCat = 0; + + // All (cat == NULL) will be stored as -1 + if ( cat.isNull() ) + intCat = -1; else - m_curr_category = -1; // Set to all + intCat = mCat.id("Contacts", cat ); - qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); + // If we just change the view, we don't have to reload any data.. + // This speeds up a lot of things ! + if ( intCat == m_curr_category ){ + qWarning ("Just change the View (Category is: %d)", m_curr_category); + m_prev_View = m_curr_View; + m_curr_View = view; - load(); + updateView(); + }else{ + qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); + + m_curr_View = view; + m_curr_category = intCat; + emit signalClearLetterPicker(); + + load(); + } @@ -152,3 +212,3 @@ void AbView::setShowByLetter( char c ) query.setLastName( QString("%1*").arg(c) ); - m_list = m_contactdb.queryByExample( query, OContactAccess::WildCards ); + m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards ); clearForCategory(); @@ -159,2 +219,9 @@ void AbView::setShowByLetter( char c ) +void AbView::setListOrder( const QValueList<int>& ordered ) +{ + m_orderedFields = ordered; + updateView(); +} + + QString AbView::showCategory() const @@ -164,6 +231,40 @@ QString AbView::showCategory() const -void AbView::showContact( const OContact& cnt ) +void AbView::showPersonal( bool personal ) { - qWarning ("void AbView::showContact( const OContact& cnt )"); - // :SX + 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(); } @@ -182,4 +283,7 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, qWarning( "void AbView::slotDoFind" ); - // Use the current Category if nothing else selected + // We reloading the data: Deselect Letterpicker + emit signalClearLetterPicker(); + + // Use the current Category if nothing else selected int category = 0; @@ -199,3 +303,3 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, // Get all matching entries out of the database - m_list = m_contactdb.matchRegexp( r ); + m_list = m_contactdb->matchRegexp( r ); @@ -247,5 +351,6 @@ void AbView::clearForCategory() // Now remove all contacts with wrong category if any category selected - // This algorithm is a litte bit ineffective + + OContactAccess::List allList = m_list; if ( m_curr_category != -1 ){ - for ( it = m_list.begin(); it != m_list.end(); ++it ){ + for ( it = allList.begin(); it != allList.end(); ++it ){ if ( !contactCompare( *it, m_curr_category ) ){ @@ -253,3 +358,2 @@ void AbView::clearForCategory() m_list.remove( (*it).uid() ); - it = m_list.begin(); } @@ -257,2 +361,3 @@ void AbView::clearForCategory() } + } @@ -270,3 +375,4 @@ bool AbView::contactCompare( const OContact &cnt, int category ) returnMe = false; - if ( cats.count() == 0 ) + if ( cats.count() == 0 && category == 0 ) + // Contacts with no category will just shown on "All" and "Unfiled" returnMe = true; @@ -286,2 +392,9 @@ bool AbView::contactCompare( const OContact &cnt, int category ) +// 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() @@ -295,3 +408,3 @@ void AbView::updateView() // If we switching the view, we have to store some information - if ( m_prev_View != m_curr_View ){ + if ( m_list.count() ){ switch ( (int) m_prev_View ) { @@ -304,3 +417,5 @@ void AbView::updateView() } - } + emit signalViewSwitched ( (int) m_curr_View ); + }else + m_curr_Contact = 0; @@ -311,2 +426,3 @@ void AbView::updateView() case TableView: + m_abTable -> setChoiceSelection( m_orderedFields ); m_abTable -> setContacts( m_list ); @@ -315,3 +431,2 @@ void AbView::updateView() m_abTable -> setFocus(); - emit signalViewSwitched ( (int) m_curr_View ); break; @@ -322,3 +437,2 @@ void AbView::updateView() m_ablabel -> setFocus(); - emit signalViewSwitched ( (int) m_curr_View ); break; diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h index 4d35338..201b521 100644 --- a/core/pim/addressbook/abview.h +++ b/core/pim/addressbook/abview.h @@ -19,5 +19,6 @@ class AbView: public QWidget public: - enum Views{ TableView=0, CardView, PhoneBook, CompanyBook, EmailBook }; + enum Views{ TableView=0, CardView, PersonalView }; - AbView( QWidget* parent, const QValueList<int>& ordered, const QStringList& slOrderedFields ); + AbView( QWidget* parent, const QValueList<int>& ordered ); + ~AbView(); @@ -29,5 +30,7 @@ public: void setView( Views view ); - void showContact( const OContact& cnt ); + void showPersonal( bool personal ); void setShowByCategory( Views view, const QString& cat ); void setShowByLetter( char c ); + void setListOrder( const QValueList<int>& ordered ); + // Add Entry and put to current @@ -55,2 +58,3 @@ public slots: private: + void updateListinViews(); void updateView(); @@ -63,2 +67,3 @@ private: bool m_inSearch; + bool m_inPersonal; int m_curr_category; @@ -68,3 +73,4 @@ private: - OContactAccess m_contactdb; + OContactAccess* m_contactdb; + OContactAccess* m_storedDB; OContactAccess::List m_list; @@ -76,3 +82,2 @@ private: QValueList<int> m_orderedFields; - QStringList m_slOrderedFields; }; diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 108e66d..e5addec 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp @@ -24,4 +24,5 @@ #include "ablabel.h" +#include "abview.h" #include "abtable.h" -#include "addresssettings.h" +// #include "addresssettings.h" #include "addressbook.h" @@ -31,7 +32,5 @@ #include <opie/ofiledialog.h> -#include <qpe/qpeapplication.h> -#include <qpe/config.h> #include <opie/ocontact.h> +#include <opie/ocontactaccessbackend_vcard.h> -#include <qpe/global.h> #include <qpe/resource.h> @@ -40,2 +39,8 @@ #include <qpe/qcopenvelope_qws.h> +#include <qpe/qpetoolbar.h> +#include <qpe/qpemenubar.h> +// #include <qtoolbar.h> +// #include <qmenubar.h> +#include <qpe/qpeapplication.h> +#include <qpe/config.h> @@ -47,3 +52,2 @@ #include <qlayout.h> -#include <qpe/qpemenubar.h> #include <qmessagebox.h> @@ -51,3 +55,2 @@ #include <qpopupmenu.h> -#include <qpe/qpetoolbar.h> #include <qstringlist.h> @@ -55,2 +58,3 @@ #include <qwhatsthis.h> +#include <qdatetime.h> @@ -62,3 +66,2 @@ -#include <qdatetime.h> @@ -67,9 +70,3 @@ -static QString addressbookPersonalVCardName() -{ - QString filename = Global::applicationFileName("addressbook", - "businesscard.vcf"); - return filename; -} - +extern QString addressbookPersonalVCardName(); @@ -78,10 +75,7 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, : QMainWindow( parent, name, f ), - abEditor(0), - useRegExp(false), - doNotifyWrapAround(true), - caseSensitive(false), - m_useQtMail(true), - m_useOpieMail(false), - bAbEditFirstTime(TRUE), - syncing(FALSE) + catMenu (0l), + abEditor(0l), + syncing(FALSE), + m_tableViewButton(0l), + m_cardViewButton(0l) { @@ -89,34 +83,38 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - // Read Config settings - Config cfg("AddressBook"); - cfg.setGroup("Search"); - useRegExp = cfg.readBoolEntry( "useRegExp" ); - caseSensitive = cfg.readBoolEntry( "caseSensitive" ); - doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" ); - cfg.setGroup("Mail"); - m_useQtMail = cfg.readBoolEntry( "useQtMail", true ); - m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); - + m_config.load(); - initFields(); - setCaption( tr("Contacts") ); setIcon( Resource::loadPixmap( "AddressBook" ) ); + + // Settings for Main Menu + setToolBarsMovable( true ); + setRightJustification( true ); - setToolBarsMovable( FALSE ); - - // Create Toolbars - - QPEToolBar *bar = new QPEToolBar( this ); - bar->setHorizontalStretchable( TRUE ); + // Create Toolbar + listTools = new QPEToolBar( this, "list operations" ); + listTools->setHorizontalStretchable( true ); + addToolBar( listTools ); + moveToolBar( listTools, m_config.getToolBarPos() ); - QPEMenuBar *mbList = new QPEMenuBar( bar ); + QPEMenuBar *mbList = new QPEMenuBar( this ); mbList->setMargin( 0 ); - QPopupMenu *edit = new QPopupMenu( this ); + QPopupMenu *edit = new QPopupMenu( mbList ); mbList->insertItem( tr( "Contact" ), edit ); - listTools = new QPEToolBar( this, "list operations" ); - + // View Icons + m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "datebook/weeklst" ), + QString::null, 0, this, 0 ); + connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); + m_tableViewButton->setToggleAction( true ); + m_tableViewButton->addTo( listTools ); + m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); + connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); + m_cardViewButton->setToggleAction( true ); + m_cardViewButton->addTo( listTools ); + + listTools->addSeparator(); + + // Other Buttons QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, @@ -163,4 +161,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, searchEdit = new QLineEdit( searchBar, "searchEdit" ); -// QFont f("unifont", 16 /*, QFont::Bold*/); -// searchEdit->setFont( f ); + +// QFont f("unifont", 16 /*, QFont::Bold*/); +// searchEdit->setFont( f ); + searchBar->setStretchableWidget( searchEdit ); @@ -169,4 +169,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); + a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); a->addTo( searchBar ); @@ -185,4 +185,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - - if ( Ir::supported() ) { @@ -198,3 +196,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); + a = new QAction( tr("Import vCard"), QString::null, 0, 0); actionPersonal = a; @@ -210,7 +208,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - // Do we need this function ? (se) -// a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); -// connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); -// a->addTo( edit ); - @@ -230,25 +223,23 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, listContainer = new QWidget( this ); - QVBoxLayout *vb = new QVBoxLayout( listContainer ); - abList = new AbTable( &orderedFields, listContainer, "table" ); - vb->addWidget(abList); + m_abView = new AbView( listContainer, m_config.orderList() ); + vb->addWidget( m_abView ); // abList->setHScrollBarMode( QScrollView::AlwaysOff ); - connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); - connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); - connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) ); - connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) ); - connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) ); - - // Maybe we should react on Wraparound and notfound ? - QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); - QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) ); + connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), + this, SLOT( slotViewSwitched( int ) ) ); + - mView = 0; + QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); - abList->load(); + m_abView->load(); + // Letter Picker pLabel = new LetterPicker( listContainer ); connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); - vb->addWidget(pLabel); + connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); + + vb->addWidget( pLabel ); + + // Category Menu catMenu = new QPopupMenu( this ); @@ -257,19 +248,8 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, populateCategories(); - mbList->insertItem( tr("View"), catMenu ); - // setCentralWidget( listContainer ); - fontMenu = new QPopupMenu(this); - fontMenu->setCheckable( true ); - connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); + defaultFont = new QFont( m_abView->font() ); + slotSetFont(m_config.fontSize()); + m_curFontSize = m_config.fontSize(); - fontMenu->insertItem(tr( "Small" ), 0); - fontMenu->insertItem(tr( "Normal" ), 1); - fontMenu->insertItem(tr( "Large" ), 2); - - defaultFont = new QFont( abList->font() ); - - slotSetFont(startFontSize); - - mbList->insertItem( tr("Font"), fontMenu); setCentralWidget(listContainer); @@ -278,3 +258,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - abList->setCurrentCell( 0, 0 ); @@ -287,7 +266,3 @@ void AddressbookWindow::slotConfig() ConfigDlg* dlg = new ConfigDlg( this, "Config" ); - dlg -> setUseRegExp ( useRegExp ); - dlg -> setBeCaseSensitive( caseSensitive ); - dlg -> setSignalWrapAround( doNotifyWrapAround ); - dlg -> setQtMail ( m_useQtMail ); - dlg -> setOpieMail ( m_useOpieMail ); + dlg -> setConfig( m_config ); dlg -> showMaximized(); @@ -295,7 +270,9 @@ void AddressbookWindow::slotConfig() qWarning ("Config Dialog accepted !"); - useRegExp = dlg -> useRegExp(); - caseSensitive = dlg -> beCaseSensitive(); - doNotifyWrapAround = dlg -> signalWrapAround(); - m_useQtMail = dlg -> useQtMail(); - m_useOpieMail= dlg -> useOpieMail(); + m_config = dlg -> getConfig(); + if ( m_curFontSize != m_config.fontSize() ){ + qWarning("Font was changed!"); + m_curFontSize = m_config.fontSize(); + emit slotSetFont( m_curFontSize ); + } + m_abView -> setListOrder( m_config.orderList() ); } @@ -306,3 +283,5 @@ void AddressbookWindow::slotConfig() -void AddressbookWindow::slotSetFont( int size ) { +void AddressbookWindow::slotSetFont( int size ) +{ + qWarning("void AddressbookWindow::slotSetFont( %d )", size); @@ -311,3 +290,3 @@ void AddressbookWindow::slotSetFont( int size ) { - startFontSize = size; + m_config.setFontSize( size ); @@ -317,27 +296,18 @@ void AddressbookWindow::slotSetFont( int size ) { case 0: - fontMenu->setItemChecked(0, true); - fontMenu->setItemChecked(1, false); - fontMenu->setItemChecked(2, false); - abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); - currentFont = new QFont (abList->font()); - // abList->resizeRows(currentFont->pixelSize() + 7); - abList->resizeRows(); + m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); + currentFont = new QFont (m_abView->font()); + // abList->resizeRows(currentFont->pixelSize() + 7); :SX + // abList->resizeRows(); break; case 1: - fontMenu->setItemChecked(0, false); - fontMenu->setItemChecked(1, true); - fontMenu->setItemChecked(2, false); - abList->setFont( *defaultFont ); - currentFont = new QFont (abList->font()); - // abList->resizeRows(currentFont->pixelSize() + 7); - abList->resizeRows(); + m_abView->setFont( *defaultFont ); + currentFont = new QFont (m_abView->font()); +// // abList->resizeRows(currentFont->pixelSize() + 7); +// abList->resizeRows(); break; case 2: - fontMenu->setItemChecked(0, false); - fontMenu->setItemChecked(1, false); - fontMenu->setItemChecked(2, true); - abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); - currentFont = new QFont (abList->font()); - //abList->resizeRows(currentFont->pixelSize() + 7); - abList->resizeRows(); + m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); + currentFont = new QFont (m_abView->font()); +// //abList->resizeRows(currentFont->pixelSize() + 7); +// abList->resizeRows(); break; @@ -350,4 +320,5 @@ void AddressbookWindow::importvCard() { QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); - if(!str.isEmpty() ) + if(!str.isEmpty() ){ setDocument((const QString&) str ); + } @@ -357,15 +328,36 @@ void AddressbookWindow::setDocument( const QString &filename ) { - if ( filename.find(".vcf") != int(filename.length()) - 4 ) - return; - - QValueList<OContact> cl = OContact::readVCard( filename ); - for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { - // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") - // .arg( (*it).fullName() ); - // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == - // QMessageBox::Ok ) { - abList->addEntry( *it ); - // } + qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); + + if ( filename.find(".vcf") != int(filename.length()) - 4 ){ + + + + switch( QMessageBox::information( this, tr ( "Right file type ?" ), + tr( "The selected File" ) + ( "\n" ) + + tr ("does not end with \".vcf\" ") + ( "\n" ) + + tr ( "Do you really want to open it?" ), + tr( "&Yes" ), tr( "&No" ), QString::null, + 0, // Enter == button 0 + 2 ) ) { // Escape == button 2 + case 0: + qWarning("YES clicked"); + break; + case 1: + qWarning("NO clicked"); + return; + break; + } + } + + OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, + filename ); + OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); + OContactAccess::List allList = access->allRecords(); + + OContactAccess::List::Iterator it; + for ( it = allList.begin(); it != allList.end(); ++it ){ + m_abView->addEntry( *it ); } + delete access; } @@ -376,6 +368,3 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e ) - if ( centralWidget() == listContainer ) - showList(); - else if ( centralWidget() == mView ) - showView(); + } @@ -384,13 +373,8 @@ AddressbookWindow::~AddressbookWindow() { - Config cfg("AddressBook"); - cfg.setGroup("Font"); - cfg.writeEntry("fontSize", startFontSize); - - cfg.setGroup("Search"); - cfg.writeEntry("useRegExp", useRegExp); - cfg.writeEntry("caseSensitive", caseSensitive); - cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround); - cfg.setGroup("Mail"); - cfg.writeEntry( "useQtMail", m_useQtMail ); - cfg.writeEntry( "useOpieMail", m_useOpieMail); + ToolBarDock dock; + int dummy; + bool bDummy; + getLocation ( listTools, dock, dummy, bDummy, dummy ); + m_config.setToolBarDock( dock ); + m_config.save(); } @@ -399,3 +383,3 @@ void AddressbookWindow::slotUpdateToolbar() { - OContact ce = abList->currentEntry(); + OContact ce = m_abView->currentEntry(); actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); @@ -403,34 +387,2 @@ void AddressbookWindow::slotUpdateToolbar() -void AddressbookWindow::showList() -{ - bool visiblemView; - - visiblemView = false; - if ( mView ) { - mView->hide(); - visiblemView = true; - } - setCentralWidget( listContainer ); - listContainer->show(); - // update our focues... (or use a stack widget!); - abList->setFocus(); - - // This makes sure we are scrolled all the way to the left - abList->setContentsPos( 0, abList->contentsY() ); - - //if ( visiblemView && abList->showBook() == "Cards" ) - // abList->setShowCategory( abList->showBook(), abList->showCategory() ); - -} - -void AddressbookWindow::showView() -{ - if ( abList->numRows() > 0 ) { - listContainer->hide(); - setCentralWidget( abView() ); - mView->show(); - mView->setFocus(); - } -} - void AddressbookWindow::slotListNew() @@ -439,5 +391,2 @@ void AddressbookWindow::slotListNew() if( !syncing ) { - if ( abEditor ) - abEditor->setEntry( cnt ); - abView()->init( cnt ); editEntry( NewEntry ); @@ -449,8 +398,8 @@ void AddressbookWindow::slotListNew() -void AddressbookWindow::slotListView() -{ - abView()->init( abList->currentEntry() ); - mView->sync(); - showView(); -} +// void AddressbookWindow::slotListView() +// { +// m_abView -> init( abList->currentEntry() ); +// // :SX mView->sync(); +// //:SX showView(); +// } @@ -459,3 +408,3 @@ void AddressbookWindow::slotListDelete() if(!syncing) { - OContact tmpEntry = abList->currentEntry(); + OContact tmpEntry = m_abView ->currentEntry(); @@ -472,4 +421,3 @@ void AddressbookWindow::slotListDelete() strName ) ) { - abList->deleteCurrentEntry(); - showList(); + m_abView->removeEntry( tmpEntry.uid() ); } @@ -481,5 +429,28 @@ void AddressbookWindow::slotListDelete() +void AddressbookWindow::slotFindOpen() +{ + searchBar->show(); + m_abView -> inSearch(); + searchEdit->setFocus(); +} +void AddressbookWindow::slotFindClose() +{ + searchBar->hide(); + m_abView -> offSearch(); + // m_abView->setFocus(); +} + + +void AddressbookWindow::slotFind() +{ + m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); + + searchEdit->clearFocus(); + // m_abView->setFocus(); + +} + void AddressbookWindow::slotViewBack() { - showList(); + // :SX showList(); } @@ -492,4 +463,2 @@ void AddressbookWindow::slotViewEdit() } else { - if ( !bAbEditFirstTime ) - abEditor->setEntry( abList->currentEntry() ); editEntry( EditEntry ); @@ -506,3 +475,3 @@ void AddressbookWindow::writeMail() { - OContact c = abList->currentEntry(); + OContact c = m_abView -> currentEntry(); QString name = c.fileAs(); @@ -518,3 +487,3 @@ void AddressbookWindow::writeMail() // switch to the other one.. - if ( m_useQtMail ){ + if ( m_config.useQtMail() ){ qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); @@ -526,5 +495,5 @@ void AddressbookWindow::writeMail() } else - m_useOpieMail = true; + m_config.setUseOpieMail( true ); } - if ( m_useOpieMail ){ + if ( m_config.useOpieMail() ){ qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); @@ -536,3 +505,3 @@ void AddressbookWindow::writeMail() } else - m_useQtMail = true; + m_config.setUseQtMail( true ); } @@ -551,10 +520,25 @@ void AddressbookWindow::slotBeam() return; // can't beam a non-existent file - c = OContact::readVCard( filename )[0]; + OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, + filename ); + OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); + OContactAccess::List allList = access->allRecords(); + OContactAccess::List::Iterator it = allList.begin(); // Just take first + c = *it; + + delete access; } else { unlink( beamfile ); // delete if exists - c = abList->currentEntry(); mkdir("/tmp/obex/", 0755); - OContact::writeVCard( beamfile, c ); + c = m_abView -> currentEntry(); + OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, + beamfile ); + OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); + access->add( c ); + access->save(); + delete access; + filename = beamfile; } + + Ir *ir = new Ir( this ); @@ -623,11 +607,6 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) - if ( bAbEditFirstTime ) { - abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, - this, "editor" ); - bAbEditFirstTime = FALSE; - } else { - abEditor->setEntry( cnt ); - } - abView()->init( cnt ); - editEntry( NewEntry ); + m_abView -> addEntry( cnt ); + + // :SXm_abView()->init( cnt ); + editEntry( EditEntry ); @@ -668,23 +647,18 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) -void AddressbookWindow::editPersonal() +void AddressbookWindow::editEntry( EntryMode entryMode ) { - QString filename = addressbookPersonalVCardName(); - OContact me; - if (QFile::exists(filename)) - me = OContact::readVCard( filename )[0]; - if (bAbEditFirstTime) { - qWarning("Editing personal data"); - abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, - this, "editor" ); - // don't create a new editor every time - bAbEditFirstTime = FALSE; - } else{ - abEditor->setEntry( me ); + OContact entry; + if ( !abEditor ) { + abEditor = new ContactEditor( entry, this, "editor" ); } - - abEditor->setPersonalView( true ); + if ( entryMode == EditEntry ) + abEditor->setEntry( m_abView -> currentEntry() ); + else if ( entryMode == NewEntry ) + abEditor->setEntry( entry ); + // other things may chane the caption. + abEditor->setCaption( tr("Edit Address") ); - abEditor->setCaption(tr("Edit My Personal Details")); +#if defined(Q_WS_QWS) || defined(_WS_QWS_) abEditor->showMaximized(); - +#endif // fix the foxus... @@ -693,12 +667,34 @@ void AddressbookWindow::editPersonal() setFocus(); - OContact new_personal = abEditor->entry(); - QString fname = addressbookPersonalVCardName(); - OContact::writeVCard( fname, new_personal ); - abView()->init(new_personal); - abView()->sync(); + if ( entryMode == NewEntry ) { + OContact insertEntry = abEditor->entry(); + insertEntry.assignUid(); + m_abView -> addEntry( insertEntry ); + } else { + OContact replEntry = abEditor->entry(); + + if ( !replEntry.isValidUid() ) + replEntry.assignUid(); + + m_abView -> replaceEntry( replEntry ); + } } - abEditor->setCaption( tr("Edit Address") ); - abEditor->setPersonalView( false ); + // populateCategories(); + +} + +void AddressbookWindow::editPersonal() +{ + OContact entry; + if ( !abEditor ) { + abEditor = new ContactEditor( entry, this, "editor" ); + } + + abEditor->setCaption(tr("Edit My Personal Details")); + abEditor->setPersonalView( true ); + editEntry( EditEntry ); + abEditor->setPersonalView( false ); + } + void AddressbookWindow::slotPersonalView() @@ -711,4 +707,7 @@ void AddressbookWindow::slotPersonalView() actionFind->setEnabled(TRUE); - slotUpdateToolbar(); // maybe some of the above could be moved there - showList(); + actionMail->setEnabled(TRUE); + // slotUpdateToolbar(); + + m_abView->showPersonal( false ); + return; @@ -719,5 +718,3 @@ void AddressbookWindow::slotPersonalView() actionTrash->setEnabled(FALSE); -#ifndef MAKE_FOR_SHARP_ROM actionFind->setEnabled(FALSE); -#endif actionMail->setEnabled(FALSE); @@ -725,50 +722,8 @@ void AddressbookWindow::slotPersonalView() setCaption( tr("Contacts - My Personal Details") ); - QString filename = addressbookPersonalVCardName(); - OContact me; - if (QFile::exists(filename)) - me = OContact::readVCard( filename )[0]; - - abView()->init( me ); - abView()->sync(); - listContainer->hide(); - setCentralWidget( abView() ); - mView->show(); - mView->setFocus(); -} -void AddressbookWindow::editEntry( EntryMode entryMode ) -{ - OContact entry; - if ( bAbEditFirstTime ) { - abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, - this, "editor" ); - bAbEditFirstTime = FALSE; - if ( entryMode == EditEntry ) - abEditor->setEntry( abList->currentEntry() ); - } - // other things may chane the caption. - abEditor->setCaption( tr("Edit Address") ); + m_abView->showPersonal( true ); -#if defined(Q_WS_QWS) || defined(_WS_QWS_) - abEditor->showMaximized(); -#endif - // fix the foxus... - abEditor->setNameFocus(); - if ( abEditor->exec() ) { - setFocus(); - if ( entryMode == NewEntry ) { - OContact insertEntry = abEditor->entry(); - insertEntry.assignUid(); - abList->addEntry( insertEntry ); - } else { - OContact replaceEntry = abEditor->entry(); - if ( !replaceEntry.isValidUid() ) - replaceEntry.assignUid(); - abList->replaceCurrentEntry( replaceEntry ); - } - } - populateCategories(); - showList(); } + void AddressbookWindow::listIsEmpty( bool empty ) @@ -783,4 +738,4 @@ void AddressbookWindow::reload() syncing = FALSE; - abList->clear(); - abList->reload(); + m_abView->clear(); + m_abView->reload(); } @@ -790,3 +745,3 @@ void AddressbookWindow::flush() syncing = TRUE; - abList->save(); + m_abView->save(); } @@ -796,13 +751,2 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) { - if ( centralWidget() == mView ) { - if (actionPersonal->isOn()) { - // pretend we clicked it off - actionPersonal->setOn(FALSE); - slotPersonalView(); - } else { - showList(); - } - e->ignore(); - return; - } @@ -830,3 +774,3 @@ bool AddressbookWindow::save() { - if ( !abList->save() ) { + if ( !m_abView->save() ) { if ( QMessageBox::critical( 0, tr( "Out of space" ), @@ -853,169 +797,2 @@ void AddressbookWindow::slotSave() -void AddressbookWindow::slotSettings() -{ - AddressSettings frmSettings( this ); -#if defined(Q_WS_QWS) || defined(_WS_QWS_) - frmSettings.showMaximized(); -#endif - - if ( frmSettings.exec() ) { - allFields.clear(); - orderedFields.clear(); - slOrderedFields.clear(); - initFields(); - if ( abEditor ) - abEditor->loadFields(); - abList->refresh(); - } -} - - -void AddressbookWindow::initFields() -{ - // we really don't need the things from the configuration, anymore - // only thing that is important are the important categories. So, - // Call the contact functions that correspond to these old functions... - - QStringList xmlFields = OContact::fields(); - QStringList visibleFields = OContact::untrfields(); - // QStringList trFields = OContact::trfields(); - - xmlFields.remove( "Title" ); - visibleFields.remove( "Name Title" ); - visibleFields.remove( "Notes" ); - - int i, version; - Config cfg( "AddressBook" ); - QString zn; - - // ### Write a function to keep this from happening again... - QStringList::ConstIterator it; - for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { - allFields.append( i + 3 ); - } - - cfg.setGroup( "Version" ); - version = cfg.readNumEntry( "version" ); - i = 0; - startFontSize = 1; - - if ( version >= ADDRESSVERSION ) { - - cfg.setGroup( "ImportantCategory" ); - - zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); - while ( !zn.isNull() ) { - if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) { - slOrderedFields.clear(); - break; - } - slOrderedFields.append( zn ); - zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); - } - cfg.setGroup( "Font" ); - startFontSize = cfg.readNumEntry( "fontSize", 1 ); - - - } else { - QString str; - str = getenv("HOME"); - str += "/Settings/AddressBook.conf"; - QFile::remove( str ); - } - - if ( slOrderedFields.count() > 0 ) { - for( QStringList::ConstIterator it = slOrderedFields.begin(); - it != slOrderedFields.end(); ++it ) { - QValueList<int>::ConstIterator itVl; - QStringList::ConstIterator itVis; - itVl = allFields.begin(); - for ( itVis = visibleFields.begin(); - itVis != visibleFields.end() && itVl != allFields.end(); - ++itVis, ++itVl ) { - if ( *it == *itVis && itVl != allFields.end() ) { - orderedFields.append( *itVl ); - } - } - } - } else { - QValueList<int>::ConstIterator it; - for ( it = allFields.begin(); it != allFields.end(); ++it ) - orderedFields.append( *it ); - - slOrderedFields = visibleFields; - orderedFields.remove( Qtopia::AddressUid ); - orderedFields.remove( Qtopia::Title ); - orderedFields.remove( Qtopia::Groups ); - orderedFields.remove( Qtopia::AddressCategory ); - orderedFields.remove( Qtopia::FirstName ); - orderedFields.remove( Qtopia::LastName ); - orderedFields.remove( Qtopia::DefaultEmail ); - orderedFields.remove( Qtopia::FileAs ); - orderedFields.remove( Qtopia::Notes ); - orderedFields.remove( Qtopia::Gender ); - slOrderedFields.remove( "Name Title" ); - slOrderedFields.remove( "First Name" ); - slOrderedFields.remove( "Last Name" ); - slOrderedFields.remove( "File As" ); - slOrderedFields.remove( "Default Email" ); - slOrderedFields.remove( "Notes" ); - slOrderedFields.remove( "Gender" ); - - } -} - - -AbLabel *AddressbookWindow::abView() -{ - if ( !mView ) { - mView = new AbLabel( this, "viewer" ); - mView->init( OContact() ); - connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); - } - return mView; -} - -void AddressbookWindow::slotFindOpen() -{ - searchBar->show(); - abList -> inSearch(); - searchEdit->setFocus(); -} -void AddressbookWindow::slotFindClose() -{ - searchBar->hide(); - abList -> offSearch(); - abList->setFocus(); -} -void AddressbookWindow::slotFindNext() -{ - if ( centralWidget() == abView() ) - showList(); - - abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false); - - searchEdit->clearFocus(); - abList->setFocus(); - if ( abList->numSelections() ) - abList->clearSelection(); - -} -void AddressbookWindow::slotFindPrevious() -{ - if ( centralWidget() == abView() ) - showList(); - - abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true); - - if ( abList->numSelections() ) - abList->clearSelection(); - -} - -void AddressbookWindow::slotFind() -{ - - abList->clearFindRow(); - slotFindNext(); -} @@ -1033,5 +810,5 @@ void AddressbookWindow::slotWrapAround() qWarning("Got wrap signal !"); - if ( doNotifyWrapAround ) - QMessageBox::information( this, tr( "End of list" ), - tr( "End of list. Wrap around now.. !" ) + "\n" ); +// if ( doNotifyWrapAround ) +// QMessageBox::information( this, tr( "End of list" ), +// tr( "End of list. Wrap around now.. !" ) + "\n" ); @@ -1041,4 +818,6 @@ void AddressbookWindow::slotSetCategory( int c ) { + qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); QString cat, book; + AbView::Views view = AbView::TableView; @@ -1047,5 +826,10 @@ void AddressbookWindow::slotSetCategory( int c ) - // Set checkItem for selected one - for ( unsigned int i = 1; i < catMenu->count(); i++ ) - catMenu->setItemChecked( i, c == (int)i ); + // Checkmark Book Menu Item Selected + if ( c < 3 ) + for ( unsigned int i = 1; i < 3; i++ ) + catMenu->setItemChecked( i, c == (int)i ); + // Checkmark Category Menu Item Selected + else + for ( unsigned int i = 3; i < catMenu->count(); i++ ) + catMenu->setItemChecked( i, c == (int)i ); @@ -1053,18 +837,19 @@ void AddressbookWindow::slotSetCategory( int c ) if (catMenu->isItemChecked( i )) { - if ( i == 1 ) // default List view + if ( i == 1 ){ // default List view book = QString::null; - else if ( i == 2 ) - book = "Phone"; - else if ( i == 3 ) - book = "Company"; - else if ( i == 4 ) - book = "Email"; - else if ( i == 5 ) - book = "Cards"; - else if ( i == 6 ) // default All Categories + view = AbView::TableView; + }else if ( i == 2 ){ + book = tr( "Cards" ); + view = AbView::CardView; +// }else if ( i == 3 ){ +// book = tr( "Personal" ); +// view = AbView:: PersonalView; + }else if ( i == 3 ){ // default All Categories cat = QString::null; - else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled + }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled cat = "Unfiled"; - else - cat = abList->categories()[i - 7]; + qWarning ("Unfiled selected!!!"); + }else{ + cat = m_abView->categories()[i - 4]; + } } @@ -1072,4 +857,6 @@ void AddressbookWindow::slotSetCategory( int c ) - abList->setShowCategory( book, cat ); - + slotViewSwitched( view ); + + m_abView -> setShowByCategory( view, cat ); + if ( book.isEmpty() ) @@ -1079,3 +866,45 @@ void AddressbookWindow::slotSetCategory( int c ) - setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); + setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); +} + +void AddressbookWindow::slotViewSwitched( int view ) +{ + qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); + int menu = 0; + switch ( view ){ + case AbView::TableView: + menu = 1; + m_tableViewButton->setOn(true); + m_cardViewButton->setOn(false); + break; + case AbView::CardView: + menu = 2; + m_tableViewButton->setOn(false); + m_cardViewButton->setOn(true); + break; +// case AbView::PersonalView: +// menu = 3; +// break; +// case AbView::CompanyBook: +// menu = 3; +// break; +// case AbView::EmailBook: +// menu = 4; +// break; + } + for ( unsigned int i = 1; i < 3; i++ ){ + if ( catMenu ) + catMenu->setItemChecked( i, menu == (int)i ); + } +} + + +void AddressbookWindow::slotListView() +{ + emit slotSetCategory( AbView::TableView +1 ); +} + +void AddressbookWindow::slotCardView() +{ + emit slotSetCategory( AbView::CardView +1 ); } @@ -1084,3 +913,3 @@ void AddressbookWindow::slotSetLetter( char c ) { - abList->setShowByLetter( c ); + m_abView->setShowByLetter( c ); @@ -1088,2 +917,3 @@ void AddressbookWindow::slotSetLetter( char c ) { + void AddressbookWindow::populateCategories() @@ -1096,7 +926,5 @@ void AddressbookWindow::populateCategories() - catMenu->insertItem( tr( "List" ), id++ ); - catMenu->insertItem( tr( "Phone Book" ), id++ ); - catMenu->insertItem( tr( "Company Book" ), id++ ); - catMenu->insertItem( tr( "Email Book" ), id++ ); - catMenu->insertItem( tr( "Cards" ), id++ ); + catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); + catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); +// catMenu->insertItem( tr( "Personal" ), id++ ); catMenu->insertSeparator(); @@ -1104,3 +932,3 @@ void AddressbookWindow::populateCategories() catMenu->insertItem( tr( "All" ), id++ ); - QStringList categories = abList->categories(); + QStringList categories = m_abView->categories(); categories.append( tr( "Unfiled" ) ); @@ -1109,3 +937,3 @@ void AddressbookWindow::populateCategories() catMenu->insertItem( *it, id ); - if ( *it == abList->showCategory() ) + if ( *it == m_abView -> showCategory() ) rememberId = id; @@ -1114,16 +942,17 @@ void AddressbookWindow::populateCategories() - if ( abList->showBook().isEmpty() ) { - catMenu->setItemChecked( 1, true ); - } else if ( abList->showBook() == "Phone" ) { - catMenu->setItemChecked( 2, true ); - } else if ( abList->showBook() == "Company" ) { - catMenu->setItemChecked( 3, true ); - } else if ( abList->showBook() == "Email" ) { - catMenu->setItemChecked( 4, true ); - } else if ( abList->showBook() == "Cards" ) { - catMenu->setItemChecked( 5, true ); - } - - if ( abList->showCategory().isEmpty() ) { - slotSetCategory( 6 ); + // :SX +// if ( abList->showBook().isEmpty() ) { +// catMenu->setItemChecked( 1, true ); +// } else if ( abList->showBook() == "Phone" ) { +// catMenu->setItemChecked( 2, true ); +// } else if ( abList->showBook() == "Company" ) { +// catMenu->setItemChecked( 3, true ); +// } else if ( abList->showBook() == "Email" ) { +// catMenu->setItemChecked( 4, true ); +// } else if ( abList->showBook() == "Cards" ) { +// catMenu->setItemChecked( 5, true ); +// } + + if ( m_abView -> showCategory().isEmpty() ) { + slotSetCategory( 3 ); } diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 8027ccf..4c1e2f2 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h @@ -30,2 +30,4 @@ #include "ofloatbar.h" +#include "abview.h" +#include "abconfig.h" @@ -46,2 +48,4 @@ class AddressbookWindow: public QMainWindow public: + enum EntryMode { NewEntry=0, EditEntry }; + AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); @@ -51,5 +55,3 @@ protected: void resizeEvent( QResizeEvent * e ); - void showList(); - void showView(); - enum EntryMode { NewEntry=0, EditEntry }; + void editPersonal(); @@ -64,4 +66,2 @@ public slots: void setDocument( const QString & ); - void slotFindNext(); - void slotFindPrevious(); #ifdef __DEBUG_RELEASE @@ -73,3 +73,3 @@ private slots: void slotListNew(); - void slotListView(); +/* void slotListView(); */ void slotListDelete(); @@ -79,3 +79,3 @@ private slots: void listIsEmpty( bool ); - void slotSettings(); +/* void slotSettings(); */ void writeMail(); @@ -94,2 +94,6 @@ private slots: + void slotViewSwitched( int ); + void slotListView(); + void slotCardView(); + void slotConfig(); @@ -97,16 +101,15 @@ private slots: private: - void initFields(); // inititialize our fields... - AbLabel *abView(); + // void initFields(); // inititialize our fields... + // AbLabel *abView(); void populateCategories(); - QPopupMenu *catMenu, *fontMenu; + QPopupMenu *catMenu; QPEToolBar *listTools; QToolButton *deleteButton; - QValueList<int> allFields, orderedFields; - QStringList slOrderedFields; + // QValueList<int> allFields, orderedFields; + // QStringList slOrderedFields; enum Panes { paneList=0, paneView, paneEdit }; ContactEditor *abEditor; - AbLabel *mView; LetterPicker *pLabel; - AbTable *abList; + AbView* m_abView; QWidget *listContainer; @@ -116,8 +119,2 @@ private: QLineEdit* searchEdit; - bool useRegExp; - bool doNotifyWrapAround; - bool caseSensitive; - - bool m_useQtMail; - bool m_useOpieMail; @@ -125,3 +122,2 @@ private: - bool bAbEditFirstTime; int viewMargin; @@ -130,5 +126,10 @@ private: QFont *defaultFont; - int startFontSize; + int m_curFontSize; bool isLoading; + + AbConfig m_config; + + QAction* m_tableViewButton; + QAction* m_cardViewButton; }; diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro index 9ed2f68..ef49374 100644 --- a/core/pim/addressbook/addressbook.pro +++ b/core/pim/addressbook/addressbook.pro @@ -1,3 +1,4 @@ TEMPLATE = app -CONFIG = qt warn_on release +#CONFIG = qt warn_on release +CONFIG = qt warn_on debug DESTDIR = $(OPIEDIR)/bin @@ -5,8 +6,10 @@ HEADERS = addressbook.h \ contacteditor.h \ + ocontactfields.h \ ablabel.h \ abtable.h \ - addresssettings.h \ picker.h \ ofloatbar.h \ - configdlg.h + configdlg.h \ + abconfig.h \ + abview.h SOURCES = main.cpp \ @@ -14,9 +17,11 @@ SOURCES = main.cpp \ contacteditor.cpp \ + ocontactfields.cpp \ ablabel.cpp \ abtable.cpp \ - addresssettings.cpp \ picker.cpp \ - configdlg.cpp + configdlg.cpp \ + abconfig.cpp \ + abview.cpp -INTERFACES = addresssettingsbase.ui configdlg_base.ui +INTERFACES = configdlg_base.ui TARGET = addressbook diff --git a/core/pim/addressbook/addresssettings.cpp b/core/pim/addressbook/addresssettings.cpp index e7c2210..2a9413c 100644 --- a/core/pim/addressbook/addresssettings.cpp +++ b/core/pim/addressbook/addresssettings.cpp @@ -24,3 +24,3 @@ #include <qpe/config.h> -#include <qpe/contact.h> +#include <opie/ocontact.h> @@ -43,3 +43,3 @@ void AddressSettings::init() { - QStringList slFields = Contact::trfields(); + QStringList slFields = OContact::trfields(); // Make this match what is in initFields diff --git a/core/pim/addressbook/addresssettingsbase.ui b/core/pim/addressbook/addresssettingsbase.ui index bd3b85b..f0eb7e8 100644 --- a/core/pim/addressbook/addresssettingsbase.ui +++ b/core/pim/addressbook/addresssettingsbase.ui @@ -34,3 +34,3 @@ <y>0</y> - <width>244</width> + <width>240</width> <height>207</height> diff --git a/core/pim/addressbook/configdlg.cpp b/core/pim/addressbook/configdlg.cpp index d1c2ef8..afba688 100644 --- a/core/pim/addressbook/configdlg.cpp +++ b/core/pim/addressbook/configdlg.cpp @@ -1,4 +1,9 @@ #include "configdlg.h" +#include "ocontactfields.h" #include <qcheckbox.h> #include <qradiobutton.h> +#include <qlistbox.h> +#include <qpushbutton.h> + +#include <opie/ocontact.h> @@ -6,56 +11,127 @@ ConfigDlg::ConfigDlg( QWidget *parent, const char *name): ConfigDlg_Base(parent, name, true ) -{} - - -bool ConfigDlg::useRegExp() const -{ - return m_useRegExp->isOn(); -} -bool ConfigDlg::useWildCards() const -{ - return m_useWildCard->isOn(); -} -bool ConfigDlg::useQtMail() const -{ - return m_useQtMail->isOn(); -} -bool ConfigDlg::useOpieMail() const { - return m_useOpieMail->isOn(); -} -bool ConfigDlg::beCaseSensitive() const -{ - return m_useCaseSensitive->isChecked(); -} -bool ConfigDlg::signalWrapAround() const -{ - return m_signalWrapAround->isChecked(); -} -void ConfigDlg::setUseRegExp( bool v ) -{ - m_useRegExp->setChecked( v ); + contFields = OContactFields::trfields(); + + // We add all Fields into the Listbox + for (uint i=0; i < contFields.count(); i++) { + allFieldListBox->insertItem( contFields[i] ); + } + + // Get the translation maps between Field ID and translated strings + m_mapStrToID = OContactFields::trFieldsToId(); + m_mapIDToStr = OContactFields::idToTrFields(); + + connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) ); + connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) ); + connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) ); + connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) ); } -void ConfigDlg::setUseWildCards( bool v ) + +void ConfigDlg::slotItemUp() { - m_useWildCard->setChecked( v ); + qWarning( "void ConfigDlg::slotItemUp()" ); + + int i = fieldListBox->currentItem(); + if ( i > 0 ) { + QString item = fieldListBox->currentText(); + fieldListBox->removeItem( i ); + fieldListBox->insertItem( item, i-1 ); + fieldListBox->setCurrentItem( i-1 ); + } + } -void ConfigDlg::setBeCaseSensitive( bool v ) + +void ConfigDlg::slotItemDown() { - m_useCaseSensitive->setChecked( v ); + qWarning( "void ConfigDlg::slotItemDown()" ); + + int i = fieldListBox->currentItem(); + if ( i < (int)fieldListBox->count() - 1 ) { + QString item = fieldListBox->currentText(); + fieldListBox->removeItem( i ); + fieldListBox->insertItem( item, i+1 ); + fieldListBox->setCurrentItem( i+1 ); + } } -void ConfigDlg::setSignalWrapAround( bool v ) + +void ConfigDlg::slotItemAdd() { - m_signalWrapAround->setChecked( v ); + qWarning( "void ConfigDlg::slotItemAdd()" ); + + int i = allFieldListBox->currentItem(); + if ( i > 0 ) { + QString item = allFieldListBox->currentText(); + qWarning("ADding %s", item.latin1()); + fieldListBox->insertItem( item ); + } } -void ConfigDlg::setQtMail( bool v ) + +void ConfigDlg::slotItemRemove() { - m_useQtMail->setChecked( v ); + qWarning( "void ConfigDlg::slotItemRemove()" ); + + int i = fieldListBox->currentItem(); + if ( i > 0 ) { + fieldListBox->removeItem( i ); + } } -void ConfigDlg::setOpieMail( bool v ) -{ - m_useOpieMail->setChecked( v ); + +void ConfigDlg::setConfig( const AbConfig& cnf ) +{ + m_config = cnf; + + m_useRegExp->setChecked( m_config.useRegExp() ); + m_useWildCard->setChecked( m_config.useWildCards() ); + m_useQtMail->setChecked( m_config.useQtMail() ); + m_useOpieMail->setChecked( m_config.useOpieMail() ); + m_useCaseSensitive->setChecked( m_config.beCaseSensitive() ); + + switch( m_config.fontSize() ){ + case 0: + m_smallFont->setChecked( true ); + m_normalFont->setChecked( false ); + m_largeFont->setChecked( false ); + break; + case 1: + m_smallFont->setChecked( false ); + m_normalFont->setChecked( true ); + m_largeFont->setChecked( false ); + break; + case 2: + m_smallFont->setChecked( false ); + m_normalFont->setChecked( false ); + m_largeFont->setChecked( true ); + break; + } + + for( uint i = 0; i < m_config.orderList().count(); i++ ) { + fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] ); + } + + } + +AbConfig ConfigDlg::getConfig() +{ + m_config.setUseRegExp( m_useRegExp->isOn() ); + m_config.setUseWildCards( m_useWildCard->isOn() ); + m_config.setUseQtMail( m_useQtMail->isOn() ); + m_config.setUseOpieMail( m_useOpieMail->isOn() ); + m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() ); + if ( m_smallFont->isChecked() ) + m_config.setFontSize( 0 ); + if ( m_normalFont->isChecked() ) + m_config.setFontSize( 1 ); + if ( m_largeFont->isChecked() ) + m_config.setFontSize( 2 ); + QValueList<int> orderlist; + for( int i = 0; i < (int)fieldListBox->count(); i++ ) { + orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] ); + } + m_config.setOrderList( orderlist ); + return m_config; +} diff --git a/core/pim/addressbook/configdlg.h b/core/pim/addressbook/configdlg.h index 34e9718..53d3d01 100644 --- a/core/pim/addressbook/configdlg.h +++ b/core/pim/addressbook/configdlg.h @@ -3,3 +3,6 @@ +#include <qmap.h> + #include "configdlg_base.h" +#include "abconfig.h" @@ -12,15 +15,16 @@ public: // Search Settings - bool useRegExp() const; - bool useWildCards() const; - bool beCaseSensitive() const; - bool signalWrapAround() const; - bool useQtMail() const; - bool useOpieMail() const; - - void setUseRegExp( bool v ); - void setUseWildCards( bool v ); - void setBeCaseSensitive( bool v ); - void setSignalWrapAround( bool v ); - void setQtMail( bool v ); - void setOpieMail( bool v ); + void setConfig( const AbConfig& cnf ); + AbConfig getConfig(); + +protected slots: + void slotItemUp(); + void slotItemDown(); + void slotItemAdd(); + void slotItemRemove(); + +protected: + QStringList contFields; + AbConfig m_config; + QMap<QString, int> m_mapStrToID; + QMap<int, QString> m_mapIDToStr; }; diff --git a/core/pim/addressbook/configdlg_base.ui b/core/pim/addressbook/configdlg_base.ui index a6fcffa..66414f5 100644 --- a/core/pim/addressbook/configdlg_base.ui +++ b/core/pim/addressbook/configdlg_base.ui @@ -14,4 +14,4 @@ <y>0</y> - <width>244</width> - <height>298</height> + <width>276</width> + <height>327</height> </rect> @@ -19,2 +19,9 @@ <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> <name>caption</name> @@ -26,2 +33,5 @@ </property> + <property> + <name>layoutMargin</name> + </property> <vbox> @@ -29,3 +39,3 @@ <name>margin</name> - <number>11</number> + <number>1</number> </property> @@ -41,2 +51,9 @@ </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + </sizepolicy> + </property> <property> @@ -44,2 +61,5 @@ </property> + <property> + <name>layoutSpacing</name> + </property> <widget> @@ -52,3 +72,3 @@ <name>title</name> - <string>Search</string> + <string>Misc</string> </attribute> @@ -64,6 +84,6 @@ <widget> - <class>QButtonGroup</class> + <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>ButtonGroup1</cstring> + <cstring>GroupBox2</cstring> </property> @@ -71,3 +91,3 @@ <name>title</name> - <string>Query Style</string> + <string>Search Settings</string> </property> @@ -83,17 +103,53 @@ <widget> - <class>QRadioButton</class> + <class>QButtonGroup</class> <property stdset="1"> <name>name</name> - <cstring>m_useRegExp</cstring> + <cstring>ButtonGroup1</cstring> </property> <property stdset="1"> - <name>text</name> - <string>Use Regular Expressions</string> + <name>title</name> + <string>Query Style</string> </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_useRegExp</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Use Regular Expressions</string> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_useWildCard</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Use Wildcards (*,?)</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + </vbox> </widget> <widget> - <class>QRadioButton</class> + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>m_useWildCard</cstring> + <cstring>m_useCaseSensitive</cstring> </property> @@ -101,7 +157,3 @@ <name>text</name> - <string>Use Wildcards (*,?)</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> + <string>Case Sensitive</string> </property> @@ -111,22 +163,58 @@ <widget> - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>m_useCaseSensitive</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Case Sensitive</string> - </property> - </widget> - <widget> - <class>QCheckBox</class> + <class>QButtonGroup</class> <property stdset="1"> <name>name</name> - <cstring>m_signalWrapAround</cstring> + <cstring>ButtonGroup3</cstring> </property> <property stdset="1"> - <name>text</name> - <string>Signal Wrap Around</string> + <name>title</name> + <string>Font</string> </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_smallFont</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Small</string> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_normalFont</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Normal</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_largeFont</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Large</string> + </property> + </widget> + </hbox> </widget> @@ -258,53 +346,194 @@ is provided free !</string> </widget> - </widget> - <widget> - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout1</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> + <widget> + <class>QWidget</class> <property stdset="1"> - <name>spacing</name> - <number>6</number> + <name>name</name> + <cstring>tab</cstring> </property> - <widget> - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>buttonOk</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>&OK</string> - </property> - <property stdset="1"> - <name>autoDefault</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>default</name> - <bool>true</bool> - </property> - </widget> - <widget> - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>buttonCancel</cstring> - </property> + <attribute> + <name>title</name> + <string>Order</string> + </attribute> + <vbox> <property stdset="1"> - <name>text</name> - <string>&Cancel</string> + <name>margin</name> + <number>-1</number> </property> <property stdset="1"> - <name>autoDefault</name> - <bool>true</bool> + <name>spacing</name> + <number>-1</number> </property> - </widget> - </hbox> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox9</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Select Contact Order:</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_upButton</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Up</string> + </property> + <property stdset="1"> + <name>autoRepeat</name> + <bool>true</bool> + </property> + </widget> + <widget row="1" column="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_downButton</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Down</string> + </property> + <property stdset="1"> + <name>autoRepeat</name> + <bool>true</bool> + </property> + </widget> + <widget row="4" column="0" rowspan="1" colspan="2" > + <class>QListBox</class> + <property stdset="1"> + <name>name</name> + <cstring>allFieldListBox</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + </sizepolicy> + </property> + </widget> + <widget row="3" column="0" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_addButton</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Add</string> + </property> + </widget> + <widget row="3" column="1" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_removeButton</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Remove</string> + </property> + </widget> + <spacer row="2" column="2" > + <property> + <name>name</name> + <cstring>Spacer23</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="3" column="2" rowspan="2" colspan="1" > + <property> + <name>name</name> + <cstring>Spacer2_2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget row="0" column="0" rowspan="3" colspan="2" > + <class>QListBox</class> + <property stdset="1"> + <name>name</name> + <cstring>fieldListBox</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + </sizepolicy> + </property> + </widget> + </grid> + </widget> + </vbox> + </widget> </widget> @@ -312,25 +541,6 @@ is provided free !</string> </widget> -<connections> - <connection> - <sender>buttonOk</sender> - <signal>clicked()</signal> - <receiver>Configuration</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>buttonCancel</sender> - <signal>clicked()</signal> - <receiver>Configuration</receiver> - <slot>reject()</slot> - </connection> -</connections> <tabstops> <tabstop>configDlg_base</tabstop> - <tabstop>m_useWildCard</tabstop> - <tabstop>m_useCaseSensitive</tabstop> - <tabstop>m_signalWrapAround</tabstop> <tabstop>m_useQtMail</tabstop> <tabstop>m_useOpieMail</tabstop> - <tabstop>buttonOk</tabstop> - <tabstop>buttonCancel</tabstop> </tabstops> diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index e034b35..5a7bf1a 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -23,2 +23,3 @@ #include "addresspicker.h" +#include "ocontactfields.h" @@ -28,2 +29,4 @@ #include <qpe/timeconversion.h> +#include <opie/ocontact.h> +#include <qpe/resource.h> @@ -42,2 +45,5 @@ #include <qlistbox.h> +#include <qhbox.h> +#include <qaction.h> +#include <qiconset.h> @@ -56,4 +62,2 @@ void parseEmailTo( const QString &strDefaultEmail, ContactEditor::ContactEditor( const OContact &entry, - const QValueList<int> *newOrderedValues, - QStringList *slNewOrdered, QWidget *parent, @@ -62,4 +66,2 @@ ContactEditor::ContactEditor( const OContact &entry, : QDialog( parent, name, TRUE, fl ), - orderedValues( newOrderedValues ), - slOrdered( *slNewOrdered ), m_personalView ( false ) @@ -68,5 +70,3 @@ ContactEditor::ContactEditor( const OContact &entry, init(); - initMap(); setEntry( entry ); - qDebug("finish"); } @@ -78,14 +78,5 @@ void ContactEditor::init() { - useFullName = TRUE; + useFullName = true; - int i = 0; -/** SHut up and stop leaking - slHomeAddress = new QStringList; - slBusinessAddress = new QStringList; - slChooserNames = new QStringList; - slChooserValues = new QStringList; - - slDynamicEntries = new QStringList; -*/ - //*slDynamicEntries = *slOrdered; + uint i = 0; @@ -98,263 +89,9 @@ void ContactEditor::init() { - { - hasGender = FALSE; - hasTitle = FALSE; - hasCompany = FALSE; - hasNotes = FALSE; - hasStreet = FALSE; - hasStreet2 = FALSE; - hasPOBox = FALSE; - hasCity = FALSE; - hasState = FALSE; - hasZip = FALSE; - hasCountry = FALSE; - - QStringList::ConstIterator it = slOrdered.begin(); - - for ( i = 0; it != slOrdered.end(); i++, ++it ) { - - if ( (*it) == "Business Fax" ) { - trlChooserNames.append( tr( "Business Fax" ) ); - slChooserNames.append( *it ); - slChooserValues.append("" ); - //slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home Fax" ) { - trlChooserNames.append( tr( "Home Fax" ) ); - slChooserNames.append( *it ); - slChooserValues.append("" ); - //slDynamicEntries->remove( it ); - continue; - } - - - if ( (*it) == "Business Phone" ) { - trlChooserNames.append( tr( "Business Phone" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home Phone" ) { - trlChooserNames.append( tr( "Home Phone" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } + trlChooserNames = OContactFields::trphonefields(); + slChooserNames = OContactFields::untrphonefields(); + slDynamicEntries = OContactFields::untrdetailsfields(); + trlDynamicEntries = OContactFields::trdetailsfields(); + for (i = 0; i < slChooserNames.count(); i++) + slChooserValues.append(""); -/* - if ( (*it).right( 2 ) == tr( "IM" ) ) { - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } */ - - if ( (*it) == "Business Mobile" ) { - trlChooserNames.append( tr( "Business Mobile" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home Mobile" ) { - trlChooserNames.append( tr( "Home Mobile" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } - - - if ( (*it) == "Business WebPage" ) { - trlChooserNames.append( tr( "Business WebPage" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home Web Page" ) { - trlChooserNames.append( tr( "Home Web Page" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Business Pager" ) { - trlChooserNames.append( tr( "Business Pager" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Default Email" ) { - trlChooserNames.append( tr( "Default Email" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Emails" ) { - trlChooserNames.append( tr( "Emails" ) ); - slChooserNames.append( *it ); - slChooserValues.append( "" ); - //slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Name Title" || - *it == "First Name" || - *it == "Middle Name" || - *it == "Last Name" || - *it == "File As" || - *it == "Default Email" || - *it == "Emails" || - *it == "Groups" || - *it == "Anniversary" || - *it == "Birthday" ) - continue; - - if ( *it == "Name Title" ) { - //slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "First Name" ) { - // slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Middle Name" ) { - // slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Last Name" ) { - // slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Suffix" ) { - // slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "File As" ) { - // slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Gender" ) { - hasGender = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Job Title" ) { - hasTitle = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( ( *it == "Company") || (*it == "Organization" ) ) { - hasCompany = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Notes" ) { - hasNotes = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( *it == "Groups" ) { - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Business Street" ) { - hasStreet = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home Street" ) { - hasStreet = TRUE; - // slDynamicEntries->remove( it ); - continue; - } -/* - if ( (*it).right( 8 ) == tr( "Street 2" ) ) { - hasStreet2 = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) { - hasPOBox = TRUE; - // slDynamicEntries->remove( it ); - continue; - } */ - - if ( (*it) == "Business City" ) { - hasCity = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Business State" ) { - hasState = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Business Zip" ) { - hasZip = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Business Country" ) { - hasCountry = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home City" ) { - hasCity = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home State" ) { - hasState = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home Zip" ) { - hasZip = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - if ( (*it) == "Home Country" ) { - hasCountry = TRUE; - // slDynamicEntries->remove( it ); - continue; - } - - slDynamicEntries.append( *it ); - } - } @@ -422,12 +159,4 @@ void ContactEditor::init() { gl->addWidget( cmbCat, 7, 1 ); - - // We don't need categories for the personal view - if ( m_personalView ){ - qWarning("Disable Category.."); - labCat->hide(); - cmbCat->hide(); - } else { - labCat->show(); - cmbCat->show(); - } + labCat->show(); + cmbCat->show(); @@ -461,13 +190,3 @@ void ContactEditor::init() { gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); -/* - l = new QLabel( tr( "Address 2" ), container ); - gl->addWidget( l, 2, 0 ); - txtAddress2 = new QLineEdit( container ); - gl->addMultiCellWidget( txtAddress2, 2, 2, 1, 2 ); - l = new QLabel( tr( "P.O. Box" ), container ); - gl->addWidget( l, 3, 0 ); - txtPOBox = new QLineEdit( container ); - gl->addMultiCellWidget( txtPOBox, 3, 3, 1, 2 ); -*/ l = new QLabel( tr( "City" ), container ); @@ -738,2 +457,3 @@ void ContactEditor::init() { // Birthday + QHBox* hBox = new QHBox( container ); l = new QLabel( tr("Birthday"), container ); @@ -745,8 +465,15 @@ void ContactEditor::init() { - birthdayButton= new QToolButton( container, "buttonStart" ); + birthdayButton= new QToolButton( hBox, "buttonStart" ); birthdayButton->setPopup( m1 ); birthdayButton->setPopupDelay(0); - gl->addWidget( birthdayButton, counter , 1 ); + + 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() ) ); @@ -755,2 +482,3 @@ void ContactEditor::init() { // Anniversary + hBox = new QHBox( container ); l = new QLabel( tr("Anniversary"), container ); @@ -762,8 +490,14 @@ void ContactEditor::init() { - anniversaryButton= new QToolButton( container, "buttonStart" ); + anniversaryButton= new QToolButton( hBox, "buttonStart" ); anniversaryButton->setPopup( m1 ); anniversaryButton->setPopupDelay(0); - gl->addWidget( anniversaryButton, counter , 1 ); + + 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() ) ); @@ -784,4 +518,9 @@ void ContactEditor::init() { QStringList::ConstIterator it = slDynamicEntries.begin(); - for (i = counter; it != slDynamicEntries.end(); i++, ++it) { - l = new QLabel( QString::null , container ); + QStringList::ConstIterator trit = trlDynamicEntries.begin(); + for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) { + + if (((*it) == "Anniversary") || + ((*it) == "Birthday")|| ((*it) == "Gender")) continue; + + l = new QLabel( (*it).utf8() , container ); listName.append( l ); @@ -793,3 +532,3 @@ void ContactEditor::init() { // Fill labels with names.. - loadFields(); + // loadFields(); @@ -880,30 +619,4 @@ void ContactEditor::init() { new QPEDialogListener(this); -} -void ContactEditor::initMap() -{ - /* - // since the fields and the XML fields exist, create a map - // between them... - Config cfg1( "AddressBook" ); - Config cfg2( "AddressBook" ); - QString strCfg1, - strCfg2; - int i; - - // This stuff better exist... - cfg1.setGroup( "AddressFields" ); -o cfg2.setGroup( "XMLFields" ); - i = 0; - strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); - strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), - QString::null ); - while ( !strCfg1.isNull() && !strCfg2.isNull() ) { - mapField.insert( strCfg1, strCfg2 ); - strCfg1 = cfg1.readEntry( "Field" + QString::number(i), - QString::null ); - strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), - QString::null ); - } - */ + setPersonalView ( m_personalView ); } @@ -1073,40 +786,3 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) { - useFullName = TRUE; - -} - -// Loads the detail fields -void ContactEditor::loadFields() { - - QStringList::ConstIterator it; - QListIterator<QLabel> lit( listName ); - for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) { - - if ( *it == "Department" ) - (*lit)->setText( tr( "Department" ) ); - - if ( *it == "Company" ) - (*lit)->setText( tr( "Company" ) ); - - if ( *it == "Office" ) - (*lit)->setText( tr( "Office" ) ); - - if ( *it == "Profession" ) - (*lit)->setText( tr( "Profession" ) ); - - if ( *it == "Assistant" ) - (*lit)->setText( tr( "Assistant" ) ); - - if ( *it == "Manager" ) - (*lit)->setText( tr( "Manager" ) ); - - if ( *it == "Spouse" ) - (*lit)->setText( tr( "Spouse" ) ); - - if ( *it == "Nickname" ) - (*lit)->setText( tr( "Nickname" ) ); - - if ( *it == "Children" ) - (*lit)->setText( tr( "Children" ) ); - } + useFullName = true; @@ -1138,3 +814,3 @@ void ContactEditor::slotName() { QString tmpName; - if (useFullName == TRUE) { + if (useFullName) { txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); @@ -1150,3 +826,3 @@ void ContactEditor::slotName() { slotFullNameChange( txtFullName->text() ); - useFullName = FALSE; + useFullName = false; } @@ -1363,3 +1039,2 @@ QString ContactEditor::parseName( const QString fullName, int type ) { void ContactEditor::cleanupFields() { - QStringList::Iterator it = slChooserValues.begin(); @@ -1374,8 +1049,7 @@ void ContactEditor::cleanupFields() { - QStringList::ConstIterator cit; - QListIterator<QLineEdit> itLE( listValue ); - for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) { - (*itLE)->setText( "" ); - } - + QListIterator<QLineEdit> itLV( listValue ); + for ( ; itLV.current(); ++itLV ) { + (*itLV)->setText( "" ); + } + txtFirstName->setText(""); @@ -1392,5 +1066,3 @@ void ContactEditor::cleanupFields() { txtAddress->setText(""); - //txtAddress2->setText(""); txtCity->setText(""); - //txtPOBox->setText(""); txtState->setText(""); @@ -1408,6 +1080,5 @@ void ContactEditor::setEntry( const OContact &entry ) { - ent = entry; - useFullName = FALSE; + useFullName = false; txtFirstName->setText( ent.firstName() ); @@ -1425,45 +1096,35 @@ void ContactEditor::setEntry( const OContact &entry ) { - if (hasTitle) + // if (hasTitle) txtJobTitle->setText( ent.jobTitle() ); - if (hasCompany) + // if (hasCompany) txtOrganization->setText( ent.company() ); - if (hasNotes) + // if (hasNotes) txtNote->setText( ent.notes() ); - if (hasStreet) { + // if (hasStreet) { slHomeAddress[0] = ent.homeStreet(); slBusinessAddress[0] = ent.businessStreet(); - } -/* - if (hasStreet2) { - (*slHomeAddress)[1] = ent.homeStreet2(); - (*slBusinessAddress)[1] = ent.businessStreet2(); - } + // } - if (hasPOBox) { - (*slHomeAddress)[2] = ent.homePOBox(); - (*slBusinessAddress)[2] = ent.businessPOBox(); - } -*/ - if (hasCity) { +// if (hasCity) { slHomeAddress[3] = ent.homeCity(); slBusinessAddress[3] = ent.businessCity(); - } +//} - if (hasState) { +//if (hasState) { slHomeAddress[4] = ent.homeState(); slBusinessAddress[4] = ent.businessState(); - } +//} - if (hasZip) { +//if (hasZip) { slHomeAddress[5] = ent.homeZip(); slBusinessAddress[5] = ent.businessZip(); - } +//} - if (hasCountry) { +//if (hasCountry) { slHomeAddress[6] = ent.homeCountry(); slBusinessAddress[6] = ent.businessCountry(); - } +//} @@ -1471,3 +1132,3 @@ void ContactEditor::setEntry( const OContact &entry ) { QListIterator<QLineEdit> itLE( listValue ); - for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { + for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { if ( *it == "Department" ) @@ -1591,3 +1252,6 @@ void ContactEditor::setEntry( const OContact &entry ) { // loadFields(); :SX - + updateDatePicker(); +} +void ContactEditor::updateDatePicker() +{ // Set DatePicker @@ -1609,3 +1273,3 @@ void ContactEditor::saveEntry() { - if ( useFullName == TRUE ) { + if ( useFullName ) { txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); @@ -1615,15 +1279,9 @@ void ContactEditor::saveEntry() { - useFullName = FALSE; -} - - /*if ( ent.firstName() != txtFirstName->text() || - ent.lastName != txtLastName->text() || - ent.middleName != txtMiddleName->text() ) { - */ - ent.setFirstName( txtFirstName->text() ); - ent.setLastName( txtLastName->text() ); - ent.setMiddleName( txtMiddleName->text() ); - ent.setSuffix( txtSuffix->text() ); + useFullName = false; + } - //} + ent.setFirstName( txtFirstName->text() ); + ent.setLastName( txtLastName->text() ); + ent.setMiddleName( txtMiddleName->text() ); + ent.setSuffix( txtSuffix->text() ); @@ -1633,45 +1291,36 @@ void ContactEditor::saveEntry() { - if (hasTitle) + + //if (hasTitle) ent.setJobTitle( txtJobTitle->text() ); - if (hasCompany) + //if (hasCompany) ent.setCompany( txtOrganization->text() ); - if (hasNotes) +// if (hasNotes) ent.setNotes( txtNote->text() ); - if (hasStreet) { + //if (hasStreet) { ent.setHomeStreet( slHomeAddress[0] ); ent.setBusinessStreet( slBusinessAddress[0] ); - } -/* - if (hasStreet2) { - ent.setHomeStreet2( (*slHomeAddress)[1] ); - ent.setBusinessStreet2( (*slBusinessAddress)[1] ); - } + // } - if (hasPOBox) { - ent.setHomePOBox( (*slHomeAddress)[2] ); - ent.setBusinessPOBox( (*slBusinessAddress)[2] ); - } -*/ - if (hasCity) { + // if (hasCity) { ent.setHomeCity( slHomeAddress[3] ); ent.setBusinessCity( slBusinessAddress[3] ); - } + // } - if (hasState) { + // if (hasState) { ent.setHomeState( slHomeAddress[4] ); ent.setBusinessState( slBusinessAddress[4] ); - } + // } - if (hasZip) { + // if (hasZip) { ent.setHomeZip( slHomeAddress[5] ); ent.setBusinessZip( slBusinessAddress[5] ); - } + // } - if (hasCountry) { + // if (hasCountry) { ent.setHomeCountry( slHomeAddress[6] ); ent.setBusinessCountry( slBusinessAddress[6] ); - } + // } @@ -1679,3 +1328,4 @@ void ContactEditor::saveEntry() { QListIterator<QLineEdit> itLE( listValue ); - for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { + for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) { + if ( *it == "Department" ) @@ -1709,2 +1359,3 @@ void ContactEditor::saveEntry() { + QStringList::ConstIterator itV; @@ -1714,6 +1365,3 @@ void ContactEditor::saveEntry() { ent.setBusinessPhone( *itV ); -/* - if ( *it == tr("Business 2 Phone" ) - ent.setBusiness2Phone( *itV ); -*/ + if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) @@ -1723,8 +1371,2 @@ void ContactEditor::saveEntry() { ent.setBusinessMobile( *itV ); -/* - if ( *it == "Company Phone" ) - ent.setCompanyPhone( *itV ); -*/ - //if ( *it == "Default Email" ) - //ent.setDefaultEmail( *itV ); @@ -1741,6 +1383,3 @@ void ContactEditor::saveEntry() { ent.setHomePhone( *itV ); -/* - if ( *it == "Home 2 Phone" ) - ent.setHome2Phone( *itV ); -*/ + if ( *it == "Home Fax" ) @@ -1750,33 +1389,6 @@ void ContactEditor::saveEntry() { ent.setHomeMobile( *itV ); -/* - if ( *it == "Car Phone" ) - ent.setCarPhone( *itV ); - - if ( *it == "ISDN Phone" ) - ent.setISDNPhone( *itV ); - if ( *it == "Other Phone" ) - ent.setOtherPhone( *itV ); -*/ if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) ent.setBusinessPager( *itV ); -/* - if ( *it == "Home Pager" ) - ent.setHomePager( *itV ); - if ( *it == "AIM IM" ) - ent.setAIMIM( *itV ); - - if ( *it == "ICQ IM" ) - ent.setICQIM( *itV ); - - if ( *it == "Jabber IM" ) - ent.setJabberIM( *itV ); - - if ( *it == "MSN IM" ) - ent.setMSNIM( *itV ); - - if ( *it == "Yahoo IM" ) - ent.setYahooIM( *itV ); -*/ if ( *it == "Home Web Page" ) @@ -1877,2 +1489,7 @@ void ContactEditor::setPersonalView( bool personal ) m_personalView = personal; + + // Currently disbled due to the fact that + // show will not work... + return; + if ( personal ){ @@ -1880,6 +1497,6 @@ void ContactEditor::setPersonalView( bool personal ) labCat->hide(); + } else{ cmbCat->show(); - labCat->show(); - + labCat->show(); } @@ -1904 +1521,15 @@ void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) } + +void ContactEditor::slotRemoveBirthday() +{ + qWarning("void ContactEditor::slotRemoveBirthday()"); + ent.setBirthday( QDate() ); + updateDatePicker(); +} + +void ContactEditor::slotRemoveAnniversary() +{ + qWarning("void ContactEditor::slotRemoveAnniversary()"); + ent.setAnniversary( QDate() ); + updateDatePicker(); +} diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index 40ce864..250b831 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h @@ -57,4 +57,2 @@ class ContactEditor : public QDialog { ContactEditor( const OContact &entry, - const QValueList<int> *newOrderedValues, - QStringList *slNewOrdered, QWidget *parent = 0, @@ -63,3 +61,2 @@ class ContactEditor : public QDialog { ~ContactEditor(); - void loadFields(); void setNameFocus(); @@ -78,3 +75,2 @@ class ContactEditor : public QDialog { void init(); - void initMap(); void saveEntry(); @@ -82,2 +78,3 @@ class ContactEditor : public QDialog { void cleanupFields(); + void updateDatePicker(); QString parseName( QString fullName, int type ); @@ -103,5 +100,8 @@ class ContactEditor : public QDialog { void slotBirthdayDateChanged( int year, int month, int day); + void slotRemoveBirthday(); + void slotRemoveAnniversary(); private: - bool useFullName, hasGender, hasTitle, hasCompany, hasNotes, hasStreet, hasStreet2, hasPOBox, hasCity, hasState, hasZip, hasCountry; + bool useFullName; + // bool hasGender, hasTitle, hasCompany, hasNotes, hasStreet, hasStreet2, hasPOBox, hasCity, hasState, hasZip, hasCountry; @@ -114,5 +114,5 @@ class ContactEditor : public QDialog { QList<QLabel> listName; - const QValueList<int> *orderedValues; - QStringList slOrdered; + QStringList slDynamicEntries; + QStringList trlDynamicEntries; diff --git a/core/pim/addressbook/ocontactfields.cpp b/core/pim/addressbook/ocontactfields.cpp new file mode 100644 index 0000000..7823a9c --- a/dev/null +++ b/core/pim/addressbook/ocontactfields.cpp @@ -0,0 +1,283 @@ + +#include "ocontactfields.h" + +#include <qstringlist.h> +#include <qobject.h> + +// We should use our own enum in the future .. +#include <qpe/recordfields.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 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" ) ); + + list.append( QObject::tr( "Default Email" ) ); + list.append( QObject::tr( "Emails" ) ); + + list.append( QObject::tr( "Home Phone" ) ); + list.append( QObject::tr( "Home Fax" ) ); + list.append( QObject::tr( "Home Mobile" ) ); + + 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; +} + + +/*! + \internal + Returns a translated list of field names for a contact. +*/ +QStringList OContactFields::trfields( bool sorted ) +{ + QStringList list; + + 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( QObject::tr( "Job Title" ) ); + list.append( QObject::tr( "Department" ) ); + list.append( QObject::tr( "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 += trdetailsfields( sorted ); + + list.append( QObject::tr( "Notes" ) ); + list.append( QObject::tr( "Groups" ) ); + + if (sorted) list.sort(); + + return list; +} + +/*! + \internal + Returns a list of phone field names for a contact. +*/ +QStringList OContactFields::untrphonefields( bool sorted ) +{ + QStringList list; + + list.append( "Business Phone" ); + list.append( "Business Fax" ); + list.append( "Business Mobile" ); + + list.append( "Default Email" ); + list.append( "Emails" ); + + list.append( "Home Phone" ); + list.append( "Home Fax" ); + list.append( "Home Mobile" ); + + if (sorted) list.sort(); + + return list; +} + +/*! + \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( "Office" ); + list.append( "Profession" ); + list.append( "Assistant" ); + list.append( "Manager" ); + + 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( "Spouse" ); + list.append( "Gender" ); + list.append( "Birthday" ); + list.append( "Anniversary" ); + list.append( "Nickname" ); + list.append( "Children" ); + + 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; +} diff --git a/core/pim/addressbook/ocontactfields.h b/core/pim/addressbook/ocontactfields.h new file mode 100644 index 0000000..796bc0a --- a/dev/null +++ b/core/pim/addressbook/ocontactfields.h @@ -0,0 +1,24 @@ +#ifndef OPIE_CONTACTS_FIELDS +#define OPIE_CONTACTS_FIELDS + +class QStringList; + +#include <qmap.h> +#include <qstring.h> + +class OContactFields{ + + 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/opie-addressbook.control b/core/pim/addressbook/opie-addressbook.control index f73ea4a..48542e7 100644 --- a/core/pim/addressbook/opie-addressbook.control +++ b/core/pim/addressbook/opie-addressbook.control @@ -7,3 +7,3 @@ Architecture: arm Version: $QPE_VERSION-$SUB_VERSION -Depends: opie-base ($QPE_VERSION) libopie +Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION) Description: Contacts diff --git a/core/pim/addressbook/picker.cpp b/core/pim/addressbook/picker.cpp index 2c7dd71..5099d68 100644 --- a/core/pim/addressbook/picker.cpp +++ b/core/pim/addressbook/picker.cpp @@ -220,2 +220,7 @@ LetterPicker::~LetterPicker() +QSizePolicy LetterPicker::sizePolicy () const +{ + return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum); +} + void LetterPicker::clear() diff --git a/core/pim/addressbook/picker.h b/core/pim/addressbook/picker.h index d76d582..d268983 100644 --- a/core/pim/addressbook/picker.h +++ b/core/pim/addressbook/picker.h @@ -15,2 +15,3 @@ #include <qevent.h> +#include <qsizepolicy.h> @@ -51,3 +52,4 @@ Q_OBJECT ~LetterPicker(); - + + QSizePolicy sizePolicy () const; diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h new file mode 100644 index 0000000..d96f857 --- a/dev/null +++ b/core/pim/addressbook/version.h @@ -0,0 +1,10 @@ +#ifndef _VERSION_H_ +#define _VERSION_H_ + +#define MAINVERSION "0" +#define SUBVERSION "1" +#define PATCHVERSION "0" + +#define APPNAME "OPIE_ADDRESSBOOK" + +#endif |