![]() |
LeechCraft 0.6.70-19214-g121e5318a7
Modular cross-platform feature rich live environment.
|
Defers populating the model until a view first asks for rows. More...
#include "lazyrootmixin.h"
Public Member Functions | |
| template<typename... Args> | |
| LazyRootMixin (std::function< void()> load, Args &&... args) | |
| Constructs the model passing the arguments to the base constructor. | |
| bool | IsLoaded () const |
| Returns whether the model has been populated. | |
| void | EnsureLoaded () |
| Populates the model if it hasn't been populated yet. | |
| void | Reload () |
| Drops the rows and populates the model anew. | |
| bool | hasChildren (const QModelIndex &parent) const override |
| bool | canFetchMore (const QModelIndex &parent) const override |
| void | fetchMore (const QModelIndex &parent) override |
Defers populating the model until a view first asks for rows.
Derive from this class (or instantiate it directly), parametrizing the template by the desired base class like QStandardItemModel, and pass the function populating the model. The function is invoked when an attached view first asks the root for more rows, and on each Reload() after that, always on an empty root: the existing rows are removed first, so the base model must support removeRows() on the root.
Only views (and proxies in front of them) drive the loading: code reading the model directly sees it empty until then and should call EnsureLoaded() first.
| Model | The model type to derive from. |
Definition at line 37 of file lazyrootmixin.h.
|
inlineexplicit |
Constructs the model passing the arguments to the base constructor.
| [in] | load | The function populating the empty model. |
| [in] | args | The list of parameters to pass to the constructor of the base Model. |
Definition at line 50 of file lazyrootmixin.h.
References LC::Model.
|
inlineoverride |
Definition at line 85 of file lazyrootmixin.h.
|
inline |
Populates the model if it hasn't been populated yet.
Definition at line 65 of file lazyrootmixin.h.
References Reload().
|
inlineoverride |
Definition at line 90 of file lazyrootmixin.h.
References Reload().
|
inlineoverride |
Definition at line 80 of file lazyrootmixin.h.
|
inline |
Returns whether the model has been populated.
Definition at line 58 of file lazyrootmixin.h.
|
inline |
Drops the rows and populates the model anew.
Definition at line 73 of file lazyrootmixin.h.
Referenced by EnsureLoaded(), and fetchMore().