Changeset View
Changeset View
Standalone View
Standalone View
src/core/entryinternal.cpp
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | |||||
128 | 128 | | |||
129 | QString EntryInternal::name() const | 129 | QString EntryInternal::name() const | ||
130 | { | 130 | { | ||
131 | return d->mName; | 131 | return d->mName; | ||
132 | } | 132 | } | ||
133 | 133 | | |||
134 | void EntryInternal::setName(const QString &name) | 134 | void EntryInternal::setName(const QString &name) | ||
135 | { | 135 | { | ||
136 | d.detach(); | ||||
136 | d->mName = name; | 137 | d->mName = name; | ||
137 | } | 138 | } | ||
138 | 139 | | |||
139 | QString EntryInternal::uniqueId() const | 140 | QString EntryInternal::uniqueId() const | ||
140 | { | 141 | { | ||
141 | return d->mUniqueId; | 142 | return d->mUniqueId; | ||
142 | } | 143 | } | ||
143 | 144 | | |||
144 | void EntryInternal::setUniqueId(const QString &id) | 145 | void EntryInternal::setUniqueId(const QString &id) | ||
145 | { | 146 | { | ||
147 | d.detach(); | ||||
146 | d->mUniqueId = id; | 148 | d->mUniqueId = id; | ||
147 | } | 149 | } | ||
148 | 150 | | |||
149 | QString EntryInternal::providerId() const | 151 | QString EntryInternal::providerId() const | ||
150 | { | 152 | { | ||
151 | return d->mProviderId; | 153 | return d->mProviderId; | ||
152 | } | 154 | } | ||
153 | 155 | | |||
154 | void EntryInternal::setProviderId(const QString &id) | 156 | void EntryInternal::setProviderId(const QString &id) | ||
155 | { | 157 | { | ||
158 | d.detach(); | ||||
156 | d->mProviderId = id; | 159 | d->mProviderId = id; | ||
157 | } | 160 | } | ||
158 | 161 | | |||
159 | QString EntryInternal::category() const | 162 | QString EntryInternal::category() const | ||
160 | { | 163 | { | ||
161 | return d->mCategory; | 164 | return d->mCategory; | ||
162 | } | 165 | } | ||
163 | 166 | | |||
164 | void EntryInternal::setCategory(const QString &category) | 167 | void EntryInternal::setCategory(const QString &category) | ||
165 | { | 168 | { | ||
169 | d.detach(); | ||||
166 | d->mCategory = category; | 170 | d->mCategory = category; | ||
broulik: Detach here also | |||||
167 | } | 171 | } | ||
168 | 172 | | |||
169 | QUrl EntryInternal::homepage() const | 173 | QUrl EntryInternal::homepage() const | ||
170 | { | 174 | { | ||
171 | return d->mHomepage; | 175 | return d->mHomepage; | ||
172 | } | 176 | } | ||
173 | 177 | | |||
174 | void EntryInternal::setHomepage(const QUrl &page) | 178 | void EntryInternal::setHomepage(const QUrl &page) | ||
175 | { | 179 | { | ||
180 | d.detach(); | ||||
176 | d->mHomepage = page; | 181 | d->mHomepage = page; | ||
177 | } | 182 | } | ||
178 | 183 | | |||
179 | Author EntryInternal::author() const | 184 | Author EntryInternal::author() const | ||
180 | { | 185 | { | ||
181 | return d->mAuthor; | 186 | return d->mAuthor; | ||
182 | } | 187 | } | ||
183 | 188 | | |||
184 | void EntryInternal::setAuthor(const KNSCore::Author &author) | 189 | void EntryInternal::setAuthor(const KNSCore::Author &author) | ||
185 | { | 190 | { | ||
191 | d.detach(); | ||||
186 | d->mAuthor = author; | 192 | d->mAuthor = author; | ||
187 | } | 193 | } | ||
188 | 194 | | |||
189 | QString EntryInternal::license() const | 195 | QString EntryInternal::license() const | ||
190 | { | 196 | { | ||
191 | return d->mLicense; | 197 | return d->mLicense; | ||
192 | } | 198 | } | ||
193 | 199 | | |||
194 | void EntryInternal::setLicense(const QString &license) | 200 | void EntryInternal::setLicense(const QString &license) | ||
195 | { | 201 | { | ||
202 | d.detach(); | ||||
196 | d->mLicense = license; | 203 | d->mLicense = license; | ||
197 | } | 204 | } | ||
198 | 205 | | |||
199 | QString EntryInternal::summary() const | 206 | QString EntryInternal::summary() const | ||
200 | { | 207 | { | ||
201 | return d->mSummary; | 208 | return d->mSummary; | ||
202 | } | 209 | } | ||
203 | 210 | | |||
204 | void EntryInternal::setSummary(const QString &summary) | 211 | void EntryInternal::setSummary(const QString &summary) | ||
205 | { | 212 | { | ||
213 | d.detach(); | ||||
206 | d->mSummary = summary; | 214 | d->mSummary = summary; | ||
207 | } | 215 | } | ||
208 | 216 | | |||
209 | QString EntryInternal::shortSummary() const | 217 | QString EntryInternal::shortSummary() const | ||
210 | { | 218 | { | ||
211 | return d->mShortSummary; | 219 | return d->mShortSummary; | ||
212 | } | 220 | } | ||
213 | 221 | | |||
214 | void EntryInternal::setShortSummary(const QString &summary) | 222 | void EntryInternal::setShortSummary(const QString &summary) | ||
215 | { | 223 | { | ||
224 | d.detach(); | ||||
216 | d->mShortSummary = summary; | 225 | d->mShortSummary = summary; | ||
217 | } | 226 | } | ||
218 | 227 | | |||
219 | void EntryInternal::setChangelog(const QString &changelog) | 228 | void EntryInternal::setChangelog(const QString &changelog) | ||
220 | { | 229 | { | ||
230 | d.detach(); | ||||
221 | d->mChangelog = changelog; | 231 | d->mChangelog = changelog; | ||
222 | } | 232 | } | ||
223 | 233 | | |||
224 | QString EntryInternal::changelog() const | 234 | QString EntryInternal::changelog() const | ||
225 | { | 235 | { | ||
226 | return d->mChangelog; | 236 | return d->mChangelog; | ||
227 | } | 237 | } | ||
228 | 238 | | |||
229 | QString EntryInternal::version() const | 239 | QString EntryInternal::version() const | ||
230 | { | 240 | { | ||
231 | return d->mVersion; | 241 | return d->mVersion; | ||
232 | } | 242 | } | ||
233 | 243 | | |||
234 | void EntryInternal::setVersion(const QString &version) | 244 | void EntryInternal::setVersion(const QString &version) | ||
235 | { | 245 | { | ||
246 | d.detach(); | ||||
236 | d->mVersion = version; | 247 | d->mVersion = version; | ||
237 | } | 248 | } | ||
238 | 249 | | |||
239 | QDate EntryInternal::releaseDate() const | 250 | QDate EntryInternal::releaseDate() const | ||
240 | { | 251 | { | ||
241 | return d->mReleaseDate; | 252 | return d->mReleaseDate; | ||
242 | } | 253 | } | ||
243 | 254 | | |||
244 | void EntryInternal::setReleaseDate(const QDate &releasedate) | 255 | void EntryInternal::setReleaseDate(const QDate &releasedate) | ||
245 | { | 256 | { | ||
257 | d.detach(); | ||||
246 | d->mReleaseDate = releasedate; | 258 | d->mReleaseDate = releasedate; | ||
247 | } | 259 | } | ||
248 | 260 | | |||
249 | QString EntryInternal::payload() const | 261 | QString EntryInternal::payload() const | ||
250 | { | 262 | { | ||
251 | return d->mPayload; | 263 | return d->mPayload; | ||
252 | } | 264 | } | ||
253 | 265 | | |||
254 | void EntryInternal::setPayload(const QString &url) | 266 | void EntryInternal::setPayload(const QString &url) | ||
255 | { | 267 | { | ||
268 | d.detach(); | ||||
256 | d->mPayload = url; | 269 | d->mPayload = url; | ||
257 | } | 270 | } | ||
258 | 271 | | |||
259 | QDate EntryInternal::updateReleaseDate() const | 272 | QDate EntryInternal::updateReleaseDate() const | ||
260 | { | 273 | { | ||
261 | return d->mUpdateReleaseDate; | 274 | return d->mUpdateReleaseDate; | ||
262 | } | 275 | } | ||
263 | 276 | | |||
264 | void EntryInternal::setUpdateReleaseDate(const QDate &releasedate) | 277 | void EntryInternal::setUpdateReleaseDate(const QDate &releasedate) | ||
265 | { | 278 | { | ||
279 | d.detach(); | ||||
266 | d->mUpdateReleaseDate = releasedate; | 280 | d->mUpdateReleaseDate = releasedate; | ||
267 | } | 281 | } | ||
268 | 282 | | |||
269 | QString EntryInternal::updateVersion() const | 283 | QString EntryInternal::updateVersion() const | ||
270 | { | 284 | { | ||
271 | return d->mUpdateVersion; | 285 | return d->mUpdateVersion; | ||
272 | } | 286 | } | ||
273 | 287 | | |||
274 | void EntryInternal::setUpdateVersion(const QString &version) | 288 | void EntryInternal::setUpdateVersion(const QString &version) | ||
275 | { | 289 | { | ||
290 | d.detach(); | ||||
276 | d->mUpdateVersion = version; | 291 | d->mUpdateVersion = version; | ||
277 | } | 292 | } | ||
278 | 293 | | |||
279 | QString EntryInternal::previewUrl(PreviewType type) const | 294 | QString EntryInternal::previewUrl(PreviewType type) const | ||
280 | { | 295 | { | ||
281 | return d->mPreviewUrl[type]; | 296 | return d->mPreviewUrl[type]; | ||
282 | } | 297 | } | ||
283 | 298 | | |||
284 | void EntryInternal::setPreviewUrl(const QString &url, PreviewType type) | 299 | void EntryInternal::setPreviewUrl(const QString &url, PreviewType type) | ||
285 | { | 300 | { | ||
301 | d.detach(); | ||||
286 | d->mPreviewUrl[type] = url; | 302 | d->mPreviewUrl[type] = url; | ||
287 | } | 303 | } | ||
288 | 304 | | |||
289 | QImage EntryInternal::previewImage(PreviewType type) const | 305 | QImage EntryInternal::previewImage(PreviewType type) const | ||
290 | { | 306 | { | ||
291 | return d->mPreviewImage[type]; | 307 | return d->mPreviewImage[type]; | ||
292 | } | 308 | } | ||
293 | 309 | | |||
294 | void EntryInternal::setPreviewImage(const QImage &image, PreviewType type) | 310 | void EntryInternal::setPreviewImage(const QImage &image, PreviewType type) | ||
295 | { | 311 | { | ||
312 | d.detach(); | ||||
296 | d->mPreviewImage[type] = image; | 313 | d->mPreviewImage[type] = image; | ||
297 | } | 314 | } | ||
298 | 315 | | |||
299 | int EntryInternal::rating() const | 316 | int EntryInternal::rating() const | ||
300 | { | 317 | { | ||
301 | return d->mRating; | 318 | return d->mRating; | ||
302 | } | 319 | } | ||
303 | 320 | | |||
304 | void EntryInternal::setRating(int rating) | 321 | void EntryInternal::setRating(int rating) | ||
305 | { | 322 | { | ||
323 | d.detach(); | ||||
306 | d->mRating = rating; | 324 | d->mRating = rating; | ||
307 | } | 325 | } | ||
308 | 326 | | |||
309 | int EntryInternal::numberOfComments() const | 327 | int EntryInternal::numberOfComments() const | ||
310 | { | 328 | { | ||
311 | return d->mRating; | 329 | return d->mRating; | ||
312 | } | 330 | } | ||
313 | 331 | | |||
314 | void EntryInternal::setNumberOfComments (int comments) | 332 | void EntryInternal::setNumberOfComments (int comments) | ||
315 | { | 333 | { | ||
334 | d.detach(); | ||||
316 | d->mNumberOfComments = comments; | 335 | d->mNumberOfComments = comments; | ||
317 | } | 336 | } | ||
318 | 337 | | |||
319 | int EntryInternal::downloadCount() const | 338 | int EntryInternal::downloadCount() const | ||
320 | { | 339 | { | ||
321 | return d->mDownloadCount; | 340 | return d->mDownloadCount; | ||
322 | } | 341 | } | ||
323 | 342 | | |||
324 | void EntryInternal::setDownloadCount(int downloads) | 343 | void EntryInternal::setDownloadCount(int downloads) | ||
325 | { | 344 | { | ||
345 | d.detach(); | ||||
326 | d->mDownloadCount = downloads; | 346 | d->mDownloadCount = downloads; | ||
327 | } | 347 | } | ||
328 | 348 | | |||
329 | int EntryInternal::numberFans() const | 349 | int EntryInternal::numberFans() const | ||
330 | { | 350 | { | ||
331 | return d->mNumberFans; | 351 | return d->mNumberFans; | ||
332 | } | 352 | } | ||
333 | 353 | | |||
334 | void EntryInternal::setNumberFans(int fans) | 354 | void EntryInternal::setNumberFans(int fans) | ||
335 | { | 355 | { | ||
356 | d.detach(); | ||||
336 | d->mNumberFans = fans; | 357 | d->mNumberFans = fans; | ||
337 | } | 358 | } | ||
338 | 359 | | |||
339 | QString EntryInternal::donationLink() const | 360 | QString EntryInternal::donationLink() const | ||
340 | { | 361 | { | ||
341 | return d->mDonationLink; | 362 | return d->mDonationLink; | ||
342 | } | 363 | } | ||
343 | 364 | | |||
344 | void EntryInternal::setDonationLink(const QString &link) | 365 | void EntryInternal::setDonationLink(const QString &link) | ||
345 | { | 366 | { | ||
367 | d.detach(); | ||||
346 | d->mDonationLink = link; | 368 | d->mDonationLink = link; | ||
347 | } | 369 | } | ||
348 | 370 | | |||
349 | int EntryInternal::numberKnowledgebaseEntries() const | 371 | int EntryInternal::numberKnowledgebaseEntries() const | ||
350 | { | 372 | { | ||
351 | return d->mNumberKnowledgebaseEntries; | 373 | return d->mNumberKnowledgebaseEntries; | ||
352 | } | 374 | } | ||
353 | void EntryInternal::setNumberKnowledgebaseEntries(int num) | 375 | void EntryInternal::setNumberKnowledgebaseEntries(int num) | ||
354 | { | 376 | { | ||
377 | d.detach(); | ||||
355 | d->mNumberKnowledgebaseEntries = num; | 378 | d->mNumberKnowledgebaseEntries = num; | ||
356 | } | 379 | } | ||
357 | 380 | | |||
358 | QString EntryInternal::knowledgebaseLink() const | 381 | QString EntryInternal::knowledgebaseLink() const | ||
359 | { | 382 | { | ||
360 | return d->mKnowledgebaseLink; | 383 | return d->mKnowledgebaseLink; | ||
361 | } | 384 | } | ||
362 | void EntryInternal::setKnowledgebaseLink(const QString &link) | 385 | void EntryInternal::setKnowledgebaseLink(const QString &link) | ||
363 | { | 386 | { | ||
387 | d.detach(); | ||||
364 | d->mKnowledgebaseLink = link; | 388 | d->mKnowledgebaseLink = link; | ||
365 | } | 389 | } | ||
366 | 390 | | |||
367 | /* | 391 | /* | ||
368 | QString EntryInternal::checksum() const | 392 | QString EntryInternal::checksum() const | ||
369 | { | 393 | { | ||
370 | 394 | | |||
371 | return d->mChecksum; | 395 | return d->mChecksum; | ||
372 | } | 396 | } | ||
373 | 397 | | |||
374 | QString EntryInternal::signature() const | 398 | QString EntryInternal::signature() const | ||
375 | { | 399 | { | ||
376 | 400 | | |||
377 | return d->mSignature; | 401 | return d->mSignature; | ||
378 | } | 402 | } | ||
379 | */ | 403 | */ | ||
380 | 404 | | |||
381 | EntryInternal::Source EntryInternal::source() const | 405 | EntryInternal::Source EntryInternal::source() const | ||
382 | { | 406 | { | ||
383 | return d->mSource; | 407 | return d->mSource; | ||
384 | } | 408 | } | ||
385 | 409 | | |||
386 | void EntryInternal::setSource(Source source) | 410 | void EntryInternal::setSource(Source source) | ||
387 | { | 411 | { | ||
412 | d.detach(); | ||||
388 | d->mSource = source; | 413 | d->mSource = source; | ||
389 | } | 414 | } | ||
390 | 415 | | |||
391 | KNS3::Entry::Status EntryInternal::status() const | 416 | KNS3::Entry::Status EntryInternal::status() const | ||
392 | { | 417 | { | ||
393 | return d->mStatus; | 418 | return d->mStatus; | ||
394 | } | 419 | } | ||
395 | 420 | | |||
396 | void EntryInternal::setStatus(KNS3::Entry::Status status) | 421 | void EntryInternal::setStatus(KNS3::Entry::Status status) | ||
397 | { | 422 | { | ||
423 | d.detach(); | ||||
398 | d->mStatus = status; | 424 | d->mStatus = status; | ||
399 | } | 425 | } | ||
400 | 426 | | |||
401 | void KNSCore::EntryInternal::setInstalledFiles(const QStringList &files) | 427 | void KNSCore::EntryInternal::setInstalledFiles(const QStringList &files) | ||
402 | { | 428 | { | ||
429 | d.detach(); | ||||
403 | d->mInstalledFiles = files; | 430 | d->mInstalledFiles = files; | ||
404 | } | 431 | } | ||
405 | 432 | | |||
406 | QStringList KNSCore::EntryInternal::installedFiles() const | 433 | QStringList KNSCore::EntryInternal::installedFiles() const | ||
407 | { | 434 | { | ||
408 | return d->mInstalledFiles; | 435 | return d->mInstalledFiles; | ||
409 | } | 436 | } | ||
410 | 437 | | |||
411 | void KNSCore::EntryInternal::setUnInstalledFiles(const QStringList &files) | 438 | void KNSCore::EntryInternal::setUnInstalledFiles(const QStringList &files) | ||
412 | { | 439 | { | ||
440 | d.detach(); | ||||
413 | d->mUnInstalledFiles = files; | 441 | d->mUnInstalledFiles = files; | ||
414 | } | 442 | } | ||
415 | 443 | | |||
416 | QStringList KNSCore::EntryInternal::uninstalledFiles() const | 444 | QStringList KNSCore::EntryInternal::uninstalledFiles() const | ||
417 | { | 445 | { | ||
418 | return d->mUnInstalledFiles; | 446 | return d->mUnInstalledFiles; | ||
419 | } | 447 | } | ||
420 | 448 | | |||
421 | int KNSCore::EntryInternal::downloadLinkCount() const | 449 | int KNSCore::EntryInternal::downloadLinkCount() const | ||
422 | { | 450 | { | ||
423 | return d->mDownloadLinkInformationList.size(); | 451 | return d->mDownloadLinkInformationList.size(); | ||
424 | } | 452 | } | ||
425 | 453 | | |||
426 | QList<KNSCore::EntryInternal::DownloadLinkInformation> KNSCore::EntryInternal::downloadLinkInformationList() const | 454 | QList<KNSCore::EntryInternal::DownloadLinkInformation> KNSCore::EntryInternal::downloadLinkInformationList() const | ||
427 | { | 455 | { | ||
428 | return d->mDownloadLinkInformationList; | 456 | return d->mDownloadLinkInformationList; | ||
429 | } | 457 | } | ||
430 | 458 | | |||
431 | void KNSCore::EntryInternal::appendDownloadLinkInformation(const KNSCore::EntryInternal::DownloadLinkInformation &info) | 459 | void KNSCore::EntryInternal::appendDownloadLinkInformation(const KNSCore::EntryInternal::DownloadLinkInformation &info) | ||
432 | { | 460 | { | ||
461 | d.detach(); | ||||
433 | d->mDownloadLinkInformationList.append(info); | 462 | d->mDownloadLinkInformationList.append(info); | ||
434 | } | 463 | } | ||
435 | 464 | | |||
436 | void EntryInternal::clearDownloadLinkInformation() | 465 | void EntryInternal::clearDownloadLinkInformation() | ||
437 | { | 466 | { | ||
467 | d.detach(); | ||||
438 | d->mDownloadLinkInformationList.clear(); | 468 | d->mDownloadLinkInformationList.clear(); | ||
439 | } | 469 | } | ||
440 | 470 | | |||
441 | static QXmlStreamReader::TokenType readNextSkipComments(QXmlStreamReader* xml) | 471 | static QXmlStreamReader::TokenType readNextSkipComments(QXmlStreamReader* xml) | ||
442 | { | 472 | { | ||
443 | do { | 473 | do { | ||
444 | xml->readNext(); | 474 | xml->readNext(); | ||
445 | } while(xml->tokenType() == QXmlStreamReader::Comment || (xml->tokenType() == QXmlStreamReader::Characters && xml->text().trimmed().isEmpty())); | 475 | } while(xml->tokenType() == QXmlStreamReader::Comment || (xml->tokenType() == QXmlStreamReader::Characters && xml->text().trimmed().isEmpty())); | ||
Show All 29 Lines | 502 | { | |||
475 | 505 | | |||
476 | xml->readNext(); | 506 | xml->readNext(); | ||
477 | Q_ASSERT(xml->tokenType() == QXmlStreamReader::EndElement); | 507 | Q_ASSERT(xml->tokenType() == QXmlStreamReader::EndElement); | ||
478 | return ret; | 508 | return ret; | ||
479 | } | 509 | } | ||
480 | 510 | | |||
481 | bool KNSCore::EntryInternal::setEntryXML(QXmlStreamReader& reader) | 511 | bool KNSCore::EntryInternal::setEntryXML(QXmlStreamReader& reader) | ||
482 | { | 512 | { | ||
513 | d.detach(); | ||||
483 | if (reader.name() != QLatin1String("stuff")) { | 514 | if (reader.name() != QLatin1String("stuff")) { | ||
484 | qWarning() << "Parsing Entry from invalid XML"; | 515 | qWarning() << "Parsing Entry from invalid XML"; | ||
485 | return false; | 516 | return false; | ||
486 | } | 517 | } | ||
487 | 518 | | |||
488 | d->mCategory = reader.attributes().value("category").toString(); | 519 | d->mCategory = reader.attributes().value("category").toString(); | ||
489 | 520 | | |||
490 | while (!reader.atEnd()) { | 521 | while (!reader.atEnd()) { | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 602 | if (d->mPayload.isEmpty()) { | |||
572 | qWarning() << "Entry: no payload URL given for: " << d->mName << " - " << d->mUniqueId; | 603 | qWarning() << "Entry: no payload URL given for: " << d->mName << " - " << d->mUniqueId; | ||
573 | return false; | 604 | return false; | ||
574 | } | 605 | } | ||
575 | return true; | 606 | return true; | ||
576 | } | 607 | } | ||
577 | 608 | | |||
578 | bool KNSCore::EntryInternal::setEntryXML(const QDomElement &xmldata) | 609 | bool KNSCore::EntryInternal::setEntryXML(const QDomElement &xmldata) | ||
579 | { | 610 | { | ||
611 | d.detach(); | ||||
580 | if (xmldata.tagName() != QLatin1String("stuff")) { | 612 | if (xmldata.tagName() != QLatin1String("stuff")) { | ||
581 | qWarning() << "Parsing Entry from invalid XML"; | 613 | qWarning() << "Parsing Entry from invalid XML"; | ||
582 | return false; | 614 | return false; | ||
583 | } | 615 | } | ||
584 | 616 | | |||
585 | d->mCategory = xmldata.attribute(QStringLiteral("category")); | 617 | d->mCategory = xmldata.attribute(QStringLiteral("category")); | ||
586 | 618 | | |||
587 | QDomNode n; | 619 | QDomNode n; | ||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |
Detach here also