55#include " view/EditorWidget.h"
66#include " viewmodel/SharedDataVM.h"
77
8+ namespace mvvm {
89/* *
910 * @brief ContainerWindow wires up the MVVM triad:
1011 * Key differences from MVC's ContainerWindow:
1112 * 1. No Controller is created.
1213 * 2. No manual addObserver() calls, each View self-registers with the ViewModel during construction.
13- * 3. Views receive a shared_ptr<SharedDataViewModel >, never a Model pointer.
14+ * 3. Views receive a shared_ptr<SharedDataVM >, never a Model pointer.
1415 */
1516class ContainerWindow : public Gtk ::Window {
1617 public:
@@ -35,7 +36,7 @@ class ContainerWindow : public Gtk::Window {
3536ContainerWindow::ContainerWindow ()
3637 : mainLayout_(Gtk::Orientation::VERTICAL),
3738 topRowLayout_ (Gtk::Orientation::HORIZONTAL) {
38- set_title (" MVC Integrated Demo" );
39+ set_title (" MVVM Integrated Demo" );
3940 set_default_size (600 , 400 );
4041
4142 // Step 1 – construct the Model.
@@ -51,10 +52,6 @@ ContainerWindow::ContainerWindow()
5152 displayViewRight_ = std::make_unique<DisplayWidget>(" ZONE 3: MONITOR B (Red)" ,
5253 " red" , viewModel_);
5354
54- dataModel_->addObserver (editorView_.get ());
55- dataModel_->addObserver (displayViewLeft_.get ());
56- dataModel_->addObserver (displayViewRight_.get ());
57-
5855 // Layout, unchanged from MVC
5956 displayViewLeft_->set_hexpand (true );
6057 displayViewRight_->set_hexpand (true );
@@ -66,8 +63,9 @@ ContainerWindow::ContainerWindow()
6663 mainLayout_.append (*editorView_);
6764 set_child (mainLayout_);
6865}
66+ } // namespace mvvm
6967
7068int main (int argc, char * argv[]) {
7169 auto app = Gtk::Application::create (" org.gtkmm.example.singlemvvm" );
72- return app->make_window_and_run <ContainerWindow>(argc, argv);
70+ return app->make_window_and_run <mvvm:: ContainerWindow>(argc, argv);
7371}
0 commit comments