The program model class was keeping a list of any errors detected when lines are translated. After a group of line changes were processed, if the list of errors changed, the entire error list was sent to the edit box via a signal. The edit box stored this list of errors and used it to generate its extra selection list, which is used to highlight the errors. Since the edit box now has access to the program model, it was no longer necessary for the edit box to keep a copy of this list.
So that the edit box can keep its extra selection list up to date, the program model was modified to send signals for when an error item has been inserted, changed, or removed. The connected edit box slots will update the extra selection list accordingly. When the program model is done updating the error list, it send a signal that the error list has changed. The connected edit box slot sets the extra selections to the base QPlainTextEdit class from updated extra selection list. The edit box no longer scans through the error list to generate its extra selection list.
The functionality for finding the next or previous error from the current cursor location was moved from the edit box class to the program model class. The current line number and column are passed to these routines, which are set to the next error line number and column upon returning along with a flag of whether the end or beginning of the program was passed so that a message can be issued.
A new routine was added to the program model class to handle when the current line is edited and contains an error. The error is shifted if the edit takes place before the error, or deleted if the edit takes place within the error. If the error list changes, the appropriate signals are sent to the edit box. This routine was not made a slot since the edit box can call it directly.
During the initial loading of the program, the text cursor in the edit box is not valid. Any errors in the program are sent as inserted error signals. Since the text cursor is not valid, the extra selections cannot be created (each extra selection contains a format and a cursor, which needs to be set to a valid cursor). The errors are temporarily saved in a list. After the text cursor becomes valid, extra selections are created from this list (which is then cleared).
The error list class used by the program model to hold the list of errors previously kept track of the first and last index affected by changes to the list. These indexes were used by the edit box to maintain its extra selection list. With the new direct change signals, these indexes are no longer needed, so the error list was changed to having a simple changed flag. The error list changed signal is only sent when this flag is set. The has changed access function was modified to clear this flag after it is read so a separate reset function is not needed.
Finally, the main window class status bar update slot was modified to receive the error message by an argument in the signal instead of it retrieving the message for the current line from the edit box, which retrieved the message from its copy of the error list. The routine sending this signal in the edit box class was modified to send the error message, which is retrieved from the program model via its list of errors.
[commit 19c5f06d0c]
Subscribe to:
Post Comments (Atom)
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.)