diff --git a/README.md b/README.md index 84a24c12fc4af3b0758e6d01d5460a4d7b550a39..f2b016017ae3a7f72d6e726e9d0aaa36f823224f 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,44 @@ The Course is about programming concepts rather than a specific language. ## Changes +### Worksheet 4 +**PanelCommandTypes** + - When using Qt, no `ActionListener`s have to be used to register the click of a button. Rather a callback function `slot` is `connect`ed to an event `signal` of the button. + So `setController()` doesn't instanciate any Listeners, but `connect`s the appropriate `slot`s to the button `signal`s. + - In Qt lists can be displayed either by a simplified `QListWidget`, or via a Model/View structure. + - `QListWidget` can only hold `QListWidgetItems`, + - Model/View can represent any data because the `QAbstractItemModel` is implemented by the user. + - For the `commandTypeList` the widget was chosen. + - Because of that the subclass `ComTypeListWidgetItem` had to be created to allow the Item to remember its `CommandType`. + +**PanelCommandConfig** + - For the Panels a `QStackedWidget`, comparable to `CardLayout` is used. + - The constants for switching between panels were moved into an `enum`. Enums are implicid integers, while `enum class`es have their own type. + - The config panels are passed a pointer to the `ControlUI` and remember it to later call `updateTableView()` directly. + This could be changed to the signals&slots mentality of Qt. + The panels would not have to know the `ControlUI` and would just emit a `signal` to initiate the update. + The connection would happed in `ControlUI.setController()`, just like with the other panels. + +**PanelCommandTable** + - `TableCommandModel` + - In Qt a change in the model is communicated by the model. + It signals `dataChanged()` for each changed cell or `layoutChanged()` if row or column counts were changed. + - Because of this the method `onChange()` was added to the model to be called by the panel. + - The `data()` method does not only define the text, but also other properties of each cell. + These should be considered when overriding the function. An empty `QVariant()` means invalid. + - `PanelCommandTable` + - The `ListSelectionListener` has again been substituted with an appropriate callback function/`slot`. + - Because `ControlUI` should be the central starting point for table updates, the buttons emit the signal `pleaseUpdateTable()` which is connected to the `ControlUI`. + - Using regular function calls this resulted in a recursive include loop where `ControlUI` and `PanelCommandTable` depended on each other. + With signals and slots neither the sender nor the receiver need to know each other, just the one who connects them does. + - This would have been completely avoidable if `updateTable()` was called directly inside the panel, but well it works. + +**ControlUI** + - `updateTableView()` and `updateConfigView()` are declared as slots such that the signals of the panels can be connected to it. + - `QActions`, needed for the `QMenubar`, are not taken ownership of by the `QMenu`s they are assigned to. + Because of this they need to be cleaned up manually. They also get `triggered()` rather then `clicked()`. + + ### Worksheet 3 **Background** - Many files were added so that all excercises could be solved, enough funtionality was introduced to allow some level of simulation.