[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: renaming some classes and using the octave namespace in the GUI
From: |
Daniel J Sebald |
Subject: |
Re: renaming some classes and using the octave namespace in the GUI |
Date: |
Thu, 8 Feb 2018 12:30:57 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 02/08/2018 11:49 AM, John W. Eaton wrote:
On 02/08/2018 12:43 PM, Daniel J Sebald wrote:
In a changeset I'm creating, the object name is important because for
the variable editor the object name matches exactly the Octave space
variable name, so that when one tries to open the variable in the
editor more than once it checks all the object names in the space to
see it isn't already open.
You lost me there. Exactly how are Qt Object names relevant for opening
a variable in the variable editor?
Below is the code hunk that I changed. If we want to get away from the
tabbed interface (i.e., only one variable visible at a time), then we
can't use a pointer m_tab_widget because that only works for QTabWidget.
The variable name was being stored in the tab widget name. The Qt
signal/slot framework allows being less specific about exactly what the
type of objects are and more simply passing data around however the
objects are arrange. (That provides flexibility because one isn't tied
into the exact arrangement.)
So, we have to store this variable name somewhere else. How about the
typically unused object name? Then we can use the Qt-provided
convenient ways of finding objects. The findChild() is nice in that it
will keep searching the whole parent/child chain. In other words, we
don't need to have some pointer and indirection to get the info we want,
just that there is some object out there by name "name". It could be a
QDockWidget, something we derive from QDockWidget (provided we don't
override the meta-type). If the overall design is changed, just change
QDockWidget to something else, and then one isn't constrained by the
whole m_tab_widget pointer approach. The other *really* nice thing
about the findChild template is that it returns a pointer of the proper
class and we can avoid that not-recommended dynamic_cast.
Dan
void
variable_editor::edit_variable (const QString& name, const
octave_value& val)
{
if (m_stylesheet.isEmpty ())
{
QSettings *settings = resource_manager::get_settings ();
notice_settings (settings);
}
- const int tab_count = m_tab_widget->count ();
- for (int i = 0; i < tab_count; ++i)
+ QDockWidget *existing_qdw = m_main->findChild<QDockWidget *> (name);
+ if (existing_qdw != NULL)
{
- if (real_var_name (i) == name)
- {
- // Already open.
+ // Already open.
- m_tab_widget->setCurrentIndex (i);
- return;
- }
+// m_tab_widget->setCurrentIndex (i);
+ return;
}
// Do not set parent.
Re: renaming some classes and using the octave namespace in the GUI, Torsten, 2018/02/08