libopie PIM API Documentation

OContactAccessBackend_XML Class Reference

This class is the XML implementation of a Contact backend it does implement everything available for OContact. More...

#include <ocontactaccessbackend_xml.h>

Inheritance diagram for OContactAccessBackend_XML:

Inheritance graph
[legend]
Collaboration diagram for OContactAccessBackend_XML:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 OContactAccessBackend_XML (const QString &appname, const QString &filename=QString::null)
bool save ()
 save the resource and all it's changes

bool load ()
 load the resource

void clear ()
 clear the back end

bool wasChangedExternally ()
 Return if database was changed externally.

QArray< intallRecords () const
 return an array of all available uids

OContact find (int uid) const
 find the OPimRecord with uid

QArray< intqueryByExample (const OContact &query, int settings, const QDateTime &d=QDateTime())
 queryByExample for T with the given Settings

QArray< intmatchRegexp (const QRegExp &r) const
 return a List of records that match the regex

const uint querySettings ()
 Return all possible settings.

bool hasQuerySettings (uint querySettings) const
 Check whether settings are correct.

QArray< intsorted (bool asc, int, int, int)
 FIXME!!! Returns a sorted list of records either ascendinf or descending for a giving criteria and category.

bool add (const OContact &newcontact)
 add T

bool replace (const OContact &contact)
 replace a record with T.uid()

bool remove (int uid)
 remove

bool reload ()
 reload the resource


Protected Attributes

bool m_changed
QString m_journalName
QString m_fileName
QString m_appName
QList< OContactm_contactList
QDateTime m_readtime
QDict< OContactm_uidToContact

Detailed Description

This class is the XML implementation of a Contact backend it does implement everything available for OContact.

See also:
OPimAccessBackend for more information of available methods

Definition at line 103 of file ocontactaccessbackend_xml.h.


Constructor & Destructor Documentation

OContactAccessBackend_XML::OContactAccessBackend_XML const QString appname,
const QString filename = QString::null
 

Definition at line 127 of file ocontactaccessbackend_xml.cpp.

References Global::applicationFileName(), load(), m_appName, m_contactList, m_fileName, m_journalName, and m_uidToContact.


Member Function Documentation

bool OContactAccessBackend_XML::save  )  [virtual]
 

save the resource and all it's changes

Implements OPimAccessBackend< OContact >.

Definition at line 151 of file ocontactaccessbackend_xml.cpp.

References QFile::close(), QListIterator::current(), QByteArray::data(), QString::latin1(), QCString::length(), m_changed, m_contactList, m_fileName, m_journalName, QFile::open(), QFile::remove(), QString::utf8(), and QIODevice::writeBlock().

bool OContactAccessBackend_XML::load  )  [virtual]
 

load the resource

Implements OPimAccessBackend< OContact >.

Definition at line 221 of file ocontactaccessbackend_xml.cpp.

References QDict< OContact >::clear(), QList< OContact >::clear(), m_contactList, m_fileName, m_journalName, and m_uidToContact.

Referenced by OContactAccessBackend_XML(), and reload().

void OContactAccessBackend_XML::clear  )  [virtual]
 

clear the back end

Implements OPimAccessBackend< OContact >.

Definition at line 240 of file ocontactaccessbackend_xml.cpp.

References QDict< OContact >::clear(), QList< OContact >::clear(), m_changed, m_contactList, and m_uidToContact.

bool OContactAccessBackend_XML::wasChangedExternally  )  [virtual]
 

Return if database was changed externally.

This may just make sense on file based databases like a XML-File. It is used to prevent to overwrite the current database content if the file was already changed by something else ! If this happens, we have to reload before save our data. If we use real databases, this should be handled by the database management system themselve, therefore this function should always return false in this case. It is not our problem to handle this conflict ...

Returns:
true if the database was changed and if save without reload will be dangerous. false if the database was not changed or it is save to write in this situation.

Implements OContactAccessBackend.

Definition at line 248 of file ocontactaccessbackend_xml.cpp.

References QFileInfo::lastModified(), m_fileName, and m_readtime.

QArray< int > OContactAccessBackend_XML::allRecords  )  const [virtual]
 

return an array of all available uids

Implements OPimAccessBackend< OContact >.

Definition at line 257 of file ocontactaccessbackend_xml.cpp.

References QList< OContact >::count(), QListIterator::current(), and m_contactList.

OContact OContactAccessBackend_XML::find int  uid  )  const [virtual]
 

find the OPimRecord with uid

Parameters:
uid returns T and T.isEmpty() if nothing was found

Implements OPimAccessBackend< OContact >.

Definition at line 270 of file ocontactaccessbackend_xml.cpp.

References QDict< OContact >::find(), and m_uidToContact.

QArray< int > OContactAccessBackend_XML::queryByExample const OContact query,
int  settings,
const QDateTime d = QDateTime()
[virtual]
 

queryByExample for T with the given Settings

Implements OPimAccessBackend< OContact >.

Definition at line 283 of file ocontactaccessbackend_xml.cpp.

References OContact::anniversary(), OContact::birthday(), QList< OContact >::count(), QListIterator::current(), QDate::currentDate(), QDateTime::date(), QDate::day(), QDate::daysTo(), OContact::field(), QRegExp::find(), QString::isEmpty(), QDate::isValid(), m_contactList, QDate::month(), QArray::resize(), QDate::setYMD(), QDate::toString(), QString::upper(), and QDate::year().

QArray< int > OContactAccessBackend_XML::matchRegexp const QRegExp r  )  const [virtual]
 

return a List of records that match the regex

Implements OContactAccessBackend.

Definition at line 424 of file ocontactaccessbackend_xml.cpp.

References QList< OContact >::count(), QListIterator::current(), m_contactList, and QArray::resize().

const uint OContactAccessBackend_XML::querySettings  )  [virtual]
 

Return all possible settings.

Returns:
All settings provided by the current backend (i.e.: query_WildCards & query_IgnoreCase)

Implements OContactAccessBackend.

Definition at line 442 of file ocontactaccessbackend_xml.cpp.

bool OContactAccessBackend_XML::hasQuerySettings uint  querySettings  )  const [virtual]
 

Check whether settings are correct.

Returns:
true if the given settings are correct and possible.

Implements OContactAccessBackend.

Definition at line 455 of file ocontactaccessbackend_xml.cpp.

QArray< int > OContactAccessBackend_XML::sorted bool  asc,
int  ,
int  ,
int 
[virtual]
 

FIXME!!! Returns a sorted list of records either ascendinf or descending for a giving criteria and category.

Implements OContactAccessBackend.

Definition at line 503 of file ocontactaccessbackend_xml.cpp.

References QValueList::append(), QValueList::begin(), QList< OContact >::count(), QListIterator::current(), QValueList::end(), QMap::insert(), m_contactList, QString::number(), and QStringList::sort().

bool OContactAccessBackend_XML::add const OContact newcontact  )  [virtual]
 

add T

Implements OPimAccessBackend< OContact >.

Definition at line 531 of file ocontactaccessbackend_xml.cpp.

References m_changed.

bool OContactAccessBackend_XML::replace const OContact contact  )  [virtual]
 

replace a record with T.uid()

Implements OPimAccessBackend< OContact >.

Definition at line 542 of file ocontactaccessbackend_xml.cpp.

References QList< OContact >::append(), QDict< OContact >::find(), QDict< OContact >::insert(), m_changed, m_contactList, m_uidToContact, QDict< OContact >::remove(), QList< OContact >::removeRef(), and Qtopia::Record::uid().

bool OContactAccessBackend_XML::remove int  uid  )  [virtual]
 

remove

Implements OPimAccessBackend< OContact >.

Definition at line 564 of file ocontactaccessbackend_xml.cpp.

References QDict< OContact >::find(), m_changed, m_contactList, m_uidToContact, QDict< OContact >::remove(), and QList< OContact >::removeRef().

bool OContactAccessBackend_XML::reload  )  [virtual]
 

reload the resource

Implements OPimAccessBackend< OContact >.

Definition at line 580 of file ocontactaccessbackend_xml.cpp.

References load().


Member Data Documentation

bool OContactAccessBackend_XML::m_changed [protected]
 

Definition at line 150 of file ocontactaccessbackend_xml.h.

Referenced by add(), clear(), remove(), replace(), and save().

QString OContactAccessBackend_XML::m_journalName [protected]
 

Definition at line 151 of file ocontactaccessbackend_xml.h.

Referenced by load(), OContactAccessBackend_XML(), and save().

QString OContactAccessBackend_XML::m_fileName [protected]
 

Definition at line 152 of file ocontactaccessbackend_xml.h.

Referenced by load(), OContactAccessBackend_XML(), save(), and wasChangedExternally().

QString OContactAccessBackend_XML::m_appName [protected]
 

Definition at line 153 of file ocontactaccessbackend_xml.h.

Referenced by OContactAccessBackend_XML().

QList<OContact> OContactAccessBackend_XML::m_contactList [protected]
 

Definition at line 154 of file ocontactaccessbackend_xml.h.

Referenced by allRecords(), clear(), load(), matchRegexp(), OContactAccessBackend_XML(), queryByExample(), remove(), replace(), save(), and sorted().

QDateTime OContactAccessBackend_XML::m_readtime [protected]
 

Definition at line 155 of file ocontactaccessbackend_xml.h.

Referenced by wasChangedExternally().

QDict<OContact> OContactAccessBackend_XML::m_uidToContact [protected]
 

Definition at line 157 of file ocontactaccessbackend_xml.h.

Referenced by clear(), find(), load(), OContactAccessBackend_XML(), remove(), and replace().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for OPIE Version 1.1.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:26:11 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001