Changeset View
Changeset View
Standalone View
Standalone View
src/core/entryinternal.cpp
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 36 | public: | |||
---|---|---|---|---|---|
74 | QString mSummary; | 74 | QString mSummary; | ||
75 | QString mShortSummary; | 75 | QString mShortSummary; | ||
76 | QString mChangelog; | 76 | QString mChangelog; | ||
77 | QString mPayload; | 77 | QString mPayload; | ||
78 | QStringList mInstalledFiles; | 78 | QStringList mInstalledFiles; | ||
79 | QString mProviderId; | 79 | QString mProviderId; | ||
80 | QStringList mUnInstalledFiles; | 80 | QStringList mUnInstalledFiles; | ||
81 | QString mDonationLink; | 81 | QString mDonationLink; | ||
82 | QStringList mTags; | ||||
82 | 83 | | |||
83 | QString mChecksum; | 84 | QString mChecksum; | ||
84 | QString mSignature; | 85 | QString mSignature; | ||
85 | KNS3::Entry::Status mStatus; | 86 | KNS3::Entry::Status mStatus; | ||
86 | EntryInternal::Source mSource; | 87 | EntryInternal::Source mSource; | ||
87 | 88 | | |||
88 | QString mPreviewUrl[6]; | 89 | QString mPreviewUrl[6]; | ||
89 | QImage mPreviewImage[6]; | 90 | QImage mPreviewImage[6]; | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 151 | { | |||
151 | return d->mProviderId; | 152 | return d->mProviderId; | ||
152 | } | 153 | } | ||
153 | 154 | | |||
154 | void EntryInternal::setProviderId(const QString &id) | 155 | void EntryInternal::setProviderId(const QString &id) | ||
155 | { | 156 | { | ||
156 | d->mProviderId = id; | 157 | d->mProviderId = id; | ||
157 | } | 158 | } | ||
158 | 159 | | |||
160 | QStringList KNSCore::EntryInternal::tags() const | ||||
161 | { | ||||
162 | return d->mTags; | ||||
163 | } | ||||
164 | | ||||
165 | void KNSCore::EntryInternal::setTags(const QStringList &tags) | ||||
ahiemstra: Nitpick, but this doesn't match with the coding style of the declaration (`const QStringList&… | |||||
166 | { | ||||
167 | d->mTags = tags; | ||||
168 | } | ||||
169 | | ||||
159 | QString EntryInternal::category() const | 170 | QString EntryInternal::category() const | ||
160 | { | 171 | { | ||
161 | return d->mCategory; | 172 | return d->mCategory; | ||
162 | } | 173 | } | ||
163 | 174 | | |||
164 | void EntryInternal::setCategory(const QString &category) | 175 | void EntryInternal::setCategory(const QString &category) | ||
165 | { | 176 | { | ||
166 | d->mCategory = category; | 177 | d->mCategory = category; | ||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Line(s) | 483 | { | |||
476 | xml->readNext(); | 487 | xml->readNext(); | ||
477 | Q_ASSERT(xml->tokenType() == QXmlStreamReader::EndElement); | 488 | Q_ASSERT(xml->tokenType() == QXmlStreamReader::EndElement); | ||
478 | return ret; | 489 | return ret; | ||
479 | } | 490 | } | ||
480 | 491 | | |||
481 | bool KNSCore::EntryInternal::setEntryXML(QXmlStreamReader& reader) | 492 | bool KNSCore::EntryInternal::setEntryXML(QXmlStreamReader& reader) | ||
482 | { | 493 | { | ||
483 | if (reader.name() != QLatin1String("stuff")) { | 494 | if (reader.name() != QLatin1String("stuff")) { | ||
484 | qWarning() << "Parsing Entry from invalid XML"; | 495 | qCWarning(KNEWSTUFFCORE) << "Parsing Entry from invalid XML. Reader tag name was expected to be \"stuff\", but was found as:" << reader.name(); | ||
mlaurent: qCWarning(KNEWSTUFF_CORE) ? | |||||
I was just adding in a bit of verbosity to the output... but yes, makes sense to fix that while i'm there anyway :) leinir: I was just adding in a bit of verbosity to the output... but yes, makes sense to fix that while… | |||||
485 | return false; | 496 | return false; | ||
486 | } | 497 | } | ||
487 | 498 | | |||
488 | d->mCategory = reader.attributes().value(QStringLiteral("category")).toString(); | 499 | d->mCategory = reader.attributes().value(QStringLiteral("category")).toString(); | ||
489 | 500 | | |||
490 | while (!reader.atEnd()) { | 501 | while (!reader.atEnd()) { | ||
491 | const auto token = readNextSkipComments(&reader); | 502 | const auto token = readNextSkipComments(&reader); | ||
492 | if (token == QXmlStreamReader::EndElement) | 503 | if (token == QXmlStreamReader::EndElement) | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
535 | } else if (reader.name() == QLatin1String("signature")) { | 546 | } else if (reader.name() == QLatin1String("signature")) { | ||
536 | d->mSignature = reader.readElementText(QXmlStreamReader::SkipChildElements); | 547 | d->mSignature = reader.readElementText(QXmlStreamReader::SkipChildElements); | ||
537 | } else if (reader.name() == QLatin1String("checksum")) { | 548 | } else if (reader.name() == QLatin1String("checksum")) { | ||
538 | d->mChecksum = reader.readElementText(QXmlStreamReader::SkipChildElements); | 549 | d->mChecksum = reader.readElementText(QXmlStreamReader::SkipChildElements); | ||
539 | } else if (reader.name() == QLatin1String("installedfile")) { | 550 | } else if (reader.name() == QLatin1String("installedfile")) { | ||
540 | d->mInstalledFiles.append(reader.readElementText(QXmlStreamReader::SkipChildElements)); | 551 | d->mInstalledFiles.append(reader.readElementText(QXmlStreamReader::SkipChildElements)); | ||
541 | } else if (reader.name() == QLatin1String("id")) { | 552 | } else if (reader.name() == QLatin1String("id")) { | ||
542 | d->mUniqueId = reader.readElementText(QXmlStreamReader::SkipChildElements); | 553 | d->mUniqueId = reader.readElementText(QXmlStreamReader::SkipChildElements); | ||
554 | } else if (reader.name() == QLatin1String("tags")) { | ||||
555 | d->mTags = reader.readElementText(QXmlStreamReader::SkipChildElements).split(QChar(',')); | ||||
543 | } else if (reader.name() == QLatin1String("status")) { | 556 | } else if (reader.name() == QLatin1String("status")) { | ||
544 | const auto statusText = readText(&reader); | 557 | const auto statusText = readText(&reader); | ||
545 | if (statusText == QLatin1String("installed")) { | 558 | if (statusText == QLatin1String("installed")) { | ||
546 | qCDebug(KNEWSTUFFCORE) << "Found an installed entry in registry"; | 559 | qCDebug(KNEWSTUFFCORE) << "Found an installed entry in registry"; | ||
547 | d->mStatus = KNS3::Entry::Installed; | 560 | d->mStatus = KNS3::Entry::Installed; | ||
548 | } else if (statusText == QLatin1String("updateable")) { | 561 | } else if (statusText == QLatin1String("updateable")) { | ||
549 | d->mStatus = KNS3::Entry::Updateable; | 562 | d->mStatus = KNS3::Entry::Updateable; | ||
550 | } | 563 | } | ||
551 | if (reader.tokenType() == QXmlStreamReader::Characters) | 564 | if (reader.tokenType() == QXmlStreamReader::Characters) | ||
552 | readNextSkipComments(&reader); | 565 | readNextSkipComments(&reader); | ||
553 | } | 566 | } | ||
554 | Q_ASSERT(reader.tokenType() == QXmlStreamReader::EndElement); | 567 | Q_ASSERT_X(reader.tokenType() == QXmlStreamReader::EndElement, Q_FUNC_INFO, QString("token name was %1 and the type was %2").arg(reader.name()).arg(reader.tokenString()).toLocal8Bit().data()); | ||
555 | } | 568 | } | ||
556 | 569 | | |||
557 | // Validation | 570 | // Validation | ||
558 | if (d->mName.isEmpty()) { | 571 | if (d->mName.isEmpty()) { | ||
559 | qWarning() << "Entry: no name given"; | 572 | qWarning() << "Entry: no name given"; | ||
560 | return false; | 573 | return false; | ||
561 | } | 574 | } | ||
562 | 575 | | |||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 601 | for (n = xmldata.firstChild(); !n.isNull(); n = n.nextSibling()) { | |||
628 | } else if (e.tagName() == QLatin1String("signature")) { | 641 | } else if (e.tagName() == QLatin1String("signature")) { | ||
629 | d->mSignature = e.text(); | 642 | d->mSignature = e.text(); | ||
630 | } else if (e.tagName() == QLatin1String("checksum")) { | 643 | } else if (e.tagName() == QLatin1String("checksum")) { | ||
631 | d->mChecksum = e.text(); | 644 | d->mChecksum = e.text(); | ||
632 | } else if (e.tagName() == QLatin1String("installedfile")) { | 645 | } else if (e.tagName() == QLatin1String("installedfile")) { | ||
633 | d->mInstalledFiles.append(e.text()); | 646 | d->mInstalledFiles.append(e.text()); | ||
634 | } else if (e.tagName() == QLatin1String("id")) { | 647 | } else if (e.tagName() == QLatin1String("id")) { | ||
635 | d->mUniqueId = e.text(); | 648 | d->mUniqueId = e.text(); | ||
649 | } else if (e.tagName() == QLatin1String("tags")) { | ||||
650 | d->mTags = e.text().split(QChar(',')); | ||||
636 | } else if (e.tagName() == QLatin1String("status")) { | 651 | } else if (e.tagName() == QLatin1String("status")) { | ||
637 | QString statusText = e.text(); | 652 | QString statusText = e.text(); | ||
638 | if (statusText == QLatin1String("installed")) { | 653 | if (statusText == QLatin1String("installed")) { | ||
639 | qCDebug(KNEWSTUFFCORE) << "Found an installed entry in registry"; | 654 | qCDebug(KNEWSTUFFCORE) << "Found an installed entry in registry"; | ||
640 | d->mStatus = KNS3::Entry::Installed; | 655 | d->mStatus = KNS3::Entry::Installed; | ||
641 | } else if (statusText == QLatin1String("updateable")) { | 656 | } else if (statusText == QLatin1String("updateable")) { | ||
642 | d->mStatus = KNS3::Entry::Updateable; | 657 | d->mStatus = KNS3::Entry::Updateable; | ||
643 | } | 658 | } | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 687 | { | |||
719 | (void)addElement(doc, el, QStringLiteral("releasedate"), | 734 | (void)addElement(doc, el, QStringLiteral("releasedate"), | ||
720 | d->mReleaseDate.toString(Qt::ISODate)); | 735 | d->mReleaseDate.toString(Qt::ISODate)); | ||
721 | 736 | | |||
722 | e = addElement(doc, el, QStringLiteral("summary"), d->mSummary); | 737 | e = addElement(doc, el, QStringLiteral("summary"), d->mSummary); | ||
723 | e = addElement(doc, el, QStringLiteral("changelog"), d->mChangelog); | 738 | e = addElement(doc, el, QStringLiteral("changelog"), d->mChangelog); | ||
724 | e = addElement(doc, el, QStringLiteral("preview"), d->mPreviewUrl[PreviewSmall1]); | 739 | e = addElement(doc, el, QStringLiteral("preview"), d->mPreviewUrl[PreviewSmall1]); | ||
725 | e = addElement(doc, el, QStringLiteral("previewBig"), d->mPreviewUrl[PreviewBig1]); | 740 | e = addElement(doc, el, QStringLiteral("previewBig"), d->mPreviewUrl[PreviewBig1]); | ||
726 | e = addElement(doc, el, QStringLiteral("payload"), d->mPayload); | 741 | e = addElement(doc, el, QStringLiteral("payload"), d->mPayload); | ||
742 | e = addElement(doc, el, QStringLiteral("tags"), d->mTags.join(QChar(','))); | ||||
727 | 743 | | |||
728 | if (d->mStatus == KNS3::Entry::Installed) { | 744 | if (d->mStatus == KNS3::Entry::Installed) { | ||
729 | (void)addElement(doc, el, QStringLiteral("status"), QStringLiteral("installed")); | 745 | (void)addElement(doc, el, QStringLiteral("status"), QStringLiteral("installed")); | ||
730 | } | 746 | } | ||
731 | if (d->mStatus == KNS3::Entry::Updateable) { | 747 | if (d->mStatus == KNS3::Entry::Updateable) { | ||
732 | (void)addElement(doc, el, QStringLiteral("status"), QStringLiteral("updateable")); | 748 | (void)addElement(doc, el, QStringLiteral("status"), QStringLiteral("updateable")); | ||
733 | } | 749 | } | ||
734 | 750 | | |||
Show All 25 Lines |
Nitpick, but this doesn't match with the coding style of the declaration (const QStringList& tags vs const QStringList &tags)