Skip to content

Comments

Add missing getters/setters for most of the properties in AS::Component#117

Merged
ximion merged 1 commit intoximion:masterfrom
grulja:master
Jun 19, 2017
Merged

Add missing getters/setters for most of the properties in AS::Component#117
ximion merged 1 commit intoximion:masterfrom
grulja:master

Conversation

@grulja
Copy link
Contributor

@grulja grulja commented Jun 14, 2017

Note: only two of them should be missing (launchables and languages), because
we don't have wrappers for them yet

/**
* \returns the internally stored AsBundle
*/
_AsBundle *asBundle() const;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these really necessary? I would argue that this is only needed in case the Qt/C++ interface is incomplete and someone therefore wants to use the C library directly. In that case, we should rather fix the Qt binding to include the missing stuff, and not give library users the means to hack around it and not report the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use these internally, i.e. in as_component_add_icon() or as_component_add_screenshot() and so on, because those methods takes AsIcon or AsScreenshot only.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should make the symbols internal and hide them from the public API... The tricky bit is that they're class members...
(I will take a look on whether it's possible to even have them as internal members, probably the only way to do that is to make them private and use friend classes for access. - in any case, just leave this as it is for now :-) )

@ximion
Copy link
Owner

ximion commented Jun 14, 2017

Looks good on a first quick look at it, except for the obvious CI failure (which hints at an actual bug ^^).

Thank you for working on this, this is great help!

qt/component.h Outdated
bool insertCustomValue(const QString& key, const QString& value);

/**
* TODO contentRating, launchable and languages
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding launchable to the Qt interface is actually a must-be-present feature for the next release, as that's a key new feature and using desktopId is deprecated in favor of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will add them later on. I'm now working on AS::Metadata class needed for parsing.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, awesome! I was going to do this when I'm done with the parser refactoring, but it looks like that will still tle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented above mentioned missing getters/setters including new classes needed for that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Now, fixing the CI failure would be useful, otherwise a lot of code won't work ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, sorry, I haven't seen the error before. I saw CI failure at the beginning but there was a different problem (something with downloading or so) and I ignored it since then.

qt/component.cpp Outdated

QStringList AppStream::Component::searchTokens() const
{
valueWrap(as_component_get_search_tokens(m_cpt));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI complains about a missing return statement here...
And I was also surprised that this thing is public API, but looking at AsComponent it indeed is...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed that one too, I wonder why I don't get a compilation error here while CI obviously reports that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configure AppStream with -DMAINTAINER=ON, that will enable (almost) all compile-time maintainer checks.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably useful to do that locally, as the CI still isn't happy :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is now happy, want me to squeeze all these commit into one or later on once you are happy about that?

@ximion
Copy link
Owner

ximion commented Jun 16, 2017

Looks good to me! Can you maybe fold in the two return-fix commits, and prefix the changes with "qt"?

I am not really happy about exposing the raw GObjects in the Qt bindings in a public interface, but we can find a solution for that after merge, if there is one.

Copy link
Collaborator

@aleixpol aleixpol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general. Just nitpicking.


AppStream::ContentRating::RatingValue AppStream::ContentRating::stringToRatingValue(const QString& ratingValue)
{
if (ratingValue == QLatin1String("none")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a hash here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed to use hash even here.

AsContentRating* m_contentRating;
};

typedef QHash<ContentRating::RatingValue, QString> RatingMap;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A vector should be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this would make any difference, QHash is used accross appstream same way so I used it here as well.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the overhead of a QHash? Would using a vector be much better? If not, keeping the QHash is fine, I guess.

#include "appstream.h"
#include "launchable.h"

#include <QDebug>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include possibly not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking back, it's needed.

Also implement missing classes like AS::Launchable, AS:Translation or
AS:ContentRating.
@ximion ximion merged commit 548a5ae into ximion:master Jun 19, 2017
@ximion
Copy link
Owner

ximion commented Jun 19, 2017

Okay, merged - it's one massive commit now, maybe breaking this down would have been nicer, but well, too late...

Thank you for your patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants