octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #7857] Replace dynamic casts of GUI/IDE ed


From: anonymous
Subject: [Octave-patch-tracker] [patch #7857] Replace dynamic casts of GUI/IDE editor with more slots/signals configuration
Date: Wed, 03 Oct 2012 10:42:40 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.6.24-1.fc14 Firefox/3.6.24

URL:
  <http://savannah.gnu.org/patch/?7857>

                 Summary: Replace dynamic casts of GUI/IDE editor with more
slots/signals configuration
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Wed 03 Oct 2012 10:42:40 AM UTC
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

Here is a patch that shuffles around the code associated with the GUI/IDE
editor.  It is meant to make the existing code more in line with the Qt
signal/slot, object-oriented paradigm.  For the most part, upward casts of
pointers are gone, replaced by signals and slots.

The most important movement of code is to put some of the file-save function
inside file editor where it has better access to all of the file names so it
can check for any conflicts.  For example, a file save can be initiated in the
file editor, thereby signaling the appropriate file editor tab.  The file
editor tab will do some of the work with message boxes and file dialogs, then
signal back to the editor that it should verify the name doesn't conflict with
any existing open file tab.  If there is no conflict, the file editor, in
turn, signals back to the file editor tab that a save should be completed. 
So, there is some ping-pong-like communication, but if one thinks about this
carefully it should make sense.

The manner in which the editor communicates with the file editor tabs (instead
of casting the lower level QObject pointer) is via a slot connection with all
the file editor tabs.  The editor passes the current active object, and if the
file_editor_tab in the slot matches the ID to its value of "this" the file
editor will process the action.  This is a fundamental difference in the use
of the pointer, i.e., ostensibly a ID tag.  As evidence that the pointer can
be used as an identifying tag in the Qt framework, consider this example Qt
gives:

 QMessageBox msgBox;
 QPushButton *connectButton = msgBox.addButton(tr("Connect"),
QMessageBox::ActionRole);
 QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);

 msgBox.exec();

 if (msgBox.clickedButton() == connectButton) {
     // connect
 } else if (msgBox.clickedButton() == abortButton) {
     // abort
 }

The above is very analogous to the Qt tab container class widget being used as
an identifier tag.  connectButton and abortButton are pointers, but used
simply as unique ID tags.

In the Qt signal/slot paradigm there is no need for lower hierarchy objects to
retain information about their parent or container.  Therefore, the pointer
_file_editor has been removed from file_editor_tab.  Instead, the file editor
sets up all the connections for the file_editor_tab.

I've changed all file and message dialogs to WindowModal or NonModal (except
the startup wizard).  This works better, in my opinion.  To do this means
making signal/slot connections on the fly, and even conditional connections of
a signal/slot.  (It's these sorts of techniques that obviate the need for
convoluted programming with state variables and return values.)  I know there
are going to be some rough edges to smooth out, but the framework is easily
modified to fix bugs.  I know how to fix these sorts of things, but I wanted
to pause before going forward so others can absorb these changes.  Sometimes
others see a creative way of doing things that simplifies code.  We'll open
any future bugs to the discussion list.  (E.g., one item I can think of is
that we need to come up with a way for Exit to convey the close signals to the
editor and file editor tabs.)

Always be diligent of memory leaks.  That is, if one creates a dialog box,
QFileDialog, etc. for which the pointer is stored, remember to delete it in
the destructor.  If the pointer isn't stored, be sure to set the widget
attribute to Qt::WA_DeleteOnClose, i.e.,

      msgBox->setAttribute (Qt::WA_DeleteOnClose);

The find feature is now NonModal so it is possible to edit the text inside the
file editor tab and leave the find dialog window open.  That's nice to have. 
One thing though: each file editor tab has its own find dialog which is
toggled visible/non-visible according to whether it is active.  I suppose the
natural thing is for there to be one find dialog for the whole editor, but
unfortunately I don't see a way to change the _edit_area of an existing
find_dialog.  The solution would be simply to delete the find dialog box upon
close--easy change.  However, it would be nice to keep search info (if only
the Qt find dialog were a bit more robust).  I've set up the find-dialog
behavior in a way that might seem peculiar at first, and it takes some getting
used to.  I'm curious about user feedback, as people might like it.  One thing
I like about the behavior is that find dialogs are reappearing in the same
location they were moved to previously.  I know I myself don't like in editors
when the find dialog keeps popping up in some location that blocks a good
portion of the screen.  It always seems like I spend so much time moving the
find dialog out of the way.

More to do after this patch, but it should be a good start for fixing bugs
(the patch already solves several bugs) and programming behavior as desired
without too much strain.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 03 Oct 2012 10:42:40 AM UTC  Name:
octave-gui_no_casts-2012oct03.patch  Size: 73kB   By: None

<http://savannah.gnu.org/patch/download.php?file_id=26686>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?7857>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]