Friday, October 11, 2013

Program – Unit Vs. Model

The original plan was for program unit class to contain the code and dictionaries for a single unit (main routine, subroutine, or function) and the program model to contain all the program units.  The program model class contained the functions for manipulating the program (inserting, replacing and removing lines), which needed to be moved to the program unit class.  However, these functions are triggered by signals from the edit box, and also generate signals for updating the program view dock widget.  The program model class still needs to be connected to receive and generate these signals.

Eventually when subroutines and functions are implemented, additional edit box windows can be created for each program unit opened.  Each edit box opened will be connected to a program unit.  This implies that the program model should only contain a single program unit that will be connected to an edit box when opened for editing, and there will be a program model for each program unit.  Something else will need to contain a list of all the program units.

Currently, the main window class contains the edit box and program model instances.  It is logical that when subroutines and functions are implemented, the main window will contain the list of program units, which are really program unit models.  As each program unit is opened for editing, the main window will create an additional edit box window.

Therefore, the program unit class members were merged into the program model class.  While doing this, all the member variables were placed at the end of the class definition to follow the same style that Qt uses.  This was also done with the program word class.  The other classes that don't currently follow this convention will be modified at some future point.

The constructor of the program model class was modified to get the table instance directly instead of being passed the table instance as an argument.  The table instance is then used to create the translator instance before proceeding to create the dictionaries.  Eventually the constructor will need to be aware if a subroutine or function program unit is being created and get the translator instance along with pointers to the global dictionaries (like the constant and remark dictionaries) from the main routine program unit.

[commit f3b76d057c]