summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO79
-rw-r--r--core/pim/addressbook/abconfig.cpp184
-rw-r--r--core/pim/addressbook/abconfig.h55
-rw-r--r--core/pim/addressbook/ablabel.cpp98
-rw-r--r--core/pim/addressbook/ablabel.h24
-rw-r--r--core/pim/addressbook/abtable.cpp914
-rw-r--r--core/pim/addressbook/abtable.h87
-rw-r--r--core/pim/addressbook/abview.cpp186
-rw-r--r--core/pim/addressbook/abview.h15
-rw-r--r--core/pim/addressbook/addressbook.cpp847
-rw-r--r--core/pim/addressbook/addressbook.h45
-rw-r--r--core/pim/addressbook/addressbook.pro17
-rw-r--r--core/pim/addressbook/addresssettings.cpp4
-rw-r--r--core/pim/addressbook/addresssettingsbase.ui2
-rw-r--r--core/pim/addressbook/configdlg.cpp156
-rw-r--r--core/pim/addressbook/configdlg.h30
-rw-r--r--core/pim/addressbook/configdlg_base.ui404
-rw-r--r--core/pim/addressbook/contacteditor.cpp605
-rw-r--r--core/pim/addressbook/contacteditor.h14
-rw-r--r--core/pim/addressbook/ocontactfields.cpp283
-rw-r--r--core/pim/addressbook/ocontactfields.h24
-rw-r--r--core/pim/addressbook/opie-addressbook.control2
-rw-r--r--core/pim/addressbook/picker.cpp5
-rw-r--r--core/pim/addressbook/picker.h4
-rw-r--r--core/pim/addressbook/version.h10
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,40 +1,63 @@
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
@@ -51,2 +74,20 @@ Fixed:
- 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
@@ -26,6 +26,7 @@
#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 )
{
}
@@ -35,12 +36,46 @@ 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 );
}
@@ -49,42 +84,33 @@ 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
@@ -24,4 +24,6 @@
#include <qtextview.h>
+#include <opie/ocontactaccess.h>
+
class AbLabel : public QTextView
{
@@ -32,16 +34,28 @@ public:
~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;
};
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,4 +1,5 @@
/**********************************************************************
** 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.
@@ -19,5 +20,4 @@
**********************************************************************/
-#define QTOPIA_INTERNAL_CONTACT_MRE
#include <qpe/categoryselect.h>
@@ -44,7 +44,4 @@
#include <ctype.h> //toupper() for key hack
-static bool contactCompare( const OContact &cnt, const QRegExp &r, int category );
-
-
/*!
\class AbTableItem abtable.h
@@ -121,19 +118,14 @@ void AbPickItem::setContentFromEditor( QWidget *w )
*/
-AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name )
- // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
- // : QTable( 0, 0, parent, name, TRUE ),
- // #else
+AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
: QTable( parent, name ),
- // #endif
- lastSortCol( -1 ),
- asc( TRUE ),
- intFields( order ),
- currFindRow( -1 ),
- mCat( 0 ),
- m_inSearch (false),
- m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. !
+ lastSortCol( -1 ),
+ asc( TRUE ),
+ intFields( order ),
+ enablePainting( true ),
+ columnVisible( true )
{
- mCat.load( categoryFileName() );
+ qWarning("C'tor start");
+
setSelectionMode( NoSelection );
init();
@@ -141,4 +133,7 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam
connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
this, SLOT(itemClicked(int,int)) );
+
+ contactList.clear();
+ qWarning("C'tor end");
}
@@ -149,5 +144,5 @@ AbTable::~AbTable()
void AbTable::init()
{
- showChar = '\0';
+ // :SX showChar = '\0';
setNumRows( 0 );
setNumCols( 2 );
@@ -160,4 +155,80 @@ void AbTable::init()
}
+void AbTable::setContacts( const OContactAccess::List& viewList )
+{
+ qWarning("AbTable::setContacts()");
+
+ clear();
+ m_viewList = viewList;
+
+ setSorting( false );
+ setUpdatesEnabled( FALSE );
+
+ OContactAccess::List::Iterator it;
+ setNumRows( m_viewList.count() );
+ int row = 0;
+ for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
+ insertIntoTable( *it, row++ );
+
+ setUpdatesEnabled( TRUE );
+
+ setSorting( true );
+
+ resort();
+
+ updateVisible();
+
+}
+
+bool AbTable::selectContact( int UID )
+{
+ qWarning( "AbTable::selectContact( %d )", UID );
+ int rows = numRows();
+ AbTableItem *abi;
+ OContact* foundContact = 0l;
+ bool found = false;
+
+ for ( int r = 0; r < rows; ++r ) {
+ abi = static_cast<AbTableItem*>( item(r, 0) );
+ foundContact = &contactList[abi];
+ if ( foundContact -> uid() == UID ){
+ ensureCellVisible( r, 0 );
+ setCurrentCell( r, 0 );
+ found = true;
+ break;
+ }
+ }
+
+ if ( !found ){
+ ensureCellVisible( 0,0 );
+ setCurrentCell( 0, 0 );
+ }
+
+ return true;
+}
+
+void AbTable::insertIntoTable( const OContact& cnt, int row )
+{
+ // qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
+ QString strName,
+ strContact;
+
+ strName = findContactName( cnt );
+ strContact = findContactContact( cnt, row );
+
+ AbTableItem *ati;
+ ati = new AbTableItem( this, QTableItem::Never, strName, strContact);
+ contactList.insert( ati, cnt );
+ setItem( row, 0, ati );
+ ati = new AbTableItem( this, QTableItem::Never, strContact, strName);
+ setItem( row, 1, ati );
+
+ //### cannot do this; table only has two columns at this point
+ // setItem( row, 2, new AbPickItem( this ) );
+
+}
+
+
+
void AbTable::columnClicked( int col )
{
@@ -180,4 +251,5 @@ void AbTable::columnClicked( int col )
void AbTable::resort()
{
+ qWarning( "void AbTable::resort()" );
if ( sorting() ) {
if ( lastSortCol == -1 )
@@ -191,4 +263,5 @@ void AbTable::resort()
OContact AbTable::currentEntry()
{
+ qWarning( "OContact AbTable::currentEntry()" );
OContact cnt;
AbTableItem *abItem;
@@ -201,29 +274,12 @@ OContact AbTable::currentEntry()
}
-void AbTable::replaceCurrentEntry( const OContact &newContact )
+int AbTable::currentEntry_UID()
{
- int row = currentRow();
- updateVisible();
-
- journalFreeReplace( newContact, row );
-
-}
-
-void AbTable::deleteCurrentEntry()
-{
- int row = currentRow();
-
- // a little wasteful, but it ensure's there is only one place
- // where we delete.
- journalFreeRemove( row );
- updateVisible();
-
- if ( numRows() == 0 )
- emit empty( TRUE );
-
+ return ( currentEntry().uid() );
}
void AbTable::clear()
{
+ qWarning( "void AbTable::clear()" );
contactList.clear();
for ( int r = 0; r < numRows(); ++r ) {
@@ -237,15 +293,12 @@ void AbTable::clear()
}
+// 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) );
@@ -263,43 +316,28 @@ void AbTable::keyPressEvent( QKeyEvent *e )
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();
@@ -347,143 +385,5 @@ QString AbTable::findContactName( const OContact &entry )
}
-QString AbTable::findContactContact( const OContact &entry, int /* row */ )
-{
- QString value;
- value = "";
- for ( QValueList<int>::ConstIterator it = intFields->begin();
- it != intFields->end(); ++it ) {
- switch ( *it ) {
- default:
- break;
- case Qtopia::Title:
- value = entry.title();
- break;
- case Qtopia::Suffix:
- value = entry.suffix();
- break;
- case Qtopia::FileAs:
- value = entry.fileAs();
- break;
- case Qtopia::DefaultEmail:
- value = entry.defaultEmail();
- case Qtopia::Emails:
- value = entry.emails();
- break;
- case Qtopia::HomeStreet:
- value = entry.homeStreet();
- break;
- case Qtopia::HomeCity:
- value = entry.homeCity();
- break;
- case Qtopia::HomeState:
- value = entry.homeState();
- break;
- case Qtopia::HomeZip:
- value = entry.homeZip();
- break;
- case Qtopia::HomeCountry:
- value = entry.homeCountry();
- break;
- case Qtopia::HomePhone:
- value = entry.homePhone();
- break;
- case Qtopia::HomeFax:
- value = entry.homeFax();
- break;
- case Qtopia::HomeMobile:
- value = entry.homeMobile();
- break;
- case Qtopia::HomeWebPage:
- value = entry.homeWebpage();
- break;
- case Qtopia::Company:
- value = entry.company();
- break;
- case Qtopia::BusinessCity:
- value = entry.businessCity();
- break;
- case Qtopia::BusinessStreet:
- value = entry.businessStreet();
- break;
- case Qtopia::BusinessZip:
- value = entry.businessZip();
- break;
- case Qtopia::BusinessCountry:
- value = entry.businessCountry();
- break;
- case Qtopia::BusinessWebPage:
- value = entry.businessWebpage();
- break;
- case Qtopia::JobTitle:
- value = entry.jobTitle();
- break;
- case Qtopia::Department:
- value = entry.department();
- break;
- case Qtopia::Office:
- value = entry.office();
- break;
- case Qtopia::BusinessPhone:
- value = entry.businessPhone();
- break;
- case Qtopia::BusinessFax:
- value = entry.businessFax();
- break;
- case Qtopia::BusinessMobile:
- value = entry.businessMobile();
- break;
- case Qtopia::BusinessPager:
- value = entry.businessPager();
- break;
- case Qtopia::Profession:
- value = entry.profession();
- break;
- case Qtopia::Assistant:
- value = entry.assistant();
- break;
- case Qtopia::Manager:
- value = entry.manager();
- break;
- case Qtopia::Spouse:
- value = entry.spouse();
- break;
- case Qtopia::Gender:
- value = entry.gender();
- break;
- case Qtopia::Birthday:
- value = TimeString::numberDateString( entry.birthday() );
- break;
- case Qtopia::Anniversary:
- value = TimeString::numberDateString( entry.anniversary() );
- break;
- case Qtopia::Nickname:
- value = entry.nickname();
- break;
- case Qtopia::Children:
- value = entry.children();
- break;
- case Qtopia::Notes:
- value = entry.notes();
- break;
- }
- if ( !value.isEmpty() )
- break;
- }
- return value;
-}
-void AbTable::addEntry( const OContact &newCnt )
-{
- int row = numRows();
-
- setNumRows( row + 1 );
- insertIntoTable( newCnt, row );
-
- qWarning("abtable:AddContact");
- m_contactdb.add ( newCnt );
-
- setCurrentCell( row, 0 );
- // updateVisible();
-}
void AbTable::resizeRows() {
@@ -499,135 +399,19 @@ void AbTable::resizeRows() {
-bool AbTable::save()
-{
- // QTime t;
- // t.start();
- qWarning("abtable:Save data");
-
- return m_contactdb.save();
-}
-
-void AbTable::load()
+void AbTable::realignTable()
{
- setSorting( false );
- setUpdatesEnabled( FALSE );
-
- qWarning("abtable:Load data");
-
- OContactAccess::List list = m_contactdb.allRecords();
- OContactAccess::List::Iterator it;
- setNumRows( list.count() );
- int row = 0;
- for ( it = list.begin(); it != list.end(); ++it )
- insertIntoTable( *it, row++ );
-
- setUpdatesEnabled( TRUE );
+ qWarning( "void AbTable::realignTable()" );
- setSorting( true );
- resort();
-}
+ setPaintingEnabled( FALSE );
+ resizeRows();
+ fitColumns();
-void AbTable::reload()
-{
- m_contactdb.reload();
- load();
-}
+ setPaintingEnabled( TRUE );
-void AbTable::realignTable( int row )
-{
- QTableItem *ti1,
- *ti2;
- int totalRows = numRows();
- for ( int curr = row; curr < totalRows - 1; curr++ ) {
- // the same info from the todo list still applies, but I
- // don't think it is _too_ bad.
- ti1 = item( curr + 1, 0 );
- ti2 = item( curr + 1, 1 );
- takeItem( ti1 );
- takeItem( ti2 );
- setItem( curr, 0, ti1 );
- setItem( curr, 1, ti2 );
- }
- setNumRows( totalRows - 1 );
- resort();
}
-// Add contact into table.
-void AbTable::insertIntoTable( const OContact &cnt, int row )
-{
- QString strName,
- strContact;
-
- strName = findContactName( cnt );
- strContact = findContactContact( cnt, row );
-
- AbTableItem *ati;
- ati = new AbTableItem( this, QTableItem::Never, strName, strContact);
- contactList.insert( ati, cnt );
- setItem( row, 0, ati );
- ati = new AbTableItem( this, QTableItem::Never, strContact, strName);
- setItem( row, 1, ati );
-
- //### cannot do this; table only has two columns at this point
- // setItem( row, 2, new AbPickItem( this ) );
-
- // resort at some point?
-}
-// Replace or add an entry
-void AbTable::journalFreeReplace( const OContact &cnt, int row )
-{
- QString strName,
- strContact;
- AbTableItem *ati = 0l;
-
- strName = findContactName( cnt );
- strContact = findContactContact( cnt, row );
- ati = static_cast<AbTableItem*>(item(row, 0));
-
- // Replace element if found in row "row"
- // or add this element if not.
- if ( ati != 0 ) { // replace
- // :SX db access -> replace
- qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() );
- m_contactdb.replace ( cnt );
-
- contactList.remove( ati );
- ati->setItem( strName, strContact );
- contactList.insert( ati, cnt );
-
- ati = static_cast<AbTableItem*>(item(row, 1));
- ati->setItem( strContact, strName );
-
- }else{ // add
- int myrows = numRows();
- setNumRows( myrows + 1 );
- insertIntoTable( cnt, myrows );
- // gets deleted when returning -- Why ? (se)
- // :SX db access -> add
- qWarning ("Are you sure to add to database ? -> Currently disabled !!");
- // m_contactdb.add( cnt );
- }
-}
-
-// Remove entry
-void AbTable::journalFreeRemove( int row )
-{
- AbTableItem *ati;
- ati = static_cast<AbTableItem*>(item(row, 0));
- if ( !ati )
- return;
-
- // :SX db access -> remove
- qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() );
- m_contactdb.remove( contactList[ati].uid() );
-
- contactList.remove( ati );
-
- realignTable( row );
-
-}
#if QT_VERSION <= 230
@@ -663,124 +447,30 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
// }
-void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool useRegExp,
- bool backwards, QString cat /* int category */ )
-{
- int category = 0;
-
- // Use the current Category if nothing else selected
- if ( cat.isEmpty() )
- category = mCat.id( "Contacts", showCat );
- else{
- category = mCat.id("Contacts", cat );
- }
-
- qWarning ("Found in Category %d", category);
-
- if ( currFindRow < -1 )
- currFindRow = - 1;
- clearSelection( TRUE );
- int rows, row;
- AbTableItem *ati;
- QRegExp r( findString );
- r.setCaseSensitive( caseSensitive );
- r.setWildcard( !useRegExp );
- rows = numRows();
- static bool wrapAround = true;
- bool try_again = false;
-
- // We will loop until we found an entry or found nothing.
- do {
- if ( !backwards ) {
- for ( row = currFindRow + 1; row < rows; row++ ) {
- ati = static_cast<AbTableItem*>( item(row, 0) );
- if ( contactCompare( contactList[ati], r, category ) ){
- try_again = false;
- break;
- }
- }
- } else {
- for ( row = currFindRow - 1; row > -1; row-- ) {
- ati = static_cast<AbTableItem*>( item(row, 0) );
- if ( contactCompare( contactList[ati], r, category ) ){
- try_again = false;
- break;
- }
- }
- }
- if ( row >= rows || row < 0 ) {
- if ( row < 0 )
- currFindRow = rows;
- else
- currFindRow = -1;
-
- if ( wrapAround ){
- emit signalWrapAround();
- try_again = true;
- }else{
- emit signalNotFound();
- try_again = false;
- }
-
- wrapAround = !wrapAround;
- } else {
- currFindRow = row;
- QTableSelection foundSelection;
- foundSelection.init( currFindRow, 0 );
- foundSelection.expandTo( currFindRow, numCols() - 1 );
- addSelection( foundSelection );
- setCurrentCell( currFindRow, 0 /* numCols() - 1 */ );
- wrapAround = true;
- try_again = false;
- }
- } while ( try_again );
-}
-static bool contactCompare( const OContact &cnt, const QRegExp &r, int category )
+void AbTable::fitColumns()
{
- bool returnMe;
- QArray<int> cats;
- cats = cnt.categories();
+ qWarning( "void AbTable::fitColumns()" );
+ int contentsWidth = visibleWidth() / 2; // :SX Why too low
+ // Fix to better value
+ // contentsWidth = 130;
- returnMe = false;
- if ( (cats.count() == 0) || (category == 0) )
- returnMe = cnt.match( r );
- else {
- int i;
- for ( i = 0; i < int(cats.count()); i++ ) {
- if ( cats[i] == category ) {
- returnMe = cnt.match( r );
- break;
- }
- }
+ if ( columnVisible == false ){
+ showColumn(0);
+ columnVisible = true;
}
- return returnMe;
-}
+ qWarning("Width: %d", contentsWidth);
-void AbTable::fitColumns()
-{
- int contentsWidth = visibleWidth() / 2;
-
- if ( showBk == "Cards" ) {
- showColumn(1);
- //adjustColumn(1);
- setColumnWidth( 1, visibleWidth() );
- columnVisible = false;
- } else {
- if ( columnVisible == false ){
- showColumn(0);
- columnVisible = true;
- }
- setColumnWidth( 0, contentsWidth );
- adjustColumn(1);
- if ( columnWidth(1) < contentsWidth )
- setColumnWidth( 1, contentsWidth );
- }
+ setColumnWidth( 0, contentsWidth );
+ adjustColumn(1);
+ if ( columnWidth(1) < contentsWidth )
+ setColumnWidth( 1, contentsWidth );
}
void AbTable::show()
{
- fitColumns();
+ qWarning( "void AbTable::show()" );
+ realignTable();
QTable::show();
}
@@ -803,8 +493,10 @@ void AbTable::setChoiceNames( const QStringList& list)
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();
}
}
@@ -815,22 +507,7 @@ QStringList AbTable::choiceNames() const
}
-void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/)
+void AbTable::setChoiceSelection( const QValueList<int>& list )
{
- /* ######
-
- QString selname = choicenames.at(index);
- for (each row) {
- OContact *c = contactForRow(row);
- if ( list.contains(c->email) ) {
- list.remove(c->email);
- setText(row, 2, selname);
- }
- }
- for (remaining list items) {
- OContact *c = new contact(item);
- setText(newrow, 2, selname);
- }
-
- */
+ intFields = list;
}
@@ -852,37 +529,6 @@ QStringList AbTable::choiceSelection(int /*index*/) const
}
-void AbTable::setShowCategory( const QString &b, const QString &c )
-{
- showBk = b;
- showCat = c;
- //QMessageBox::information( this, "setShowCategory", "setShowCategory" );
- //updateVisible();
- refresh();
- ensureCellVisible( currentRow(), 0 );
- updateVisible(); // :SX
-}
-void AbTable::setShowByLetter( char c )
-{
- showChar = tolower(c);
- updateVisible();
-}
-QString AbTable::showCategory() const
-{
- return showCat;
-}
-
-QString AbTable::showBook() const
-{
- return showBk;
-}
-
-QStringList AbTable::categories()
-{
- mCat.load( categoryFileName() );
- QStringList categoryList = mCat.labels( "Contacts" );
- return categoryList;
-}
void AbTable::updateVisible()
@@ -890,148 +536,33 @@ 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 );
+
+
}
@@ -1055,2 +586,127 @@ void AbTable::rowHeightChanged( int row )
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,4 +1,5 @@
/**********************************************************************
** 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.
@@ -24,4 +25,5 @@
#include <qpe/categories.h>
#include <opie/ocontact.h>
+#include <opie/ocontactaccess.h>
#include <qmap.h>
@@ -30,6 +32,4 @@
#include <qcombobox.h>
-#include <opie/ocontactaccess.h>
-
class AbTableItem : public QTableItem
{
@@ -64,52 +64,38 @@ class AbTable : public QTable
public:
- AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 );
+ AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 );
~AbTable();
- // NEW
- void addEntry( const OContact &newContact );
+
+ // Set the contacts shown in the table
+ void setContacts( const OContactAccess::List& viewList );
+ // Selects a contact of a specific UID
+ bool selectContact( int UID );
+
+ // Get the current selected entry
OContact currentEntry();
- void replaceCurrentEntry( const OContact &newContact );
- void init();
+ // Get the UID of the current selected Entry
+ int currentEntry_UID();
+
+ QString findContactName( const OContact &entry );
- void deleteCurrentEntry();
+ void init();
void clear();
- void clearFindRow() { currFindRow = -1; }
- void loadFields();
void refresh();
- bool save();
- void load();
- void reload();
-
- // addresspicker mode
- void setChoiceNames( const QStringList& list);
- QStringList choiceNames() const;
- void setChoiceSelection(int index, const QStringList& list);
- QStringList choiceSelection(int index) const;
- void setShowCategory( const QString &b, const QString &c );
- void setShowByLetter( char c );
- QString showCategory() const;
- QStringList categories();
-
- void resizeRows();
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:
@@ -128,33 +114,22 @@ protected slots:
private:
- void loadFile( const QString &strFile, bool journalFile );
+ void insertIntoTable( const OContact &cnt, int row );
+ QString findContactContact( const OContact &entry, int row );
void fitColumns();
+ void resizeRows();
+ void realignTable();
void resort();
- void updateJournal( const OContact &contact, OContact::journal_action action,
- int row = -1 );
- void insertIntoTable( const OContact &contact, int row );
- QString findContactName( const OContact &entry );
- QString findContactContact( const OContact &entry, int row );
- void journalFreeReplace( const OContact &cnt, int row );
- void journalFreeRemove( int row );
- void realignTable( int );
void updateVisible();
+
int lastSortCol;
bool asc;
- char showChar;
QMap<AbTableItem*, OContact> contactList;
- const QValueList<int> *intFields;
- int currFindRow;
- QString showCat;
+ QValueList<int> intFields;
QStringList choicenames;
bool enablePainting;
- Categories mCat;
- QString showBk;
bool columnVisible;
- bool m_inSearch;
-
- OContactAccess m_contactdb;
+ OContactAccess::List m_viewList;
};
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index d35e392..8d22129 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,23 +1,39 @@
#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() );
@@ -29,5 +45,5 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL
// 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();
@@ -50,4 +66,16 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered, const QStringL
}
+AbView::~AbView()
+{
+ m_contactdb -> save();
+ delete m_contactdb;
+
+ if ( m_storedDB ){
+ m_storedDB -> save();
+ delete m_storedDB;
+ }
+}
+
+
void AbView::setView( Views view )
{
@@ -60,5 +88,5 @@ void AbView::addEntry( const OContact &newContact )
{
qWarning("abview:AddContact");
- m_contactdb.add ( newContact );
+ m_contactdb->add ( newContact );
load();
@@ -67,5 +95,5 @@ void AbView::removeEntry( const int UID )
{
qWarning("abview:RemoveContact");
- m_contactdb.remove( UID );
+ m_contactdb->remove( UID );
load();
}
@@ -74,5 +102,5 @@ void AbView::replaceEntry( const OContact &contact )
{
qWarning("abview:ReplaceContact");
- m_contactdb.replace( contact );
+ m_contactdb->replace( contact );
load();
@@ -96,15 +124,20 @@ 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());
@@ -116,5 +149,7 @@ void AbView::load()
void AbView::reload()
{
- m_contactdb.reload();
+ qWarning( "void AbView::reload()" );
+
+ m_contactdb->reload();
load();
}
@@ -128,16 +163,41 @@ 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();
+ }
}
@@ -151,5 +211,5 @@ void AbView::setShowByLetter( char c )
}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;
@@ -158,4 +218,11 @@ void AbView::setShowByLetter( char c )
}
+void AbView::setListOrder( const QValueList<int>& ordered )
+{
+ m_orderedFields = ordered;
+ updateView();
+}
+
+
QString AbView::showCategory() const
{
@@ -163,8 +230,42 @@ QString AbView::showCategory() const
}
-void AbView::showContact( const OContact& cnt )
+void AbView::showPersonal( bool personal )
{
- qWarning ("void AbView::showContact( const OContact& cnt )");
- // :SX
+ qWarning ("void AbView::showPersonal( %d )", personal);
+
+ if ( personal ){
+
+ if ( m_inPersonal )
+ return;
+
+ // Now switch to vCard Backend and load data.
+ // The current default backend will be stored
+ // to avoid unneeded load/stores.
+ m_storedDB = m_contactdb;
+
+ OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
+ addressbookPersonalVCardName() );
+ m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
+
+ m_inPersonal = true;
+ m_curr_View = CardView;
+
+ }else{
+
+ if ( !m_inPersonal )
+ return;
+
+ // Remove vCard Backend and restore default
+ m_contactdb->save();
+ delete m_contactdb;
+
+ m_contactdb = m_storedDB;
+ m_storedDB = 0l;
+
+ m_curr_View = TableView;
+ m_inPersonal = false;
+
+ }
+ load();
}
@@ -181,6 +282,9 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
{
qWarning( "void AbView::slotDoFind" );
- // Use the current Category if nothing else selected
+ // We reloading the data: Deselect Letterpicker
+ emit signalClearLetterPicker();
+
+ // Use the current Category if nothing else selected
int category = 0;
@@ -198,5 +302,5 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
// Get all matching entries out of the database
- m_list = m_contactdb.matchRegexp( r );
+ m_list = m_contactdb->matchRegexp( r );
qWarning( "found: %d", m_list.count() );
@@ -246,14 +350,15 @@ 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();
}
}
}
+
}
@@ -269,5 +374,6 @@ bool AbView::contactCompare( const OContact &cnt, int category )
returnMe = false;
- if ( cats.count() == 0 )
+ if ( cats.count() == 0 && category == 0 )
+ // Contacts with no category will just shown on "All" and "Unfiled"
returnMe = true;
else {
@@ -285,4 +391,11 @@ bool AbView::contactCompare( const OContact &cnt, int category )
}
+// In Some rare cases we have to update all lists..
+void AbView::updateListinViews()
+{
+ m_abTable -> setContacts( m_list );
+ m_ablabel -> setContacts( m_list );
+}
+
void AbView::updateView()
{
@@ -294,5 +407,5 @@ void AbView::updateView()
// If we switching the view, we have to store some information
- if ( m_prev_View != m_curr_View ){
+ if ( m_list.count() ){
switch ( (int) m_prev_View ) {
case TableView:
@@ -303,5 +416,7 @@ void AbView::updateView()
break;
}
- }
+ emit signalViewSwitched ( (int) m_curr_View );
+ }else
+ m_curr_Contact = 0;
m_prev_View = m_curr_View;
@@ -310,9 +425,9 @@ void AbView::updateView()
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:
@@ -321,5 +436,4 @@ void AbView::updateView()
m_ablabel -> selectContact( m_curr_Contact );
m_ablabel -> setFocus();
- emit signalViewSwitched ( (int) m_curr_View );
break;
}
diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h
index 4d35338..201b521 100644
--- a/core/pim/addressbook/abview.h
+++ b/core/pim/addressbook/abview.h
@@ -18,7 +18,8 @@ class AbView: public QWidget
public:
- enum Views{ TableView=0, CardView, PhoneBook, CompanyBook, EmailBook };
+ enum Views{ TableView=0, CardView, PersonalView };
- AbView( QWidget* parent, const QValueList<int>& ordered, const QStringList& slOrderedFields );
+ AbView( QWidget* parent, const QValueList<int>& ordered );
+ ~AbView();
bool save();
@@ -28,7 +29,9 @@ public:
void setView( Views view );
- void showContact( const OContact& cnt );
+ void showPersonal( bool personal );
void setShowByCategory( Views view, const QString& cat );
void setShowByLetter( char c );
+ void setListOrder( const QValueList<int>& ordered );
+
// Add Entry and put to current
void addEntry( const OContact &newContact );
@@ -54,4 +57,5 @@ public slots:
private:
+ void updateListinViews();
void updateView();
void clearForCategory();
@@ -62,4 +66,5 @@ private:
Categories mCat;
bool m_inSearch;
+ bool m_inPersonal;
int m_curr_category;
Views m_curr_View;
@@ -67,5 +72,6 @@ private:
int m_curr_Contact;
- OContactAccess m_contactdb;
+ OContactAccess* m_contactdb;
+ OContactAccess* m_storedDB;
OContactAccess::List m_list;
@@ -75,5 +81,4 @@ private:
QValueList<int> m_orderedFields;
- QStringList m_slOrderedFields;
};
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 108e66d..e5addec 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -23,6 +23,7 @@
#include "contacteditor.h"
#include "ablabel.h"
+#include "abview.h"
#include "abtable.h"
-#include "addresssettings.h"
+// #include "addresssettings.h"
#include "addressbook.h"
@@ -30,13 +31,17 @@
#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>
@@ -46,12 +51,11 @@
#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>
@@ -61,63 +65,57 @@
#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 );
@@ -162,12 +160,14 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 );
@@ -184,6 +184,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
a->addTo( listTools );
-
-
if ( Ir::supported() ) {
a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
@@ -197,5 +195,5 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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() ) );
@@ -209,9 +207,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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
@@ -229,53 +222,39 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
// 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;
@@ -286,17 +265,15 @@ 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() );
}
@@ -305,10 +282,12 @@ void AddressbookWindow::slotConfig()
-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;
@@ -316,29 +295,20 @@ void AddressbookWindow::slotSetFont( int size ) {
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;
}
@@ -349,6 +319,7 @@ void AddressbookWindow::slotSetFont( int size ) {
void AddressbookWindow::importvCard() {
QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
- if(!str.isEmpty() )
+ if(!str.isEmpty() ){
setDocument((const QString&) str );
+ }
}
@@ -356,17 +327,38 @@ void AddressbookWindow::importvCard() {
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;
}
@@ -375,70 +367,27 @@ 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 {
@@ -448,15 +397,15 @@ void AddressbookWindow::slotListNew()
}
-void AddressbookWindow::slotListView()
-{
- abView()->init( abList->currentEntry() );
- mView->sync();
- showView();
-}
+// void AddressbookWindow::slotListView()
+// {
+// m_abView -> init( abList->currentEntry() );
+// // :SX mView->sync();
+// //:SX showView();
+// }
void AddressbookWindow::slotListDelete()
{
if(!syncing) {
- OContact tmpEntry = abList->currentEntry();
+ OContact tmpEntry = m_abView ->currentEntry();
// get a name, do the best we can...
@@ -471,6 +420,5 @@ void AddressbookWindow::slotListDelete()
if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
strName ) ) {
- abList->deleteCurrentEntry();
- showList();
+ m_abView->removeEntry( tmpEntry.uid() );
}
} else {
@@ -480,7 +428,30 @@ void AddressbookWindow::slotListDelete()
}
+void AddressbookWindow::slotFindOpen()
+{
+ searchBar->show();
+ m_abView -> inSearch();
+ searchEdit->setFocus();
+}
+void AddressbookWindow::slotFindClose()
+{
+ searchBar->hide();
+ m_abView -> offSearch();
+ // m_abView->setFocus();
+}
+
+
+void AddressbookWindow::slotFind()
+{
+ m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
+
+ searchEdit->clearFocus();
+ // m_abView->setFocus();
+
+}
+
void AddressbookWindow::slotViewBack()
{
- showList();
+ // :SX showList();
}
@@ -491,6 +462,4 @@ void AddressbookWindow::slotViewEdit()
editPersonal();
} else {
- if ( !bAbEditFirstTime )
- abEditor->setEntry( abList->currentEntry() );
editEntry( EditEntry );
}
@@ -505,5 +474,5 @@ void AddressbookWindow::slotViewEdit()
void AddressbookWindow::writeMail()
{
- OContact c = abList->currentEntry();
+ OContact c = m_abView -> currentEntry();
QString name = c.fileAs();
QString email = c.defaultEmail();
@@ -517,5 +486,5 @@ void AddressbookWindow::writeMail()
// 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" ) ){
@@ -525,7 +494,7 @@ void AddressbookWindow::writeMail()
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" ) ){
@@ -535,5 +504,5 @@ void AddressbookWindow::writeMail()
return;
} else
- m_useQtMail = true;
+ m_config.setUseQtMail( true );
}
@@ -550,12 +519,27 @@ void AddressbookWindow::slotBeam()
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 * ) ) );
@@ -622,13 +606,8 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
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 );
@@ -667,39 +646,56 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
}
-void AddressbookWindow::editPersonal()
+void AddressbookWindow::editEntry( EntryMode entryMode )
{
- QString filename = addressbookPersonalVCardName();
- OContact me;
- if (QFile::exists(filename))
- me = OContact::readVCard( filename )[0];
- if (bAbEditFirstTime) {
- qWarning("Editing personal data");
- abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields,
- this, "editor" );
- // don't create a new editor every time
- bAbEditFirstTime = FALSE;
- } else{
- abEditor->setEntry( me );
+ OContact entry;
+ if ( !abEditor ) {
+ abEditor = new ContactEditor( entry, this, "editor" );
}
-
- abEditor->setPersonalView( true );
+ if ( entryMode == EditEntry )
+ abEditor->setEntry( m_abView -> currentEntry() );
+ else if ( entryMode == NewEntry )
+ abEditor->setEntry( entry );
+ // other things may chane the caption.
+ abEditor->setCaption( tr("Edit Address") );
- abEditor->setCaption(tr("Edit My Personal Details"));
+#if defined(Q_WS_QWS) || defined(_WS_QWS_)
abEditor->showMaximized();
-
+#endif
// fix the foxus...
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()
{
@@ -710,6 +706,9 @@ void AddressbookWindow::slotPersonalView()
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;
}
@@ -718,58 +717,14 @@ void AddressbookWindow::slotPersonalView()
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 )
{
@@ -782,6 +737,6 @@ void AddressbookWindow::reload()
{
syncing = FALSE;
- abList->clear();
- abList->reload();
+ m_abView->clear();
+ m_abView->reload();
}
@@ -789,5 +744,5 @@ void AddressbookWindow::flush()
{
syncing = TRUE;
- abList->save();
+ m_abView->save();
}
@@ -795,15 +750,4 @@ void AddressbookWindow::flush()
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) {
@@ -829,5 +773,5 @@ void AddressbookWindow::closeEvent( QCloseEvent *e )
bool AddressbookWindow::save()
{
- if ( !abList->save() ) {
+ if ( !m_abView->save() ) {
if ( QMessageBox::critical( 0, tr( "Out of space" ),
tr("Unable to save information.\n"
@@ -852,171 +796,4 @@ void AddressbookWindow::slotSave()
#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()
@@ -1032,7 +809,7 @@ 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" );
}
@@ -1040,37 +817,47 @@ void AddressbookWindow::slotWrapAround()
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";
@@ -1078,13 +865,56 @@ void AddressbookWindow::slotSetCategory( int c )
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()
{
@@ -1095,36 +925,35 @@ void AddressbookWindow::populateCategories()
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 {
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
@@ -29,4 +29,6 @@
#include <qlineedit.h>
#include "ofloatbar.h"
+#include "abview.h"
+#include "abconfig.h"
class ContactEditor;
@@ -45,4 +47,6 @@ class AddressbookWindow: public QMainWindow
Q_OBJECT
public:
+ enum EntryMode { NewEntry=0, EditEntry };
+
AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~AddressbookWindow();
@@ -50,7 +54,5 @@ public:
protected:
void resizeEvent( QResizeEvent * e );
- void showList();
- void showView();
- enum EntryMode { NewEntry=0, EditEntry };
+
void editPersonal();
void editEntry( EntryMode );
@@ -63,6 +65,4 @@ public slots:
void appMessage(const QCString &, const QByteArray &);
void setDocument( const QString & );
- void slotFindNext();
- void slotFindPrevious();
#ifdef __DEBUG_RELEASE
void slotSave();
@@ -72,5 +72,5 @@ private slots:
void importvCard();
void slotListNew();
- void slotListView();
+/* void slotListView(); */
void slotListDelete();
void slotViewBack();
@@ -78,5 +78,5 @@ private slots:
void slotPersonalView();
void listIsEmpty( bool );
- void slotSettings();
+/* void slotSettings(); */
void writeMail();
void slotBeam();
@@ -93,21 +93,24 @@ private slots:
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;
@@ -115,21 +118,19 @@ private:
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;
};
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,23 +1,28 @@
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
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
@@ -23,5 +23,5 @@
#include <qpe/config.h>
-#include <qpe/contact.h>
+#include <opie/ocontact.h>
#include <qfile.h>
@@ -42,5 +42,5 @@ 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") );
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
@@ -33,5 +33,5 @@
<x>0</x>
<y>0</y>
- <width>244</width>
+ <width>240</width>
<height>207</height>
</rect>
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
@@ -2,5 +2,8 @@
#define _CONFIGDLG_H_
+#include <qmap.h>
+
#include "configdlg_base.h"
+#include "abconfig.h"
class ConfigDlg: public ConfigDlg_Base
@@ -11,17 +14,18 @@ public:
// Search Settings
- bool useRegExp() const;
- bool useWildCards() const;
- bool beCaseSensitive() const;
- bool signalWrapAround() const;
- bool useQtMail() const;
- bool useOpieMail() const;
-
- void setUseRegExp( bool v );
- void setUseWildCards( bool v );
- void setBeCaseSensitive( bool v );
- void setSignalWrapAround( bool v );
- void setQtMail( bool v );
- void setOpieMail( bool v );
+ void setConfig( const AbConfig& cnf );
+ AbConfig getConfig();
+
+protected slots:
+ void slotItemUp();
+ void slotItemDown();
+ void slotItemAdd();
+ void slotItemRemove();
+
+protected:
+ QStringList contFields;
+ AbConfig m_config;
+ QMap<QString, int> m_mapStrToID;
+ QMap<int, QString> m_mapIDToStr;
};
diff --git a/core/pim/addressbook/configdlg_base.ui b/core/pim/addressbook/configdlg_base.ui
index a6fcffa..66414f5 100644
--- a/core/pim/addressbook/configdlg_base.ui
+++ b/core/pim/addressbook/configdlg_base.ui
@@ -13,9 +13,16 @@
<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>
@@ -25,8 +32,11 @@
<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">
@@ -40,7 +50,17 @@
<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>
@@ -51,5 +71,5 @@
<attribute>
<name>title</name>
- <string>Search</string>
+ <string>Misc</string>
</attribute>
<vbox>
@@ -63,12 +83,12 @@
</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>
@@ -82,27 +102,59 @@
</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>
@@ -110,24 +162,60 @@
</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>
@@ -257,81 +345,203 @@ is provided free !</string>
</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>&amp;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>&amp;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
@@ -22,4 +22,5 @@
#include "contacteditor.h"
#include "addresspicker.h"
+#include "ocontactfields.h"
#include <qpe/categoryselect.h>
@@ -27,4 +28,6 @@
#include <qpe/qpedialog.h>
#include <qpe/timeconversion.h>
+#include <opie/ocontact.h>
+#include <qpe/resource.h>
#include <qcombobox.h>
@@ -41,4 +44,7 @@
#include <qpopupmenu.h>
#include <qlistbox.h>
+#include <qhbox.h>
+#include <qaction.h>
+#include <qiconset.h>
static inline bool containsAlphaNum( const QString &str );
@@ -55,19 +61,13 @@ void parseEmailTo( const QString &strDefaultEmail,
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");
}
@@ -77,16 +77,7 @@ 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;
@@ -97,265 +88,11 @@ void ContactEditor::init() {
}
- {
- hasGender = FALSE;
- hasTitle = FALSE;
- hasCompany = FALSE;
- hasNotes = FALSE;
- hasStreet = FALSE;
- hasStreet2 = FALSE;
- hasPOBox = FALSE;
- hasCity = FALSE;
- hasState = FALSE;
- hasZip = FALSE;
- hasCountry = FALSE;
-
- QStringList::ConstIterator it = slOrdered.begin();
-
- for ( i = 0; it != slOrdered.end(); i++, ++it ) {
-
- if ( (*it) == "Business Fax" ) {
- trlChooserNames.append( tr( "Business Fax" ) );
- slChooserNames.append( *it );
- slChooserValues.append("" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Fax" ) {
- trlChooserNames.append( tr( "Home Fax" ) );
- slChooserNames.append( *it );
- slChooserValues.append("" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
-
- if ( (*it) == "Business Phone" ) {
- trlChooserNames.append( tr( "Business Phone" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Phone" ) {
- trlChooserNames.append( tr( "Home Phone" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
+ trlChooserNames = OContactFields::trphonefields();
+ slChooserNames = OContactFields::untrphonefields();
+ slDynamicEntries = OContactFields::untrdetailsfields();
+ trlDynamicEntries = OContactFields::trdetailsfields();
+ for (i = 0; i < slChooserNames.count(); i++)
+ slChooserValues.append("");
-/*
- if ( (*it).right( 2 ) == tr( "IM" ) ) {
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- } */
-
- if ( (*it) == "Business Mobile" ) {
- trlChooserNames.append( tr( "Business Mobile" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Mobile" ) {
- trlChooserNames.append( tr( "Home Mobile" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
-
- if ( (*it) == "Business WebPage" ) {
- trlChooserNames.append( tr( "Business WebPage" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Web Page" ) {
- trlChooserNames.append( tr( "Home Web Page" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business Pager" ) {
- trlChooserNames.append( tr( "Business Pager" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Default Email" ) {
- trlChooserNames.append( tr( "Default Email" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Emails" ) {
- trlChooserNames.append( tr( "Emails" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Name Title" ||
- *it == "First Name" ||
- *it == "Middle Name" ||
- *it == "Last Name" ||
- *it == "File As" ||
- *it == "Default Email" ||
- *it == "Emails" ||
- *it == "Groups" ||
- *it == "Anniversary" ||
- *it == "Birthday" )
- continue;
-
- if ( *it == "Name Title" ) {
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "First Name" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Middle Name" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Last Name" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Suffix" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "File As" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Gender" ) {
- hasGender = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Job Title" ) {
- hasTitle = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( ( *it == "Company") || (*it == "Organization" ) ) {
- hasCompany = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Notes" ) {
- hasNotes = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Groups" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business Street" ) {
- hasStreet = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Street" ) {
- hasStreet = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-/*
- if ( (*it).right( 8 ) == tr( "Street 2" ) ) {
- hasStreet2 = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) {
- hasPOBox = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- } */
-
- if ( (*it) == "Business City" ) {
- hasCity = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business State" ) {
- hasState = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business Zip" ) {
- hasZip = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business Country" ) {
- hasCountry = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home City" ) {
- hasCity = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home State" ) {
- hasState = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Zip" ) {
- hasZip = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Country" ) {
- hasCountry = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- slDynamicEntries.append( *it );
- }
- }
QVBoxLayout *vb = new QVBoxLayout( this );
@@ -421,14 +158,6 @@ void ContactEditor::init() {
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 );
@@ -460,15 +189,5 @@ void ContactEditor::init() {
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 );
@@ -737,4 +456,5 @@ void ContactEditor::init() {
// Birthday
+ QHBox* hBox = new QHBox( container );
l = new QLabel( tr("Birthday"), container );
gl->addWidget( l, counter, 0 );
@@ -744,14 +464,22 @@ void ContactEditor::init() {
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 );
@@ -761,10 +489,16 @@ void ContactEditor::init() {
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;
@@ -783,6 +517,11 @@ void ContactEditor::init() {
// 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 );
@@ -792,5 +531,5 @@ void ContactEditor::init() {
}
// Fill labels with names..
- loadFields();
+ // loadFields();
@@ -879,32 +618,6 @@ void ContactEditor::init() {
new QPEDialogListener(this);
-}
-void ContactEditor::initMap()
-{
- /*
- // since the fields and the XML fields exist, create a map
- // between them...
- Config cfg1( "AddressBook" );
- Config cfg2( "AddressBook" );
- QString strCfg1,
- strCfg2;
- int i;
-
- // This stuff better exist...
- cfg1.setGroup( "AddressFields" );
-o cfg2.setGroup( "XMLFields" );
- i = 0;
- strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null );
- strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++),
- QString::null );
- while ( !strCfg1.isNull() && !strCfg2.isNull() ) {
- mapField.insert( strCfg1, strCfg2 );
- strCfg1 = cfg1.readEntry( "Field" + QString::number(i),
- QString::null );
- strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++),
- QString::null );
- }
- */
+ setPersonalView ( m_personalView );
}
@@ -1072,42 +785,5 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) {
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;
}
@@ -1137,5 +813,5 @@ void ContactEditor::slotName() {
QString tmpName;
- if (useFullName == TRUE) {
+ if (useFullName) {
txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
@@ -1149,5 +825,5 @@ void ContactEditor::slotName() {
txtFullName->setText( tmpName.simplifyWhiteSpace() );
slotFullNameChange( txtFullName->text() );
- useFullName = FALSE;
+ useFullName = false;
}
@@ -1362,5 +1038,4 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
void ContactEditor::cleanupFields() {
-
QStringList::Iterator it = slChooserValues.begin();
for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
@@ -1373,10 +1048,9 @@ void ContactEditor::cleanupFields() {
}
- QStringList::ConstIterator cit;
- QListIterator<QLineEdit> itLE( listValue );
- for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) {
- (*itLE)->setText( "" );
- }
-
+ QListIterator<QLineEdit> itLV( listValue );
+ for ( ; itLV.current(); ++itLV ) {
+ (*itLV)->setText( "" );
+ }
+
txtFirstName->setText("");
txtMiddleName->setText("");
@@ -1391,7 +1065,5 @@ void ContactEditor::cleanupFields() {
txtChooserField3->setText("");
txtAddress->setText("");
- //txtAddress2->setText("");
txtCity->setText("");
- //txtPOBox->setText("");
txtState->setText("");
txtZip->setText("");
@@ -1407,8 +1079,7 @@ void ContactEditor::setEntry( const OContact &entry ) {
cleanupFields();
-
ent = entry;
- useFullName = FALSE;
+ useFullName = false;
txtFirstName->setText( ent.firstName() );
txtMiddleName->setText( ent.middleName() );
@@ -1424,51 +1095,41 @@ void ContactEditor::setEntry( const OContact &entry ) {
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() );
@@ -1590,5 +1251,8 @@ void ContactEditor::setEntry( const OContact &entry ) {
// loadFields(); :SX
-
+ updateDatePicker();
+}
+void ContactEditor::updateDatePicker()
+{
// Set DatePicker
if ( !ent.birthday().isNull() ){
@@ -1608,5 +1272,5 @@ void ContactEditor::setEntry( const OContact &entry ) {
void ContactEditor::saveEntry() {
- if ( useFullName == TRUE ) {
+ if ( useFullName ) {
txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) );
txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) );
@@ -1614,17 +1278,11 @@ void ContactEditor::saveEntry() {
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() );
@@ -1632,51 +1290,43 @@ void ContactEditor::saveEntry() {
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() );
@@ -1708,4 +1358,5 @@ void ContactEditor::saveEntry() {
}
+
QStringList::ConstIterator itV;
for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
@@ -1713,8 +1364,5 @@ void ContactEditor::saveEntry() {
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 );
@@ -1722,10 +1370,4 @@ void ContactEditor::saveEntry() {
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" ){
@@ -1740,8 +1382,5 @@ void ContactEditor::saveEntry() {
if ( *it == "Home Phone" )
ent.setHomePhone( *itV );
-/*
- if ( *it == "Home 2 Phone" )
- ent.setHome2Phone( *itV );
-*/
+
if ( *it == "Home Fax" )
ent.setHomeFax( *itV );
@@ -1749,35 +1388,8 @@ void ContactEditor::saveEntry() {
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 );
@@ -1876,11 +1488,16 @@ 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();
}
}
@@ -1903,2 +1520,16 @@ void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
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
@@ -56,11 +56,8 @@ class ContactEditor : public QDialog {
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 );
@@ -77,8 +74,8 @@ class ContactEditor : public QDialog {
private:
void init();
- void initMap();
void saveEntry();
bool isEmpty();
void cleanupFields();
+ void updateDatePicker();
QString parseName( QString fullName, int type );
private slots:
@@ -102,7 +99,10 @@ class ContactEditor : public QDialog {
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;
@@ -113,7 +113,7 @@ class ContactEditor : public QDialog {
QList<QLineEdit> listValue;
QList<QLabel> listName;
- const QValueList<int> *orderedValues;
- QStringList slOrdered;
+
QStringList slDynamicEntries;
+ QStringList trlDynamicEntries;
bool m_personalView;
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
@@ -6,5 +6,5 @@ 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
@@ -219,4 +219,9 @@ LetterPicker::~LetterPicker()
}
+QSizePolicy LetterPicker::sizePolicy () const
+{
+ return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum);
+}
+
void LetterPicker::clear()
{
diff --git a/core/pim/addressbook/picker.h b/core/pim/addressbook/picker.h
index d76d582..d268983 100644
--- a/core/pim/addressbook/picker.h
+++ b/core/pim/addressbook/picker.h
@@ -14,4 +14,5 @@
#include <qframe.h>
#include <qevent.h>
+#include <qsizepolicy.h>
class PickerLabel: public QLabel {
@@ -50,5 +51,6 @@ Q_OBJECT
LetterPicker( QWidget *parent = 0, const char *name = 0 );
~LetterPicker();
-
+
+ QSizePolicy sizePolicy () const;
public 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