Skip to content

Commit

Permalink
Refs #5421 Updated interface to respond to change dir notifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Oct 8, 2013
1 parent 970de4c commit 4206273
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "MantidQtAPI/UserSubWindow.h"
#include "MantidQtCustomInterfaces/IndirectBayesTab.h"

#include <Poco/NObserver.h>
#include "MantidKernel/ConfigService.h"

namespace MantidQt
{
namespace CustomInterfaces
Expand Down Expand Up @@ -76,12 +79,17 @@ namespace MantidQt
void showMessageBox(const QString& message);

private:
/// Called upon a close event.
virtual void closeEvent(QCloseEvent*);
/// handle POCO event
void handleDirectoryChange(Mantid::Kernel::ConfigValChangeNotification_ptr pNf);
/// Load default interface settings for each tab
void loadSettings();

/// Map of tabs indexed by position on the window
std::map<unsigned int, IndirectBayesTab*> m_bayesTabs;

/// Change Observer for ConfigService (monitors user directories)
Poco::NObserver<IndirectBayes, Mantid::Kernel::ConfigValChangeNotification> m_changeObserver;
///Main interface window
Ui::IndirectBayes m_uiForm;
};
Expand Down
29 changes: 26 additions & 3 deletions Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ namespace MantidQt

using namespace MantidQt::CustomInterfaces;

IndirectBayes::IndirectBayes(QWidget *parent) : UserSubWindow(parent)
IndirectBayes::IndirectBayes(QWidget *parent) : UserSubWindow(parent),
m_changeObserver(*this, &IndirectBayes::handleDirectoryChange)
{
m_uiForm.setupUi(this);

// Connect Poco Notification Observer
Mantid::Kernel::ConfigService::Instance().addObserver(m_changeObserver);

//insert each tab into the interface on creation
m_bayesTabs.insert(std::make_pair(RES_NORM, new ResNorm(m_uiForm.indirectBayesTabs->widget(RES_NORM))));
m_bayesTabs.insert(std::make_pair(QUASI, new Quasi(m_uiForm.indirectBayesTabs->widget(QUASI))));
Expand All @@ -44,14 +48,33 @@ IndirectBayes::IndirectBayes(QWidget *parent) : UserSubWindow(parent)
connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(runClicked()));
connect(m_uiForm.pbHelp, SIGNAL(clicked()), this, SLOT(helpClicked()));
connect(m_uiForm.pbManageDirs, SIGNAL(clicked()), this, SLOT(manageUserDirectories()));


}

void IndirectBayes::initLayout()
{
}

/**
* @param :: the detected close event
*/
void IndirectBayes::closeEvent(QCloseEvent*)
{
Mantid::Kernel::ConfigService::Instance().removeObserver(m_changeObserver);
}

/**
* Handles a change in directory.
*
* @param pNf :: notification
*/
void IndirectBayes::handleDirectoryChange(Mantid::Kernel::ConfigValChangeNotification_ptr pNf)
{
std::string key = pNf->key();

if ( key == "defaultsave.directory" )
loadSettings();
}

/**
* Load the setting for each tab on the interface.
*
Expand Down

0 comments on commit 4206273

Please sign in to comment.