Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OContactAccessBackend_XML Class Reference

#include </home/clem/local/src/opie/noncore/unsupported/libopie/pim/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 ()
bool load ()
void clear ()
bool wasChangedExternally ()
QArray< int > allRecords () const
OContact find (int uid) const
QArray< int > queryByExample (const OContact &query, int settings, const QDateTime &d=QDateTime())
QArray< int > matchRegexp (const QRegExp &r) const
const uint querySettings ()
bool hasQuerySettings (uint querySettings) const
QArray< int > sorted (bool asc, int, int, int)
bool add (const OContact &newcontact)
bool replace (const OContact &contact)
bool remove (int uid)
bool reload ()

Protected Attributes

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

Private Types

enum  journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }

Private Member Functions

void addContact_p (const OContact &newcontact)
bool load (const QString filename, bool isJournal)
void updateJournal (const OContact &cnt, journal_action action)
void removeJournal ()

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 106 of file ocontactaccessbackend_xml.h.


Member Enumeration Documentation

enum OContactAccessBackend_XML::journal_action [private]
 

Enumeration values:
ACTION_ADD 
ACTION_REMOVE 
ACTION_REPLACE 

Definition at line 141 of file ocontactaccessbackend_xml.h.


Constructor & Destructor Documentation

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

Definition at line 131 of file ocontactaccessbackend_xml.cpp.

References Global::applicationFileName(), QString::isEmpty(), load(), m_appName, m_contactList, m_fileName, m_journalName, m_uidToContact, and QPtrCollection::setAutoDelete().


Member Function Documentation

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

add T

Implements OPimAccessBackend< OContact >.

Definition at line 535 of file ocontactaccessbackend_xml.cpp.

References ACTION_ADD, addContact_p(), m_changed, and updateJournal().

void OContactAccessBackend_XML::addContact_p const OContact newcontact  )  [private]
 

Definition at line 589 of file ocontactaccessbackend_xml.cpp.

References QDict< type >::insert(), m_contactList, m_uidToContact, and Qtopia::Record::uid().

Referenced by add(), and load().

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

return an array of all available uids

Implements OPimAccessBackend< OContact >.

Definition at line 261 of file ocontactaccessbackend_xml.cpp.

References m_contactList.

void OContactAccessBackend_XML::clear  )  [virtual]
 

clear the back end

Implements OPimAccessBackend< OContact >.

Definition at line 244 of file ocontactaccessbackend_xml.cpp.

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

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 274 of file ocontactaccessbackend_xml.cpp.

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

Referenced by load().

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 459 of file ocontactaccessbackend_xml.cpp.

References OContactAccess::DateDay, OContactAccess::DateDiff, OContactAccess::DateMonth, OContactAccess::DateYear, OContactAccess::ExactMatch, OContactAccess::IgnoreCase, OContactAccess::RegExp, and OContactAccess::WildCards.

bool OContactAccessBackend_XML::load const QString  filename,
bool  isJournal
[private]
 

Definition at line 598 of file ocontactaccessbackend_xml.cpp.

References ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE, addContact_p(), Qtopia::AddressCategory, Qtopia::AddressUid, Qtopia::Anniversary, Qtopia::Assistant, Opie::XMLElement::attributes(), QMap< Key, T >::begin(), Qtopia::Birthday, Qtopia::BusinessCity, Qtopia::BusinessCountry, Qtopia::BusinessFax, Qtopia::BusinessMobile, Qtopia::BusinessPager, Qtopia::BusinessPhone, Qtopia::BusinessState, Qtopia::BusinessStreet, Qtopia::BusinessWebPage, Qtopia::BusinessZip, Qtopia::Children, QMap< Key, T >::clear(), Qtopia::Company, Qtopia::DefaultEmail, Qtopia::Department, Qtopia::Emails, QMap< Key, T >::end(), Qtopia::FileAs, find(), Opie::XMLElement::firstChild(), Qtopia::FirstName, QString::fromLatin1(), Qtopia::Gender, Qtopia::HomeCity, Qtopia::HomeCountry, Qtopia::HomeFax, Qtopia::HomeMobile, Qtopia::HomePhone, Qtopia::HomeState, Qtopia::HomeStreet, Qtopia::HomeWebPage, Qtopia::HomeZip, QMap< Key, T >::insert(), QAsciiDict< type >::insert(), Qtopia::JobTitle, l, QFileInfo::lastModified(), Qtopia::LastName, Opie::XMLElement::load(), m_readtime, Qtopia::Manager, Qtopia::MiddleName, Opie::XMLElement::nextChild(), Qtopia::Nickname, Qtopia::Notes, Qtopia::Office, Qtopia::Profession, qWarning(), remove(), replace(), QPtrCollection::setAutoDelete(), Qtopia::Record::setCustomField(), Qtopia::Spouse, Qtopia::Suffix, Opie::XMLElement::tagName(), Qtopia::Title, and TRUE.

bool OContactAccessBackend_XML::load  )  [virtual]
 

load the resource

Implements OPimAccessBackend< OContact >.

Definition at line 225 of file ocontactaccessbackend_xml.cpp.

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

Referenced by OContactAccessBackend_XML(), and reload().

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

return a List of records that match the regex

Implements OContactAccessBackend.

Definition at line 428 of file ocontactaccessbackend_xml.cpp.

References m_contactList.

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 287 of file ocontactaccessbackend_xml.cpp.

References Qtopia::Anniversary, Qtopia::Birthday, QDate::currentDate(), QDateTime::date(), OContactAccess::DateDay, OContactAccess::DateDiff, OContactAccess::DateMonth, OContactAccess::DateYear, QDate::day(), QDate::daysTo(), OContactAccess::ExactMatch, false, Qtopia::Groups, i, OContactAccess::IgnoreCase, QDate::isValid(), l, m_contactList, OContactAccess::MatchOne, QDate::month(), qWarning(), OContactAccess::RegExp, QDate::setYMD(), QDate::toString(), true, OContactAccess::WildCards, and QDate::year().

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 446 of file ocontactaccessbackend_xml.cpp.

References OContactAccess::DateDay, OContactAccess::DateDiff, OContactAccess::DateMonth, OContactAccess::DateYear, OContactAccess::ExactMatch, OContactAccess::IgnoreCase, OContactAccess::RegExp, and OContactAccess::WildCards.

bool OContactAccessBackend_XML::reload  )  [virtual]
 

reload the resource

Implements OPimAccessBackend< OContact >.

Definition at line 584 of file ocontactaccessbackend_xml.cpp.

References load().

bool OContactAccessBackend_XML::remove int  uid  )  [virtual]
 

remove

Implements OPimAccessBackend< OContact >.

Definition at line 568 of file ocontactaccessbackend_xml.cpp.

References ACTION_REMOVE, QDict< type >::find(), m_changed, m_contactList, m_uidToContact, QDict< type >::remove(), and updateJournal().

Referenced by load().

void OContactAccessBackend_XML::removeJournal  )  [private]
 

Definition at line 818 of file ocontactaccessbackend_xml.cpp.

References QFile::exists(), f, m_journalName, and QFile::remove().

Referenced by save().

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

replace a record with T.uid()

Implements OPimAccessBackend< OContact >.

Definition at line 546 of file ocontactaccessbackend_xml.cpp.

References ACTION_REPLACE, QDict< type >::find(), QDict< type >::insert(), m_changed, m_contactList, m_uidToContact, qWarning(), QDict< type >::remove(), Qtopia::Record::uid(), and updateJournal().

Referenced by load().

bool OContactAccessBackend_XML::save  )  [virtual]
 

save the resource and all it's changes

Implements OPimAccessBackend< OContact >.

Definition at line 155 of file ocontactaccessbackend_xml.cpp.

References QFile::close(), f, IO_Raw, IO_WriteOnly, QString::latin1(), QCString::length(), m_changed, m_contactList, m_fileName, m_journalName, QFile::open(), out, qWarning(), QFile::remove(), removeJournal(), QString::utf8(), and QFile::writeBlock().

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 507 of file ocontactaccessbackend_xml.cpp.

References QValueList< T >::append(), QValueList< T >::begin(), QValueList< T >::end(), i, QMap< Key, T >::insert(), m_contactList, QString::number(), and QStringList::sort().

void OContactAccessBackend_XML::updateJournal const OContact cnt,
journal_action  action
[private]
 

Definition at line 790 of file ocontactaccessbackend_xml.cpp.

References buf, created, QFile::exists(), f, IO_Append, IO_WriteOnly, QCString::length(), m_journalName, QString::number(), QFile::open(), OContact::save(), str, QString::utf8(), and QFile::writeBlock().

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

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 252 of file ocontactaccessbackend_xml.cpp.

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


Member Data Documentation

QString OContactAccessBackend_XML::m_appName [protected]
 

Definition at line 156 of file ocontactaccessbackend_xml.h.

Referenced by OContactAccessBackend_XML().

bool OContactAccessBackend_XML::m_changed [protected]
 

Definition at line 153 of file ocontactaccessbackend_xml.h.

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

QList<OContact> OContactAccessBackend_XML::m_contactList [protected]
 

Definition at line 157 of file ocontactaccessbackend_xml.h.

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

QString OContactAccessBackend_XML::m_fileName [protected]
 

Definition at line 155 of file ocontactaccessbackend_xml.h.

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

QString OContactAccessBackend_XML::m_journalName [protected]
 

Definition at line 154 of file ocontactaccessbackend_xml.h.

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

QDateTime OContactAccessBackend_XML::m_readtime [protected]
 

Definition at line 158 of file ocontactaccessbackend_xml.h.

Referenced by load(), and wasChangedExternally().

QDict<OContact> OContactAccessBackend_XML::m_uidToContact [protected]
 

Definition at line 160 of file ocontactaccessbackend_xml.h.

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


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:42:10 2005 for OPIE by  doxygen 1.4.2