author | ar <ar> | 2004-06-01 22:21:23 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-01 22:21:23 (UTC) |
commit | d4fe7d53ddf8f3e7ae046a511f0dc061f30d45ce (patch) (side-by-side diff) | |
tree | 4bab082304716df1ec924ef040161e3cf9c10366 | |
parent | baed1d5ab8589aef14440009bc4e7380bcc5a741 (diff) | |
download | opie-d4fe7d53ddf8f3e7ae046a511f0dc061f30d45ce.zip opie-d4fe7d53ddf8f3e7ae046a511f0dc061f30d45ce.tar.gz opie-d4fe7d53ddf8f3e7ae046a511f0dc061f30d45ce.tar.bz2 |
- convert to odebug framework
-rw-r--r-- | libopie2/opiepim/backend/obackendfactory.h | 24 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | 36 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 25 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 11 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimcontact.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecordlist.h | 5 |
7 files changed, 60 insertions, 49 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index 6f46652..3680ded 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h @@ -13,168 +13,174 @@ .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * ===================================================================== * ToDo: Use plugins * ===================================================================== */ #ifndef OPIE_BACKENDFACTORY_H_ #define OPIE_BACKENDFACTORY_H_ -#include <qstring.h> -#include <qasciidict.h> -#include <qpe/config.h> - +/* OPIE */ #include <opie2/opimaccessbackend.h> #include <opie2/opimglobal.h> #include <opie2/otodoaccessxml.h> #include <opie2/otodoaccessvcal.h> #include <opie2/ocontactaccessbackend_xml.h> #include <opie2/ocontactaccessbackend_vcard.h> #include <opie2/odatebookaccessbackend_xml.h> +#include <opie2/odebug.h> #ifdef __USE_SQL #include <opie2/otodoaccesssql.h> #include <opie2/ocontactaccessbackend_sql.h> #include <opie2/odatebookaccessbackend_sql.h> #endif +#include <qpe/config.h> + +/* QT */ +#include <qstring.h> +#include <qasciidict.h> + + + using namespace Opie; using namespace Opie::Pim; namespace Opie { class OBackendPrivate; /** * This class is our factory. It will give us the default implementations * of at least Todolist, Contacts and Datebook. In the future this class will * allow users to switch the backend with ( XML->SQLite ) without the need * to recompile.# * This class - as the whole PIM Api - is making use of templates * * <pre> * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default( OPimGlobal::TODOLIST, QString::null ); * backend->load(); * </pre> * * @author Stefan Eilers * @version 0.1 */ template<class T> class OBackendFactory { public: OBackendFactory() {}; /** * Returns a selected backend implementation * @param type the type of the backend * @param database the type of the used database * @param appName The name of your application. It will be passed on to the backend. * @param filename Filename of the database file if you don't want to access the default * @see OPimGlobal() */ static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, const QString& appName, const QString& filename = QString::null ){ - qWarning("Selected backend for %d is: %d", type, database ); + owarn << "Selected backend for " << type << " is: " << database << oendl; // If we should use the dafult database style, we have to request it OPimGlobal::DatabaseStyle use_database = database; if ( use_database == OPimGlobal::DEFAULT ){ use_database = defaultDB( type ); } switch ( type ){ case OPimGlobal::TODOLIST: switch ( use_database ){ default: // Use SQL if something weird is given. // Fall through !! case OPimGlobal::SQL: #ifdef __USE_SQL return (T*) new OPimTodoAccessBackendSQL( filename ); break; #else - qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); + owarn << "OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!" << oendl; // Fall through !! #endif case OPimGlobal::XML: return (T*) new OPimTodoAccessXML( appName, filename ); break; case OPimGlobal::VCARD: return (T*) new OPimTodoAccessVCal( filename ); break; } case OPimGlobal::CONTACTLIST: switch ( use_database ){ default: // Use SQL if something weird is given. // Fall through !! case OPimGlobal::SQL: #ifdef __USE_SQL return (T*) new OPimContactAccessBackend_SQL( appName, filename ); break; #else - qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); + owarn << "OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!" << oendl; // Fall through !! #endif case OPimGlobal::XML: return (T*) new OPimContactAccessBackend_XML( appName, filename ); break; case OPimGlobal::VCARD: return (T*) new OPimContactAccessBackend_VCard( appName, filename ); break; } case OPimGlobal::DATEBOOK: switch ( use_database ){ default: // Use SQL if something weird is given. // Fall through !! case OPimGlobal::SQL: #ifdef __USE_SQL return (T*) new ODateBookAccessBackend_SQL( appName, filename ); break; #else - qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); + owarn << "OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!" << oendl; // Fall through !! #endif case OPimGlobal::XML: return (T*) new ODateBookAccessBackend_XML( appName, filename ); break; case OPimGlobal::VCARD: - qWarning("OBackendFactory:: VCal Backend for DATEBOOK not implemented!"); + owarn << "OBackendFactory:: VCal Backend for DATEBOOK not implemented!" << oendl; return (T*) NULL; break; } default: return (T*) NULL; } } /** * Returns the style of the default database which is used to contact PIM data. * @param type the type of the backend * @see OPimGlobal() */ static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ QString group_name; switch ( type ){ case OPimGlobal::TODOLIST: group_name = "todo"; break; case OPimGlobal::CONTACTLIST: group_name = "contact"; break; case OPimGlobal::DATEBOOK: diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp index 5ffcb11..00d62ee 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp @@ -116,50 +116,50 @@ bool OPimContactAccessBackend_XML::save() total_written = f.writeBlock( cstr.data(), cstr.length() ); idx_offset += cstr.length(); if ( total_written != int(cstr.length()) ) { f.close(); QFile::remove( strNewFile ); return false; } out = ""; } out += " </Contacts>\n</AddressBook>\n"; // Write Footer cstr = out.utf8(); total_written = f.writeBlock( cstr.data(), cstr.length() ); if ( total_written != int( cstr.length() ) ) { f.close(); QFile::remove( strNewFile ); return false; } f.close(); // move the file over, I'm just going to use the system call // because, I don't feel like using QDir. if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { - qWarning( "problem renaming file %s to %s, errno: %d", - strNewFile.latin1(), m_journalName.latin1(), errno ); + owarn << "problem renaming file " << strNewFile << " to " << m_journalName + << ", errno: " << errno << oendl; // remove the tmp file... QFile::remove( strNewFile ); } /* The journalfile should be removed now... */ removeJournal(); m_changed = false; return true; } bool OPimContactAccessBackend_XML::load () { m_contactList.clear(); m_uidToContact.clear(); /* Load XML-File and journal if it exists */ if ( !load ( m_fileName, false ) ) return false; /* The returncode of the journalfile is ignored due to the * fact that it does not exist when this class is instantiated ! * But there may such a file exist, if the application crashed. * Therefore we try to load it to get the changes before the # * crash happened... @@ -257,57 +257,55 @@ QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &qu } if ( settings & OPimContactAccess::DateDiff ) { QDate current; // If we get an additional date, we // will take this date instead of // the current one.. if ( !d.date().isValid() ) current = QDate::currentDate(); else current = d.date(); // We have to equalize the year, otherwise // the search will fail.. checkDate->setYMD( current.year(), checkDate->month(), checkDate->day() ); if ( *checkDate < current ) checkDate->setYMD( current.year()+1, checkDate->month(), checkDate->day() ); // Check whether the birthday/anniversary date is between // the current/given date and the maximum date // ( maximum time range ) ! - qWarning("Checking if %s is between %s and %s ! ", - checkDate->toString().latin1(), - current.toString().latin1(), - queryDate->toString().latin1() ); + owarn << "Checking if " << checkDate->toString() << " is between " << current.toString() + << " and " << queryDate->toString() << " ! " << oendl; if ( current.daysTo( *queryDate ) >= 0 ){ if ( !( ( *checkDate >= current ) && ( *checkDate <= *queryDate ) ) ){ allcorrect = false; - qWarning (" Nope!.."); + owarn << " Nope!.." << oendl; } } } } else{ // checkDate is invalid. Therefore this entry is always rejected allcorrect = false; } } delete queryDate; queryDate = 0l; delete checkDate; checkDate = 0l; break; default: /* Just compare fields which are not empty in the query object */ if ( !query.field(i).isEmpty() ){ switch ( settings & ~( OPimContactAccess::IgnoreCase | OPimContactAccess::DateDiff | OPimContactAccess::DateYear | OPimContactAccess::DateMonth | OPimContactAccess::DateDay | OPimContactAccess::MatchOne ) ){ @@ -586,138 +584,136 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal dict.insert( "Spouse", new int(Qtopia::Spouse) ); dict.insert( "Children", new int(Qtopia::Children) ); dict.insert( "Gender", new int(Qtopia::Gender) ); dict.insert( "Birthday", new int(Qtopia::Birthday) ); dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); dict.insert( "Nickname", new int(Qtopia::Nickname) ); dict.insert( "Notes", new int(Qtopia::Notes) ); dict.insert( "action", new int(JOURNALACTION) ); dict.insert( "actionrow", new int(JOURNALROW) ); //owarn << "OPimContactDefaultBackEnd::loading " << filename << "" << oendl; XMLElement *root = XMLElement::load( filename ); if(root != 0l ){ // start parsing /* Parse all XML-Elements and put the data into the * Contact-Class */ XMLElement *element = root->firstChild(); //owarn << "OPimContactAccess::load tagName(): " << root->tagName() << "" << oendl; element = element->firstChild(); /* Search Tag "Contacts" which is the parent of all Contacts */ while( element && !isJournal ){ if( element->tagName() != QString::fromLatin1("Contacts") ){ - //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s", - // element->tagName().latin1()); + //owarn << "OPimContactDefBack::Searching for Tag \"Contacts\"! Found: " + // << element->tagName() << oendl; element = element->nextChild(); } else { element = element->firstChild(); break; } } /* Parse all Contacts and ignore unknown tags */ while( element ){ if( element->tagName() != QString::fromLatin1("Contact") ){ - //qWarning ("OPimContactDefBack::Searching for Tag \"Contact\"! Found: %s", - // element->tagName().latin1()); + //owarn << "OPimContactDefBack::Searching for Tag \"Contact\"! Found: " + // << element->tagName() << oendl; element = element->nextChild(); continue; } /* Found alement with tagname "contact", now parse and store all * attributes contained */ - //qWarning("OPimContactDefBack::load element tagName() : %s", - // element->tagName().latin1() ); + //owarn << "OPimContactDefBack::load element tagName() : " + // << element->tagName() << oendl; QString dummy; foundAction = false; XMLElement::AttributeMap aMap = element->attributes(); XMLElement::AttributeMap::Iterator it; contactMap.clear(); customMap.clear(); for( it = aMap.begin(); it != aMap.end(); ++it ){ - // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); + // owarn << "Read Attribute: " << it.key() << "=" << it.data() << oendl; int *find = dict[ it.key() ]; /* Unknown attributes will be stored as "Custom" elements */ if ( !find ) { // owarn << "Attribute " << it.key() << " not known." << oendl; //contact.setCustomField(it.key(), it.data()); customMap.insert( it.key(), it.data() ); continue; } /* Check if special conversion is needed and add attribute * into Contact class */ switch( *find ) { /* case Qtopia::AddressUid: contact.setUid( it.data().toInt() ); break; case Qtopia::AddressCategory: contact.setCategories( Qtopia::Record::idsFromString( it.data( ))); break; */ case JOURNALACTION: action = journal_action(it.data().toInt()); foundAction = true; - qWarning ("ODefBack(journal)::ACTION found: %d", action); + owarn << "ODefBack(journal)::ACTION found: " << action << oendl; break; case JOURNALROW: journalKey = it.data().toInt(); break; default: // no conversion needed add them to the map contactMap.insert( *find, it.data() ); break; } } /* now generate the Contact contact */ OPimContact contact( contactMap ); for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { contact.setCustomField( customIt.key(), customIt.data() ); } if (foundAction){ foundAction = false; switch ( action ) { case ACTION_ADD: addContact_p (contact); break; case ACTION_REMOVE: if ( !remove (contact.uid()) ) - qWarning ("ODefBack(journal)::Unable to remove uid: %d", - contact.uid() ); + owarn << "ODefBack(journal)::Unable to remove uid: " << contact.uid() << oendl; break; case ACTION_REPLACE: if ( !replace ( contact ) ) - qWarning ("ODefBack(journal)::Unable to replace uid: %d", - contact.uid() ); + owarn << "ODefBack(journal)::Unable to replace uid: " << contact.uid() << oendl; break; default: - qWarning ("Unknown action: ignored !"); + owarn << "Unknown action: ignored !" << oendl; break; } }else{ /* Add contact to list */ addContact_p (contact); } /* Move to next element */ element = element->nextChild(); } }else { owarn << "ODefBack::could not load" << oendl; } delete root; owarn << "returning from loading" << oendl; return true; } void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt, journal_action action ) { QFile f( m_journalName ); bool created = !f.exists(); diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index a372267..7a3d7cb 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp @@ -15,78 +15,83 @@ + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * ===================================================================== * ToDo: XML-Backend: Automatic reload if something was changed... * * */ #include "ocontactaccess.h" #include "obackendfactory.h" +/* OPIE */ +#include <opie2/ocontactaccessbackend_xml.h> +#include <opie2/opimresolver.h> +#include <opie2/opimglobal.h> +#include <opie2/odebug.h> + +//#include <qpe/qcopenvelope_qws.h> +#include <qpe/global.h> + +/* QT */ #include <qasciidict.h> #include <qdatetime.h> #include <qfile.h> #include <qregexp.h> #include <qlist.h> #include <qcopchannel_qws.h> -//#include <qpe/qcopenvelope_qws.h> -#include <qpe/global.h> - +/* STD */ #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> -#include <opie2/ocontactaccessbackend_xml.h> -#include <opie2/opimresolver.h> -#include <opie2/opimglobal.h> namespace Opie { OPimContactAccess::OPimContactAccess ( const QString appname, const QString , OPimContactAccessBackend* end, bool autosync ): OPimAccessTemplate<OPimContact>( end ) { /* take care of the backend. If there is no one defined, we * will use the XML-Backend as default (until we have a cute SQL-Backend..). */ if( end == 0 ) { - qWarning ("Using BackendFactory !"); + owarn << "Using BackendFactory !" << oendl; end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname ); } // Set backend locally and in template m_backEnd = end; OPimAccessTemplate<OPimContact>::setBackEnd (end); /* Connect signal of external db change to function */ QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(copMessage(const QCString&,const QByteArray&)) ); if ( autosync ){ QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(copMessage(const QCString&,const QByteArray&)) ); } } OPimContactAccess::~OPimContactAccess () { /* The user may forget to save the changed database, therefore try to * do it for him.. */ @@ -118,42 +123,42 @@ const uint OPimContactAccess::querySettings() { return ( m_backEnd->querySettings() ); } bool OPimContactAccess::hasQuerySettings ( int querySettings ) const { return ( m_backEnd->hasQuerySettings ( querySettings ) ); } OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const { QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); return ( OPimRecordList<OPimContact>(matchingContacts, this) ); } bool OPimContactAccess::wasChangedExternally()const { return ( m_backEnd->wasChangedExternally() ); } void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) { if ( msg == "addressbookUpdated()" ){ - qWarning ("OPimContactAccess: Received addressbokUpdated()"); + owarn << "OPimContactAccess: Received addressbokUpdated()" << oendl; emit signalChanged ( this ); } else if ( msg == "flush()" ) { - qWarning ("OPimContactAccess: Received flush()"); + owarn << "OPimContactAccess: Received flush()" << oendl; save (); } else if ( msg == "reload()" ) { - qWarning ("OPimContactAccess: Received reload()"); + owarn << "OPimContactAccess: Received reload()" << oendl; reload (); emit signalChanged ( this ); } } int OPimContactAccess::rtti() const { return OPimResolver::AddressBook; } } diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index e438980..55d600a 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h @@ -9,56 +9,59 @@ .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OPIE_PIM_ACCESS_TEMPLATE_H #define OPIE_PIM_ACCESS_TEMPLATE_H -#include <qarray.h> - +/* OPIE */ #include <opie2/opimrecord.h> #include <opie2/opimaccessbackend.h> #include <opie2/opimrecordlist.h> #include <opie2/opimcache.h> #include <opie2/opimtemplatebase.h> +#include <opie2/odebug.h> + +/* QT */ +#include <qarray.h> namespace Opie { class OPimAccessTemplatePrivate; /** * Thats the frontend to our OPIE PIM * Library. Either you want to use it's * interface or you want to implement * your own Access lib * Just create a OPimRecord and inherit from * the templates */ template <class T = OPimRecord > class OPimAccessTemplate : public OTemplateBase<T> { public: enum Access { Random = 0, SortedAccess }; typedef OPimRecordList<T> List; typedef OPimAccessBackend<T> BackEnd; typedef OPimCache<T> Cache; @@ -184,49 +187,49 @@ protected: void invalidateCache(); void setBackEnd( BackEnd* end ); /** * returns the backend */ BackEnd* backEnd(); BackEnd* m_backEnd; Cache m_cache; private: OPimAccessTemplatePrivate *d; }; template <class T> OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) : OTemplateBase<T>(), m_backEnd( end ) { if (end ) end->setFrontend( this ); } template <class T> OPimAccessTemplate<T>::~OPimAccessTemplate() { - qWarning("~OPimAccessTemplate<T>"); + owarn << "~OPimAccessTemplate<T>" << oendl; delete m_backEnd; } template <class T> bool OPimAccessTemplate<T>::load() { invalidateCache(); return m_backEnd->load(); } template <class T> bool OPimAccessTemplate<T>::reload() { invalidateCache(); // zecke: I think this should be added (se) return m_backEnd->reload(); } template <class T> bool OPimAccessTemplate<T>::save() { return m_backEnd->save(); } template <class T> typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { QArray<int> ints = m_backEnd->allRecords(); List lis(ints, this ); return lis; } template <class T> typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { @@ -239,49 +242,49 @@ QArray<int> OPimAccessTemplate<T>::records()const { return m_backEnd->allRecords(); } template <class T> typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); List lis(ints, this ); return lis; } template <class T> T OPimAccessTemplate<T>::find( int uid ) const{ T t = m_backEnd->find( uid ); cache( t ); return t; } template <class T> T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, uint current, typename OTemplateBase<T>::CacheDirection dir )const { /* * better do T.isEmpty() * after a find this way we would * avoid two finds in QCache... */ - // qWarning("find it now %d", uid ); + // owarn << "find it now " << uid << oendl; if (m_cache.contains( uid ) ) { return m_cache.find( uid ); } T t = m_backEnd->find( uid, ar, current, dir ); cache( t ); return t; } template <class T> void OPimAccessTemplate<T>::clear() { invalidateCache(); m_backEnd->clear(); } template <class T> bool OPimAccessTemplate<T>::add( const T& t ) { cache( t ); return m_backEnd->add( t ); } template <class T> bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { /* same type */ T tempInstance; if ( rec.rtti() == tempInstance.rtti() ) { diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp index 48a74d0..36e9a93 100644 --- a/libopie2/opiepim/core/opimcontact.cpp +++ b/libopie2/opiepim/core/opimcontact.cpp @@ -1152,64 +1152,64 @@ void OPimContact::setBirthday( const QDate &v ) /*! \fn void OPimContact::setAnniversary( const QDate &date ) Sets the anniversary of the contact to \a date. If date is null, the current stored date will be removed. */ void OPimContact::setAnniversary( const QDate &v ) { if ( v.isNull() ) { owarn << "Remove Anniversary" << oendl; replace( Qtopia::Anniversary, QString::null ); return ; } if ( v.isValid() ) replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); } /*! \fn QDate OPimContact::birthday() const Returns the birthday of the contact. */ QDate OPimContact::birthday() const { QString str = find( Qtopia::Birthday ); - // qWarning ("Birthday %s", str.latin1() ); + // owarn << "Birthday " << str << oendl; if ( !str.isEmpty() ) return OPimDateConversion::dateFromString ( str ); else return QDate(); } /*! \fn QDate OPimContact::anniversary() const Returns the anniversary of the contact. */ QDate OPimContact::anniversary() const { QDate empty; QString str = find( Qtopia::Anniversary ); - // qWarning ("Anniversary %s", str.latin1() ); + // owarn << "Anniversary " << str << oendl; if ( !str.isEmpty() ) return OPimDateConversion::dateFromString ( str ); else return empty; } void OPimContact::insertEmail( const QString &v ) { //odebug << "insertEmail " << v << "" << oendl; QString e = v.simplifyWhiteSpace(); QString def = defaultEmail(); // if no default, set it as the default email and don't insert if ( def.isEmpty() ) { setDefaultEmail( e ); // will insert into the list for us return ; } // otherwise, insert assuming doesn't already exist QString emailsStr = find( Qtopia::Emails ); if ( emailsStr.contains( e ) ) return ; diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 0f863aa..516dc79 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp @@ -206,45 +206,45 @@ QString OPimNotifyManager::remindersToString() const OPimNotifyManager::Reminders reminders = m_rem; if ( !reminders.isEmpty() ) { OPimNotifyManager::Reminders::Iterator it = reminders.begin(); QStringList records; for ( ; it != reminders.end(); ++it ) { records << QString::number( ( *it ).recordUid() ); } str = records.join( ";" ); } return str; } void OPimNotifyManager::alarmsFromString( const QString& str ) { QStringList als = QStringList::split( ";", str ); for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty owarn << "alarm: " << alarm.join( "___" ) << "" << oendl; - qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(), - OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() ); + owarn << "alarm[0]: " << alarm[ 0 ] << " " + << OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString() << oendl; OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ), alarm[ 1 ].toInt() ); add( al ); } } void OPimNotifyManager::remindersFromString( const QString& str ) { QStringList rems = QStringList::split( ";", str ); for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { OPimReminder rem( ( *it ).toInt() ); add( rem ); } } } diff --git a/libopie2/opiepim/core/opimrecordlist.h b/libopie2/opiepim/core/opimrecordlist.h index b23138d..1d5027f 100644 --- a/libopie2/opiepim/core/opimrecordlist.h +++ b/libopie2/opiepim/core/opimrecordlist.h @@ -12,48 +12,49 @@ ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef ORECORDLIST_H #define ORECORDLIST_H /* OPIE */ #include <opie2/opimtemplatebase.h> #include <opie2/opimrecord.h> +//#include <opie2/odebug.h> /* QT */ #include <qarray.h> namespace Opie { class OPimRecordListIteratorPrivate; /** * Our List Iterator * it behaves like STL or Qt * * for(it = list.begin(); it != list.end(); ++it ) * doSomeCoolStuff( (*it) ); */ template <class T> class OPimRecordList; template <class T = OPimRecord> class OPimRecordListIterator { friend class OPimRecordList<T>; public: typedef OTemplateBase<T> Base; @@ -168,75 +169,75 @@ class OPimRecordList /* ok now implement it */ template <class T> OPimRecordListIterator<T>::OPimRecordListIterator() { m_current = 0; m_temp = 0l; m_end = true; m_record = T(); /* forward */ m_direction = TRUE; } template <class T> OPimRecordListIterator<T>::~OPimRecordListIterator() { /* nothing to delete */ } template <class T> OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator<T>& it ) { - // qWarning("OPimRecordListIterator copy c'tor"); + //owarn << "OPimRecordListIterator copy c'tor" << oendl; m_uids = it.m_uids; m_current = it.m_current; m_temp = it.m_temp; m_end = it.m_end; m_record = it.m_record; m_direction = it.m_direction; } template <class T> OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator=( const OPimRecordListIterator<T>& it ) { m_uids = it.m_uids; m_current = it.m_current; m_temp = it.m_temp; m_end = it.m_end; m_record = it.m_record; return *this; } template <class T> T OPimRecordListIterator<T>::operator*() { - //qWarning("operator* %d %d", m_current, m_uids[m_current] ); + //owarn << "operator* " << m_current << " " << m_uids[m_current] << oendl; if ( !m_end ) m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current, m_direction ? Base::Forward : Base::Reverse ); else m_record = T(); return m_record; } template <class T> OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator++() { m_direction = true; if ( m_current < m_uids.count() ) { m_end = false; ++m_current; } else m_end = true; return *this; |