Skip to content

Commit 44bf515

Browse files
committed
Refactor
1 parent 3d5a74f commit 44bf515

106 files changed

Lines changed: 2065 additions & 2880 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"name": "(gdb) Launch",
66
"type": "cppdbg",
77
"request": "launch",
8-
// "program": "${workspaceFolder}/build/debug/bin/cpp_lab_project", // path to the executable
9-
"program": "${workspaceFolder}/build/debug/bin/mvc_ap", // path to the executable
8+
"program": "${workspaceFolder}/build/debug/bin/cpp_lab_project", // path to the executable
9+
// "program": "${workspaceFolder}/build/debug/bin/mvc_ap", // path to the executable
1010
"args": [],
1111
"stopAtEntry": true,
1212
"cwd": "${workspaceFolder}", // working directory

src/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ add_subdirectory(core)
77
add_subdirectory(controller)
88
add_subdirectory(dp)
99
add_subdirectory(socket)
10-
add_subdirectory(exercise)
1110
add_subdirectory(ap)
1211

1312
# main application executable does NOT link to this library.
@@ -26,7 +25,6 @@ add_executable(${PROJECT_NAME}
2625
${SOCKET_SOURCES}
2726
${CONTROLLER_SOURCES}
2827
${DP_SOURCES}
29-
${EXCERCISE_SOURCES}
3028
)
3129

3230
# Add header include paths
@@ -37,10 +35,4 @@ target_include_directories(${PROJECT_NAME}
3735
# Optional: add project-specific compiler options
3836
target_compile_options(${PROJECT_NAME}
3937
PRIVATE -Wall -Wextra -Wpedantic
40-
)
41-
42-
target_link_libraries(${PROJECT_NAME}
43-
PRIVATE
44-
ex_account
45-
ex_student_manager
4638
)

src/ap/mvc/model/SharedData.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class SharedData {
1515
private:
1616
void notifyObservers();
1717

18-
private:
1918
std::string data_;
2019
std::vector<IObserver*> observers_;
2120
};

src/ap/mvc/view/DisplayWidget.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class DisplayWidget : public Gtk::Box, public IObserver {
1111
private:
1212
void updateLabel(const std::string& text);
1313

14-
private:
1514
std::string color_;
1615
Gtk::Frame frame_;
1716
Gtk::Box innerBox_;

src/ap/simple_ap.cpp

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,94 +6,94 @@
66
class MainWindow : public Gtk::Window {
77

88
// --- Layout Containers ---
9-
Gtk::Box m_mainLayout;
10-
Gtk::Box m_topRowLayout;
9+
Gtk::Box m_mainLayout_;
10+
Gtk::Box m_topRowLayout_;
1111

1212
// --- Widgets ---
1313
// We must declare everything here so that the buttons are accessible
1414

1515
// Editor
16-
Gtk::Frame frame_Editor;
17-
Gtk::Box m_boxEditor;
18-
Gtk::Entry entry_Input;
19-
Gtk::Button button_Update;
16+
Gtk::Frame frame_Editor_;
17+
Gtk::Box m_boxEditor_;
18+
Gtk::Entry entry_Input_;
19+
Gtk::Button button_Update_;
2020

2121
// Monitor A
22-
Gtk::Frame frame_MonitorA;
23-
Gtk::Box m_boxMonitorA;
24-
Gtk::Label m_labelMonitorA;
22+
Gtk::Frame frame_MonitorA_;
23+
Gtk::Box m_boxMonitorA_;
24+
Gtk::Label m_labelMonitorA_;
2525

2626
// Monitor B
27-
Gtk::Frame frame_MonitorB;
28-
Gtk::Box m_boxMonitorB;
29-
Gtk::Label m_labelMonitorB;
27+
Gtk::Frame frame_MonitorB_;
28+
Gtk::Box m_boxMonitorB_;
29+
Gtk::Label m_labelMonitorB_;
3030

3131
public:
3232
MainWindow()
33-
: m_mainLayout(Gtk::Orientation::VERTICAL),
34-
m_topRowLayout(Gtk::Orientation::HORIZONTAL),
35-
m_boxEditor(Gtk::Orientation::VERTICAL),
36-
m_boxMonitorA(Gtk::Orientation::VERTICAL),
37-
m_boxMonitorB(Gtk::Orientation::VERTICAL) {
33+
: m_mainLayout_(Gtk::Orientation::VERTICAL),
34+
m_topRowLayout_(Gtk::Orientation::HORIZONTAL),
35+
m_boxEditor_(Gtk::Orientation::VERTICAL),
36+
m_boxMonitorA_(Gtk::Orientation::VERTICAL),
37+
m_boxMonitorB_(Gtk::Orientation::VERTICAL) {
3838
set_title("No-MVC (Coupled) Demo");
3939
set_default_size(600, 400);
4040

4141
// 1. SETUP UI (Visually identical to MVC)
4242
// --- Monitor A ---
43-
frame_MonitorA.set_label("ZONE 2: MONITOR A (Blue)");
44-
m_labelMonitorA.set_markup(
43+
frame_MonitorA_.set_label("ZONE 2: MONITOR A (Blue)");
44+
m_labelMonitorA_.set_markup(
4545
"<span foreground='blue' size='x-large'>Initial Data</span>");
46-
m_boxMonitorA.append(m_labelMonitorA);
47-
frame_MonitorA.set_child(m_boxMonitorA);
48-
frame_MonitorA.set_hexpand(true); // Stretch
46+
m_boxMonitorA_.append(m_labelMonitorA_);
47+
frame_MonitorA_.set_child(m_boxMonitorA_);
48+
frame_MonitorA_.set_hexpand(true); // Stretch
4949

5050
// --- Monitor B ---
51-
frame_MonitorB.set_label("ZONE 3: MONITOR B (Red)");
52-
m_labelMonitorB.set_markup(
51+
frame_MonitorB_.set_label("ZONE 3: MONITOR B (Red)");
52+
m_labelMonitorB_.set_markup(
5353
"<span foreground='red' size='x-large'>Initial Data</span>");
54-
m_boxMonitorB.append(m_labelMonitorB);
55-
frame_MonitorB.set_child(m_boxMonitorB);
56-
frame_MonitorB.set_hexpand(true);
54+
m_boxMonitorB_.append(m_labelMonitorB_);
55+
frame_MonitorB_.set_child(m_boxMonitorB_);
56+
frame_MonitorB_.set_hexpand(true);
5757

5858
// --- Editor ---
59-
frame_Editor.set_label("ZONE 1: EDITOR");
60-
entry_Input.set_text("Initial Data");
61-
button_Update.set_label("Direct Update"); // Live updates
62-
m_boxEditor.append(entry_Input);
63-
m_boxEditor.append(button_Update);
64-
frame_Editor.set_child(m_boxEditor);
59+
frame_Editor_.set_label("ZONE 1: EDITOR");
60+
entry_Input_.set_text("Initial Data");
61+
button_Update_.set_label("Direct Update"); // Live updates
62+
m_boxEditor_.append(entry_Input_);
63+
m_boxEditor_.append(button_Update_);
64+
frame_Editor_.set_child(m_boxEditor_);
6565

6666
// --- Layout ---
67-
m_topRowLayout.append(frame_MonitorA);
68-
m_topRowLayout.append(frame_MonitorB);
69-
m_mainLayout.append(m_topRowLayout);
70-
m_mainLayout.append(frame_Editor);
67+
m_topRowLayout_.append(frame_MonitorA_);
68+
m_topRowLayout_.append(frame_MonitorB_);
69+
m_mainLayout_.append(m_topRowLayout_);
70+
m_mainLayout_.append(frame_Editor_);
7171

7272
// Margin for aesthetics
73-
m_boxEditor.set_margin(10);
74-
m_boxEditor.set_spacing(5);
75-
m_boxMonitorA.set_margin(20);
76-
m_boxMonitorB.set_margin(20);
77-
set_child(m_mainLayout);
73+
m_boxEditor_.set_margin(10);
74+
m_boxEditor_.set_spacing(5);
75+
m_boxMonitorA_.set_margin(20);
76+
m_boxMonitorB_.set_margin(20);
77+
set_child(m_mainLayout_);
7878

7979
// 2. LOGIC HANDLING
8080
// Here, the button must "know" exactly who m_labelMonitorA and m_labelMonitorB are.
8181
// It directly controls the other widgets.
8282
// (THE BAD PART)
83-
button_Update.signal_clicked().connect([this]() {
83+
button_Update_.signal_clicked().connect([this]() {
8484
// Step 1: Get data directly from UI (Entry)
85-
std::string text = entry_Input.get_text();
85+
std::string text = entry_Input_.get_text();
8686
// There may be processing logic here (Validating...)
8787
if (text.empty())
8888
return;
8989

9090
// Step 2: Update Monitor A (Hard-coded) directly
91-
m_labelMonitorA.set_markup("<span foreground='blue' size='x-large'>" +
92-
text + "</span>");
91+
m_labelMonitorA_.set_markup("<span foreground='blue' size='x-large'>" +
92+
text + "</span>");
9393

9494
// Step 3: Update Monitor B (Hard-coded) directly
95-
m_labelMonitorB.set_markup("<span foreground='red' size='x-large'>" +
96-
text + "</span>");
95+
m_labelMonitorB_.set_markup("<span foreground='red' size='x-large'>" +
96+
text + "</span>");
9797
std::cout << "Updated directly without Model!" << std::endl;
9898
});
9999
}

0 commit comments

Comments
 (0)