summaryrefslogtreecommitdiff
authoreilers <eilers>2002-10-08 12:33:52 (UTC)
committer eilers <eilers>2002-10-08 12:33:52 (UTC)
commita194611bf645fe7e2e9e83733ababc587fd42f1d (patch) (side-by-side diff)
tree2c21a5576bce48dba2fe83f6c849c0d16025a848
parent333fec32d47ea32de9fb4c8cd378a519785a1ff8 (diff)
downloadopie-a194611bf645fe7e2e9e83733ababc587fd42f1d.zip
opie-a194611bf645fe7e2e9e83733ababc587fd42f1d.tar.gz
opie-a194611bf645fe7e2e9e83733ababc587fd42f1d.tar.bz2
Joined development branch: It uses the new PIM API
Some features in "View" added by Darwin Zins, but they are not finished..
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/abeditor.cpp5
-rw-r--r--core/pim/addressbook/abeditor.h8
-rw-r--r--core/pim/addressbook/ablabel.cpp2
-rw-r--r--core/pim/addressbook/ablabel.h6
-rw-r--r--core/pim/addressbook/abtable.cpp444
-rw-r--r--core/pim/addressbook/abtable.h36
-rw-r--r--core/pim/addressbook/addressbook.cpp191
-rw-r--r--core/pim/addressbook/addressbook.h9
-rw-r--r--core/pim/addressbook/contacteditor.cpp4
-rw-r--r--core/pim/addressbook/contacteditor.h10
10 files changed, 295 insertions, 420 deletions
diff --git a/core/pim/addressbook/abeditor.cpp b/core/pim/addressbook/abeditor.cpp
index 6354db9..91e8722 100644
--- a/core/pim/addressbook/abeditor.cpp
+++ b/core/pim/addressbook/abeditor.cpp
@@ -53,3 +53,3 @@ void parseEmailTo( const QString &strDefaultEmail,
-AbEditor::AbEditor( const Contact &entry, const QValueList<int> *newOrdered,
+AbEditor::AbEditor( const OContact &entry, const QValueList<int> *newOrdered,
QStringList *slNewOrdered,
@@ -184,3 +184,3 @@ void AbEditor::loadFields()
-void AbEditor::setEntry( const Contact &entry )
+void AbEditor::setEntry( const OContact &entry )
{
@@ -551,2 +551,3 @@ void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
return;
+
// find the first
diff --git a/core/pim/addressbook/abeditor.h b/core/pim/addressbook/abeditor.h
index 9ce6704..a9c1c5f 100644
--- a/core/pim/addressbook/abeditor.h
+++ b/core/pim/addressbook/abeditor.h
@@ -40,3 +40,3 @@ class AbEditor : public QDialog
public:
- AbEditor( const Contact &entry, const QValueList<int> *newOrdedValues,
+ AbEditor( const OContact &entry, const QValueList<int> *newOrdedValues,
QStringList *slNewOrdered,
@@ -46,3 +46,3 @@ public:
void setNameFocus();
- Contact entry() const { return ent; }
+ OContact entry() const { return ent; }
@@ -50,3 +50,3 @@ public slots:
void slotNote();
- void setEntry( const Contact &entry );
+ void setEntry( const OContact &entry );
@@ -65,3 +65,3 @@ private:
QMultiLineEdit *txtNote;
- Contact ent;
+ OContact ent;
QScrollView *svPage;
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp
index 3bf3e12..cf1e39f 100644
--- a/core/pim/addressbook/ablabel.cpp
+++ b/core/pim/addressbook/ablabel.cpp
@@ -36,3 +36,3 @@ AbLabel::~AbLabel()
-void AbLabel::init( const Contact &entry )
+void AbLabel::init( const OContact &entry )
{
diff --git a/core/pim/addressbook/ablabel.h b/core/pim/addressbook/ablabel.h
index cfbd999..9086c4a 100644
--- a/core/pim/addressbook/ablabel.h
+++ b/core/pim/addressbook/ablabel.h
@@ -22,3 +22,3 @@
-#include <qpe/contact.h>
+#include <opie/ocontact.h>
#include <qtextview.h>
@@ -34,3 +34,3 @@ public:
public slots:
- void init( const Contact &entry );
+ void init( const OContact &entry );
void sync();
@@ -44,3 +44,3 @@ protected:
private:
- Contact ent;
+ OContact ent;
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 3fa1a7c..08c6d0a 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -27,2 +27,4 @@
+#include <opie/orecordlist.h>
+
#include <qasciidict.h>
@@ -31,2 +33,3 @@
#include <qregexp.h>
+#include <qmessagebox.h>
@@ -41,12 +44,3 @@
-static bool contactCompare( const Contact &cnt, const QRegExp &r, int category );
-
-//### qtmail/addresslist.cpp hardcodes this filename as well
-static QString journalFileName()
-{
- QString str = getenv("HOME");
- str +="/.abjournal";
- return str;
-}
-
+static bool contactCompare( const OContact &cnt, const QRegExp &r, int category );
@@ -137,3 +131,4 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam
currFindRow( -2 ),
- mCat( 0 )
+ mCat( 0 ),
+ m_contactdb ("addressbook")
{
@@ -161,2 +156,3 @@ void AbTable::init()
verticalHeader()->hide();
+ columnVisible = true;
}
@@ -177,2 +173,3 @@ void AbTable::columnClicked( int col )
}
+ //QMessageBox::information( this, "resort", "columnClicked" );
resort();
@@ -186,2 +183,3 @@ void AbTable::resort()
sortColumn( lastSortCol, asc, TRUE );
+ //QMessageBox::information( this, "resort", "resort" );
updateVisible();
@@ -190,5 +188,5 @@ void AbTable::resort()
-Contact AbTable::currentEntry()
+OContact AbTable::currentEntry()
{
- Contact cnt;
+ OContact cnt;
AbTableItem *abItem;
@@ -197,2 +195,3 @@ Contact AbTable::currentEntry()
cnt = contactList[abItem];
+ //cnt = contactList[currentRow()];
}
@@ -201,6 +200,5 @@ Contact AbTable::currentEntry()
-void AbTable::replaceCurrentEntry( const Contact &newContact )
+void AbTable::replaceCurrentEntry( const OContact &newContact )
{
int row = currentRow();
- updateJournal( newContact, Contact::ACTION_REPLACE, row );
updateVisible();
@@ -208,2 +206,3 @@ void AbTable::replaceCurrentEntry( const Contact &newContact )
journalFreeReplace( newContact, row );
+
}
@@ -213,7 +212,2 @@ void AbTable::deleteCurrentEntry()
int row = currentRow();
- AbTableItem *abItem;
- abItem = static_cast<AbTableItem*>(item( row, 0 ));
- Contact oldContact;
- oldContact = contactList[abItem];
- updateJournal( oldContact, Contact::ACTION_REMOVE, row );
@@ -226,2 +220,3 @@ void AbTable::deleteCurrentEntry()
emit empty( TRUE );
+
}
@@ -246,5 +241,11 @@ void AbTable::refresh()
AbTableItem *abi;
+
+ // hide columns so no flashing ?
+ if ( showBk == "Cards" ) {
+ hideColumn(0);
+ hideColumn(1);
+ }
for ( int r = 0; r < rows; ++r ) {
abi = static_cast<AbTableItem*>( item(r, 0) );
- value = findContactContact( contactList[abi] );
+ value = findContactContact( contactList[abi], r );
static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() );
@@ -305,3 +306,3 @@ void AbTable::moveTo( char c )
-QString AbTable::findContactName( const Contact &entry )
+QString AbTable::findContactName( const OContact &entry )
{
@@ -319,3 +320,3 @@ QString AbTable::findContactName( const Contact &entry )
-QString AbTable::findContactContact( const Contact &entry )
+QString AbTable::findContactContact( const OContact &entry, int /* row */ )
{
@@ -445,13 +446,17 @@ QString AbTable::findContactContact( const Contact &entry )
-void AbTable::addEntry( const Contact &newCnt )
+void AbTable::addEntry( const OContact &newCnt )
{
int row = numRows();
+
setNumRows( row + 1 );
- updateJournal( newCnt, Contact::ACTION_ADD );
insertIntoTable( newCnt, row );
+
+ qWarning("abtable:AddContact");
+ m_contactdb.add ( newCnt );
+
setCurrentCell( row, 0 );
- updateVisible();
+ // updateVisible();
}
-void AbTable::resizeRows( int size ) {
+void AbTable::resizeRows() {
/*
@@ -461,26 +466,9 @@ void AbTable::resizeRows( int size ) {
}
- }*/
+ }
updateVisible();
+ */
}
-void AbTable::updateJournal( const Contact &cnt,
- Contact::journal_action action, int row )
-{
- QFile f( journalFileName() );
- if ( !f.open(IO_WriteOnly|IO_Append) )
- return;
- QString buf;
- QCString str;
- buf = "<Contact ";
- cnt.save( buf );
- buf += " action=\"" + QString::number( (int)action ) + "\" ";
- if ( action == Contact::ACTION_REMOVE || action == Contact::ACTION_REPLACE)
- buf += " actionrow=\"" + QString::number(row) + "\" ";
- buf += "/>\n";
- QCString cstr = buf.utf8();
- f.writeBlock( cstr.data(), cstr.length() );
- QCopEnvelope( "QPE/PIM", "addressbookUpdated()" );
-}
-
-bool AbTable::save( const QString &fn )
+
+bool AbTable::save( const QString& /* fn */ )
{
@@ -488,51 +476,5 @@ bool AbTable::save( const QString &fn )
// t.start();
+ qWarning("abtable:Save data");
+ m_contactdb.save();
- QString strNewFile = fn + ".new";
- QFile f( strNewFile );
- if ( !f.open( IO_WriteOnly|IO_Raw ) )
- return false;
-
- int total_written;
- QString out;
- out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
- " <Groups>\n"
- " </Groups>\n"
- " <Contacts>\n";
- QMapIterator<AbTableItem*, Contact> it;
- for ( it = contactList.begin(); it != contactList.end(); ++it ) {
- out += "<Contact ";
- it.data().save( out );
- out += "/>\n";
- QCString cstr = out.utf8();
- total_written = f.writeBlock( cstr.data(), cstr.length() );
- if ( total_written != int(cstr.length()) ) {
- f.close();
- QFile::remove( strNewFile );
- return false;
- }
- out = "";
- }
- out += " </Contacts>\n</AddressBook>\n";
-
- QCString cstr = out.utf8();
- total_written = f.writeBlock( cstr.data(), cstr.length() );
- if ( total_written != int(cstr.length()) ) {
- f.close();
- QFile::remove( strNewFile );
- return false;
- }
- f.close();
-
-// qDebug("saving: %d", t.elapsed() );
-
- // move the file over, I'm just going to use the system call
- // because, I don't feel like using QDir.
- if ( ::rename( strNewFile.latin1(), fn.latin1() ) < 0 ) {
- qWarning( "problem renaming file %s to %s, errno: %d",
- strNewFile.latin1(), fn.latin1(), errno );
- // remove the tmp file...
- QFile::remove( strNewFile );
- }
- // remove the journal...
- QFile::remove( journalFileName() );
return true;
@@ -540,206 +482,25 @@ bool AbTable::save( const QString &fn )
-void AbTable::load( const QString &fn )
+void AbTable::load( const QString& /* fn */ )
{
setSorting( false );
- loadFile( fn, false );
- // merge in the journal
- if ( QFile::exists( journalFileName() ) ) {
- loadFile( journalFileName(), true );
- save( fn );
- }
- setSorting( true );
- resort();
-}
+ setUpdatesEnabled( FALSE );
-void AbTable::loadFile( const QString &strFile, bool journalFile )
-{
-// QTime t;
-// t.start();
- QFile f( strFile );
- if ( !f.open(IO_ReadOnly) )
- return;
- QList<Contact> list;
- list.setAutoDelete( TRUE );
- QByteArray ba = f.readAll();
- f.close();
- if (ba.isEmpty() )
- return;
- char *uc = ba.data();//(QChar *)data.unicode();
- int len = ba.size();//data.length();
- bool foundAction = false;
- Contact::journal_action action;
- bool foundKey = false;
- int journalKey = 0;
-
- const int JOURNALACTION = Qtopia::Notes + 1;
- const int JOURNALROW = JOURNALACTION + 1;
-
- // **********************************
- // CHANGE THE SIZE OF THE DICT IF YOU ADD ANY MORE FIELDS!!!!
- // **********************************
- QAsciiDict<int> dict( 47 );
- dict.setAutoDelete( TRUE );
- dict.insert( "Uid", new int(Qtopia::AddressUid) );
- dict.insert( "Title", new int(Qtopia::Title) );
- dict.insert( "FirstName", new int(Qtopia::FirstName) );
- dict.insert( "MiddleName", new int(Qtopia::MiddleName) );
- dict.insert( "LastName", new int(Qtopia::LastName) );
- dict.insert( "Suffix", new int(Qtopia::Suffix) );
- dict.insert( "FileAs", new int(Qtopia::FileAs) );
- dict.insert( "Categories", new int(Qtopia::AddressCategory) );
- dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) );
- dict.insert( "Emails", new int(Qtopia::Emails) );
- dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) );
- dict.insert( "HomeCity", new int(Qtopia::HomeCity) );
- dict.insert( "HomeState", new int(Qtopia::HomeState) );
- dict.insert( "HomeZip", new int(Qtopia::HomeZip) );
- dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) );
- dict.insert( "HomePhone", new int(Qtopia::HomePhone) );
- dict.insert( "HomeFax", new int(Qtopia::HomeFax) );
- dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) );
- dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) );
- dict.insert( "Company", new int(Qtopia::Company) );
- dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) );
- dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) );
- dict.insert( "BusinessState", new int(Qtopia::BusinessState) );
- dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) );
- dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) );
- dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) );
- dict.insert( "JobTitle", new int(Qtopia::JobTitle) );
- dict.insert( "Department", new int(Qtopia::Department) );
- dict.insert( "Office", new int(Qtopia::Office) );
- dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) );
- dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) );
- dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) );
- dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) );
- dict.insert( "Profession", new int(Qtopia::Profession) );
- dict.insert( "Assistant", new int(Qtopia::Assistant) );
- dict.insert( "Manager", new int(Qtopia::Manager) );
- dict.insert( "Spouse", new int(Qtopia::Spouse) );
- dict.insert( "Children", new int(Qtopia::Children) );
- dict.insert( "Gender", new int(Qtopia::Gender) );
- dict.insert( "Birthday", new int(Qtopia::Birthday) );
- dict.insert( "Anniversary", new int(Qtopia::Anniversary) );
- dict.insert( "Nickname", new int(Qtopia::Nickname) );
- dict.insert( "Notes", new int(Qtopia::Notes) );
- dict.insert( "action", new int(JOURNALACTION) );
- dict.insert( "actionrow", new int(JOURNALROW) );
-
- int i = 0;
- int num = 0;
- char *point;
- while ( (point = strstr( uc+i, "<Contact " ) ) != NULL ) {
- i = point - uc;
- // if we are reading the standard file, we just need to
- // insert info, so just say we'll do an insert...
- action = Contact::ACTION_ADD;
- // new Contact
- Contact *cnt = new Contact;
- i += 9;
- while ( 1 ) {
- while ( i < len && (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') )
- i++;
- if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') )
- break;
- // we have another attribute read it.
- int j = i;
- while ( j < len && uc[j] != '=' )
- j++;
- char *attr = uc+i;
- uc[j] = '\0';
- //qDebug("attr=%s", attr.latin1() );
- i = ++j; // skip =
- while ( i < len && uc[i] != '"' )
- i++;
- j = ++i;
- bool haveEnt = FALSE;
- bool haveUtf = FALSE;
- while ( j < len && uc[j] != '"' ) {
- if ( uc[j] == '&' )
- haveEnt = TRUE;
- if ( ((unsigned char)uc[j]) > 0x7f )
- haveUtf = TRUE;
- j++;
- }
-
- if ( j == i ) {
- // empty value
- i = j + 1;
- continue;
- }
-
- QString value = haveUtf ? QString::fromUtf8( uc+i, j-i )
- : QString::fromLatin1( uc+i, j-i );
- if ( haveEnt )
- value = Qtopia::plainString( value );
- i = j + 1;
-
- int *find = dict[ attr ];
- if ( !find ) {
- cnt->setCustomField(attr, value);
- continue;
- }
-#if 1
- switch( *find ) {
- case Qtopia::AddressUid:
- cnt->setUid( value.toInt() );
- break;
- case Qtopia::AddressCategory:
- cnt->setCategories( Qtopia::Record::idsFromString( value ));
- break;
- case JOURNALACTION:
- action = Contact::journal_action(value.toInt());
- break;
- case JOURNALROW:
- journalKey = value.toInt();
- break;
+ qWarning("abtable:Load data");
- default:
- cnt->insert( *find, value );
- break;
- }
-#endif
- }
+ 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++ );
- // sadly we can't delay adding of items from the journal to get
- // the proper effect, but then, the journal should _never_ be
- // that huge, and recovering from a crash is not necessarily
- // a *fast* thing.
- switch ( action ) {
- case Contact::ACTION_ADD:
- if ( journalFile ) {
- int myrows = numRows();
- setNumRows( myrows + 1 );
- insertIntoTable( *cnt, myrows );
- delete cnt;
- }
- else
- list.append( cnt );
- break;
- case Contact::ACTION_REMOVE:
- // yup, we don't use the entry to remove the object...
- journalFreeRemove( journalKey );
- delete cnt;
- break;
- case Contact::ACTION_REPLACE:
- journalFreeReplace( *cnt, journalKey );
- delete cnt;
- break;
- default:
- break;
- }
- num++;
- foundAction = false;
- foundKey = false;
-// if ( num % 100 == 0 ) {
-// qDebug("loading file, num=%d, t=%d", num, t.elapsed() );
-// }
- }
- if ( list.count() > 0 ) {
- internalAddEntries( list );
- }
-// qDebug("done loading %d, t=%d", num, t.elapsed() );
+ resort();
+
+ setUpdatesEnabled( TRUE );
+ setSorting( true );
+ //resort();
}
+
void AbTable::realignTable( int row )
@@ -763,3 +524,4 @@ void AbTable::realignTable( int row )
-void AbTable::insertIntoTable( const Contact &cnt, int row )
+// Add contact into table.
+void AbTable::insertIntoTable( const OContact &cnt, int row )
{
@@ -769,3 +531,3 @@ void AbTable::insertIntoTable( const Contact &cnt, int row )
strName = findContactName( cnt );
- strContact = findContactContact( cnt );
+ strContact = findContactContact( cnt, row );
@@ -784,16 +546,5 @@ void AbTable::insertIntoTable( const Contact &cnt, int row )
-void AbTable::internalAddEntries( QList<Contact> &list )
-{
- setUpdatesEnabled( FALSE );
- setNumRows( list.count() );
- int row = 0;
- Contact *it;
- for ( it = list.first(); it; it = list.next() )
- insertIntoTable( *it, row++ );
- resort();
- setUpdatesEnabled( TRUE );
-}
-
-void AbTable::journalFreeReplace( const Contact &cnt, int row )
+// Replace or add an entry
+void AbTable::journalFreeReplace( const OContact &cnt, int row )
{
@@ -804,5 +555,12 @@ void AbTable::journalFreeReplace( const Contact &cnt, int row )
strName = findContactName( cnt );
- strContact = findContactContact( cnt );
+ strContact = findContactContact( cnt, row );
ati = static_cast<AbTableItem*>(item(row, 0));
- if ( ati != 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 );
@@ -813,3 +571,4 @@ void AbTable::journalFreeReplace( const Contact &cnt, int row )
ati->setItem( strContact, strName );
- }else{
+
+ }else{ // add
int myrows = numRows();
@@ -817,3 +576,6 @@ void AbTable::journalFreeReplace( const Contact &cnt, int row )
insertIntoTable( cnt, myrows );
- // gets deleted when returning
+ // gets deleted when returning -- Why ? (se)
+ // :SX db access -> add
+ qWarning ("Are you sure to add to database ? -> Currently disabled !!");
+ // m_contactdb.add( cnt );
}
@@ -821,2 +583,3 @@ void AbTable::journalFreeReplace( const Contact &cnt, int row )
+// Remove entry
void AbTable::journalFreeRemove( int row )
@@ -827,4 +590,11 @@ void AbTable::journalFreeRemove( int row )
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 );
+
}
@@ -869,4 +639,3 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive,
clearSelection( TRUE );
- int rows,
- row;
+ int rows, row;
AbTableItem *ati;
@@ -881,4 +650,4 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive,
if ( contactCompare( contactList[ati], r, category ) )
+ //if ( contactCompare( contactList[row], r, category ) )
break;
-
}
@@ -888,2 +657,3 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive,
if ( contactCompare( contactList[ati], r, category ) )
+ //if ( contactCompare( contactList[row], r, category ) )
break;
@@ -914,3 +684,3 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive,
-static bool contactCompare( const Contact &cnt, const QRegExp &r, int category )
+static bool contactCompare( const OContact &cnt, const QRegExp &r, int category )
{
@@ -932,2 +702,3 @@ static bool contactCompare( const Contact &cnt, const QRegExp &r, int category )
}
+
return returnMe;
@@ -937,7 +708,19 @@ void AbTable::fitColumns()
{
- int contentsWidth = visibleWidth();
- int n = numCols();
- int pw = n == 3 ? columnWidth(2) : 0;
- setColumnWidth( 0, contentsWidth - contentsWidth / 2 );
- setColumnWidth( 1, contentsWidth / 2 - pw );
+ 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 );
+ }
}
@@ -985,3 +768,3 @@ void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/)
for (each row) {
- Contact *c = contactForRow(row);
+ OContact *c = contactForRow(row);
if ( list.contains(c->email) ) {
@@ -992,3 +775,3 @@ void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/)
for (remaining list items) {
- Contact *c = new contact(item);
+ OContact *c = new contact(item);
setText(newrow, 2, selname);
@@ -1006,3 +789,3 @@ QStringList AbTable::choiceSelection(int /*index*/) const
for (each row) {
- Contact *c = contactForRow(row);
+ OContact *c = contactForRow(row);
if ( text(row,2) == selname ) {
@@ -1016,6 +799,11 @@ QStringList AbTable::choiceSelection(int /*index*/) const
-void AbTable::setShowCategory( const QString &c )
+void AbTable::setShowCategory( const QString &b, const QString &c )
{
+ showBk = b;
showCat = c;
- updateVisible();
+ //QMessageBox::information( this, "setShowCategory", "setShowCategory" );
+ //updateVisible();
+ refresh();
+ ensureCellVisible( currentRow(), 0 );
+ updateVisible(); // :SX
}
@@ -1033,2 +821,6 @@ QString AbTable::showCategory() const
+QString AbTable::showBook() const
+{
+ return showBk;
+}
@@ -1051,3 +843,3 @@ void AbTable::updateVisible()
AbTableItem *ati;
- Contact *cnt;
+ OContact *cnt;
QString fileAsName;
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index d5ff279..84aef1e 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -24,3 +24,3 @@
#include <qpe/categories.h>
-#include <qpe/contact.h>
+#include <opie/ocontact.h>
@@ -31,2 +31,4 @@
+#include <opie/ocontactaccess.h>
+
class AbTableItem : public QTableItem
@@ -66,5 +68,5 @@ public:
// NEW
- void addEntry( const Contact &newContact );
- Contact currentEntry();
- void replaceCurrentEntry( const Contact &newContact );
+ void addEntry( const OContact &newContact );
+ OContact currentEntry();
+ void replaceCurrentEntry( const OContact &newContact );
@@ -85,3 +87,3 @@ public:
QStringList choiceSelection(int index) const;
- void setShowCategory( const QString &c );
+ void setShowCategory( const QString &b, const QString &c );
void setShowByLetter( char c );
@@ -89,3 +91,4 @@ public:
QStringList categories();
- void resizeRows( int size );
+
+ void resizeRows();
@@ -94,2 +97,4 @@ public:
+ QString showBook() const;
+
public slots:
@@ -121,9 +126,8 @@ private:
void resort();
- void updateJournal( const Contact &contact, Contact::journal_action action,
+ void updateJournal( const OContact &contact, OContact::journal_action action,
int row = -1 );
- void insertIntoTable( const Contact &contact, int row );
- void internalAddEntries( QList<Contact> &list );
- QString findContactName( const Contact &entry );
- QString findContactContact( const Contact &entry );
- void journalFreeReplace( const Contact &cnt, int row );
+ 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 );
@@ -134,3 +138,3 @@ private:
char showChar;
- QMap<AbTableItem*, Contact> contactList;
+ QMap<AbTableItem*, OContact> contactList;
const QValueList<int> *intFields;
@@ -141,2 +145,8 @@ private:
Categories mCat;
+
+ QString showBk;
+ bool columnVisible;
+
+ OContactAccess m_contactdb;
+
};
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 3255269..cf2eddf 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -15,3 +15,3 @@
**
-** Contact info@trolltech.com if any conditions of this licensing are
+** OContact info@trolltech.com if any conditions of this licensing are
** not clear to you.
@@ -97,2 +97,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
{
+ isLoading = true;
+
initFields();
@@ -189,3 +191,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
-
edit->insertSeparator();
@@ -209,3 +210,5 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
if ( str.isNull() ) {
- QMessageBox::warning( this, tr("Out of Space"),
+ QMessageBox::warning(
+ this,
+ tr("Out of Space"),
tr("There is not enough space to create\n"
@@ -222,9 +225,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
vb->addWidget(abList);
- 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()) );
+ // 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()) );
@@ -247,3 +247,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
mbList->insertItem( tr("View"), catMenu );
- setCentralWidget( listContainer );
+ // setCentralWidget( listContainer );
@@ -265,2 +265,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
// qDebug("adressbook contrsuction: t=%d", t.elapsed() );
+
+ abList->setCurrentCell( 0, 0 );
+
+ isLoading = false;
}
@@ -284,3 +288,4 @@ void AddressbookWindow::slotSetFont( int size ) {
currentFont = new QFont (abList->font());
- abList->resizeRows(currentFont->pixelSize() + 7);
+ // abList->resizeRows(currentFont->pixelSize() + 7);
+ abList->resizeRows();
break;
@@ -292,3 +297,4 @@ void AddressbookWindow::slotSetFont( int size ) {
currentFont = new QFont (abList->font());
- abList->resizeRows(currentFont->pixelSize() + 7);
+ // abList->resizeRows(currentFont->pixelSize() + 7);
+ abList->resizeRows();
break;
@@ -300,3 +306,4 @@ void AddressbookWindow::slotSetFont( int size ) {
currentFont = new QFont (abList->font());
- abList->resizeRows(currentFont->pixelSize() + 7);
+ //abList->resizeRows(currentFont->pixelSize() + 7);
+ abList->resizeRows();
break;
@@ -316,6 +323,7 @@ void AddressbookWindow::setDocument( const QString &filename )
{
- if ( filename.find(".vcf") != int(filename.length()) - 4 ) return;
+ if ( filename.find(".vcf") != int(filename.length()) - 4 )
+ return;
- QValueList<Contact> cl = Contact::readVCard( filename );
- for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
+ 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?")
@@ -349,3 +357,3 @@ void AddressbookWindow::slotUpdateToolbar()
{
- Contact ce = abList->currentEntry();
+ OContact ce = abList->currentEntry();
actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
@@ -355,3 +363,9 @@ void AddressbookWindow::showList()
{
- if ( mView ) mView->hide();
+ bool visiblemView;
+
+ visiblemView = false;
+ if ( mView ) {
+ mView->hide();
+ visiblemView = true;
+ }
setCentralWidget( listContainer );
@@ -360,2 +374,9 @@ void AddressbookWindow::showList()
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() );
+
}
@@ -374,3 +395,3 @@ void AddressbookWindow::slotListNew()
{
- Contact cnt;
+ OContact cnt;
if( !syncing ) {
@@ -381,3 +402,3 @@ void AddressbookWindow::slotListNew()
} else {
- QMessageBox::warning(this, tr("Contacts"),
+ QMessageBox::warning(this, tr("OContacts"),
tr("Can not edit data, currently syncing"));
@@ -396,3 +417,3 @@ void AddressbookWindow::slotListDelete()
if(!syncing) {
- Contact tmpEntry = abList->currentEntry();
+ OContact tmpEntry = abList->currentEntry();
@@ -443,3 +464,3 @@ void AddressbookWindow::writeMail()
{
- Contact c = abList->currentEntry();
+ OContact c = abList->currentEntry();
QString name = c.fileAs();
@@ -450,5 +471,2 @@ void AddressbookWindow::writeMail()
-
-
-
static const char * beamfile = "/tmp/obex/contact.vcf";
@@ -458,3 +476,3 @@ void AddressbookWindow::slotBeam()
QString filename;
- Contact c;
+ OContact c;
if ( actionPersonal->isOn() ) {
@@ -463,3 +481,3 @@ void AddressbookWindow::slotBeam()
return; // can't beam a non-existent file
- c = Contact::readVCard( filename )[0];
+ c = OContact::readVCard( filename )[0];
} else {
@@ -468,3 +486,3 @@ void AddressbookWindow::slotBeam()
mkdir("/tmp/obex/", 0755);
- Contact::writeVCard( beamfile, c );
+ OContact::writeVCard( beamfile, c );
filename = beamfile;
@@ -524,3 +542,3 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
- Contact cnt;
+ OContact cnt;
QString fn, mn, ln;
@@ -583,5 +601,5 @@ void AddressbookWindow::editPersonal()
QString filename = addressbookPersonalVCardName();
- Contact me;
+ OContact me;
if (QFile::exists(filename))
- me = Contact::readVCard( filename )[0];
+ me = OContact::readVCard( filename )[0];
if (bAbEditFirstTime) {
@@ -601,5 +619,5 @@ void AddressbookWindow::editPersonal()
setFocus();
- Contact new_personal = abEditor->entry();
+ OContact new_personal = abEditor->entry();
QString fname = addressbookPersonalVCardName();
- Contact::writeVCard( fname, new_personal );
+ OContact::writeVCard( fname, new_personal );
abView()->init(new_personal);
@@ -635,5 +653,5 @@ void AddressbookWindow::slotPersonalView()
QString filename = addressbookPersonalVCardName();
- Contact me;
+ OContact me;
if (QFile::exists(filename))
- me = Contact::readVCard( filename )[0];
+ me = OContact::readVCard( filename )[0];
@@ -649,3 +667,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
{
- Contact entry;
+ OContact entry;
if ( bAbEditFirstTime ) {
@@ -668,3 +686,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
if ( entryMode == NewEntry ) {
- Contact insertEntry = abEditor->entry();
+ OContact insertEntry = abEditor->entry();
insertEntry.assignUid();
@@ -672,3 +690,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
} else {
- Contact replaceEntry = abEditor->entry();
+ OContact replaceEntry = abEditor->entry();
if ( !replaceEntry.isValidUid() )
@@ -726,2 +744,3 @@ void AddressbookWindow::closeEvent( QCloseEvent *e )
//################## shouldn't always save
+ // True, but the database handles this automatically ! (se)
if ( save() )
@@ -794,4 +813,4 @@ void AddressbookWindow::initFields()
- QStringList xmlFields = Contact::fields();
- QStringList visibleFields = Contact::trfields();
+ QStringList xmlFields = OContact::fields();
+ QStringList visibleFields = OContact::trfields();
xmlFields.remove( "Title" );
@@ -800,4 +819,3 @@ void AddressbookWindow::initFields()
- int i,
- version;
+ int i, version;
Config cfg( "AddressBook" );
@@ -885,3 +903,3 @@ AbLabel *AddressbookWindow::abView()
mView = new AbLabel( this, "viewer" );
- mView->init( Contact() );
+ mView->init( OContact() );
connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
@@ -913,16 +931,36 @@ void AddressbookWindow::slotSetCategory( int c )
{
+
+ QString cat, book;
+
if ( c <= 0 )
return;
- for ( unsigned int i = 1; i < catMenu->count(); i++ )
+
+ // Checkmark Book Menu Item Selected
+ if ( c < 6 )
+ for ( unsigned int i = 1; i < 6; i++ )
catMenu->setItemChecked( i, c == (int)i );
- if ( c == 1 ) {
- abList->setShowCategory( QString::null );
- setCaption( tr("Contacts") + " - " + tr ( "All" ) );
- } else if ( c == (int)catMenu->count() ) {
- abList->setShowCategory( tr( "Unfiled" ) );
- setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) );
- } else {
- QString cat = abList->categories()[c - 2];
- abList->setShowCategory( cat );
- setCaption( tr("Contacts") + " - " + cat );
+
+ // Checkmark Category Menu Item Selected
+ else
+ for ( unsigned int i = 6; 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
+ 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
+ cat = QString::null;
+ else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled
+ cat = "Unfiled";
+ else
+ cat = abList->categories()[i - 7];
}
@@ -930,2 +968,12 @@ void AddressbookWindow::slotSetCategory( int c )
+ abList->setShowCategory( book, cat );
+
+ if ( book.isEmpty() )
+ book = "List";
+ if ( cat.isEmpty() )
+ cat = "All";
+
+ setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) );
+}
+
void AddressbookWindow::slotSetLetter( char c ) {
@@ -940,6 +988,13 @@ void AddressbookWindow::populateCategories()
- int id,
- rememberId;
+ int id, rememberId;
id = 1;
rememberId = 0;
+
+ catMenu->insertItem( tr( "List" ), id++ );
+ catMenu->insertItem( tr( "Phone Book" ), id++ );
+ catMenu->insertItem( tr( "Company Book" ), id++ );
+ catMenu->insertItem( tr( "Email Book" ), id++ );
+ catMenu->insertItem( tr( "Cards" ), id++ );
+ catMenu->insertSeparator();
+
catMenu->insertItem( tr( "All" ), id++ );
@@ -954,6 +1009,22 @@ void AddressbookWindow::populateCategories()
}
- if ( abList->showCategory().isEmpty() )
- slotSetCategory( 1 );
- else
+
+ 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 );
+ }
+ else {
slotSetCategory( rememberId );
}
+}
+
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 34ca85d..bf36407 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -78,2 +78,3 @@ private slots:
void slotSetFont(int);
+
private:
@@ -86,4 +87,3 @@ private:
QToolButton *deleteButton;
- QValueList<int> allFields,
- orderedFields;
+ QValueList<int> allFields, orderedFields;
QStringList slOrderedFields;
@@ -96,4 +96,3 @@ private:
- QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
- *actionPersonal, *actionMail;
+ QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail;
@@ -105,2 +104,4 @@ private:
int startFontSize;
+
+ bool isLoading;
};
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index ae86ed0..fd7f009 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -51,3 +51,3 @@ void parseEmailTo( const QString &strDefaultEmail,
-ContactEditor::ContactEditor( const Contact &entry,
+ContactEditor::ContactEditor( const OContact &entry,
const QValueList<int> *newOrderedValues,
@@ -1294,3 +1294,3 @@ void ContactEditor::cleanupFields() {
-void ContactEditor::setEntry( const Contact &entry ) {
+void ContactEditor::setEntry( const OContact &entry ) {
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index 4f3b56e..8ed8553 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -23,3 +23,3 @@
-#include <qpe/contact.h>
+#include <opie/ocontact.h>
@@ -54,3 +54,3 @@ class ContactEditor : public QDialog {
public:
- ContactEditor( const Contact &entry,
+ ContactEditor( const OContact &entry,
const QValueList<int> *newOrderedValues,
@@ -63,3 +63,3 @@ class ContactEditor : public QDialog {
void setNameFocus();
- Contact entry() const { return ent; }
+ OContact entry() const { return ent; }
@@ -68,3 +68,3 @@ class ContactEditor : public QDialog {
void slotName();
- void setEntry(const Contact &entry);
+ void setEntry(const OContact &entry);
@@ -103,3 +103,3 @@ class ContactEditor : public QDialog {
- Contact ent;
+ OContact ent;