summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
authoreilers <eilers>2002-11-18 09:38:28 (UTC)
committer eilers <eilers>2002-11-18 09:38:28 (UTC)
commit8401def65aa4f19d91873bc57a3dcf25c358c490 (patch) (side-by-side diff)
tree3e64bd2d1b6f92c77304cc2d2c0fd06b07d718e5 /core/pim/addressbook/addressbook.cpp
parent4d0773414a0fb59e53f30d4d2363f73304f474dc (diff)
downloadopie-8401def65aa4f19d91873bc57a3dcf25c358c490.zip
opie-8401def65aa4f19d91873bc57a3dcf25c358c490.tar.gz
opie-8401def65aa4f19d91873bc57a3dcf25c358c490.tar.bz2
Back to main tree. Back to main tree.
Back to main tree. Waiting for moving to feature freeze ..
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp847
1 files changed, 338 insertions, 509 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 108e66d..e5addec 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -24,4 +24,5 @@
#include "ablabel.h"
+#include "abview.h"
#include "abtable.h"
-#include "addresssettings.h"
+// #include "addresssettings.h"
#include "addressbook.h"
@@ -31,7 +32,5 @@
#include <opie/ofiledialog.h>
-#include <qpe/qpeapplication.h>
-#include <qpe/config.h>
#include <opie/ocontact.h>
+#include <opie/ocontactaccessbackend_vcard.h>
-#include <qpe/global.h>
#include <qpe/resource.h>
@@ -40,2 +39,8 @@
#include <qpe/qcopenvelope_qws.h>
+#include <qpe/qpetoolbar.h>
+#include <qpe/qpemenubar.h>
+// #include <qtoolbar.h>
+// #include <qmenubar.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/config.h>
@@ -47,3 +52,2 @@
#include <qlayout.h>
-#include <qpe/qpemenubar.h>
#include <qmessagebox.h>
@@ -51,3 +55,2 @@
#include <qpopupmenu.h>
-#include <qpe/qpetoolbar.h>
#include <qstringlist.h>
@@ -55,2 +58,3 @@
#include <qwhatsthis.h>
+#include <qdatetime.h>
@@ -62,3 +66,2 @@
-#include <qdatetime.h>
@@ -67,9 +70,3 @@
-static QString addressbookPersonalVCardName()
-{
- QString filename = Global::applicationFileName("addressbook",
- "businesscard.vcf");
- return filename;
-}
-
+extern QString addressbookPersonalVCardName();
@@ -78,10 +75,7 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
: QMainWindow( parent, name, f ),
- abEditor(0),
- useRegExp(false),
- doNotifyWrapAround(true),
- caseSensitive(false),
- m_useQtMail(true),
- m_useOpieMail(false),
- bAbEditFirstTime(TRUE),
- syncing(FALSE)
+ catMenu (0l),
+ abEditor(0l),
+ syncing(FALSE),
+ m_tableViewButton(0l),
+ m_cardViewButton(0l)
{
@@ -89,34 +83,38 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
- // Read Config settings
- Config cfg("AddressBook");
- cfg.setGroup("Search");
- useRegExp = cfg.readBoolEntry( "useRegExp" );
- caseSensitive = cfg.readBoolEntry( "caseSensitive" );
- doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" );
- cfg.setGroup("Mail");
- m_useQtMail = cfg.readBoolEntry( "useQtMail", true );
- m_useOpieMail=cfg.readBoolEntry( "useOpieMail" );
-
+ m_config.load();
- initFields();
-
setCaption( tr("Contacts") );
setIcon( Resource::loadPixmap( "AddressBook" ) );
+
+ // Settings for Main Menu
+ setToolBarsMovable( true );
+ setRightJustification( true );
- setToolBarsMovable( FALSE );
-
- // Create Toolbars
-
- QPEToolBar *bar = new QPEToolBar( this );
- bar->setHorizontalStretchable( TRUE );
+ // Create Toolbar
+ listTools = new QPEToolBar( this, "list operations" );
+ listTools->setHorizontalStretchable( true );
+ addToolBar( listTools );
+ moveToolBar( listTools, m_config.getToolBarPos() );
- QPEMenuBar *mbList = new QPEMenuBar( bar );
+ QPEMenuBar *mbList = new QPEMenuBar( this );
mbList->setMargin( 0 );
- QPopupMenu *edit = new QPopupMenu( this );
+ QPopupMenu *edit = new QPopupMenu( mbList );
mbList->insertItem( tr( "Contact" ), edit );
- listTools = new QPEToolBar( this, "list operations" );
-
+ // View Icons
+ m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "datebook/weeklst" ),
+ QString::null, 0, this, 0 );
+ connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
+ m_tableViewButton->setToggleAction( true );
+ m_tableViewButton->addTo( listTools );
+ m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 );
+ connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
+ m_cardViewButton->setToggleAction( true );
+ m_cardViewButton->addTo( listTools );
+
+ listTools->addSeparator();
+
+ // Other Buttons
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
@@ -163,4 +161,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
searchEdit = new QLineEdit( searchBar, "searchEdit" );
-// QFont f("unifont", 16 /*, QFont::Bold*/);
-// searchEdit->setFont( f );
+
+// QFont f("unifont", 16 /*, QFont::Bold*/);
+// searchEdit->setFont( f );
+
searchBar->setStretchableWidget( searchEdit );
@@ -169,4 +169,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
- a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) );
+ a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
a->addTo( searchBar );
@@ -185,4 +185,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
-
-
if ( Ir::supported() ) {
@@ -198,3 +196,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
- a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE );
+ a = new QAction( tr("Import vCard"), QString::null, 0, 0);
actionPersonal = a;
@@ -210,7 +208,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
- // Do we need this function ? (se)
-// a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
-// connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
-// a->addTo( edit );
-
@@ -230,25 +223,23 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
listContainer = new QWidget( this );
-
QVBoxLayout *vb = new QVBoxLayout( listContainer );
- abList = new AbTable( &orderedFields, listContainer, "table" );
- vb->addWidget(abList);
+ m_abView = new AbView( listContainer, m_config.orderList() );
+ vb->addWidget( m_abView );
// abList->setHScrollBarMode( QScrollView::AlwaysOff );
- connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) );
- connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) );
- connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) );
- connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) );
- connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) );
-
- // Maybe we should react on Wraparound and notfound ?
- QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
- QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) );
+ connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
+ this, SLOT( slotViewSwitched( int ) ) );
+
- mView = 0;
+ QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
- abList->load();
+ m_abView->load();
+ // Letter Picker
pLabel = new LetterPicker( listContainer );
connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
- vb->addWidget(pLabel);
+ connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
+
+ vb->addWidget( pLabel );
+
+ // Category Menu
catMenu = new QPopupMenu( this );
@@ -257,19 +248,8 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
populateCategories();
-
mbList->insertItem( tr("View"), catMenu );
- // setCentralWidget( listContainer );
- fontMenu = new QPopupMenu(this);
- fontMenu->setCheckable( true );
- connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
+ defaultFont = new QFont( m_abView->font() );
+ slotSetFont(m_config.fontSize());
+ m_curFontSize = m_config.fontSize();
- fontMenu->insertItem(tr( "Small" ), 0);
- fontMenu->insertItem(tr( "Normal" ), 1);
- fontMenu->insertItem(tr( "Large" ), 2);
-
- defaultFont = new QFont( abList->font() );
-
- slotSetFont(startFontSize);
-
- mbList->insertItem( tr("Font"), fontMenu);
setCentralWidget(listContainer);
@@ -278,3 +258,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
- abList->setCurrentCell( 0, 0 );
@@ -287,7 +266,3 @@ void AddressbookWindow::slotConfig()
ConfigDlg* dlg = new ConfigDlg( this, "Config" );
- dlg -> setUseRegExp ( useRegExp );
- dlg -> setBeCaseSensitive( caseSensitive );
- dlg -> setSignalWrapAround( doNotifyWrapAround );
- dlg -> setQtMail ( m_useQtMail );
- dlg -> setOpieMail ( m_useOpieMail );
+ dlg -> setConfig( m_config );
dlg -> showMaximized();
@@ -295,7 +270,9 @@ void AddressbookWindow::slotConfig()
qWarning ("Config Dialog accepted !");
- useRegExp = dlg -> useRegExp();
- caseSensitive = dlg -> beCaseSensitive();
- doNotifyWrapAround = dlg -> signalWrapAround();
- m_useQtMail = dlg -> useQtMail();
- m_useOpieMail= dlg -> useOpieMail();
+ m_config = dlg -> getConfig();
+ if ( m_curFontSize != m_config.fontSize() ){
+ qWarning("Font was changed!");
+ m_curFontSize = m_config.fontSize();
+ emit slotSetFont( m_curFontSize );
+ }
+ m_abView -> setListOrder( m_config.orderList() );
}
@@ -306,3 +283,5 @@ void AddressbookWindow::slotConfig()
-void AddressbookWindow::slotSetFont( int size ) {
+void AddressbookWindow::slotSetFont( int size )
+{
+ qWarning("void AddressbookWindow::slotSetFont( %d )", size);
@@ -311,3 +290,3 @@ void AddressbookWindow::slotSetFont( int size ) {
- startFontSize = size;
+ m_config.setFontSize( size );
@@ -317,27 +296,18 @@ void AddressbookWindow::slotSetFont( int size ) {
case 0:
- fontMenu->setItemChecked(0, true);
- fontMenu->setItemChecked(1, false);
- fontMenu->setItemChecked(2, false);
- abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
- currentFont = new QFont (abList->font());
- // abList->resizeRows(currentFont->pixelSize() + 7);
- abList->resizeRows();
+ m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
+ currentFont = new QFont (m_abView->font());
+ // abList->resizeRows(currentFont->pixelSize() + 7); :SX
+ // abList->resizeRows();
break;
case 1:
- fontMenu->setItemChecked(0, false);
- fontMenu->setItemChecked(1, true);
- fontMenu->setItemChecked(2, false);
- abList->setFont( *defaultFont );
- currentFont = new QFont (abList->font());
- // abList->resizeRows(currentFont->pixelSize() + 7);
- abList->resizeRows();
+ m_abView->setFont( *defaultFont );
+ currentFont = new QFont (m_abView->font());
+// // abList->resizeRows(currentFont->pixelSize() + 7);
+// abList->resizeRows();
break;
case 2:
- fontMenu->setItemChecked(0, false);
- fontMenu->setItemChecked(1, false);
- fontMenu->setItemChecked(2, true);
- abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
- currentFont = new QFont (abList->font());
- //abList->resizeRows(currentFont->pixelSize() + 7);
- abList->resizeRows();
+ m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
+ currentFont = new QFont (m_abView->font());
+// //abList->resizeRows(currentFont->pixelSize() + 7);
+// abList->resizeRows();
break;
@@ -350,4 +320,5 @@ void AddressbookWindow::importvCard() {
QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
- if(!str.isEmpty() )
+ if(!str.isEmpty() ){
setDocument((const QString&) str );
+ }
@@ -357,15 +328,36 @@ void AddressbookWindow::setDocument( const QString &filename )
{
- if ( filename.find(".vcf") != int(filename.length()) - 4 )
- return;
-
- QValueList<OContact> cl = OContact::readVCard( filename );
- for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
- // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?")
- // .arg( (*it).fullName() );
- // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) ==
- // QMessageBox::Ok ) {
- abList->addEntry( *it );
- // }
+ qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
+
+ if ( filename.find(".vcf") != int(filename.length()) - 4 ){
+
+
+
+ switch( QMessageBox::information( this, tr ( "Right file type ?" ),
+ tr( "The selected File" ) + ( "\n" ) +
+ tr ("does not end with \".vcf\" ") + ( "\n" ) +
+ tr ( "Do you really want to open it?" ),
+ tr( "&Yes" ), tr( "&No" ), QString::null,
+ 0, // Enter == button 0
+ 2 ) ) { // Escape == button 2
+ case 0:
+ qWarning("YES clicked");
+ break;
+ case 1:
+ qWarning("NO clicked");
+ return;
+ break;
+ }
+ }
+
+ OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
+ filename );
+ OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
+ OContactAccess::List allList = access->allRecords();
+
+ OContactAccess::List::Iterator it;
+ for ( it = allList.begin(); it != allList.end(); ++it ){
+ m_abView->addEntry( *it );
}
+ delete access;
}
@@ -376,6 +368,3 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e )
- if ( centralWidget() == listContainer )
- showList();
- else if ( centralWidget() == mView )
- showView();
+
}
@@ -384,13 +373,8 @@ AddressbookWindow::~AddressbookWindow()
{
- Config cfg("AddressBook");
- cfg.setGroup("Font");
- cfg.writeEntry("fontSize", startFontSize);
-
- cfg.setGroup("Search");
- cfg.writeEntry("useRegExp", useRegExp);
- cfg.writeEntry("caseSensitive", caseSensitive);
- cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround);
- cfg.setGroup("Mail");
- cfg.writeEntry( "useQtMail", m_useQtMail );
- cfg.writeEntry( "useOpieMail", m_useOpieMail);
+ ToolBarDock dock;
+ int dummy;
+ bool bDummy;
+ getLocation ( listTools, dock, dummy, bDummy, dummy );
+ m_config.setToolBarDock( dock );
+ m_config.save();
}
@@ -399,3 +383,3 @@ void AddressbookWindow::slotUpdateToolbar()
{
- OContact ce = abList->currentEntry();
+ OContact ce = m_abView->currentEntry();
actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
@@ -403,34 +387,2 @@ void AddressbookWindow::slotUpdateToolbar()
-void AddressbookWindow::showList()
-{
- bool visiblemView;
-
- visiblemView = false;
- if ( mView ) {
- mView->hide();
- visiblemView = true;
- }
- setCentralWidget( listContainer );
- listContainer->show();
- // update our focues... (or use a stack widget!);
- abList->setFocus();
-
- // This makes sure we are scrolled all the way to the left
- abList->setContentsPos( 0, abList->contentsY() );
-
- //if ( visiblemView && abList->showBook() == "Cards" )
- // abList->setShowCategory( abList->showBook(), abList->showCategory() );
-
-}
-
-void AddressbookWindow::showView()
-{
- if ( abList->numRows() > 0 ) {
- listContainer->hide();
- setCentralWidget( abView() );
- mView->show();
- mView->setFocus();
- }
-}
-
void AddressbookWindow::slotListNew()
@@ -439,5 +391,2 @@ void AddressbookWindow::slotListNew()
if( !syncing ) {
- if ( abEditor )
- abEditor->setEntry( cnt );
- abView()->init( cnt );
editEntry( NewEntry );
@@ -449,8 +398,8 @@ void AddressbookWindow::slotListNew()
-void AddressbookWindow::slotListView()
-{
- abView()->init( abList->currentEntry() );
- mView->sync();
- showView();
-}
+// void AddressbookWindow::slotListView()
+// {
+// m_abView -> init( abList->currentEntry() );
+// // :SX mView->sync();
+// //:SX showView();
+// }
@@ -459,3 +408,3 @@ void AddressbookWindow::slotListDelete()
if(!syncing) {
- OContact tmpEntry = abList->currentEntry();
+ OContact tmpEntry = m_abView ->currentEntry();
@@ -472,4 +421,3 @@ void AddressbookWindow::slotListDelete()
strName ) ) {
- abList->deleteCurrentEntry();
- showList();
+ m_abView->removeEntry( tmpEntry.uid() );
}
@@ -481,5 +429,28 @@ void AddressbookWindow::slotListDelete()
+void AddressbookWindow::slotFindOpen()
+{
+ searchBar->show();
+ m_abView -> inSearch();
+ searchEdit->setFocus();
+}
+void AddressbookWindow::slotFindClose()
+{
+ searchBar->hide();
+ m_abView -> offSearch();
+ // m_abView->setFocus();
+}
+
+
+void AddressbookWindow::slotFind()
+{
+ m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
+
+ searchEdit->clearFocus();
+ // m_abView->setFocus();
+
+}
+
void AddressbookWindow::slotViewBack()
{
- showList();
+ // :SX showList();
}
@@ -492,4 +463,2 @@ void AddressbookWindow::slotViewEdit()
} else {
- if ( !bAbEditFirstTime )
- abEditor->setEntry( abList->currentEntry() );
editEntry( EditEntry );
@@ -506,3 +475,3 @@ void AddressbookWindow::writeMail()
{
- OContact c = abList->currentEntry();
+ OContact c = m_abView -> currentEntry();
QString name = c.fileAs();
@@ -518,3 +487,3 @@ void AddressbookWindow::writeMail()
// switch to the other one..
- if ( m_useQtMail ){
+ if ( m_config.useQtMail() ){
qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
@@ -526,5 +495,5 @@ void AddressbookWindow::writeMail()
} else
- m_useOpieMail = true;
+ m_config.setUseOpieMail( true );
}
- if ( m_useOpieMail ){
+ if ( m_config.useOpieMail() ){
qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
@@ -536,3 +505,3 @@ void AddressbookWindow::writeMail()
} else
- m_useQtMail = true;
+ m_config.setUseQtMail( true );
}
@@ -551,10 +520,25 @@ void AddressbookWindow::slotBeam()
return; // can't beam a non-existent file
- c = OContact::readVCard( filename )[0];
+ OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
+ filename );
+ OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
+ OContactAccess::List allList = access->allRecords();
+ OContactAccess::List::Iterator it = allList.begin(); // Just take first
+ c = *it;
+
+ delete access;
} else {
unlink( beamfile ); // delete if exists
- c = abList->currentEntry();
mkdir("/tmp/obex/", 0755);
- OContact::writeVCard( beamfile, c );
+ c = m_abView -> currentEntry();
+ OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
+ beamfile );
+ OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
+ access->add( c );
+ access->save();
+ delete access;
+
filename = beamfile;
}
+
+
Ir *ir = new Ir( this );
@@ -623,11 +607,6 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
- if ( bAbEditFirstTime ) {
- abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields,
- this, "editor" );
- bAbEditFirstTime = FALSE;
- } else {
- abEditor->setEntry( cnt );
- }
- abView()->init( cnt );
- editEntry( NewEntry );
+ m_abView -> addEntry( cnt );
+
+ // :SXm_abView()->init( cnt );
+ editEntry( EditEntry );
@@ -668,23 +647,18 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
-void AddressbookWindow::editPersonal()
+void AddressbookWindow::editEntry( EntryMode entryMode )
{
- QString filename = addressbookPersonalVCardName();
- OContact me;
- if (QFile::exists(filename))
- me = OContact::readVCard( filename )[0];
- if (bAbEditFirstTime) {
- qWarning("Editing personal data");
- abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields,
- this, "editor" );
- // don't create a new editor every time
- bAbEditFirstTime = FALSE;
- } else{
- abEditor->setEntry( me );
+ OContact entry;
+ if ( !abEditor ) {
+ abEditor = new ContactEditor( entry, this, "editor" );
}
-
- abEditor->setPersonalView( true );
+ if ( entryMode == EditEntry )
+ abEditor->setEntry( m_abView -> currentEntry() );
+ else if ( entryMode == NewEntry )
+ abEditor->setEntry( entry );
+ // other things may chane the caption.
+ abEditor->setCaption( tr("Edit Address") );
- abEditor->setCaption(tr("Edit My Personal Details"));
+#if defined(Q_WS_QWS) || defined(_WS_QWS_)
abEditor->showMaximized();
-
+#endif
// fix the foxus...
@@ -693,12 +667,34 @@ void AddressbookWindow::editPersonal()
setFocus();
- OContact new_personal = abEditor->entry();
- QString fname = addressbookPersonalVCardName();
- OContact::writeVCard( fname, new_personal );
- abView()->init(new_personal);
- abView()->sync();
+ if ( entryMode == NewEntry ) {
+ OContact insertEntry = abEditor->entry();
+ insertEntry.assignUid();
+ m_abView -> addEntry( insertEntry );
+ } else {
+ OContact replEntry = abEditor->entry();
+
+ if ( !replEntry.isValidUid() )
+ replEntry.assignUid();
+
+ m_abView -> replaceEntry( replEntry );
+ }
}
- abEditor->setCaption( tr("Edit Address") );
- abEditor->setPersonalView( false );
+ // populateCategories();
+
+}
+
+void AddressbookWindow::editPersonal()
+{
+ OContact entry;
+ if ( !abEditor ) {
+ abEditor = new ContactEditor( entry, this, "editor" );
+ }
+
+ abEditor->setCaption(tr("Edit My Personal Details"));
+ abEditor->setPersonalView( true );
+ editEntry( EditEntry );
+ abEditor->setPersonalView( false );
+
}
+
void AddressbookWindow::slotPersonalView()
@@ -711,4 +707,7 @@ void AddressbookWindow::slotPersonalView()
actionFind->setEnabled(TRUE);
- slotUpdateToolbar(); // maybe some of the above could be moved there
- showList();
+ actionMail->setEnabled(TRUE);
+ // slotUpdateToolbar();
+
+ m_abView->showPersonal( false );
+
return;
@@ -719,5 +718,3 @@ void AddressbookWindow::slotPersonalView()
actionTrash->setEnabled(FALSE);
-#ifndef MAKE_FOR_SHARP_ROM
actionFind->setEnabled(FALSE);
-#endif
actionMail->setEnabled(FALSE);
@@ -725,50 +722,8 @@ void AddressbookWindow::slotPersonalView()
setCaption( tr("Contacts - My Personal Details") );
- QString filename = addressbookPersonalVCardName();
- OContact me;
- if (QFile::exists(filename))
- me = OContact::readVCard( filename )[0];
-
- abView()->init( me );
- abView()->sync();
- listContainer->hide();
- setCentralWidget( abView() );
- mView->show();
- mView->setFocus();
-}
-void AddressbookWindow::editEntry( EntryMode entryMode )
-{
- OContact entry;
- if ( bAbEditFirstTime ) {
- abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields,
- this, "editor" );
- bAbEditFirstTime = FALSE;
- if ( entryMode == EditEntry )
- abEditor->setEntry( abList->currentEntry() );
- }
- // other things may chane the caption.
- abEditor->setCaption( tr("Edit Address") );
+ m_abView->showPersonal( true );
-#if defined(Q_WS_QWS) || defined(_WS_QWS_)
- abEditor->showMaximized();
-#endif
- // fix the foxus...
- abEditor->setNameFocus();
- if ( abEditor->exec() ) {
- setFocus();
- if ( entryMode == NewEntry ) {
- OContact insertEntry = abEditor->entry();
- insertEntry.assignUid();
- abList->addEntry( insertEntry );
- } else {
- OContact replaceEntry = abEditor->entry();
- if ( !replaceEntry.isValidUid() )
- replaceEntry.assignUid();
- abList->replaceCurrentEntry( replaceEntry );
- }
- }
- populateCategories();
- showList();
}
+
void AddressbookWindow::listIsEmpty( bool empty )
@@ -783,4 +738,4 @@ void AddressbookWindow::reload()
syncing = FALSE;
- abList->clear();
- abList->reload();
+ m_abView->clear();
+ m_abView->reload();
}
@@ -790,3 +745,3 @@ void AddressbookWindow::flush()
syncing = TRUE;
- abList->save();
+ m_abView->save();
}
@@ -796,13 +751,2 @@ void AddressbookWindow::closeEvent( QCloseEvent *e )
{
- if ( centralWidget() == mView ) {
- if (actionPersonal->isOn()) {
- // pretend we clicked it off
- actionPersonal->setOn(FALSE);
- slotPersonalView();
- } else {
- showList();
- }
- e->ignore();
- return;
- }
@@ -830,3 +774,3 @@ bool AddressbookWindow::save()
{
- if ( !abList->save() ) {
+ if ( !m_abView->save() ) {
if ( QMessageBox::critical( 0, tr( "Out of space" ),
@@ -853,169 +797,2 @@ void AddressbookWindow::slotSave()
-void AddressbookWindow::slotSettings()
-{
- AddressSettings frmSettings( this );
-#if defined(Q_WS_QWS) || defined(_WS_QWS_)
- frmSettings.showMaximized();
-#endif
-
- if ( frmSettings.exec() ) {
- allFields.clear();
- orderedFields.clear();
- slOrderedFields.clear();
- initFields();
- if ( abEditor )
- abEditor->loadFields();
- abList->refresh();
- }
-}
-
-
-void AddressbookWindow::initFields()
-{
- // we really don't need the things from the configuration, anymore
- // only thing that is important are the important categories. So,
- // Call the contact functions that correspond to these old functions...
-
- QStringList xmlFields = OContact::fields();
- QStringList visibleFields = OContact::untrfields();
- // QStringList trFields = OContact::trfields();
-
- xmlFields.remove( "Title" );
- visibleFields.remove( "Name Title" );
- visibleFields.remove( "Notes" );
-
- int i, version;
- Config cfg( "AddressBook" );
- QString zn;
-
- // ### Write a function to keep this from happening again...
- QStringList::ConstIterator it;
- for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) {
- allFields.append( i + 3 );
- }
-
- cfg.setGroup( "Version" );
- version = cfg.readNumEntry( "version" );
- i = 0;
- startFontSize = 1;
-
- if ( version >= ADDRESSVERSION ) {
-
- cfg.setGroup( "ImportantCategory" );
-
- zn = cfg.readEntry( "Category" + QString::number(i), QString::null );
- while ( !zn.isNull() ) {
- if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) {
- slOrderedFields.clear();
- break;
- }
- slOrderedFields.append( zn );
- zn = cfg.readEntry( "Category" + QString::number(++i), QString::null );
- }
- cfg.setGroup( "Font" );
- startFontSize = cfg.readNumEntry( "fontSize", 1 );
-
-
- } else {
- QString str;
- str = getenv("HOME");
- str += "/Settings/AddressBook.conf";
- QFile::remove( str );
- }
-
- if ( slOrderedFields.count() > 0 ) {
- for( QStringList::ConstIterator it = slOrderedFields.begin();
- it != slOrderedFields.end(); ++it ) {
- QValueList<int>::ConstIterator itVl;
- QStringList::ConstIterator itVis;
- itVl = allFields.begin();
- for ( itVis = visibleFields.begin();
- itVis != visibleFields.end() && itVl != allFields.end();
- ++itVis, ++itVl ) {
- if ( *it == *itVis && itVl != allFields.end() ) {
- orderedFields.append( *itVl );
- }
- }
- }
- } else {
- QValueList<int>::ConstIterator it;
- for ( it = allFields.begin(); it != allFields.end(); ++it )
- orderedFields.append( *it );
-
- slOrderedFields = visibleFields;
- orderedFields.remove( Qtopia::AddressUid );
- orderedFields.remove( Qtopia::Title );
- orderedFields.remove( Qtopia::Groups );
- orderedFields.remove( Qtopia::AddressCategory );
- orderedFields.remove( Qtopia::FirstName );
- orderedFields.remove( Qtopia::LastName );
- orderedFields.remove( Qtopia::DefaultEmail );
- orderedFields.remove( Qtopia::FileAs );
- orderedFields.remove( Qtopia::Notes );
- orderedFields.remove( Qtopia::Gender );
- slOrderedFields.remove( "Name Title" );
- slOrderedFields.remove( "First Name" );
- slOrderedFields.remove( "Last Name" );
- slOrderedFields.remove( "File As" );
- slOrderedFields.remove( "Default Email" );
- slOrderedFields.remove( "Notes" );
- slOrderedFields.remove( "Gender" );
-
- }
-}
-
-
-AbLabel *AddressbookWindow::abView()
-{
- if ( !mView ) {
- mView = new AbLabel( this, "viewer" );
- mView->init( OContact() );
- connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
- }
- return mView;
-}
-
-void AddressbookWindow::slotFindOpen()
-{
- searchBar->show();
- abList -> inSearch();
- searchEdit->setFocus();
-}
-void AddressbookWindow::slotFindClose()
-{
- searchBar->hide();
- abList -> offSearch();
- abList->setFocus();
-}
-void AddressbookWindow::slotFindNext()
-{
- if ( centralWidget() == abView() )
- showList();
-
- abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false);
-
- searchEdit->clearFocus();
- abList->setFocus();
- if ( abList->numSelections() )
- abList->clearSelection();
-
-}
-void AddressbookWindow::slotFindPrevious()
-{
- if ( centralWidget() == abView() )
- showList();
-
- abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true);
-
- if ( abList->numSelections() )
- abList->clearSelection();
-
-}
-
-void AddressbookWindow::slotFind()
-{
-
- abList->clearFindRow();
- slotFindNext();
-}
@@ -1033,5 +810,5 @@ void AddressbookWindow::slotWrapAround()
qWarning("Got wrap signal !");
- if ( doNotifyWrapAround )
- QMessageBox::information( this, tr( "End of list" ),
- tr( "End of list. Wrap around now.. !" ) + "\n" );
+// if ( doNotifyWrapAround )
+// QMessageBox::information( this, tr( "End of list" ),
+// tr( "End of list. Wrap around now.. !" ) + "\n" );
@@ -1041,4 +818,6 @@ void AddressbookWindow::slotSetCategory( int c )
{
+ qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
QString cat, book;
+ AbView::Views view = AbView::TableView;
@@ -1047,5 +826,10 @@ void AddressbookWindow::slotSetCategory( int c )
- // Set checkItem for selected one
- for ( unsigned int i = 1; i < catMenu->count(); i++ )
- catMenu->setItemChecked( i, c == (int)i );
+ // Checkmark Book Menu Item Selected
+ if ( c < 3 )
+ for ( unsigned int i = 1; i < 3; i++ )
+ catMenu->setItemChecked( i, c == (int)i );
+ // Checkmark Category Menu Item Selected
+ else
+ for ( unsigned int i = 3; i < catMenu->count(); i++ )
+ catMenu->setItemChecked( i, c == (int)i );
@@ -1053,18 +837,19 @@ void AddressbookWindow::slotSetCategory( int c )
if (catMenu->isItemChecked( i )) {
- if ( i == 1 ) // default List view
+ if ( i == 1 ){ // default List view
book = QString::null;
- else if ( i == 2 )
- book = "Phone";
- else if ( i == 3 )
- book = "Company";
- else if ( i == 4 )
- book = "Email";
- else if ( i == 5 )
- book = "Cards";
- else if ( i == 6 ) // default All Categories
+ view = AbView::TableView;
+ }else if ( i == 2 ){
+ book = tr( "Cards" );
+ view = AbView::CardView;
+// }else if ( i == 3 ){
+// book = tr( "Personal" );
+// view = AbView:: PersonalView;
+ }else if ( i == 3 ){ // default All Categories
cat = QString::null;
- else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled
+ }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
cat = "Unfiled";
- else
- cat = abList->categories()[i - 7];
+ qWarning ("Unfiled selected!!!");
+ }else{
+ cat = m_abView->categories()[i - 4];
+ }
}
@@ -1072,4 +857,6 @@ void AddressbookWindow::slotSetCategory( int c )
- abList->setShowCategory( book, cat );
-
+ slotViewSwitched( view );
+
+ m_abView -> setShowByCategory( view, cat );
+
if ( book.isEmpty() )
@@ -1079,3 +866,45 @@ void AddressbookWindow::slotSetCategory( int c )
- setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) );
+ setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
+}
+
+void AddressbookWindow::slotViewSwitched( int view )
+{
+ qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
+ int menu = 0;
+ switch ( view ){
+ case AbView::TableView:
+ menu = 1;
+ m_tableViewButton->setOn(true);
+ m_cardViewButton->setOn(false);
+ break;
+ case AbView::CardView:
+ menu = 2;
+ m_tableViewButton->setOn(false);
+ m_cardViewButton->setOn(true);
+ break;
+// case AbView::PersonalView:
+// menu = 3;
+// break;
+// case AbView::CompanyBook:
+// menu = 3;
+// break;
+// case AbView::EmailBook:
+// menu = 4;
+// break;
+ }
+ for ( unsigned int i = 1; i < 3; i++ ){
+ if ( catMenu )
+ catMenu->setItemChecked( i, menu == (int)i );
+ }
+}
+
+
+void AddressbookWindow::slotListView()
+{
+ emit slotSetCategory( AbView::TableView +1 );
+}
+
+void AddressbookWindow::slotCardView()
+{
+ emit slotSetCategory( AbView::CardView +1 );
}
@@ -1084,3 +913,3 @@ void AddressbookWindow::slotSetLetter( char c ) {
- abList->setShowByLetter( c );
+ m_abView->setShowByLetter( c );
@@ -1088,2 +917,3 @@ void AddressbookWindow::slotSetLetter( char c ) {
+
void AddressbookWindow::populateCategories()
@@ -1096,7 +926,5 @@ void AddressbookWindow::populateCategories()
- catMenu->insertItem( tr( "List" ), id++ );
- catMenu->insertItem( tr( "Phone Book" ), id++ );
- catMenu->insertItem( tr( "Company Book" ), id++ );
- catMenu->insertItem( tr( "Email Book" ), id++ );
- catMenu->insertItem( tr( "Cards" ), id++ );
+ catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ );
+ catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ );
+// catMenu->insertItem( tr( "Personal" ), id++ );
catMenu->insertSeparator();
@@ -1104,3 +932,3 @@ void AddressbookWindow::populateCategories()
catMenu->insertItem( tr( "All" ), id++ );
- QStringList categories = abList->categories();
+ QStringList categories = m_abView->categories();
categories.append( tr( "Unfiled" ) );
@@ -1109,3 +937,3 @@ void AddressbookWindow::populateCategories()
catMenu->insertItem( *it, id );
- if ( *it == abList->showCategory() )
+ if ( *it == m_abView -> showCategory() )
rememberId = id;
@@ -1114,16 +942,17 @@ void AddressbookWindow::populateCategories()
- if ( abList->showBook().isEmpty() ) {
- catMenu->setItemChecked( 1, true );
- } else if ( abList->showBook() == "Phone" ) {
- catMenu->setItemChecked( 2, true );
- } else if ( abList->showBook() == "Company" ) {
- catMenu->setItemChecked( 3, true );
- } else if ( abList->showBook() == "Email" ) {
- catMenu->setItemChecked( 4, true );
- } else if ( abList->showBook() == "Cards" ) {
- catMenu->setItemChecked( 5, true );
- }
-
- if ( abList->showCategory().isEmpty() ) {
- slotSetCategory( 6 );
+ // :SX
+// if ( abList->showBook().isEmpty() ) {
+// catMenu->setItemChecked( 1, true );
+// } else if ( abList->showBook() == "Phone" ) {
+// catMenu->setItemChecked( 2, true );
+// } else if ( abList->showBook() == "Company" ) {
+// catMenu->setItemChecked( 3, true );
+// } else if ( abList->showBook() == "Email" ) {
+// catMenu->setItemChecked( 4, true );
+// } else if ( abList->showBook() == "Cards" ) {
+// catMenu->setItemChecked( 5, true );
+// }
+
+ if ( m_abView -> showCategory().isEmpty() ) {
+ slotSetCategory( 3 );
}