Skip to content

Commit

Permalink
Refs #8348. Use actual tab widget instead of numbers.
Browse files Browse the repository at this point in the history
This makes the code independent from the order of tabs.
  • Loading branch information
arturbekasov committed Nov 6, 2013
1 parent b96eb22 commit 0d954df
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
Expand Up @@ -339,8 +339,8 @@ private slots:
/// which pair table row has the user last clicked on
int m_pairTableRowInFocus;

/// Index of the current tab.
int m_tabNumber;
/// Widget of the current tab
QWidget* m_currentTab;

/// used to test that a new filename has been entered
QStringList m_previousFilenames;
Expand Down
Expand Up @@ -1332,7 +1332,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="DataAnalysis">
<attribute name="title">
<string>Data Analysis</string>
</attribute>
Expand Down Expand Up @@ -1391,7 +1391,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<widget class="QWidget" name="ResultsTable">
<attribute name="title">
<string>Results Table</string>
</attribute>
Expand Down Expand Up @@ -1659,7 +1659,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="PlotOptions">
<widget class="QWidget" name="Settings">
<attribute name="title">
<string>Settings</string>
</attribute>
Expand Down
35 changes: 19 additions & 16 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp
Expand Up @@ -80,10 +80,11 @@ const QString MuonAnalysis::NOT_AVAILABLE("N/A");
//----------------------
///Constructor
MuonAnalysis::MuonAnalysis(QWidget *parent) :
UserSubWindow(parent), m_last_dir(), m_workspace_name("MuonAnalysis"), m_currentDataName(),
m_groupTableRowInFocus(0), m_pairTableRowInFocus(0),m_tabNumber(0), m_groupNames(),
m_settingsGroup("CustomInterfaces/MuonAnalysis/"), m_updating(false), m_loaded(false),
m_deadTimesChanged(false), m_textToDisplay(""), m_dataTimeZero(0.0), m_dataFirstGoodData(0.0)
UserSubWindow(parent), m_last_dir(), m_workspace_name("MuonAnalysis"), m_currentDataName(),
m_groupTableRowInFocus(0), m_pairTableRowInFocus(0), m_currentTab(NULL),
m_groupNames(), m_settingsGroup("CustomInterfaces/MuonAnalysis/"),
m_updating(false), m_loaded(false), m_deadTimesChanged(false), m_textToDisplay(""), m_dataTimeZero(0.0),
m_dataFirstGoodData(0.0)
{}

/**
Expand Down Expand Up @@ -218,6 +219,8 @@ void MuonAnalysis::initLayout()

connect(m_uiForm.deadTimeType, SIGNAL(currentIndexChanged(int)), this, SLOT(changeDeadTimeType(int) ) );
connect(m_uiForm.mwRunDeadTimeFile, SIGNAL(fileFindingFinished()), this, SLOT(deadTimeFileSelected() ) );

m_currentTab = m_uiForm.tabWidget->currentWidget();
}

/**
Expand Down Expand Up @@ -3634,9 +3637,7 @@ void MuonAnalysis::getFullCode(int originalSize, QString & run)
*/
void MuonAnalysis::changeTab(int newTabNumber)
{
int oldTabNumber = m_tabNumber;

m_tabNumber = newTabNumber;
QWidget* newTab = m_uiForm.tabWidget->widget(newTabNumber);

// Make sure all toolbars are still not visible. May have brought them back to do a plot.
if (m_uiForm.hideToolbars->isChecked())
Expand All @@ -3645,7 +3646,7 @@ void MuonAnalysis::changeTab(int newTabNumber)
m_uiForm.fitBrowser->setStartX(m_uiForm.timeAxisStartAtInput->text().toDouble());
m_uiForm.fitBrowser->setEndX(m_uiForm.timeAxisFinishAtInput->text().toDouble());

if(oldTabNumber == 3) // Closing DA tab
if(m_currentTab == m_uiForm.DataAnalysis) // Leaving DA tab
{
// Say MantidPlot to use default fit prop. browser
emit setFitPropertyBrowser(NULL);
Expand All @@ -3658,7 +3659,7 @@ void MuonAnalysis::changeTab(int newTabNumber)
this, SLOT(showPlot(const QString&)));
}

if (newTabNumber == 3) // Opening DA tab
if(newTab == m_uiForm.DataAnalysis) // Entering DA tab
{
// Say MantidPlot to use Muon Analysis fit prop. browser
emit setFitPropertyBrowser(m_uiForm.fitBrowser);
Expand All @@ -3671,10 +3672,12 @@ void MuonAnalysis::changeTab(int newTabNumber)
connect(m_uiForm.fitBrowser, SIGNAL(workspaceNameChanged(const QString&)),
this, SLOT(showPlot(const QString&)), Qt::QueuedConnection);
}
else if(newTabNumber == 4) // Opening results table tab
else if(newTab == m_uiForm.ResultsTable)
{
m_resultTableTab->populateTables(m_uiForm.fitBrowser->getWorkspaceNames());
}

m_currentTab = newTab;
}

/**
Expand Down Expand Up @@ -3783,7 +3786,7 @@ void MuonAnalysis::loadWidgetValue(QWidget* target, const QVariant& defaultValue

void MuonAnalysis::changeHomeFunction()
{
if (m_tabNumber == 0)
if (m_currentTab == m_uiForm.Home)
{
m_uiForm.groupTablePlotChoice->setCurrentIndex(m_uiForm.frontPlotFuncs->currentIndex());
homeTabUpdatePlot();
Expand Down Expand Up @@ -3813,13 +3816,13 @@ void MuonAnalysis::secondPeriodSelectionChanged()

void MuonAnalysis::homeTabUpdatePlot()
{
if (isAutoUpdateEnabled() && m_tabNumber == 0 && m_loaded)
if (isAutoUpdateEnabled() && m_currentTab == m_uiForm.Home && m_loaded)
runFrontPlotButton();
}

void MuonAnalysis::groupTabUpdateGroup()
{
if (m_tabNumber == 1)
if (m_currentTab == m_uiForm.GroupingOptions)
{
if (m_uiForm.frontPlotFuncs->count() <= 1)
{
Expand All @@ -3835,13 +3838,13 @@ void MuonAnalysis::groupTabUpdateGroup()

void MuonAnalysis::groupTabUpdatePair()
{
if (isAutoUpdateEnabled() && m_tabNumber == 1 && m_loaded == true)
if (isAutoUpdateEnabled() && m_currentTab == m_uiForm.GroupingOptions && m_loaded == true)
runPairTablePlotButton();
}

void MuonAnalysis::settingsTabUpdatePlot()
{
if (isAutoUpdateEnabled() && m_tabNumber == 2 && m_loaded == true)
if (isAutoUpdateEnabled() && m_currentTab == m_uiForm.Settings && m_loaded == true)
runFrontPlotButton();
}

Expand Down Expand Up @@ -3886,7 +3889,7 @@ void MuonAnalysis::hideEvent(QHideEvent *e)
setToolbarsHidden(false);

// If closed while on DA tab, reassign fit property browser to default one
if(m_tabNumber == 3)
if(m_currentTab == m_uiForm.DataAnalysis)
emit setFitPropertyBrowser(NULL);

// Delete the peak picker tool because it is no longer needed.
Expand Down

0 comments on commit 0d954df

Please sign in to comment.