summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-09 08:12:00 (UTC)
committer ulf69 <ulf69>2004-07-09 08:12:00 (UTC)
commitaae8af24992bf3b7b59fb425955153b86f31bb5d (patch) (side-by-side diff)
tree2ad2e501a14c5a96bf5c7deebd3638bed405350e
parentde99e22a7093e857ee3c08a67ccc389d6374099a (diff)
downloadkdepimpi-aae8af24992bf3b7b59fb425955153b86f31bb5d.zip
kdepimpi-aae8af24992bf3b7b59fb425955153b86f31bb5d.tar.gz
kdepimpi-aae8af24992bf3b7b59fb425955153b86f31bb5d.tar.bz2
IntDateFormat is now an enum instead of an ionteger value
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/field.cpp8
-rw-r--r--kabc/plugins/opie/resourceopie.cpp16
-rw-r--r--kabc/plugins/opie/resourceopieconfig.cpp11
-rw-r--r--kabc/plugins/opie/resourceopieconfig.h3
4 files changed, 20 insertions, 18 deletions
diff --git a/kabc/field.cpp b/kabc/field.cpp
index bc2e176..e27970e 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -240,52 +240,52 @@ QString Field::value( const KABC::Addressee &a )
case FieldImpl::AdditionalName:
return a.additionalName();
case FieldImpl::Prefix:
return a.prefix();
case FieldImpl::Suffix:
return a.suffix();
case FieldImpl::NickName:
return a.nickName();
case FieldImpl::Mailer:
return a.mailer();
case FieldImpl::Title:
return a.title();
case FieldImpl::Role:
return a.role();
case FieldImpl::Organization:
return a.organization();
case FieldImpl::Note:
return a.note();
case FieldImpl::Email:
return a.preferredEmail();
case FieldImpl::Birthday:
if ( a.birthday().isValid() ) {
//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
// But Qt::IsoDate was not specified.
- QString _oldFormat = KGlobal::locale()->dateFormat();
- KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
- QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false);
- KGlobal::locale()->setDateFormat(_oldFormat);
+// QString _oldFormat = KGlobal::locale()->dateFormat();
+// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
+ QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
+// KGlobal::locale()->setDateFormat(_oldFormat);
return dt;
}
else
return QString::null;
case FieldImpl::Url:
return a.url().prettyURL();
//US
case FieldImpl::Resource:
return a.resource()->resourceName();
case FieldImpl::HomePhone:
return a.phoneNumber( PhoneNumber::Home ).number();
case FieldImpl::BusinessPhone:
return a.phoneNumber( PhoneNumber::Work ).number();
case FieldImpl::MobilePhone:
return a.phoneNumber( PhoneNumber::Cell ).number();
case FieldImpl::HomeFax:
return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
case FieldImpl::BusinessFax:
return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
case FieldImpl::CarPhone:
return a.phoneNumber( PhoneNumber::Car ).number();
case FieldImpl::Isdn:
return a.phoneNumber( PhoneNumber::Isdn ).number();
case FieldImpl::Pager:
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 3b2a6b7..a7d271f 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -76,64 +76,64 @@ ResourceOpie::ResourceOpie( const KConfig *config )
}
// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
init( fileName );
}
ResourceOpie::ResourceOpie( const QString &fileName )
: Resource( 0 )
{
// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
init( fileName );
}
void ResourceOpie::init( const QString &fileName )
{
/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
*/
//US opie addressbook is always readonly
- setReadOnly( true );
+//US setReadOnly( true );
setFileName( fileName );
}
ResourceOpie::~ResourceOpie()
{
if (mConverter != 0)
delete mConverter;
}
void ResourceOpie::writeConfig( KConfig *config )
{
//US opie addressbook is always readonly
- setReadOnly( true );
+//US setReadOnly( true );
Resource::writeConfig( config );
config->writeEntry( "FileName", mFileName );
// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
}
Ticket *ResourceOpie::requestSaveTicket()
{
kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
if ( !addressBook() ) return 0;
if ( !lock( mFileName ) ) {
kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '"
<< mFileName << "'" << endl;
return 0;
}
return createTicket( this );
}
@@ -173,55 +173,65 @@ bool ResourceOpie::doOpen()
void ResourceOpie::doClose()
{
// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
}
bool ResourceOpie::load()
{
// qDebug("ResourceOpie::load() %s", mFileName.latin1());
kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
if ( !access ) {
qDebug("Unable to load file() %s", mFileName.latin1());
addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
return false;
}
access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
+ bool res = false;
if (mConverter == 0)
+ {
mConverter = new OpieConverter();
+ res = mConverter->init();
+ if ( !res )
+ {
+ qDebug("Unable to initialize opie converter. Most likely a problem with the category file");
+ addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) );
+ delete access;
+ return false;
+ }
+ }
OContactAccess::List::Iterator it;
OContactAccess::List allList = access->allRecords();
- bool res = false;
for ( it = allList.begin(); it != allList.end(); ++it )
{
OContact c = (*it);
KABC::Addressee addressee;
res = mConverter->opieToAddressee( c, addressee );
if ( !addressee.isEmpty() && res )
{
addressee.setResource( this );
addressBook()->insertAddressee( addressee );
}
// qDebug("found %s", c.fullName().latin1());
}
delete access;
// it seems so, that deletion of access deletes backend as well
//delete backend;
return true;
}
diff --git a/kabc/plugins/opie/resourceopieconfig.cpp b/kabc/plugins/opie/resourceopieconfig.cpp
index f4cc4f9..eef9cc9 100644
--- a/kabc/plugins/opie/resourceopieconfig.cpp
+++ b/kabc/plugins/opie/resourceopieconfig.cpp
@@ -41,71 +41,66 @@ $Id$
//US #include <qpe/qpeapplication.h>
//US #include "stdaddressbook.h"
#include "resourceopieconfig.h"
using namespace KABC;
ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name )
: ConfigWidget( parent, name )
{
//qDebug("ResourceFileConfig::ResourceFileConfig");
QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0,
KDialog::spacingHint() );
QLabel *label = new QLabel( i18n( "Location:" ), this );
mFileNameEdit = new KURLRequester( this );
connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
SLOT( checkFilePermissions( const QString & ) ) );
mainLayout->addWidget( label, 0, 0 );
mainLayout->addWidget( mFileNameEdit, 0, 1 );
-
-//US mInEditMode = false;
-}
-/*US
-void ResourceOpieConfig::setEditMode( bool value )
-{
- mInEditMode = value;
}
-*/
void ResourceOpieConfig::loadSettings( KRES::Resource *res )
{
//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
ResourceOpie *resource = (ResourceOpie*)( res );
if ( !resource ) {
kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl;
return;
}
mFileNameEdit->setURL( resource->fileName() );
if ( mFileNameEdit->url().isEmpty() )
mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
+
+ //US Opie resources are ReadOnly by definition
+ emit setPersistentReadOnly( true );
}
void ResourceOpieConfig::saveSettings( KRES::Resource *res )
{
//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
ResourceOpie *resource = (ResourceOpie*)( res );
if ( !resource ) {
kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl;
return;
}
resource->setFileName( mFileNameEdit->url() );
}
void ResourceOpieConfig::checkFilePermissions( const QString& fileName )
{
// If file exist but is not writeable...
/*US
if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
*/
}
diff --git a/kabc/plugins/opie/resourceopieconfig.h b/kabc/plugins/opie/resourceopieconfig.h
index 533b7f4..8cc192c 100644
--- a/kabc/plugins/opie/resourceopieconfig.h
+++ b/kabc/plugins/opie/resourceopieconfig.h
@@ -21,41 +21,38 @@
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef RESOURCEOPIECONFIG_H
#define RESOURCEOPIECONFIG_H
#include <kurlrequester.h>
#include <kresources/configwidget.h>
namespace KABC {
class ResourceOpieConfig : public KRES::ConfigWidget
{
Q_OBJECT
public:
ResourceOpieConfig( QWidget* parent = 0, const char* name = 0 );
-//US void setEditMode( bool value );
-
public slots:
void loadSettings( KRES::Resource *resource );
void saveSettings( KRES::Resource *resource );
protected slots:
void checkFilePermissions( const QString& fileName );
private:
KURLRequester* mFileNameEdit;
-//US bool mInEditMode;
};
}
#endif