Sunday, December 29, 2013

Program – New Action

The next addition to the program class is to handle the New program action.  Previously, the clear function of the edit box was called.  This function is part of the QPlainTextEdit base class that the edit box class is derived from.  When this function was called, it generated a document changed signal, which the edit box processed and ended up clearing the program unit that was attached to the edit box.  However, the program class should have this responsibility since there may not be an attached edit box.

The new action routine in the main window class was modified to call the new clear function in the program class.  This new clear function calls a new clear function of the program unit member (a program model instance).  Eventually, all of the program units of the program (for subroutines and functions) will be deleted with only the program unit for the main routine being cleared.

The new program model class clear function clears the line information list, program code vector, error list and all of the dictionaries.  This required new clear functions be added to the dictionary and information dictionary classes.  A new clear function was also added to the abstract information class, which was implemented for the constant number and string information classes.  Finally, the clear function sends the new program cleared signal, which is connected to the edit box clear funtion.

The clear function was reimplemented in the edit box class.  This was necessary so that a flag could be set before calling the clear function of the QPlainTextEdit base class.  This flag indicates to the document changed slot of the edit box routine that the signal should be ignored as it didn't originate by editing the program.  The recreating line flag, that is used to ignore document changes when lines are replaced with their recreated text, was used for this purpose.  This flag was renamed to the more appropriate ignore change.

A minor problem was also corrected in the main window class.  Previously, before a program was saved, the main window instance called the capture modified line routine of the edit box to make sure that any changes made to the current line are saved.  This normally takes place when the cursor is moved from the line being changed.  This check also needs to take place before the check to see if the program should be saved before it is cleared by the new action.  This functionality was put into the new program capture edit changes routine since it is called from two different places.

[commit 8d6e5703c0]

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)