author | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
commit | c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852 (patch) (unidiff) | |
tree | dc59744a6d59ba241e793ce051da485d0bf16d06 /kabc/stdaddressbook.cpp | |
parent | b83866e08ddcc5cb2734801977927f48b53a2e1c (diff) | |
download | kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.zip kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.gz kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.bz2 |
final changes for addressbook sync config dialog
-rw-r--r-- | kabc/stdaddressbook.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp index 1e00cc6..760820e 100644 --- a/kabc/stdaddressbook.cpp +++ b/kabc/stdaddressbook.cpp | |||
@@ -50,109 +50,107 @@ QString StdAddressBook::fileName() | |||
50 | QString StdAddressBook::directoryName() | 50 | QString StdAddressBook::directoryName() |
51 | { | 51 | { |
52 | return locateLocal( "data", "kabc/stdvcf" ); | 52 | return locateLocal( "data", "kabc/stdvcf" ); |
53 | } | 53 | } |
54 | 54 | ||
55 | void StdAddressBook::handleCrash() | 55 | void StdAddressBook::handleCrash() |
56 | { | 56 | { |
57 | StdAddressBook::self()->cleanUp(); | 57 | StdAddressBook::self()->cleanUp(); |
58 | } | 58 | } |
59 | 59 | ||
60 | StdAddressBook *StdAddressBook::self() | 60 | StdAddressBook *StdAddressBook::self() |
61 | { | 61 | { |
62 | 62 | ||
63 | if ( !mSelf ) | 63 | if ( !mSelf ) |
64 | { | 64 | { |
65 | QString appdir = StdAddressBook::setTempAppDir(); | 65 | QString appdir = StdAddressBook::setTempAppDir(); |
66 | 66 | ||
67 | kdDebug(5700) << "StdAddressBook::self()" << endl; | 67 | kdDebug(5700) << "StdAddressBook::self()" << endl; |
68 | // US im am not sure why I have to use the other format here?? | 68 | // US im am not sure why I have to use the other format here?? |
69 | #ifdef KAB_EMBEDDED | 69 | #ifdef KAB_EMBEDDED |
70 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); | 70 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); |
71 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
72 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); | 72 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); |
73 | #endif //KAB_EMBEDDED | 73 | #endif //KAB_EMBEDDED |
74 | KStandardDirs::setAppDir( appdir ); | 74 | KStandardDirs::setAppDir( appdir ); |
75 | } | 75 | } |
76 | 76 | ||
77 | return mSelf; | 77 | return mSelf; |
78 | } | 78 | } |
79 | 79 | ||
80 | QString StdAddressBook::setTempAppDir() | 80 | QString StdAddressBook::setTempAppDir() |
81 | { | 81 | { |
82 | QString appDIR = KStandardDirs::appDir(); | 82 | QString appDIR = KStandardDirs::appDir(); |
83 | #ifdef DESKTOP_VERSION | 83 | #ifdef DESKTOP_VERSION |
84 | QString appdir = QDir::homeDirPath(); | 84 | QString appdir = QDir::homeDirPath(); |
85 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) | 85 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) |
86 | appdir += "kaddressbook/"; | 86 | appdir += "kaddressbook/"; |
87 | else | 87 | else |
88 | appdir += "/kaddressbook/"; | 88 | appdir += "/kaddressbook/"; |
89 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); | 89 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); |
90 | #else | 90 | #else |
91 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; | 91 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; |
92 | 92 | ||
93 | KStandardDirs::setAppDir( appdir ); | 93 | KStandardDirs::setAppDir( appdir ); |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | return appDIR; | 96 | return appDIR; |
97 | } | 97 | } |
98 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) | 98 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) |
99 | { | 99 | { |
100 | 100 | ||
101 | if ( !mSelf ) | 101 | if ( !mSelf ) |
102 | { | 102 | { |
103 | QString appdir =StdAddressBook::setTempAppDir(); | 103 | QString appdir =StdAddressBook::setTempAppDir(); |
104 | #ifdef KAB_EMBEDDED | 104 | #ifdef KAB_EMBEDDED |
105 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); | 105 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); |
106 | #else //KAB_EMBEDDED | 106 | #else //KAB_EMBEDDED |
107 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); | 107 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); |
108 | #endif //KAB_EMBEDDED | 108 | #endif //KAB_EMBEDDED |
109 | KStandardDirs::setAppDir( appdir ); | 109 | KStandardDirs::setAppDir( appdir ); |
110 | } | 110 | } |
111 | return mSelf; | 111 | return mSelf; |
112 | } | 112 | } |
113 | 113 | ||
114 | StdAddressBook::StdAddressBook() | 114 | StdAddressBook::StdAddressBook() |
115 | //US : AddressBook( "kabcrc" ) | 115 | : AddressBook( "kabcrc" ) |
116 | : AddressBook( locateLocal( "config", "kabcrc") ) | ||
117 | { | 116 | { |
118 | 117 | ||
119 | init( false ); | 118 | init( false ); |
120 | } | 119 | } |
121 | 120 | ||
122 | StdAddressBook::StdAddressBook( bool onlyFastResources ) | 121 | StdAddressBook::StdAddressBook( bool onlyFastResources ) |
123 | //US : AddressBook( "kabcrc" ) | 122 | : AddressBook( "kabcrc" ) |
124 | : AddressBook( locateLocal( "config", "kabcrc") ) | ||
125 | { | 123 | { |
126 | 124 | ||
127 | init( onlyFastResources ); | 125 | init( onlyFastResources ); |
128 | } | 126 | } |
129 | 127 | ||
130 | StdAddressBook::~StdAddressBook() | 128 | StdAddressBook::~StdAddressBook() |
131 | { | 129 | { |
132 | if ( mAutomaticSave ) | 130 | if ( mAutomaticSave ) |
133 | save(); | 131 | save(); |
134 | } | 132 | } |
135 | 133 | ||
136 | void StdAddressBook::init( bool ) | 134 | void StdAddressBook::init( bool ) |
137 | { | 135 | { |
138 | KRES::Manager<Resource> *manager = resourceManager(); | 136 | KRES::Manager<Resource> *manager = resourceManager(); |
139 | KRES::Manager<Resource>::ActiveIterator it; | 137 | KRES::Manager<Resource>::ActiveIterator it; |
140 | 138 | ||
141 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 139 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
142 | (*it)->setAddressBook( this ); | 140 | (*it)->setAddressBook( this ); |
143 | if ( !(*it)->open() ) | 141 | if ( !(*it)->open() ) |
144 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 142 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
145 | } | 143 | } |
146 | 144 | ||
147 | Resource *res = standardResource(); | 145 | Resource *res = standardResource(); |
148 | if ( !res ) { | 146 | if ( !res ) { |
149 | res = manager->createResource( "file" ); | 147 | res = manager->createResource( "file" ); |
150 | if ( res ) | 148 | if ( res ) |
151 | { | 149 | { |
152 | addResource( res ); | 150 | addResource( res ); |
153 | } | 151 | } |
154 | else | 152 | else |
155 | qDebug(" No resource available!!!"); | 153 | qDebug(" No resource available!!!"); |
156 | } | 154 | } |
157 | 155 | ||
158 | setStandardResource( res ); | 156 | setStandardResource( res ); |
@@ -177,34 +175,34 @@ bool StdAddressBook::save() | |||
177 | Ticket *ticket = ab->requestSaveTicket( *it ); | 175 | Ticket *ticket = ab->requestSaveTicket( *it ); |
178 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 176 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
179 | if ( !ticket ) { | 177 | if ( !ticket ) { |
180 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) | 178 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) |
181 | .arg( (*it)->resourceName() ) ); | 179 | .arg( (*it)->resourceName() ) ); |
182 | return false; | 180 | return false; |
183 | } | 181 | } |
184 | 182 | ||
185 | if ( !ab->save( ticket ) ) | 183 | if ( !ab->save( ticket ) ) |
186 | ok = false; | 184 | ok = false; |
187 | } | 185 | } |
188 | } | 186 | } |
189 | 187 | ||
190 | return ok; | 188 | return ok; |
191 | } | 189 | } |
192 | 190 | ||
193 | void StdAddressBook::close() | 191 | void StdAddressBook::close() |
194 | { | 192 | { |
195 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? | 193 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? |
196 | //US addressBookDeleter.destructObject(); | 194 | //US addressBookDeleter.destructObject(); |
197 | addressBookDeleter.setObject(0); | 195 | addressBookDeleter.setObject(0); |
198 | 196 | ||
199 | } | 197 | } |
200 | 198 | ||
201 | void StdAddressBook::setAutomaticSave( bool enable ) | 199 | void StdAddressBook::setAutomaticSave( bool enable ) |
202 | { | 200 | { |
203 | mAutomaticSave = enable; | 201 | mAutomaticSave = enable; |
204 | } | 202 | } |
205 | 203 | ||
206 | bool StdAddressBook::automaticSave() | 204 | bool StdAddressBook::automaticSave() |
207 | { | 205 | { |
208 | return mAutomaticSave; | 206 | return mAutomaticSave; |
209 | } | 207 | } |
210 | 208 | ||