summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_xml.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index 50ea329..12a75ba 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
@@ -17,6 +17,9 @@
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.4 2002/10/16 10:52:40 eilers
21 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
22 *
20 * Revision 1.3 2002/10/14 16:21:54 eilers 23 * Revision 1.3 2002/10/14 16:21:54 eilers
21 * Some minor interface updates 24 * Some minor interface updates
22 * 25 *
@@ -56,7 +59,8 @@ using namespace Opie;
56/* the default xml implementation */ 59/* the default xml implementation */
57class OContactAccessBackend_XML : public OContactAccessBackend { 60class OContactAccessBackend_XML : public OContactAccessBackend {
58 public: 61 public:
59 OContactAccessBackend_XML ( QString appname, QString filename = 0l ) 62 OContactAccessBackend_XML ( QString appname, QString filename = 0l ):
63 m_changed( false )
60 { 64 {
61 m_appName = appname; 65 m_appName = appname;
62 66
@@ -75,6 +79,10 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
75 } 79 }
76 80
77 bool save() { 81 bool save() {
82
83 if ( !m_changed )
84 return true;
85
78 QString strNewFile = m_fileName + ".new"; 86 QString strNewFile = m_fileName + ".new";
79 QFile f( strNewFile ); 87 QFile f( strNewFile );
80 if ( !f.open( IO_WriteOnly|IO_Raw ) ) 88 if ( !f.open( IO_WriteOnly|IO_Raw ) )
@@ -123,6 +131,8 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
123 131
124 /* The journalfile should be removed now... */ 132 /* The journalfile should be removed now... */
125 removeJournal(); 133 removeJournal();
134
135 m_changed = false;
126 return true; 136 return true;
127 } 137 }
128 138
@@ -145,6 +155,7 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
145 155
146 void clear () { 156 void clear () {
147 m_contactList.clear(); 157 m_contactList.clear();
158 m_changed = false;
148 159
149 } 160 }
150 161
@@ -275,11 +286,16 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
275 //qWarning("odefaultbackend: ACTION::ADD"); 286 //qWarning("odefaultbackend: ACTION::ADD");
276 updateJournal (newcontact, OContact::ACTION_ADD); 287 updateJournal (newcontact, OContact::ACTION_ADD);
277 addContact_p( newcontact ); 288 addContact_p( newcontact );
289
290 m_changed = true;
291
278 return true; 292 return true;
279 } 293 }
280 294
281 bool replace ( const OContact &contact ) 295 bool replace ( const OContact &contact )
282 { 296 {
297 m_changed = true;
298
283 bool found = false; 299 bool found = false;
284 300
285 QValueListIterator<OContact> it; 301 QValueListIterator<OContact> it;
@@ -300,6 +316,8 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
300 316
301 bool remove ( int uid ) 317 bool remove ( int uid )
302 { 318 {
319 m_changed = true;
320
303 bool found = false; 321 bool found = false;
304 QValueListIterator<OContact> it; 322 QValueListIterator<OContact> it;
305 for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ 323 for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){
@@ -553,6 +571,7 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
553 } 571 }
554 572
555 protected: 573 protected:
574 bool m_changed;
556 QString m_journalName; 575 QString m_journalName;
557 QString m_fileName; 576 QString m_fileName;
558 QString m_appName; 577 QString m_appName;