Skip to content

Commit

Permalink
Make population of list public. Refs #9112.
Browse files Browse the repository at this point in the history
- This allows it to be populated when the button is pressed, so if a user logs in while the search GUI is open then it will work as expected.
  • Loading branch information
jawrainey committed Mar 11, 2014
1 parent a77c0bf commit ff95730
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Expand Up @@ -17,12 +17,12 @@ namespace MantidQt
CatalogSelector(QWidget *parent = 0);
/// Obtain the session information for the facilities selected.
std::vector<std::string> getSelectedCatalogSessions();
/// Populate the ListWidget with the facilities of the catalogs the user is logged in to.
void populateFacilitySelection();

private:
/// Initialise the layout
virtual void initLayout();
/// Populate the ListWidget with the facilities of the catalogs the user is logged in to.
void populateTable();

protected:
/// The form generated by QT Designer.
Expand Down
34 changes: 23 additions & 11 deletions Code/Mantid/MantidQt/MantidWidgets/src/CatalogSelector.cpp
Expand Up @@ -32,6 +32,28 @@ namespace MantidQt
return selectedSessions;
}


/**
* Populate the ListWidget with the facilities of the catalogs the user is logged in to.
*/
void CatalogSelector::populateFacilitySelection()
{
auto session = Mantid::API::CatalogManager::Instance().getActiveSessions();

for (unsigned row = 0; row < session.size(); ++row)
{
// This prevents the same items being appended (again) to the list widget.
if (!m_uiForm.selectedCatalogs->item(row))
{
QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(session.at(row)->getFacility()));
// Set sessionID to user specific meta-data to easily obtain it later.
item->setData(Qt::UserRole,QVariant(QString::fromStdString(session.at(row)->getSessionId())));
item->setCheckState(Qt::Unchecked);
m_uiForm.selectedCatalogs->insertItem(row,item);
}
}
}

/**
* Initialise the default layout.
*/
Expand All @@ -45,19 +67,9 @@ namespace MantidQt
}

/**
* Populate the ListWidget with the facilities of the catalogs the user is logged in to.
*
*/
void CatalogSelector::populateTable()
{
auto session = Mantid::API::CatalogManager::Instance().getActiveSessions();

for (unsigned row = 0; row < session.size(); ++row)
{
QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(session.at(row)->getFacility()));
// Set sessionID to user specific meta-data to easily obtain it later.
item->setData(Qt::UserRole,QVariant(QString::fromStdString(session.at(row)->getSessionId())));
m_uiForm.selectedCatalogs->insertItem(row,item);
}
}

} // namespace MantidWidgets
Expand Down

0 comments on commit ff95730

Please sign in to comment.