14#include <Poco/AutoPtr.h>
15#include <Poco/NObserver.h>
16#include <Poco/Notification.h>
17#include <Poco/NotificationCenter.h>
27#include <QStyledItemDelegate>
35QStringList headerLabels = {
"Workspace Name",
"Ws Index"};
45namespace MantidWidgets {
68 this->setColumnCount(headerLabels.size());
69 this->verticalHeader()->setVisible(
false);
70 this->horizontalHeader()->setVisible(
true);
71 this->setHorizontalHeaderLabels(headerLabels);
73 this->setSelectionMode(QAbstractItemView::ExtendedSelection);
74 this->setSortingEnabled(
true);
75 this->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
81 Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(
m_addObserver);
82 Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(
m_remObserver);
83 Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(
m_clearObserver);
84 Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(
m_renameObserver);
85 Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(
m_replaceObserver);
101 const QTableWidgetItem *item = currentItem();
102 return (item !=
nullptr);
113 insertRow(rowCount());
114 auto nameItem = std::make_unique<QTableWidgetItem>(QString::fromStdString(
name));
115 auto indexItem = std::make_unique<QTableWidgetItem>(QString::fromStdString(
getIndexString(
name)));
117 nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
119 setItem(rowCount() - 1,
namesCol, nameItem.release());
120 setItem(rowCount() - 1,
indexCol, indexItem.release());
125 this->item(row,
namesCol)->setText(QString::fromStdString(newName));
130 for (
auto const &
name : names) {
138 auto selRows = selectionModel()->selectedRows();
140 nameIndexPairVec.reserve(
static_cast<std::size_t
>(selRows.size()));
141 for (
auto const &
index : selRows) {
142 std::string txt = item(
index.row(),
namesCol)->text().toStdString();
144 std::string idx = item(
index.row(),
indexCol)->text().toStdString();
145 nameIndexPairVec.push_back(std::make_pair(txt, idx));
148 nameIndexPairVec.shrink_to_fit();
149 return nameIndexPairVec;
153 auto selIndex = this->selectedIndexes();
154 if (!selIndex.isEmpty()) {
155 for (
auto &
index : selIndex) {
156 std::string selName = this->item(
index.row(),
namesCol)->text().toStdString();
163 auto selIndex = this->selectedIndexes();
164 if (!selIndex.isEmpty()) {
165 auto rangeFirst = this->item(selIndex.takeFirst().row(),
indexCol)->text();
166 for (
auto &
index : selIndex) {
173 const std::lock_guard<std::mutex> lock(
m_adsMutex);
180 const std::lock_guard<std::mutex> lock(
m_adsMutex);
181 QString
name = QString::fromStdString(pNf->objectName());
182 auto items = findItems(
name, Qt::MatchExactly);
183 if (!items.isEmpty()) {
184 for (
auto &item : items)
185 removeRow(item->row());
187 if (rowCount() == 0) {
193 const std::lock_guard<std::mutex> lock(
m_adsMutex);
194 this->clearContents();
195 while (rowCount() > 0) {
202 const std::lock_guard<std::mutex> lock(
m_adsMutex);
204 QString newName = QString::fromStdString(pNf->newObjectName());
205 QString currName = QString::fromStdString(pNf->objectName());
208 auto currItems = findItems(currName, Qt::MatchExactly);
209 auto newItems = findItems(newName, Qt::MatchExactly);
212 if (!currItems.isEmpty() && newItems.isEmpty())
213 renameItem(pNf->newObjectName(), currItems.first()->row());
214 else if (currItems.isEmpty() && newItems.isEmpty())
216 else if (!currItems.isEmpty() && !newItems.isEmpty()) {
218 removeRow(currItems.first()->row());
219 renameItem(pNf->newObjectName(), newItems.first()->row());
222 if (!currItems.isEmpty())
223 removeRow(currItems.first()->row());
228 const std::lock_guard<std::mutex> lock(
m_adsMutex);
229 QString
name = QString::fromStdString(pNf->objectName());
231 auto items = findItems(
name, Qt::MatchExactly);
233 if ((eligible && !items.isEmpty()) || (!eligible && items.isEmpty()))
235 else if (items.isEmpty() && eligible) {
238 removeRow(items.first()->row());
243 auto const workspace = Mantid::API::AnalysisDataService::Instance().retrieve(
name);
252 if (
name.find_last_of(
"_") <
name.size())
253 return m_suffix.contains(QString::fromStdString(
name.substr(
name.find_last_of(
"_"))));
258 const std::lock_guard<std::mutex> lock(
m_adsMutex);
259 this->clearContents();
260 auto const items = Mantid::API::AnalysisDataService::Instance().getObjectNames();
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
std::vector< std::pair< std::string, std::string > > StringPairVec
The Analysis data service stores instances of the Workspace objects and anything that derives from te...
Poco::NotificationCenter notificationCenter
Sends notifications to observers.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::AfterReplaceNotification > & WorkspaceAfterReplaceNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::ClearNotification > & ClearADSNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::RenameNotification > & WorkspaceRenameNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::AddNotification > & WorkspaceAddNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::PostDeleteNotification > & WorkspacePostDeleteNotification_ptr