KNewStuff: Split up UI and business logic (and initial Qt Quick components)
ClosedPublic

Authored by leinir on Nov 4 2016, 11:14 AM.

Details

Reviewers
apol
whiting
mart
Group Reviewers
KNewStuff
Summary

This represents the work to split up the business logic and the user interface logic in KNewStuff. The results are the retention of the existing KNewStuff framework (binary compatible as per the Frameworks promise), and the creation of two new frameworks, KNewStuffCore and KNewStuffQuick, which are the business logic and the new (so far very basic) Qt Quick components respectively.

PS: i realise this is a Very Big Patch(TM), but it does represent a fair chunk of work. Apart from the Qt Quick components (which represent a fairly small part of the diff), i don't see how it could sensibly be split into smaller chunks than this.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
leinir updated this revision to Diff 7892.Nov 4 2016, 11:14 AM
leinir retitled this revision from to KNewStuff: Split up UI and business logic (and initial Qt Quick components).
leinir updated this object.
leinir edited the test plan for this revision. (Show Details)
leinir added a reviewer: KNewStuff.
leinir added a subscriber: KNewStuff.
apol added inline comments.Nov 4 2016, 12:02 PM
CMakeLists.txt
56

Won't KNewStuffQuick be a runtime dependency in the end?

src/CMakeLists.txt
40

Why isn't the downloadmanager core?

168

Is it really needed to leave QML optional?

src/downloadmanager.cpp
150

Why the change? Can't EntryPrivate keep a toEntry method?

src/qtquick/CMakeLists.txt
9

QML plugins are MODULE instead of SHARED.

leinir marked 2 inline comments as done.Nov 7 2016, 11:33 AM

No new diff yet...

CMakeLists.txt
56

It will... Though, this is pretty much just doing what Kirigami does as well, am i doing something wrong here?

src/CMakeLists.txt
40

DownloadManager is already an exported symbol in KNewStuff, and consequently i am rather worried about binary compatibility with this. The same is the issue with Entry, which is why i had to swap the logic for converting Entry and EntryInternal instances (though that one already has all the logic in EntryPrivate, which is a terrible name that we could sort, and probably should).

The prime option i see for this would be: Replace the namespace KNS3 with KNSCore in the Core library, rename KNS3::DownloadManager to KNSCore::DownloadManager, and create a new, straight forward reimplementation of KNSCore::DownloadManager called KNS3::DownloadManager, which would result in us still having that symbol exported from KNewStuff, while the functionality would end up in Core. The same (basic) situation as with Entry and EntryInternal (which should then, perhaps, become KNS3::Entry and KNSCore::Entry respectively). Thoughts?

168

Hmm... i guess it isn't really, no... i'll just make that un-optional, makes it a bit cleaner as well, which is always nice :)

src/qtquick/CMakeLists.txt
9

Ah, so they are :)

mart edited edge metadata.Nov 7 2016, 1:32 PM

awesome to see this!
i would need a bit more rationale oh how the architecture is and has been changed, but looking good

src/core/jobs/filecopyjob.h
31

i get that probably the problem of kio is depending from widgets, but is it wise to have such a big reimplementation here? (note, i'm probably ok with this, just want to see a rationale for it)

src/downloadmanager.cpp
150

+1 on that

leinir marked 2 inline comments as done.Nov 7 2016, 1:55 PM
leinir added inline comments.
src/core/jobs/filecopyjob.h
31

It's all terribly annoying, yes, and the rationale is, quite simply, to retain the job based method for copying and downloading things, while also not adding a dependency on kio... One option would be to move this into a separate framework of its own, but i'm also not sure that is the best idea in the world - possibly an option, mind, and to facilitate this it might be an idea to not export the symbols from this part of the work (so it could be moved out while retaining binary compatibility).

src/downloadmanager.cpp
150

See comment regarding DownloadManager in general... In principle that'd be lovely, but Entry is in KNewStuff, while EntryInternal is in Core...

mart added inline comments.Nov 7 2016, 2:08 PM
src/core/jobs/filecopyjob.h
31

do you see particular problems by publicly exposing just the kjobs, even if the actual implementation of the jobs would be those (not exported) subclasses?
not super-important to me tough, just trying to see what's the lest footprint solution

src/downloadmanager.cpp
150

ok

leinir added inline comments.Nov 7 2016, 2:10 PM
src/core/jobs/filecopyjob.h
31

No, that does seem likely to be the most straightforward option - i'll fiddle it a bit and unexport these ones, for potential future ripping-out-and-frameworkifying, in case we decide to do that at some point :)

leinir updated this revision to Diff 8039.Nov 9 2016, 3:40 PM
leinir edited edge metadata.

So, new things include in particular the bits discussed in comments (not quite exhaustive, but this covers the majority):

A new namespace, KNSCore, is used for all of Core
DownloadManager is deprecated, and a (slightly simplified) copy exists in Core
The jobs are unexported (no need to do that)
Qt Quick plugin is no longer a build-optional

apol added inline comments.Nov 11 2016, 1:17 PM
autotests/knewstuffauthortest.cpp
42

Is this change really necessary? The API should be backwards compatible.

src/core/installation_p.h
98

const &?

Also in the ones below.

src/core/itemsmodel_p.h
55

const &

src/core/xmlloader.cpp
45

Why do we de-couple from KIO?

src/qtquick/itemsmodel.cpp
82

It's possibly a good opportunity to use initializer lists.

Also aren't standard Qt roles supported? i.e. Qt::DisplayRole...

199

This looks odd, maybe remove all empty?

230

why's the commented code?

332

I would emit after the ResetModel transaction, it's usually better that they're as atomic as possible.

338

Maybe it's an assert? Or a warning in the else branch? When is it going to fail?

leinir added inline comments.Nov 11 2016, 1:51 PM
autotests/knewstuffauthortest.cpp
42

Author was not previously exported, so there isn't a great deal of difference here... Not sure why this would be an issue? Anything in KNSCore was previously not exported, so the API was never publicly exposed...

src/core/installation_p.h
98

Good call, yup, i'll get that sorted

src/core/xmlloader.cpp
45

We decouple from KIO because it is a very large dependency (or, rather, tree of dependencies), and because depending on a tier 3 framework would push KNSCore into tier 3, which is explicitly what we are trying to avoid. We did discuss this in Randa, though i must confess that i do not remember if you were present when we talked about it...

src/qtquick/itemsmodel.cpp
82

Hmm, i guess that might make sense... i never did use those before, so i guess this is as good a time as any ;)

Personally i prefer to not expose the magic values, but that is a personal thing without any particularly good reasoning behind it, other than not being fond of making that kind of choice for the api user... i guess display and decoration are reasonably well defined in this case (as name and the first item in previewsSmall), i just was never fond of those. If this is a thing that is commonly done in frameworks, though, i'm not absolutely against it.

199

Hmm... yeah, i guess that would be the least-odd choice here, i'll do that

230

because the model is not fully completed yet...

332

i tend to view begin/end calls in models as parenthetic, and moving the engine change emit outside that logical parenthesis just feels... wrong to me...

338

It is really a "don't be silly, programmer" so yes, an assert would likely make more sense, i'll change it to that instead.

mart added inline comments.Nov 11 2016, 2:52 PM
src/attica/atticaprovider.cpp
319

if i understood correctly both qwidget and qml implementation implement a questionmanager that would render the dialog or whatever...

I wouldn't know how to do it differently, but would be possible to make this asyncronous in some way?

src/core/installation_p.h
110

const & here too

src/core/jobs/httpjob.cpp
85

what's the reason for this timer?

New patch under way, with the changes as discussed. Also, one minor reversion - QML plugins are /not/ modules, as it turns out (the plugin finder refuses to find them if you mark them as such, it really, really wants them to be called libsomething... which makes me think it should be fixed in Qt, but also means we have to retain the shared (or nothing) marker, as per the rest of our software)

src/attica/atticaprovider.cpp
319

i was racking my brains to try and come up with other ways of doing it and just couldn't figure anything out... Making it asynchronous would be lovely, i just don't see how to do so... which, obviously, sucks, but... yeah.

src/core/installation_p.h
98

Ah, as it turns out, no, these are not const. The documentation is, however, not correct, so i will fix that.

110

Normally yes... but, i looked through these, and the problem turns out to be that in most of these, you basically /want/ the entry to change (uninstalling or installing changes the status of the entry to either Deleted or Installed, respectively).

src/core/jobs/httpjob.cpp
85

It intends to postpones the job starting until after the calling function has it in hand again... In reality, i guess it's not really needed, though, i'll just remove that :)

leinir updated this revision to Diff 8135.Nov 14 2016, 1:54 PM

Changes as discussed (also includes download link information, as apol suggested through asking about code being commented out).

apol accepted this revision.Nov 15 2016, 4:35 PM
apol edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 15 2016, 4:35 PM
leinir closed this revision.Nov 16 2016, 1:14 PM

This revision is closed as the work was committed and pushed to the master branch.

Commit in master: http://commits.kde.org/knewstuff/29e1276039878c52fa331862deb259c75908ab5c

shumski added inline comments.
CMakeLists.txt
122

Are these two necessary to install? AFAICS the new targets don't install any headers.