MCPcopy Create free account
hub / github.com/MITK/MITK / Run

Method Run

Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.cpp:204–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204void QmitkFileSaveAction::Run()
205{
206 // get the list of selected base data objects
207 mitk::DataNodeSelection::ConstPointer selection = d->m_Window.Lock()->GetSelectionService()->GetSelection().Cast<const mitk::DataNodeSelection>();
208 if (selection.IsNull() || selection->IsEmpty())
209 {
210 MITK_ERROR << "Assertion failed: data node selection is nullptr or empty";
211 return;
212 }
213
214 std::list<mitk::DataNode::Pointer> dataNodes = selection->GetSelectedDataNodes();
215
216 std::vector<const mitk::BaseData*> data;
217 QStringList names;
218 for (std::list<mitk::DataNode::Pointer>::const_iterator nodeIter = dataNodes.begin(), nodeIterEnd = dataNodes.end(); nodeIter != nodeIterEnd; ++nodeIter)
219 {
220 data.push_back((*nodeIter)->GetData());
221 std::string name;
222 (*nodeIter)->GetStringProperty("name", name);
223 names.push_back(QString::fromStdString(name));
224 }
225
226 QString path;
227
228 if (1 == data.size())
229 {
230 if (nullptr != data[0])
231 {
232 auto pathProperty = data[0]->GetConstProperty("path");
233
234 if (pathProperty.IsNotNull())
235 path = QFileInfo(QString::fromStdString(pathProperty->GetValueAsString())).canonicalPath();
236 }
237
238 if (path.isEmpty())
239 path = GetParentPath(dataNodes.front());
240 }
241
242 if (path.isEmpty())
243 path = d->GetLastFileSavePath();
244
245 try
246 {
247 auto setPathProperty = true;
248 auto fileNames = QmitkIOUtil::Save(data, names, path, qobject_cast<QWidget*>(d->m_Action->parent()), setPathProperty);
249
250 if (!fileNames.empty())
251 d->SetLastFileSavePath(QFileInfo(fileNames.back()).absolutePath());
252 }
253 catch (const mitk::Exception& e)
254 {
255 MITK_INFO << e;
256 return;
257 }
258}

Callers

nothing calls this directly

Calls 15

GetParentPathFunction · 0.85
GetSelectedDataNodesMethod · 0.80
IsNotNullMethod · 0.80
frontMethod · 0.80
GetLastFileSavePathMethod · 0.80
SetLastFileSavePathMethod · 0.80
backMethod · 0.80
GetSelectionMethod · 0.45
GetSelectionServiceMethod · 0.45
LockMethod · 0.45
IsNullMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected