summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp54
1 files changed, 4 insertions, 50 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 2eb9ddf..93581e8 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -58,36 +58,24 @@
#include <qtoolbutton.h>
#include <qwhatsthis.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <qdatetime.h>
#include "picker.h"
-static QString addressbookOldXMLFilename()
-{
- QString filename = QPEApplication::documentDir() + "addressbook.xml";
- return filename;
-}
-
-static QString addressbookXMLFilename()
-{
- QString filename = Global::applicationFileName("addressbook",
- "addressbook.xml");
- return filename;
-}
static QString addressbookPersonalVCardName()
{
QString filename = Global::applicationFileName("addressbook",
"businesscard.vcf");
return filename;
}
AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
WFlags f )
: QMainWindow( parent, name, f ),
@@ -193,57 +181,38 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
actionPersonal = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
a->addTo( edit );
a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( edit );
// Create Views
-
- // This is safe to call without checking to see if it exists...
- // not to mention it also does the necessary stuff for the
- // journaling...
- QString str = addressbookXMLFilename();
- if ( str.isNull() ) {
- QMessageBox::warning(
- this,
- tr("Out of Space"),
- tr("There is not enough space to create\n"
- "neccessary startup files.\n"
- "\nFree up some space before\nentering data!")
- );
- }
-
listContainer = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( listContainer );
abList = new AbTable( &orderedFields, listContainer, "table" );
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()) );
mView = 0;
- abList->load( addressbookXMLFilename() );
- if ( QFile::exists(addressbookOldXMLFilename()) ) {
- abList->load( addressbookOldXMLFilename() );
- QFile::remove(addressbookOldXMLFilename());
- }
+ abList->load();
pLabel = new LetterPicker( listContainer );
connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
vb->addWidget(pLabel);
catMenu = new QPopupMenu( this );
catMenu->setCheckable( TRUE );
connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
populateCategories();
mbList->insertItem( tr("View"), catMenu );
// setCentralWidget( listContainer );
@@ -700,31 +669,31 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
void AddressbookWindow::listIsEmpty( bool empty )
{
if ( !empty ) {
deleteButton->setEnabled( TRUE );
}
}
void AddressbookWindow::reload()
{
syncing = FALSE;
abList->clear();
- abList->load( addressbookXMLFilename() );
+ abList->reload();
}
void AddressbookWindow::flush()
{
syncing = TRUE;
- abList->save( addressbookXMLFilename() );
+ abList->save();
}
void AddressbookWindow::closeEvent( QCloseEvent *e )
{
if ( centralWidget() == mView ) {
if (actionPersonal->isOn()) {
// pretend we clicked it off
actionPersonal->setOn(FALSE);
slotPersonalView();
} else {
showList();
@@ -746,51 +715,36 @@ void AddressbookWindow::closeEvent( QCloseEvent *e )
if ( save() )
e->accept();
else
e->ignore();
}
/*
Returns TRUE if it is OK to exit
*/
bool AddressbookWindow::save()
{
- QString str = addressbookXMLFilename();
- if ( str.isNull() ) {
+ if ( !abList->save() ) {
if ( QMessageBox::critical( 0, tr("Out of space"),
tr("Unable to save information.\n"
"Free up some space\n"
"and try again.\n"
"\nQuit anyway?"),
QMessageBox::Yes|QMessageBox::Escape,
QMessageBox::No|QMessageBox::Default )
!= QMessageBox::No )
return TRUE;
else
return FALSE;
- } else {
- if ( !abList->save( str ) ) {
- if ( QMessageBox::critical( 0, tr( "Out of space" ),
- tr("Unable to save information.\n"
- "Free up some space\n"
- "and try again.\n"
- "\nQuit anyway?"),
- QMessageBox::Yes|QMessageBox::Escape,
- QMessageBox::No|QMessageBox::Default )
- != QMessageBox::No )
- return TRUE;
- else
- return FALSE;
- }
}
return TRUE;
}
void AddressbookWindow::slotSettings()
{
AddressSettings frmSettings( this );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
frmSettings.showMaximized();
#endif
if ( frmSettings.exec() ) {