Skip to content
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

File-like model #97

Open
mottosso opened this issue Aug 17, 2019 · 0 comments
Open

File-like model #97

mottosso opened this issue Aug 17, 2019 · 0 comments
Labels
enhancement New feature or request performance

Comments

@mottosso
Copy link
Owner

Goal

Reduce complexity, improve ease of maintenance.

Motivation

There are too many models involved at the moment. Models doing too specific things; like one for the app view, one for the Environment tab, one for the Packages tab. Even though environments are part of a Context, as are packages that are each responsible for generating each part of an environment. It's tricky to know where to change things, or where things break. There is some duplication in how data is retrieves.

Furthermore, it isn't clear how to asynchronise data retrieval. Many operations, such as resolving a context and searching for packages to fill in the version combobox of each package, takes time. At the moment, that operation is handled directly in the controller, the models being fed data when really it should be the one to go out into th world and fetch this data, providing the caller with some temporary "I'm working on it"-type data in the meantime.

Implementation

Create a new model, one that is akin to a file-system, with paths, treating folders and files differently. One can have data. The other files.

Why? Files are familiar and flexible. But slow. A FileLikeModel maintains the mental model of a filesystem with the performance of a in-memory datastore.

How?

alita = model.data("/projects/alita")
projects = model.ls("/projects")
model.ls("/projects", callback=on_ls)

# Recursive, projects is deferred
model.ls("/projects/alita/packages", on_ls)

alita.data(DisplayRole)

# dot-access
model.data("/projects/alita.name")

# role access
model.data("/projects/alita", DisplayRole)

# path for index
path = model.path("/projects/alita")
pkg = model.data(path, PackageRole)

Effectively an async QAbstractItemModel. How do others do it? There doesn't seem to be much about that online, or maybe I haven't been looking hard enough.

@mottosso mottosso added enhancement New feature or request performance labels Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance
Projects
None yet
Development

No branches or pull requests

1 participant