-rw-r--r-- | kabc/resource.cpp | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 9a1a5f8..9632a3f 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp | |||
@@ -22,34 +22,48 @@ | |||
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include <ksyncprofile.h> | ||
31 | |||
30 | #include "resource.h" | 32 | #include "resource.h" |
31 | 33 | ||
32 | using namespace KABC; | 34 | using namespace KABC; |
33 | 35 | ||
34 | Resource::Resource( const KConfig *config ) | 36 | Resource::Resource( const KConfig *config, bool syncable ) |
35 | : KRES::Resource( config ), mAddressBook( 0 ) | 37 | : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 ) |
36 | { | 38 | { |
39 | if(syncable == true) { | ||
40 | mSyncProfile = new KSyncProfile( identifier() ); | ||
41 | mSyncProfile->setName(resourceName()); | ||
42 | mSyncProfile->readConfig( (KConfig *)config ); | ||
43 | } | ||
37 | } | 44 | } |
38 | 45 | ||
39 | Resource::~Resource() | 46 | Resource::~Resource() |
40 | { | 47 | { |
48 | if (mSyncProfile != 0) { | ||
49 | delete mSyncProfile; | ||
50 | } | ||
41 | } | 51 | } |
42 | 52 | ||
43 | void Resource::writeConfig( KConfig *config ) | 53 | void Resource::writeConfig( KConfig *config ) |
44 | { | 54 | { |
45 | KRES::Resource::writeConfig( config ); | 55 | KRES::Resource::writeConfig( config ); |
56 | |||
57 | if(mSyncProfile != 0) | ||
58 | mSyncProfile->writeConfig( config ); | ||
46 | } | 59 | } |
47 | 60 | ||
61 | |||
48 | void Resource::setAddressBook( AddressBook *ab ) | 62 | void Resource::setAddressBook( AddressBook *ab ) |
49 | { | 63 | { |
50 | mAddressBook = ab; | 64 | mAddressBook = ab; |
51 | } | 65 | } |
52 | 66 | ||
53 | AddressBook *Resource::addressBook() | 67 | AddressBook *Resource::addressBook() |
54 | { | 68 | { |
55 | return mAddressBook; | 69 | return mAddressBook; |
@@ -88,8 +102,53 @@ void Resource::removeAddressee( const Addressee& ) | |||
88 | { | 102 | { |
89 | // do nothing | 103 | // do nothing |
90 | } | 104 | } |
91 | 105 | ||
92 | void Resource::cleanUp() | 106 | void Resource::cleanUp() |
93 | { | 107 | { |
94 | // do nothing | 108 | // do nothing |
95 | } | 109 | } |
110 | |||
111 | bool Resource::isSyncable() const | ||
112 | { | ||
113 | return (mSyncProfile != 0); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * This method returns the number of elements that are currently in the resource. | ||
118 | */ | ||
119 | int Resource::count() const | ||
120 | { | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * This method removes all elements from the resource!! (Not from the addressbook) | ||
126 | */ | ||
127 | bool Resource::clear() | ||
128 | { | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | QString Resource::fileName() const | ||
133 | { | ||
134 | return mFileName; | ||
135 | } | ||
136 | |||
137 | void Resource::setFileName( const QString &fileName ) | ||
138 | { | ||
139 | mFileName = fileName; | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * Set the name of resource.You can override this method, | ||
144 | * but also remember to call Resource::setResourceName(). | ||
145 | */ | ||
146 | void Resource::setResourceName( const QString &name ) | ||
147 | { | ||
148 | KRES::Resource::setResourceName(name); | ||
149 | if(mSyncProfile != 0) { | ||
150 | mSyncProfile->setName( name ); | ||
151 | } | ||
152 | |||
153 | } | ||
154 | |||