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,52 +1,93 @@ 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 ) 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): +------------------------------------------------------------- Fixed: +------- - Syncing: abtable not reloaded after sync. - Find widget should be replaced by something like qpdf has. - Adding a configuration dialog - Picker: Activated letter schould be more visible - Advanced handling of cursor keys (search..) - Mail-Icon is missing - Use opie-mail insted of qt-mail if possible. - Font menu is invisible using german translation - Personal contact editor: Disable categories - "Nonenglish" translation bug has to be fixed. - contacteditor: Birthday, annyversary, ... : Use Dateselector - The names of the countries are sorted by there english names, only.. Even if they are translated.. :S +- Cursor keys should work in detail-view (ablabel) + -> Ablabel should be removed and Abtable should be increased with + different views (as started by darwin zins).. +- Use advanced database functions in abtable to decrease + memory footprint and to make everything more easy ! + (abtable should store Iterator for selected Category) +- Abtable: Configure Contact column (internally already available, + need configuration) +- Select of primary contact (see #274 on mantis) +- Category-select does not work completely: "Unfiled" is always in listview .. +- Return from Contacteditor: Category resettet to all +- Personal Details not working +- If category changed, the letterpicker should be resetted +- There should be some icons for List and Cardview +- If in Cardview and a category change removes all entries: + There are already entries in Cardview after up/down +- Personal Details: Anniversary zeigt Fantasie-Werte +- Unfiled shown just in Category "All" and "Unfiled". 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 @@ -16,75 +16,101 @@ ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "ablabel.h" #include <qpe/stringutil.h> #include <qregexp.h> #include <qstylesheet.h> -AbLabel::AbLabel( QWidget *parent, const char *name ) - : QTextView( parent, name ) +AbLabel::AbLabel( QWidget *parent, const char *name ): + QTextView( parent, name ), + m_empty( false ) { } 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 ); } 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; } } + } 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 @@ -14,37 +14,51 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef ABLABEL_H #define ABLABEL_H #include <opie/ocontact.h> #include <qtextview.h> +#include <opie/ocontactaccess.h> + class AbLabel : public QTextView { Q_OBJECT public: AbLabel( QWidget *parent, const char *name = 0 ); ~AbLabel(); -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 * ); private: - OContact ent; + OContactAccess::List m_viewList; + OContactAccess::List::Iterator m_itCurContact; + + bool m_empty; }; #endif // ABLABEL_H 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 @@ -1,60 +1,57 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ -#define QTOPIA_INTERNAL_CONTACT_MRE #include <qpe/categoryselect.h> #include <qpe/config.h> #include <qpe/stringutil.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/timestring.h> #include <opie/orecordlist.h> #include <qasciidict.h> #include <qdatetime.h> #include <qfile.h> #include <qregexp.h> #include <qmessagebox.h> #include "abtable.h" #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <ctype.h> //toupper() for key hack -static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); - - /*! \class AbTableItem abtable.h \brief QTableItem based class for showing a field of an entry */ AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, const QString &secondSortKey) : QTableItem( t, et, s ) { // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); sortKey = Qtopia::buildSortKey( s, secondSortKey ); @@ -111,205 +108,246 @@ void AbPickItem::setContentFromEditor( QWidget *w ) if ( w->inherits("QComboBox") ) setText( ( (QComboBox*)w )->currentText() ); else QTableItem::setContentFromEditor( w ); } /*! \class AbTable abtable.h \brief QTable based class for showing a list of entries */ -AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) - // #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 ); init(); setSorting( TRUE ); connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), this, SLOT(itemClicked(int,int)) ); + + contactList.clear(); + qWarning("C'tor end"); } AbTable::~AbTable() { } void AbTable::init() { - showChar = '\0'; + // :SX showChar = '\0'; setNumRows( 0 ); setNumCols( 2 ); horizontalHeader()->setLabel( 0, tr( "Full Name" )); horizontalHeader()->setLabel( 1, tr( "Contact" )); setLeftMargin( 0 ); verticalHeader()->hide(); columnVisible = true; } +void AbTable::setContacts( const OContactAccess::List& viewList ) +{ + qWarning("AbTable::setContacts()"); + + clear(); + m_viewList = viewList; + + setSorting( false ); + 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 ) { if ( !sorting() ) return; if ( lastSortCol == -1 ) lastSortCol = col; if ( col == lastSortCol ) { asc = !asc; } else { lastSortCol = col; asc = TRUE; } //QMessageBox::information( this, "resort", "columnClicked" ); resort(); } void AbTable::resort() { + qWarning( "void AbTable::resort()" ); if ( sorting() ) { if ( lastSortCol == -1 ) lastSortCol = 0; sortColumn( lastSortCol, asc, TRUE ); //QMessageBox::information( this, "resort", "resort" ); updateVisible(); } } OContact AbTable::currentEntry() { + qWarning( "OContact AbTable::currentEntry()" ); OContact cnt; AbTableItem *abItem; abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); if ( abItem ) { cnt = contactList[abItem]; //cnt = contactList[currentRow()]; } return cnt; } -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() ); } void AbTable::clear() { + qWarning( "void AbTable::clear()" ); contactList.clear(); for ( int r = 0; r < numRows(); ++r ) { for ( int c = 0; c < numCols(); ++c ) { if ( cellWidget( r, c ) ) clearCellWidget( r, c ); clearCell( r, c ); } } setNumRows( 0 ); } +// Refresh updates column 2 if the contactsettings changed void AbTable::refresh() { + qWarning( "void AbTable::refresh()" ); int rows = numRows(); QString value; AbTableItem *abi; - - // hide columns so no flashing ? - if ( showBk == "Cards" ) { - hideColumn(0); - hideColumn(1); - } + for ( int r = 0; r < rows; ++r ) { abi = static_cast<AbTableItem*>( item(r, 0) ); value = findContactContact( contactList[abi], r ); static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); } resort(); } void AbTable::keyPressEvent( QKeyEvent *e ) { char key = toupper( e->ascii() ); if ( key >= 'A' && key <= 'Z' ) moveTo( key ); - 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 ); } + } void AbTable::moveTo( char c ) { + qWarning( "void AbTable::moveTo( char c )" ); int rows = numRows(); QString value; AbTableItem *abi; int r; if ( asc ) { r = 0; while ( r < rows-1) { abi = static_cast<AbTableItem*>( item(r, 0) ); QChar first = abi->key()[0]; //### is there a bug in QChar to char comparison??? if ( first.row() || first.cell() >= c ) @@ -337,307 +375,53 @@ QString AbTable::findContactName( const OContact &entry ) // We use the fileAs, then company, defaultEmail QString str; str = entry.fileAs(); if ( str.isEmpty() ) { str = entry.company(); if ( str.isEmpty() ) { str = entry.defaultEmail(); } } return str; } -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(); -} void AbTable::resizeRows() { /* if (numRows()) { for (int i = 0; i < numRows(); i++) { setRowHeight( i, size ); } } updateVisible(); */ } -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 ); - -} #if QT_VERSION <= 230 #ifndef SINGLE_APP void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) { // Region of the rect we should draw QRegion reg( QRect( cx, cy, cw, ch ) ); // Subtract the table from it reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); // And draw the rectangles (transformed as needed) QArray<QRect> r = reg.rects(); for (unsigned int i=0; i<r.count(); i++) @@ -653,404 +437,276 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) // } // int AbTable::rowPos( int row ) const // { // return 18*row; // } // int AbTable::rowAt( int pos ) const // { // return QMIN( pos/18, numRows()-1 ); // } -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 ); } void AbTable::show() { - fitColumns(); + qWarning( "void AbTable::show()" ); + realignTable(); QTable::show(); } void AbTable::setChoiceNames( const QStringList& list) { choicenames = list; if ( choicenames.isEmpty() ) { // hide pick column setNumCols( 2 ); } else { // show pick column setNumCols( 3 ); setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); horizontalHeader()->setLabel( 2, tr( "Pick" )); } fitColumns(); } void AbTable::itemClicked(int,int col) { + qWarning( "AbTable::itemClicked(int, col:%d)", col); if ( col == 2 ) { return; } else { - emit details(); + qWarning ("Emitting signalSwitch()"); + emit signalSwitch(); } } QStringList AbTable::choiceNames() const { return choicenames; } -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; } QStringList AbTable::choiceSelection(int /*index*/) const { QStringList r; /* ###### QString selname = choicenames.at(index); for (each row) { OContact *c = contactForRow(row); if ( text(row,2) == selname ) { r.append(c->email); } } */ return r; } -void AbTable::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; -} void AbTable::updateVisible() { int visible, 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 ) setCurrentCell( -1, 0 ); setPaintingEnabled( TRUE ); + + } void AbTable::setPaintingEnabled( bool e ) { if ( e != enablePainting ) { if ( !enablePainting ) { enablePainting = true; rowHeightChanged( 0 ); viewport()->update(); } else { enablePainting = false; } } } void AbTable::rowHeightChanged( int row ) { if ( enablePainting ) QTable::rowHeightChanged( row ); } +QString AbTable::findContactContact( const OContact &entry, int /* row */ ) +{ + QString value; + value = ""; + for ( QValueList<int>::ConstIterator it = intFields.begin(); + it != intFields.end(); ++it ) { + switch ( *it ) { + default: + break; + case Qtopia::Title: + value = entry.title(); + break; + case Qtopia::Suffix: + value = entry.suffix(); + break; + case Qtopia::FileAs: + value = entry.fileAs(); + break; + case Qtopia::DefaultEmail: + value = entry.defaultEmail(); + case Qtopia::Emails: + value = entry.emails(); + break; + case Qtopia::HomeStreet: + value = entry.homeStreet(); + break; + case Qtopia::HomeCity: + value = entry.homeCity(); + break; + case Qtopia::HomeState: + value = entry.homeState(); + break; + case Qtopia::HomeZip: + value = entry.homeZip(); + break; + case Qtopia::HomeCountry: + value = entry.homeCountry(); + 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 @@ -1,45 +1,45 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef ABTABLE_H #define ABTABLE_H #include <qpe/categories.h> #include <opie/ocontact.h> +#include <opie/ocontactaccess.h> #include <qmap.h> #include <qtable.h> #include <qstringlist.h> #include <qcombobox.h> -#include <opie/ocontactaccess.h> - class AbTableItem : public QTableItem { public: AbTableItem( QTable *t, EditType et, const QString &s, const QString &secondSortKey); QString entryKey() const; void setEntryKey( const QString & k ); virtual int alignment() const; virtual QString key() const; void setItem( const QString &txt, const QString &secondKey ); private: @@ -54,108 +54,83 @@ public: QWidget *createEditor() const; void setContentFromEditor( QWidget *w ); private: QGuardedPtr<QComboBox> cb; }; class AbTable : public QTable { Q_OBJECT public: - AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); + AbTable( 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(); void show(); void setPaintingEnabled( bool e ); - 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(); protected: virtual void keyPressEvent( QKeyEvent *e ); // int rowHeight( int ) const; // int rowPos( int row ) const; // virtual int rowAt( int pos ) const; protected slots: void moveTo( char ); virtual void columnClicked( int col ); void itemClicked(int,int col); void rowHeightChanged( int row ); private: - void 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; }; #endif // ABTABLE_H 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 @@ -1,212 +1,316 @@ #include "abview.h" +#include <qlayout.h> + +#include <qpe/global.h> + +#include <opie/ocontactaccessbackend_vcard.h> + + // Is defined in LibQPE 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), mCat(0), m_inSearch( false ), - m_curr_category( 0 ), + m_inPersonal( false ), + m_curr_category( -1 ), m_curr_View( TableView ), m_prev_View( TableView ), 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() ); // Create Layout and put WidgetStack into it. QVBoxLayout *vb = new QVBoxLayout( this ); m_viewStack = new QWidgetStack( this ); vb->addWidget( m_viewStack ); // Creat TableView QVBox* tableBox = new QVBox( m_viewStack ); - m_abTable = new AbTable( &m_orderedFields, tableBox, "table" ); + m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); m_abTable->setCurrentCell( 0, 0 ); m_abTable->setFocus(); // Add TableView to WidgetStack and raise it m_viewStack -> addWidget( tableBox , TableView ); // Create CardView and add it to WidgetStack QVBox* cardBox = new QVBox( m_viewStack ); m_ablabel = new AbLabel( cardBox, "CardView"); m_viewStack -> addWidget( cardBox , CardView ); // Connect views to me connect ( m_abTable, SIGNAL( signalSwitch( void ) ), this, SLOT( slotSwitch( void ) ) ); connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), this, SLOT( slotSwitch( void ) ) ); load(); } +AbView::~AbView() +{ + m_contactdb -> save(); + delete m_contactdb; + + if ( m_storedDB ){ + m_storedDB -> save(); + delete m_storedDB; + } +} + + void AbView::setView( Views view ) { qWarning("AbView::setView( Views view )"); m_curr_View = view; load(); } void AbView::addEntry( const OContact &newContact ) { qWarning("abview:AddContact"); - m_contactdb.add ( newContact ); + m_contactdb->add ( newContact ); load(); } void AbView::removeEntry( const int UID ) { qWarning("abview:RemoveContact"); - m_contactdb.remove( UID ); + m_contactdb->remove( UID ); load(); } void AbView::replaceEntry( const OContact &contact ) { qWarning("abview:ReplaceContact"); - m_contactdb.replace( contact ); + m_contactdb->replace( contact ); load(); } OContact AbView::currentEntry() { switch ( (int) m_curr_View ) { case TableView: return ( m_abTable -> currentEntry() ); break; case CardView: return ( m_ablabel -> currentEntry() ); break; } return OContact(); } bool AbView::save() { qWarning("abView:Save data"); - return m_contactdb.save(); + return m_contactdb->save(); } -// :SX Add: Just load for specific Category void AbView::load() { qWarning("abView:Load data"); - 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(); qWarning ("Number of contacts: %d", m_list.count()); updateView(); } void AbView::reload() { - m_contactdb.reload(); + qWarning( "void AbView::reload()" ); + + m_contactdb->reload(); load(); } void AbView::clear() { // :SX } 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(); + } } void AbView::setShowByLetter( char c ) { qWarning("void AbView::setShowByLetter( %c )", c ); OContact query; if ( c == 0 ){ load(); return; }else{ query.setLastName( QString("%1*").arg(c) ); - m_list = m_contactdb.queryByExample( query, OContactAccess::WildCards ); + m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards ); clearForCategory(); m_curr_Contact = 0; } updateView(); } +void AbView::setListOrder( const QValueList<int>& ordered ) +{ + m_orderedFields = ordered; + updateView(); +} + + QString AbView::showCategory() const { return mCat.label( "Contacts", m_curr_category ); } -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(); } QStringList AbView::categories() { mCat.load( categoryFileName() ); QStringList categoryList = mCat.labels( "Contacts" ); return categoryList; } // BEGIN: Slots void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, bool , QString cat = QString::null ) { 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; if ( cat.isEmpty() ) category = m_curr_category; else{ category = mCat.id("Contacts", cat ); } qWarning ("Find in Category %d", category); QRegExp r( str ); r.setCaseSensitive( caseSensitive ); r.setWildcard( !useRegExp ); // Get all matching entries out of the database - m_list = m_contactdb.matchRegexp( r ); + m_list = m_contactdb->matchRegexp( r ); qWarning( "found: %d", m_list.count() ); if ( m_list.count() == 0 ){ emit signalNotFound(); return; } // Now remove all contacts with wrong category (if any selected) // This algorithm is a litte bit ineffective, but // we will not have a lot of matching entries.. clearForCategory(); @@ -236,96 +340,106 @@ void AbView::slotSwitch(){ break; } updateView(); } // END: Slots void AbView::clearForCategory() { OContactAccess::List::Iterator it; // 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 ) ){ qWarning("Removing %d", (*it).uid()); m_list.remove( (*it).uid() ); - it = m_list.begin(); } } } + } bool AbView::contactCompare( const OContact &cnt, int category ) { qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); bool returnMe; QArray<int> cats; cats = cnt.categories(); qWarning ("Number of categories: %d", cats.count() ); 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; else { int i; for ( i = 0; i < int(cats.count()); i++ ) { qWarning("Comparing %d with %d",cats[i],category ); if ( cats[i] == category ) { returnMe = true; break; } } } qWarning ("Return: %d", returnMe); return returnMe; } +// In Some rare cases we have to update all lists.. +void AbView::updateListinViews() +{ + m_abTable -> setContacts( m_list ); + m_ablabel -> setContacts( m_list ); +} + void AbView::updateView() { qWarning("AbView::updateView()"); if ( m_viewStack -> visibleWidget() ){ m_viewStack -> visibleWidget() -> clearFocus(); } // 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 ) { case TableView: m_curr_Contact = m_abTable -> currentEntry_UID(); break; case CardView: m_curr_Contact = m_ablabel -> currentEntry_UID(); break; } - } + emit signalViewSwitched ( (int) m_curr_View ); + }else + m_curr_Contact = 0; m_prev_View = m_curr_View; // Switch to new View switch ( (int) m_curr_View ) { case TableView: + m_abTable -> setChoiceSelection( m_orderedFields ); m_abTable -> setContacts( m_list ); if ( m_curr_Contact != 0 ) m_abTable -> selectContact ( m_curr_Contact ); m_abTable -> setFocus(); - emit signalViewSwitched ( (int) m_curr_View ); break; case CardView: m_ablabel -> setContacts( m_list ); if ( m_curr_Contact != 0 ) m_ablabel -> selectContact( m_curr_Contact ); m_ablabel -> setFocus(); - emit signalViewSwitched ( (int) m_curr_View ); break; } // Raise the current View m_viewStack -> raiseWidget( m_curr_View ); } 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 @@ -8,74 +8,79 @@ #include <opie/ocontact.h> #include <opie/ocontactaccess.h> #include "contacteditor.h" #include "abtable.h" #include "ablabel.h" class AbView: public QWidget { Q_OBJECT 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(); bool save(); void load(); void reload(); void clear(); 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 void addEntry( const OContact &newContact ); void removeEntry( const int UID ); void replaceEntry( const OContact &contact ); OContact currentEntry(); void inSearch() { m_inSearch = true; } void offSearch(); QString showCategory() const; QStringList categories(); signals: void signalNotFound(); void signalClearLetterPicker(); void signalViewSwitched ( int ); public slots: void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, bool backwards, QString category = QString::null ); void slotSwitch(); private: + void updateListinViews(); void updateView(); void clearForCategory(); bool contactCompare( const OContact &cnt, int category ); void parseName( const QString& name, QString *first, QString *middle, QString * last ); Categories mCat; bool m_inSearch; + bool m_inPersonal; int m_curr_category; Views m_curr_View; Views m_prev_View; int m_curr_Contact; - OContactAccess m_contactdb; + OContactAccess* m_contactdb; + OContactAccess* m_storedDB; OContactAccess::List m_list; QWidgetStack* m_viewStack; AbTable* m_abTable; AbLabel* m_ablabel; QValueList<int> m_orderedFields; - QStringList m_slOrderedFields; }; #endif 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 @@ -13,121 +13,119 @@ ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** OContact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #define QTOPIA_INTERNAL_FD #include "contacteditor.h" #include "ablabel.h" +#include "abview.h" #include "abtable.h" -#include "addresssettings.h" +// #include "addresssettings.h" #include "addressbook.h" #include <opie/ofileselector.h> #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> #include <qpe/ir.h> #include <qpe/qpemessagebox.h> #include <qpe/qcopenvelope_qws.h> +#include <qpe/qpetoolbar.h> +#include <qpe/qpemenubar.h> +// #include <qtoolbar.h> +// #include <qmenubar.h> +#include <qpe/qpeapplication.h> +#include <qpe/config.h> #include <qaction.h> #include <qdialog.h> #include <qdir.h> #include <qfile.h> #include <qimage.h> #include <qlayout.h> -#include <qpe/qpemenubar.h> #include <qmessagebox.h> #include <qpixmap.h> #include <qpopupmenu.h> -#include <qpe/qpetoolbar.h> #include <qstringlist.h> #include <qtoolbutton.h> #include <qwhatsthis.h> +#include <qdatetime.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> -#include <qdatetime.h> #include "picker.h" #include "configdlg.h" -static QString addressbookPersonalVCardName() -{ - QString filename = Global::applicationFileName("addressbook", - "businesscard.vcf"); - return filename; -} - +extern QString addressbookPersonalVCardName(); AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, WFlags f ) : 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) { isLoading = true; - // 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, 0, this, 0 ); actionNew = a; connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); a->addTo( edit ); a->addTo( listTools ); a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); actionEdit = a; connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); a->addTo( edit ); @@ -152,420 +150,406 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); actionFind = a; connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); a->addTo( edit ); a->addTo( listTools ); // Much better search widget, taken from QTReader.. (se) searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); searchBar->setHorizontalStretchable( TRUE ); searchBar->hide(); searchEdit = new QLineEdit( searchBar, "searchEdit" ); -// QFont f("unifont", 16 /*, QFont::Bold*/); -// searchEdit->setFont( f ); + +// QFont f("unifont", 16 /*, QFont::Bold*/); +// searchEdit->setFont( f ); + searchBar->setStretchableWidget( searchEdit ); connect( searchEdit, SIGNAL( returnPressed( ) ), this, SLOT( slotFind( ) ) ); - 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 ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); a->addTo( searchBar ); a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "mail/sendmail" ), QString::null, 0, this, 0 ); //a->setEnabled( FALSE ); we got support for it now :) zecke actionMail = a; connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); a->addTo( edit ); a->addTo( listTools ); - - if ( Ir::supported() ) { a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); actionBeam = a; connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); a->addTo( edit ); a->addTo( listTools ); } edit->insertSeparator(); - a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); + a = new QAction( tr("Import vCard"), QString::null, 0, 0); actionPersonal = a; connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); a->addTo( edit ); edit->insertSeparator(); a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); actionPersonal = a; connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); a->addTo( edit ); - // 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 ); - #ifdef __DEBUG_RELEASE // Remove this function for public Release ! This is only // for debug purposes .. a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); a->addTo( edit ); #endif a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); a->addTo( edit ); // Create Views 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 ); catMenu->setCheckable( TRUE ); connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 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); // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); - abList->setCurrentCell( 0, 0 ); isLoading = false; } 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(); if ( dlg -> exec() ) { 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() ); } delete dlg; } -void AddressbookWindow::slotSetFont( int size ) { +void AddressbookWindow::slotSetFont( int size ) +{ + qWarning("void AddressbookWindow::slotSetFont( %d )", size); if (size > 2 || size < 0) size = 1; - startFontSize = size; + m_config.setFontSize( size ); QFont *currentFont; switch (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; } } void AddressbookWindow::importvCard() { QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); - if(!str.isEmpty() ) + if(!str.isEmpty() ){ setDocument((const QString&) str ); + } } 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; } void AddressbookWindow::resizeEvent( QResizeEvent *e ) { QMainWindow::resizeEvent( e ); - if ( centralWidget() == listContainer ) - showList(); - else if ( centralWidget() == mView ) - showView(); + } 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(); } void AddressbookWindow::slotUpdateToolbar() { - OContact ce = abList->currentEntry(); + OContact ce = m_abView->currentEntry(); actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); } -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() { OContact cnt; if( !syncing ) { - if ( abEditor ) - abEditor->setEntry( cnt ); - abView()->init( cnt ); editEntry( NewEntry ); } else { QMessageBox::warning(this, tr("OContacts"), tr("Can not edit data, currently syncing")); } } -void AddressbookWindow::slotListView() -{ - abView()->init( abList->currentEntry() ); - mView->sync(); - showView(); -} +// void AddressbookWindow::slotListView() +// { +// m_abView -> init( abList->currentEntry() ); +// // :SX mView->sync(); +// //:SX showView(); +// } void AddressbookWindow::slotListDelete() { if(!syncing) { - OContact tmpEntry = abList->currentEntry(); + OContact tmpEntry = m_abView ->currentEntry(); // get a name, do the best we can... QString strName = tmpEntry.fullName(); if ( strName.isEmpty() ) { strName = tmpEntry.company(); if ( strName.isEmpty() ) strName = "No Name"; } if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), strName ) ) { - abList->deleteCurrentEntry(); - showList(); + m_abView->removeEntry( tmpEntry.uid() ); } } else { QMessageBox::warning( this, tr("Contacts"), tr("Can not edit data, currently syncing") ); } } +void AddressbookWindow::slotFindOpen() +{ + searchBar->show(); + m_abView -> inSearch(); + searchEdit->setFocus(); +} +void AddressbookWindow::slotFindClose() +{ + searchBar->hide(); + m_abView -> offSearch(); + // m_abView->setFocus(); +} + + +void AddressbookWindow::slotFind() +{ + m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); + + searchEdit->clearFocus(); + // m_abView->setFocus(); + +} + void AddressbookWindow::slotViewBack() { - showList(); + // :SX showList(); } void AddressbookWindow::slotViewEdit() { if(!syncing) { if (actionPersonal->isOn()) { editPersonal(); } else { - if ( !bAbEditFirstTime ) - abEditor->setEntry( abList->currentEntry() ); editEntry( EditEntry ); } } else { QMessageBox::warning( this, tr("Contacts"), tr("Can not edit data, currently syncing") ); } } void AddressbookWindow::writeMail() { - OContact c = abList->currentEntry(); + OContact c = m_abView -> currentEntry(); QString name = c.fileAs(); QString email = c.defaultEmail(); // I prefer the OPIE-Environment variable before the // QPE-one.. QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); if ( basepath.isEmpty() ) basepath = QString::fromLatin1( getenv("QPEDIR") ); // Try to access the preferred. If not possible, try to // switch to the other one.. - if ( m_useQtMail ){ + if ( m_config.useQtMail() ){ qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); if ( QFile::exists( basepath + "/bin/qtmail" ) ){ qWarning ("QCop"); QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); e << name << email; return; } else - m_useOpieMail = true; + m_config.setUseOpieMail( true ); } - if ( m_useOpieMail ){ + if ( m_config.useOpieMail() ){ qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); if ( QFile::exists( basepath + "/bin/mail" ) ){ qWarning ("QCop"); QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); e << name << email; return; } else - m_useQtMail = true; + m_config.setUseQtMail( true ); } } static const char * beamfile = "/tmp/obex/contact.vcf"; void AddressbookWindow::slotBeam() { QString filename; OContact c; if ( actionPersonal->isOn() ) { filename = addressbookPersonalVCardName(); if (!QFile::exists(filename)) return; // can't beam a non-existent file - 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 ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); QString description = c.fullName(); ir->send( filename, description, "text/x-vCard" ); } void AddressbookWindow::beamDone( Ir *ir ) { delete ir; unlink( beamfile ); } @@ -612,33 +596,28 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) OContact cnt; QString fn, mn, ln; parseName( name, &fn, &mn, &ln ); // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); cnt.setFirstName( fn ); cnt.setMiddleName( mn ); cnt.setLastName( ln ); cnt.insertEmails( email ); cnt.setDefaultEmail( email ); cnt.setFileAs(); - 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 ); } #if 0 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { QDataStream stream(data,IO_ReadOnly); QCString ch,m; QStringList types; stream >> ch >> m >> types; AddressPicker picker(abList,this,0,TRUE); picker.showMaximized(); @@ -657,478 +636,328 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) setCentralWidget(abList); QCopEnvelope e(ch,m); i=0; for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { QStringList sel = picker.selection(i++); e << sel; } } #endif } -void AddressbookWindow::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... abEditor->setNameFocus(); if ( abEditor->exec() ) { 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() { if (!actionPersonal->isOn()) { // we just turned it off setCaption( tr("Contacts") ); actionNew->setEnabled(TRUE); actionTrash->setEnabled(TRUE); actionFind->setEnabled(TRUE); - slotUpdateToolbar(); // maybe some of the above could be moved there - showList(); + actionMail->setEnabled(TRUE); + // slotUpdateToolbar(); + + m_abView->showPersonal( false ); + return; } // XXX need to disable some QActions. actionNew->setEnabled(FALSE); actionTrash->setEnabled(FALSE); -#ifndef MAKE_FOR_SHARP_ROM actionFind->setEnabled(FALSE); -#endif actionMail->setEnabled(FALSE); 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 ) { if ( !empty ) { deleteButton->setEnabled( TRUE ); } } void AddressbookWindow::reload() { syncing = FALSE; - abList->clear(); - abList->reload(); + m_abView->clear(); + m_abView->reload(); } void AddressbookWindow::flush() { syncing = TRUE; - abList->save(); + m_abView->save(); } 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; - } if(syncing) { /* shouldn't we save, I hear you say? well its already been set so that an edit can not occur during a sync, and we flushed at the start of the sync, so there is no need to save Saving however itself would cause problems. */ e->accept(); return; } //################## shouldn't always save // True, but the database handles this automatically ! (se) if ( save() ) e->accept(); else e->ignore(); } /* Returns TRUE if it is OK to exit */ bool AddressbookWindow::save() { - if ( !abList->save() ) { + if ( !m_abView->save() ) { if ( QMessageBox::critical( 0, tr( "Out of space" ), tr("Unable to save information.\n" "Free up some space\n" "and try again.\n" "\nQuit anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default ) != QMessageBox::No ) return TRUE; else return FALSE; } return TRUE; } #ifdef __DEBUG_RELEASE void AddressbookWindow::slotSave() { save(); } #endif -void AddressbookWindow::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(); -} void AddressbookWindow::slotNotFound() { qWarning("Got notfound signal !"); QMessageBox::information( this, tr( "Not Found" ), tr( "Unable to find a contact for this" ) + "\n" + tr( "search pattern !" ) ); } void AddressbookWindow::slotWrapAround() { qWarning("Got wrap signal !"); - if ( doNotifyWrapAround ) - QMessageBox::information( this, tr( "End of list" ), - tr( "End of list. Wrap around now.. !" ) + "\n" ); +// if ( doNotifyWrapAround ) +// QMessageBox::information( this, tr( "End of list" ), +// tr( "End of list. Wrap around now.. !" ) + "\n" ); } void AddressbookWindow::slotSetCategory( int c ) { + qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); QString cat, book; + AbView::Views view = AbView::TableView; if ( c <= 0 ) return; - // 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 ); for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 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]; + } } } - abList->setShowCategory( book, cat ); - + slotViewSwitched( view ); + + m_abView -> setShowByCategory( view, cat ); + if ( book.isEmpty() ) book = "List"; if ( cat.isEmpty() ) cat = "All"; - 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 ); } void AddressbookWindow::slotSetLetter( char c ) { - abList->setShowByLetter( c ); + m_abView->setShowByLetter( c ); } + void AddressbookWindow::populateCategories() { catMenu->clear(); int id, rememberId; id = 1; rememberId = 0; - 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(); catMenu->insertItem( tr( "All" ), id++ ); - QStringList categories = abList->categories(); + QStringList categories = m_abView->categories(); categories.append( tr( "Unfiled" ) ); for ( QStringList::Iterator it = categories.begin(); it != categories.end(); ++it ) { catMenu->insertItem( *it, id ); - if ( *it == abList->showCategory() ) + if ( *it == m_abView -> showCategory() ) rememberId = id; ++id; } - 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 ); } else { slotSetCategory( rememberId ); } } 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 @@ -19,118 +19,119 @@ **********************************************************************/ #ifndef Addressbook_H #define Addressbook_H // Remove this for OPIE releae 1.0 ! #define __DEBUG_RELEASE #include <qmainwindow.h> #include <qvaluelist.h> #include <qstringlist.h> #include <qlineedit.h> #include "ofloatbar.h" +#include "abview.h" +#include "abconfig.h" class ContactEditor; class AbLabel; class AbTable; class QPEToolBar; class QPopupMenu; class QToolButton; class QDialog; class Ir; class QAction; class LetterPicker; class AddressbookWindow: public QMainWindow { Q_OBJECT public: + enum EntryMode { NewEntry=0, EditEntry }; + AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~AddressbookWindow(); protected: void resizeEvent( QResizeEvent * e ); - void showList(); - void showView(); - enum EntryMode { NewEntry=0, EditEntry }; + void editPersonal(); void editEntry( EntryMode ); void closeEvent( QCloseEvent *e ); bool save(); public slots: void flush(); void reload(); void appMessage(const QCString &, const QByteArray &); void setDocument( const QString & ); - void slotFindNext(); - void slotFindPrevious(); #ifdef __DEBUG_RELEASE void slotSave(); #endif private slots: void importvCard(); void slotListNew(); - void slotListView(); +/* void slotListView(); */ void slotListDelete(); void slotViewBack(); void slotViewEdit(); void slotPersonalView(); void listIsEmpty( bool ); - void slotSettings(); +/* void slotSettings(); */ void writeMail(); void slotBeam(); void beamDone( Ir * ); void slotSetCategory( int ); void slotSetLetter( char ); void slotUpdateToolbar(); void slotSetFont(int); void slotFindOpen(); void slotFindClose(); void slotFind(); void slotNotFound(); void slotWrapAround(); + void slotViewSwitched( int ); + void slotListView(); + void slotCardView(); + void slotConfig(); 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; // Searching stuff OFloatBar* searchBar; QLineEdit* searchEdit; - bool useRegExp; - bool doNotifyWrapAround; - bool caseSensitive; - - bool m_useQtMail; - bool m_useOpieMail; QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; - bool bAbEditFirstTime; int viewMargin; bool syncing; QFont *defaultFont; - int startFontSize; + int m_curFontSize; bool isLoading; + + AbConfig m_config; + + QAction* m_tableViewButton; + QAction* m_cardViewButton; }; #endif 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,33 +1,38 @@ TEMPLATE = app -CONFIG = qt warn_on release +#CONFIG = qt warn_on release +CONFIG = qt warn_on debug DESTDIR = $(OPIEDIR)/bin 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 \ addressbook.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 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TRANSLATIONS = ../../../i18n/de/addressbook.ts \ ../../../i18n/en/addressbook.ts \ ../../../i18n/es/addressbook.ts \ ../../../i18n/fr/addressbook.ts \ ../../../i18n/hu/addressbook.ts \ ../../../i18n/ja/addressbook.ts \ ../../../i18n/ko/addressbook.ts \ 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 @@ -13,44 +13,44 @@ ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "addresssettings.h" #include <qpe/config.h> -#include <qpe/contact.h> +#include <opie/ocontact.h> #include <qfile.h> #include <qlistbox.h> #include <stdlib.h> AddressSettings::AddressSettings( QWidget *parent, const char *name ) : AddressSettingsBase( parent, name, TRUE ) { init(); } AddressSettings::~AddressSettings() { } void AddressSettings::init() { - QStringList slFields = Contact::trfields(); + QStringList slFields = OContact::trfields(); // Make this match what is in initFields slFields.remove( tr("Name Title") ); slFields.remove( tr("First Name") ); slFields.remove( tr("Last Name") ); slFields.remove( tr("File As") ); slFields.remove( tr("Default Email") ); slFields.remove( tr("Notes") ); slFields.remove( tr("Gender") ); for( QStringList::Iterator it = slFields.begin(); it != slFields.end(); ++it ) { 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 @@ -23,25 +23,25 @@ **********************************************************************/</comment> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>AddressSettingsBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>244</width> + <width>240</width> <height>207</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Arrange Edit Fields</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> 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,61 +1,137 @@ #include "configdlg.h" +#include "ocontactfields.h" #include <qcheckbox.h> #include <qradiobutton.h> +#include <qlistbox.h> +#include <qpushbutton.h> + +#include <opie/ocontact.h> 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 @@ -1,29 +1,33 @@ #ifndef _CONFIGDLG_H_ #define _CONFIGDLG_H_ +#include <qmap.h> + #include "configdlg_base.h" +#include "abconfig.h" class ConfigDlg: public ConfigDlg_Base { Q_OBJECT public: ConfigDlg( QWidget *parent = 0, const char *name = 0 ); // 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; }; #endif 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 @@ -3,141 +3,229 @@ <author>Stefan Eilers</author> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>Configuration</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>244</width> - <height>298</height> + <width>276</width> + <height>327</height> </rect> </property> <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> <name>caption</name> <string>MyDialog1</string> </property> <property stdset="1"> <name>sizeGripEnabled</name> <bool>true</bool> </property> + <property> + <name>layoutMargin</name> + </property> <vbox> <property stdset="1"> <name>margin</name> - <number>11</number> + <number>1</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>configDlg_base</cstring> </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + </sizepolicy> + </property> <property> <name>layoutMargin</name> </property> + <property> + <name>layoutSpacing</name> + </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>Widget5</cstring> </property> <attribute> <name>title</name> - <string>Search</string> + <string>Misc</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> - <class>QButtonGroup</class> + <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>ButtonGroup1</cstring> + <cstring>GroupBox2</cstring> </property> <property stdset="1"> <name>title</name> - <string>Query Style</string> + <string>Search Settings</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> + <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> <property stdset="1"> <name>text</name> - <string>Use Wildcards (*,?)</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> + <string>Case Sensitive</string> </property> </widget> </vbox> </widget> <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> <spacer> <property> <name>name</name> <cstring>Spacer3</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> @@ -247,91 +335,213 @@ is provided free !</string> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </vbox> </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> </vbox> </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> </UI> 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 @@ -12,360 +12,97 @@ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * This is a rewrite of the abeditor.h file, modified to provide a more * intuitive interface to TrollTech's original Address Book editor. This * is made to operate exactly in interface with the exception of name. * */ #include "contacteditor.h" #include "addresspicker.h" +#include "ocontactfields.h" #include <qpe/categoryselect.h> #include <qpe/qpeapplication.h> #include <qpe/qpedialog.h> #include <qpe/timeconversion.h> +#include <opie/ocontact.h> +#include <qpe/resource.h> #include <qcombobox.h> #include <qlabel.h> #include <qtabwidget.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qscrollview.h> #include <qtoolbutton.h> #include <qpushbutton.h> #include <qmainwindow.h> #include <qvaluelist.h> #include <qpopupmenu.h> #include <qlistbox.h> +#include <qhbox.h> +#include <qaction.h> +#include <qiconset.h> static inline bool containsAlphaNum( const QString &str ); static inline bool constainsWhiteSpace( const QString &str ); // helper functions, convert our comma delimited list to proper // file format... void parseEmailFrom( const QString &txt, QString &strDefaultEmail, QString &strAll ); // helper convert from file format to comma delimited... void parseEmailTo( const QString &strDefaultEmail, const QString &strOtherEmail, QString &strBack ); ContactEditor::ContactEditor( const OContact &entry, - const QValueList<int> *newOrderedValues, - QStringList *slNewOrdered, QWidget *parent, const char *name, WFlags fl ) : QDialog( parent, name, TRUE, fl ), - orderedValues( newOrderedValues ), - slOrdered( *slNewOrdered ), m_personalView ( false ) { init(); - initMap(); setEntry( entry ); - qDebug("finish"); } ContactEditor::~ContactEditor() { } 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; QStringList trlChooserNames; for (i = 0; i <= 6; i++) { slHomeAddress.append( "" ); slBusinessAddress.append( "" ); } - { - 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 ); - } - } QVBoxLayout *vb = new QVBoxLayout( this ); tabMain = new QTabWidget( this ); vb->addWidget( tabMain ); QWidget *tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); svGeneral = new QScrollView( tabViewport ); vb->addWidget( svGeneral, 0, 0 ); @@ -411,34 +148,26 @@ void ContactEditor::init() { txtChooserField3 = new QLineEdit( container ); gl->addWidget( txtChooserField3, 5, 1 ); l = new QLabel( tr( "File As" ), container ); gl->addWidget( l, 6, 0 ); cmbFileAs = new QComboBox( TRUE, container ); gl->addWidget( cmbFileAs, 6, 1 ); labCat = new QLabel( tr( "Category" ), container ); gl->addWidget( labCat, 7, 0 ); cmbCat = new CategorySelect( container ); gl->addWidget( cmbCat, 7, 1 ); - - // 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(); btnNote = new QPushButton( tr( "Notes..." ), container ); gl->addWidget( btnNote, 8, 1 ); tabMain->insertTab( tabViewport, tr( "General" ) ); tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); svAddress = new QScrollView( tabViewport ); vb->addWidget( svAddress, 0, 0 ); @@ -450,35 +179,25 @@ void ContactEditor::init() { gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem cmbAddress = new QComboBox( FALSE, container ); cmbAddress->insertItem( tr( "Business" ) ); cmbAddress->insertItem( tr( "Home" ) ); gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); l = new QLabel( tr( "Address" ), container ); gl->addWidget( l, 1, 0 ); txtAddress = new QLineEdit( container ); gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); -/* - l = new QLabel( tr( "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 ); gl->addWidget( l, 2, 0 ); txtCity = new QLineEdit( container ); gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); l = new QLabel( tr( "State" ), container ); gl->addWidget( l, 3, 0 ); txtState = new QLineEdit( container ); gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); l = new QLabel( tr( "Zip Code" ), container ); gl->addWidget( l, 4, 0 ); @@ -727,80 +446,100 @@ void ContactEditor::init() { vb->addWidget( svDetails, 0, 0 ); svDetails->setResizePolicy( QScrollView::AutoOneFit ); svDetails->setFrameStyle( QFrame::NoFrame ); container = new QWidget( svDetails->viewport() ); svDetails->addChild( container ); gl = new QGridLayout( container, 1, 2, 2, 4 ); int counter = 0; // Birthday + QHBox* hBox = new QHBox( container ); l = new QLabel( tr("Birthday"), container ); gl->addWidget( l, counter, 0 ); QPopupMenu* m1 = new QPopupMenu( container ); birthdayPicker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( birthdayPicker ); - birthdayButton= new QToolButton( 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() ) ); ++counter; // Anniversary + hBox = new QHBox( container ); l = new QLabel( tr("Anniversary"), container ); gl->addWidget( l, counter, 0 ); m1 = new QPopupMenu( container ); anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( anniversaryPicker ); - anniversaryButton= new QToolButton( 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() ) ); ++counter; // Gender l = new QLabel( tr("Gender"), container ); gl->addWidget( l, counter, 0 ); cmbGender = new QComboBox( container ); cmbGender->insertItem( "", 0 ); cmbGender->insertItem( tr("Male"), 1); cmbGender->insertItem( tr("Female"), 2); gl->addWidget( cmbGender, counter, 1 ); ++counter; // Create Labels and lineedit fields for every dynamic entry QStringList::ConstIterator it = slDynamicEntries.begin(); - 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 ); gl->addWidget( l, i, 0 ); QLineEdit *e = new QLineEdit( container ); listValue.append( e ); gl->addWidget( e, i, 1); } // Fill labels with names.. - loadFields(); + // loadFields(); tabMain->insertTab( tabViewport, tr( "Details" ) ); dlgNote = new QDialog( this, "Note Dialog", TRUE ); dlgNote->setCaption( tr("Enter Note") ); QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); txtNote = new QMultiLineEdit( dlgNote ); vbNote->addWidget( txtNote ); connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); dlgName = new QDialog( this, "Name Dialog", TRUE ); @@ -869,52 +608,26 @@ void ContactEditor::init() { connect( cmbChooserField1, SIGNAL(activated(int)), this, SLOT(slotCmbChooser1Change(int)) ); connect( cmbChooserField2, SIGNAL(activated(int)), this, SLOT(slotCmbChooser2Change(int)) ); connect( cmbChooserField3, SIGNAL(activated(int)), this, SLOT(slotCmbChooser3Change(int)) ); connect( cmbChooserField4, SIGNAL(activated(int)), this, SLOT(slotCmbChooser4Change(int)) ); connect( cmbAddress, SIGNAL(activated(int)), this, SLOT(slotAddressTypeChange(int)) ); new QPEDialogListener(this); -} -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 ); } void ContactEditor::slotChooser1Change( const QString &textChanged ) { int index = cmbChooserField1->currentItem(); slChooserValues[index] = textChanged; } void ContactEditor::slotChooser2Change( const QString &textChanged ) { @@ -1062,62 +775,25 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) { int index = cmbFileAs->currentItem(); cmbFileAs->clear(); cmbFileAs->insertItem( parseName( textChanged, 0 ) ); cmbFileAs->insertItem( parseName( textChanged, 1 ) ); cmbFileAs->insertItem( parseName( textChanged, 2 ) ); cmbFileAs->insertItem( parseName( textChanged, 3 ) ); cmbFileAs->setCurrentItem( index ); - useFullName = TRUE; - -} - -// 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; } void ContactEditor::accept() { if ( isEmpty() ) { cleanupFields(); reject(); } else { saveEntry(); cleanupFields(); QDialog::accept(); @@ -1127,37 +803,37 @@ void ContactEditor::accept() { void ContactEditor::slotNote() { dlgNote->showMaximized(); if ( !dlgNote->exec() ) { txtNote->setText( ent.notes() ); } } void ContactEditor::slotName() { QString tmpName; - if (useFullName == TRUE) { + if (useFullName) { txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); } dlgName->showMaximized(); if ( dlgName->exec() ) { tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); txtFullName->setText( tmpName.simplifyWhiteSpace() ); slotFullNameChange( txtFullName->text() ); - useFullName = FALSE; + useFullName = false; } } void ContactEditor::setNameFocus() { txtFullName->setFocus(); } bool ContactEditor::isEmpty() { // Test and see if the record should be saved. @@ -1352,133 +1028,118 @@ QString ContactEditor::parseName( const QString fullName, int type ) { case NAME_L: return strLastName; case NAME_S: return strSuffix; } return QString::null; } void ContactEditor::cleanupFields() { - QStringList::Iterator it = slChooserValues.begin(); for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { (*it) = ""; } for ( int i = 0; i < 7; i++ ) { slHomeAddress[i] = ""; slBusinessAddress[i] = ""; } - 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(""); txtMiddleName->setText(""); txtLastName->setText(""); txtSuffix->setText(""); txtNote->setText(""); txtFullName->setText(""); txtJobTitle->setText(""); txtOrganization->setText(""); txtChooserField1->setText(""); txtChooserField2->setText(""); txtChooserField3->setText(""); txtAddress->setText(""); - //txtAddress2->setText(""); txtCity->setText(""); - //txtPOBox->setText(""); txtState->setText(""); txtZip->setText(""); QLineEdit *txtTmp = cmbCountry->lineEdit(); txtTmp->setText(""); txtTmp = cmbFileAs->lineEdit(); txtTmp->setText(""); } void ContactEditor::setEntry( const OContact &entry ) { cleanupFields(); - ent = entry; - useFullName = FALSE; + useFullName = false; txtFirstName->setText( ent.firstName() ); txtMiddleName->setText( ent.middleName() ); txtLastName->setText( ent.lastName() ); txtSuffix->setText( ent.suffix() ); QString *tmpString = new QString; *tmpString = ent.firstName() + " " + ent.middleName() + + " " + ent.lastName() + " " + ent.suffix(); txtFullName->setText( tmpString->simplifyWhiteSpace() ); cmbFileAs->setEditText( ent.fileAs() ); - if (hasTitle) + // 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(); - } +//} QStringList::ConstIterator it; 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" ) (*itLE)->setText( ent.department() ); if ( *it == "Company" ) (*itLE)->setText( ent.company() ); if ( *it == "Office" ) (*itLE)->setText( ent.office() ); if ( *it == "Profession" ) (*itLE)->setText( ent.profession() ); @@ -1580,113 +1241,102 @@ void ContactEditor::setEntry( const OContact &entry ) { QString gender = ent.gender(); cmbGender->setCurrentItem( gender.toInt() ); txtNote->setText( ent.notes() ); slotCmbChooser1Change( cmbChooserField1->currentItem() ); slotCmbChooser2Change( cmbChooserField2->currentItem() ); slotCmbChooser3Change( cmbChooserField3->currentItem() ); slotAddressTypeChange( cmbAddress->currentItem() ); // loadFields(); :SX - + updateDatePicker(); +} +void ContactEditor::updateDatePicker() +{ // Set DatePicker if ( !ent.birthday().isNull() ){ birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); birthdayPicker->setDate( ent.birthday() ); } else birthdayButton->setText( tr ("Unknown") ); if ( !ent.anniversary().isNull() ){ anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); anniversaryPicker->setDate( ent.anniversary() ); } else anniversaryButton->setText( tr ("Unknown") ); } void ContactEditor::saveEntry() { - if ( useFullName == TRUE ) { + if ( useFullName ) { txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); - useFullName = FALSE; -} - - /*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() ); ent.setFileAs( cmbFileAs->currentText() ); ent.setCategories( cmbCat->currentCategories() ); - 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] ); - } + // } QStringList::ConstIterator it; 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" ) ent.setDepartment( (*itLE)->text() ); if ( *it == "Company" ) ent.setCompany( (*itLE)->text() ); if ( *it == "Office" ) ent.setOffice( (*itLE)->text() ); if ( *it == "Profession" ) ent.setProfession( (*itLE)->text() ); @@ -1698,96 +1348,58 @@ void ContactEditor::saveEntry() { if ( *it == "Spouse" ) ent.setSpouse( (*itLE)->text() ); if ( *it == "Nickname" ) ent.setNickname( (*itLE)->text() ); if ( *it == "Children" ) ent.setChildren( (*itLE)->text() ); } + QStringList::ConstIterator itV; for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) ent.setBusinessPhone( *itV ); -/* - if ( *it == tr("Business 2 Phone" ) - ent.setBusiness2Phone( *itV ); -*/ + if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) ent.setBusinessFax( *itV ); if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) ent.setBusinessMobile( *itV ); -/* - if ( *it == "Company Phone" ) - ent.setCompanyPhone( *itV ); -*/ - //if ( *it == "Default Email" ) - //ent.setDefaultEmail( *itV ); if ( *it == "Emails" ){ QString allemail; QString defaultmail; parseEmailFrom( *itV, defaultmail, allemail ); // ent.clearEmails(); ent.setDefaultEmail( defaultmail ); ent.setEmails( allemail ); } if ( *it == "Home Phone" ) ent.setHomePhone( *itV ); -/* - if ( *it == "Home 2 Phone" ) - ent.setHome2Phone( *itV ); -*/ + if ( *it == "Home Fax" ) ent.setHomeFax( *itV ); if ( *it == "Home Mobile" ) 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" ) ent.setHomeWebpage( *itV ); if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) ent.setBusinessWebpage( *itV ); } int gender = cmbGender->currentItem(); ent.setGender( QString::number( gender ) ); @@ -1866,39 +1478,58 @@ static inline bool constainsWhiteSpace( const QString &str ) { int i, count = str.length(); for (i = 0; i < count; i++ ) if ( str[i].isSpace() ) return TRUE; return FALSE; } void ContactEditor::setPersonalView( bool personal ) { m_personalView = personal; + + // Currently disbled due to the fact that + // show will not work... + return; + if ( personal ){ cmbCat->hide(); labCat->hide(); + } else{ cmbCat->show(); - labCat->show(); - + labCat->show(); } } void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) { QDate date; date.setYMD( year, month, day ); QString dateString = TimeString::numberDateString( date ); anniversaryButton->setText( dateString ); ent.setAnniversary ( date ); } void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) { QDate date; date.setYMD( year, month, day ); QString dateString = TimeString::numberDateString( date ); birthdayButton->setText( dateString ); ent.setBirthday ( date ); } + +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 @@ -46,84 +46,84 @@ class QTabWidget; class QMultiLineEdit; class QLineEdit; class QComboBox; class QPushButton; class CategorySelect; class QLabel; class ContactEditor : public QDialog { Q_OBJECT public: ContactEditor( const OContact &entry, - const QValueList<int> *newOrderedValues, - QStringList *slNewOrdered, QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); ~ContactEditor(); - void loadFields(); void setNameFocus(); void setPersonalView( bool personal = true ); OContact entry() const { return ent; } public slots: void slotNote(); void slotName(); void setEntry(const OContact &entry); protected slots: void accept(); private: void init(); - void initMap(); void saveEntry(); bool isEmpty(); void cleanupFields(); + void updateDatePicker(); QString parseName( QString fullName, int type ); private slots: void slotChooser1Change( const QString &textChanged ); void slotChooser2Change( const QString &textChanged ); void slotChooser3Change( const QString &textChanged ); void slotChooser4Change( const QString &textChanged ); void slotCmbChooser1Change( int index ); void slotCmbChooser2Change( int index ); void slotCmbChooser3Change( int index ); void slotCmbChooser4Change( int index ); void slotAddressTypeChange( int index ); void slotAddressChange( const QString &textChanged ); void slotAddress2Change( const QString &textChanged ); void slotPOBoxChange( const QString &textChanged ); void slotCityChange( const QString &textChanged ); void slotStateChange( const QString &textChanged ); void slotZipChange( const QString &textChanged ); void slotCountryChange( const QString &textChanged ); void slotFullNameChange( const QString &textChanged ); void slotAnniversaryDateChanged( int year, int month, int day); void slotBirthdayDateChanged( int year, int month, int day); + void slotRemoveBirthday(); + void slotRemoveAnniversary(); 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; OContact ent; QDialog *dlgNote; QDialog *dlgName; QList<QLineEdit> listValue; QList<QLabel> listName; - const QValueList<int> *orderedValues; - QStringList slOrdered; + QStringList slDynamicEntries; + QStringList trlDynamicEntries; bool m_personalView; QStringList slHomeAddress; QStringList slBusinessAddress; QStringList slChooserNames; QStringList slChooserValues; QMultiLineEdit *txtNote; QLabel *lblNote; //QLineEdit *txtTitle; 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 @@ -1,10 +1,10 @@ Files: bin/addressbook apps/1Pim/addressbook.desktop Priority: optional Section: opie/applications Conflicts: qpe-tkcaddressbook Maintainer: Stefan Eilers <eilers.stefan@epost.de> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION -Depends: opie-base ($QPE_VERSION) libopie +Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION) Description: Contacts A simple addressbook for the Opie environment. 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 @@ -209,24 +209,29 @@ LetterPicker::LetterPicker( QWidget *parent, const char *name ) connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear())); connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear())); connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear())); connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear())); connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear())); } LetterPicker::~LetterPicker() { } +QSizePolicy LetterPicker::sizePolicy () const +{ + return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum); +} + void LetterPicker::clear() { lblABC->clearLetter(); lblDEF->clearLetter(); lblGHI->clearLetter(); lblJKL->clearLetter(); lblMNO->clearLetter(); lblPQR->clearLetter(); lblSTU->clearLetter(); lblVWX->clearLetter(); lblYZ->clearLetter(); } 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 @@ -4,24 +4,25 @@ * (c) 2002 Mike Crawford * * This file is FREE SOFTWARE covered under the GUN General Public License. * * */ #ifndef PICKER_H #define PICKER_H #include <qlabel.h> #include <qframe.h> #include <qevent.h> +#include <qsizepolicy.h> class PickerLabel: public QLabel { Q_OBJECT public: PickerLabel( QWidget *parent = 0, const char *name = 0 ); ~PickerLabel(); void setLetters( char ch1, char ch2, char ch3 ); void clearLetter(); signals: @@ -40,25 +41,26 @@ Q_OBJECT char letter1, letter2, letter3; private slots: void emitClearSignal(); }; class LetterPicker: public QFrame { Q_OBJECT public: LetterPicker( QWidget *parent = 0, const char *name = 0 ); ~LetterPicker(); - + + QSizePolicy sizePolicy () const; public slots: void clear(); signals: void letterClicked( char ); private: PickerLabel *lblABC, *lblDEF, *lblGHI, *lblJKL, *lblMNO, *lblPQR, *lblSTU, *lblVWX, *lblYZ; PickerLabel *lastLabel; private slots: 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 |