| 22 | /** Returns a Model that constructs a Module and ModuleWidget subclass. */ |
| 23 | template <class TModule, class TModuleWidget> |
| 24 | plugin::Model* createModel(std::string slug) { |
| 25 | struct TModel : plugin::Model { |
| 26 | engine::Module* createModule() override { |
| 27 | engine::Module* m = new TModule; |
| 28 | m->model = this; |
| 29 | return m; |
| 30 | } |
| 31 | app::ModuleWidget* createModuleWidget(engine::Module* m) override { |
| 32 | TModule* tm = NULL; |
| 33 | if (m) { |
| 34 | assert(m->model == this); |
| 35 | tm = dynamic_cast<TModule*>(m); |
| 36 | } |
| 37 | app::ModuleWidget* mw = new TModuleWidget(tm); |
| 38 | assert(mw->module == m); |
| 39 | mw->setModel(this); |
| 40 | return mw; |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | plugin::Model* o = new TModel; |
| 45 | o->slug = slug; |
| 46 | return o; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | /** Creates a Widget subclass with its top-left at a position. */ |
nothing calls this directly
no outgoing calls
no test coverage detected