-rw-r--r-- | libopie/pim/ocontactaccess.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp index 2d808f7..8a8ff08 100644 --- a/libopie/pim/ocontactaccess.cpp +++ b/libopie/pim/ocontactaccess.cpp | |||
@@ -12,24 +12,27 @@ | |||
12 | * Info: This class could just work with a change in the header-file | 12 | * Info: This class could just work with a change in the header-file |
13 | * of the Contact class ! Therefore our libopie only compiles | 13 | * of the Contact class ! Therefore our libopie only compiles |
14 | * with our version of libqpe | 14 | * with our version of libqpe |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * ToDo: XML-Backend: Automatic reload if something was changed... | 16 | * ToDo: XML-Backend: Automatic reload if something was changed... |
17 | * | 17 | * |
18 | * | 18 | * |
19 | * ===================================================================== | 19 | * ===================================================================== |
20 | * Version: $Id$ | 20 | * Version: $Id$ |
21 | * ===================================================================== | 21 | * ===================================================================== |
22 | * History: | 22 | * History: |
23 | * $Log$ | 23 | * $Log$ |
24 | * Revision 1.2 2002/10/02 16:18:11 eilers | ||
25 | * debugged and seems to work almost perfectly .. | ||
26 | * | ||
24 | * Revision 1.1 2002/09/27 17:11:44 eilers | 27 | * Revision 1.1 2002/09/27 17:11:44 eilers |
25 | * Added API for accessing the Contact-Database ! It is compiling, but | 28 | * Added API for accessing the Contact-Database ! It is compiling, but |
26 | * please do not expect that anything is working ! | 29 | * please do not expect that anything is working ! |
27 | * I will debug that stuff in the next time .. | 30 | * I will debug that stuff in the next time .. |
28 | * Please read README_COMPILE for compiling ! | 31 | * Please read README_COMPILE for compiling ! |
29 | * | 32 | * |
30 | * | 33 | * |
31 | */ | 34 | */ |
32 | 35 | ||
33 | #include "ocontactaccess.h" | 36 | #include "ocontactaccess.h" |
34 | 37 | ||
35 | #include <qasciidict.h> | 38 | #include <qasciidict.h> |
@@ -52,46 +55,49 @@ | |||
52 | 55 | ||
53 | OContactAccess::OContactAccess ( const QString appname, const QString filename, | 56 | OContactAccess::OContactAccess ( const QString appname, const QString filename, |
54 | OContactAccessBackend* end, bool autosync ): | 57 | OContactAccessBackend* end, bool autosync ): |
55 | OPimAccessTemplate<OContact>( end ), | 58 | OPimAccessTemplate<OContact>( end ), |
56 | m_changed ( false ) | 59 | m_changed ( false ) |
57 | { | 60 | { |
58 | /* take care of the backend. If there is no one defined, we | 61 | /* take care of the backend. If there is no one defined, we |
59 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 62 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
60 | */ | 63 | */ |
61 | if( end == 0 ) { | 64 | if( end == 0 ) { |
62 | end = new OContactAccessBackend_XML( appname, filename ); | 65 | end = new OContactAccessBackend_XML( appname, filename ); |
63 | } | 66 | } |
67 | // Set backend locally and in template | ||
64 | m_backEnd = end; | 68 | m_backEnd = end; |
69 | OPimAccessTemplate<OContact>::setBackEnd (end); | ||
70 | |||
65 | 71 | ||
66 | /* Connect signal of external db change to function */ | 72 | /* Connect signal of external db change to function */ |
67 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 73 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
68 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 74 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
69 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 75 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); |
70 | if ( autosync ){ | 76 | if ( autosync ){ |
71 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 77 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
72 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 78 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
73 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 79 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); |
74 | } | 80 | } |
75 | 81 | ||
76 | 82 | ||
77 | } | 83 | } |
78 | OContactAccess::~OContactAccess () | 84 | OContactAccess::~OContactAccess () |
79 | { | 85 | { |
80 | /* The user may forget to save the changed database, therefore try to | 86 | /* The user may forget to save the changed database, therefore try to |
81 | * do it for him.. | 87 | * do it for him.. |
82 | */ | 88 | */ |
83 | if ( m_changed ) | 89 | if ( m_changed ) |
84 | save(); | 90 | save(); |
85 | delete m_backEnd; | 91 | // delete m_backEnd; is done by template.. |
86 | } | 92 | } |
87 | 93 | ||
88 | bool OContactAccess::load() | 94 | bool OContactAccess::load() |
89 | { | 95 | { |
90 | return ( m_backEnd->load() ); | 96 | return ( m_backEnd->load() ); |
91 | } | 97 | } |
92 | 98 | ||
93 | bool OContactAccess::save () | 99 | bool OContactAccess::save () |
94 | { | 100 | { |
95 | /* If the database was changed externally, we could not save the | 101 | /* If the database was changed externally, we could not save the |
96 | * Data. This will remove added items which is unacceptable ! | 102 | * Data. This will remove added items which is unacceptable ! |
97 | * Therefore: Reload database and merge the data... | 103 | * Therefore: Reload database and merge the data... |