Skip to content

Commit

Permalink
Add method to get selected session from meta-data. Refs #9112.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Mar 10, 2014
1 parent fa50a4f commit 9f7b2d3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Expand Up @@ -15,6 +15,8 @@ namespace MantidQt
public:
/// Default constructor
CatalogSelector(QWidget *parent = 0);
/// Obtain the session information for the facilities selected.
std::vector<std::string> getSelectedCatalogSessions();

private:
/// Initialise the layout
Expand Down
23 changes: 23 additions & 0 deletions Code/Mantid/MantidQt/MantidWidgets/src/CatalogSelector.cpp
@@ -1,4 +1,5 @@
#include "MantidQtMantidWidgets/CatalogSelector.h"
#include "MantidAPI/CatalogManager.h"

#include <QDesktopWidget>
#include <QListWidgetItem>
Expand All @@ -7,11 +8,33 @@ namespace MantidQt
{
namespace MantidWidgets
{
/**
* Constructor
*/
CatalogSelector::CatalogSelector(QWidget* parent) : QWidget(parent), m_uiForm()
{
initLayout();
}

/**
* Obtain the session information for the facilities selected.
* @return A vector holding the sessions ids of the selected facilities to search.
*/
std::vector<std::string> CatalogSelector::getSelectedCatalogSessions()
{
QModelIndexList indexes = m_uiForm.selectedCatalogs->selectionModel()->selectedRows();

std::vector<std::string> selectedSessions;
for (int i = 0; i < indexes.count(); ++i)
{
selectedSessions.push_back(m_uiForm.selectedCatalogs->item(i)->data(Qt::UserRole).toString().toStdString());
}
return selectedSessions;
}

/**
* Initialise the default layout.
*/
void CatalogSelector::initLayout()
{
m_uiForm.setupUi(this);
Expand Down

0 comments on commit 9f7b2d3

Please sign in to comment.