New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce AppStream::Suggested in the Qt frontend #93
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| /* | ||
| * Copyright (C) 2016 Aleix Pol Gonzalez <aleixpol@kde.org> | ||
| * | ||
| * Licensed under the GNU Lesser General Public License Version 2.1 | ||
| * | ||
| * This library is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Lesser General Public License as published by | ||
| * the Free Software Foundation, either version 2.1 of the license, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License | ||
| * along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #include "appstream.h" | ||
| #include "suggested.h" | ||
|
|
||
| #include <QSharedData> | ||
| #include <QSize> | ||
| #include <QUrl> | ||
| #include <QDebug> | ||
| #include "chelpers.h" | ||
|
|
||
| using namespace AppStream; | ||
|
|
||
| class AppStream::SuggestedData : public QSharedData { | ||
| public: | ||
| SuggestedData() | ||
| { | ||
| m_suggested = as_suggested_new(); | ||
| } | ||
|
|
||
| SuggestedData(AsSuggested *suggested) | ||
| : m_suggested(suggested) | ||
| { | ||
| g_object_ref(m_suggested); | ||
| } | ||
|
|
||
| ~SuggestedData() | ||
| { | ||
| g_object_unref(m_suggested); | ||
| } | ||
|
|
||
| bool operator==(const SuggestedData& rd) const | ||
| { | ||
| return rd.m_suggested == m_suggested; | ||
| } | ||
|
|
||
| AsSuggested *m_suggested; | ||
| }; | ||
|
|
||
| Suggested::Suggested(const Suggested& other) | ||
| : d(other.d) | ||
| {} | ||
|
|
||
| Suggested::Suggested() | ||
| : d(new SuggestedData) | ||
| {} | ||
|
|
||
| Suggested::Suggested(_AsSuggested *suggested) | ||
| : d(new SuggestedData(suggested)) | ||
| {} | ||
|
|
||
| Suggested::~Suggested() | ||
| {} | ||
|
|
||
| Suggested& Suggested::operator=(const Suggested& other) | ||
| { | ||
| this->d = other.d; | ||
| return *this; | ||
| } | ||
|
|
||
| Suggested::Kind Suggested::kind() const | ||
| { | ||
| return Suggested::Kind(as_suggested_get_kind(d->m_suggested)); | ||
| } | ||
|
|
||
| void Suggested::setKind(Suggested::Kind kind) | ||
| { | ||
| as_suggested_set_kind(d->m_suggested, (AsSuggestedKind) kind); | ||
| } | ||
|
|
||
| const QStringList AppStream::Suggested::ids() const | ||
| { | ||
| return valueWrap(as_suggested_get_ids(d->m_suggested)); | ||
| } | ||
|
|
||
| void AppStream::Suggested::addSuggested(const QString& id) | ||
| { | ||
| as_suggested_add_id(d->m_suggested, qPrintable(id)); | ||
| } | ||
|
|
||
| QDebug operator<<(QDebug s, const AppStream::Suggested& image) { | ||
| s.nospace() << "AppStream::Suggested(" << image.ids() << ")"; | ||
| return s.space(); | ||
| } | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Copyright (C) 2016 Aleix Pol Gonzalez <aleixpol@kde.org> | ||
| * | ||
| * Licensed under the GNU Lesser General Public License Version 2.1 | ||
| * | ||
| * This library is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Lesser General Public License as published by | ||
| * the Free Software Foundation, either version 2.1 of the license, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License | ||
| * along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #ifndef APPSTREAMQT_SUGGESTED_H | ||
| #define APPSTREAMQT_SUGGESTED_H | ||
|
|
||
| #include <QSharedDataPointer> | ||
| #include <QObject> | ||
| #include "appstreamqt_export.h" | ||
|
|
||
| class QUrl; | ||
| class QString; | ||
| struct _AsSuggested; | ||
| namespace AppStream { | ||
|
|
||
| class SuggestedData; | ||
|
|
||
| /** | ||
| * This class provides a list of other component-ids suggested by a software component, as well | ||
| * as an origin of the suggestion (manually suggested by the upstream project, or | ||
| * automatically determined by heuristics).. | ||
| */ | ||
| class APPSTREAMQT_EXPORT Suggested { | ||
| Q_GADGET | ||
| public: | ||
| enum Kind { | ||
| KindUnknown, | ||
| KindUpstream, | ||
| KindHeuristic | ||
| }; | ||
| Q_ENUM(Kind) | ||
|
|
||
| Suggested(); | ||
| Suggested(_AsSuggested *suggested); | ||
| Suggested(const Suggested& other); | ||
| ~Suggested(); | ||
|
|
||
| Suggested& operator=(const Suggested& other); | ||
|
|
||
| /** | ||
| * \return the kind of suggestion | ||
| */ | ||
| Kind kind() const; | ||
| void setKind(Kind kind); | ||
|
|
||
| /** | ||
| * \return the local or remote url for this suggested | ||
| */ | ||
| const QStringList ids() const; | ||
| void addSuggested(const QString &id); | ||
|
|
||
| private: | ||
| QSharedDataPointer<SuggestedData> d; | ||
| }; | ||
| } | ||
|
|
||
| APPSTREAMQT_EXPORT QDebug operator<<(QDebug s, const AppStream::Suggested& suggested); | ||
|
|
||
| #endif // APPSTREAMQT_SUGGESTED_H |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Image? (also, bracked should come after a newline for functions)