Skip to content
Snippets Groups Projects
Commit 7b18e007 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

some direct access to OwningVector

parent 75eb5d07
No related branches found
No related tags found
1 merge request!2359Use same tree view with delegate for datafiles, samples, and instruments. Also move some code between GUI/View directories. Restore Py wrappers lost in previous MR.
......@@ -41,6 +41,7 @@ public:
void writeTo(QXmlStreamWriter* w) const;
void writeDatafiles(const QString& projectDir) const;
const OwningVector<DatafileItem>& dfileItems2() const { return m_dfile_items; }
QVector<DatafileItem*> dfileItems() const;
QStringList realItemNames() const;
int currentIndex() const { return m_current_index; }
......
......@@ -86,7 +86,7 @@ LinkInstrumentManager::LinkInstrumentManager(ProjectDocument* document)
&LinkInstrumentManager::onInstrumentChanged);
}
bool LinkInstrumentManager::canLinkDataToInstrument(const DatafileItem* dfile_item,
bool LinkInstrumentManager::canLinkDataToInstrument(const DatafileItem* dfi,
const QString& identifier,
QWidget* parent) const
{
......@@ -96,23 +96,23 @@ bool LinkInstrumentManager::canLinkDataToInstrument(const DatafileItem* dfile_it
if (!instrumentItem)
return true;
if (instrumentItem->axdims().size() != dfile_item->axdims().size()) {
if (instrumentItem->axdims().size() != dfi->axdims().size()) {
::warn(parent, "Cannot link, data is incompatible with the instrument.");
return false;
}
if (instrumentItem->alignedWith(dfile_item))
if (instrumentItem->alignedWith(dfi))
return true;
ASSERT(parent);
QString message =
dfile_item->holdsDimensionalData()
dfi->holdsDimensionalData()
? "Experimental data carries information on the range/points of measurement."
: printShapeMessage(instrumentItem->axdims(), dfile_item->axdims());
: printShapeMessage(instrumentItem->axdims(), dfi->axdims());
if (!QuestionOnInstrumentReshaping(message))
return false;
instrumentItem->updateToRealData(dfile_item);
instrumentItem->updateToRealData(dfi);
emit m_doc->instruments()->instrumentChanged(instrumentItem);
return true;
}
......@@ -121,20 +121,20 @@ void LinkInstrumentManager::onInstrumentChanged(const InstrumentItem* instrument
{
// Run through all DatafileItem and refresh linking to match possible change in detector
// axes definition.
for (auto* dfile_item : m_doc->datafiles()->dfileItems())
if (dfile_item->instrumentId() == instrument->id()) {
if (!instrument->alignedWith(dfile_item)) {
dfile_item->unlinkFromInstrument();
emit linkToInstrumentChanged(dfile_item);
for (auto* dfi : m_doc->datafiles()->dfileItems2())
if (dfi->instrumentId() == instrument->id()) {
if (!instrument->alignedWith(dfi)) {
dfi->unlinkFromInstrument();
emit linkToInstrumentChanged(dfi);
} else
dfile_item->linkToInstrument(instrument); // link stays same, only data is updated
dfi->linkToInstrument(instrument); // link stays same, only data is updated
}
}
void LinkInstrumentManager::onInstrumentAddedOrRemoved()
{
// remove links in realItems (in case of a linked instrument was removed)
for (auto* dfile_item : m_doc->datafiles()->dfileItems())
if (!m_doc->instruments()->instrumentExists(dfile_item->instrumentId()))
dfile_item->unlinkFromInstrument();
for (auto* dfi : m_doc->datafiles()->dfileItems2())
if (!m_doc->instruments()->instrumentExists(dfi->instrumentId()))
dfi->unlinkFromInstrument();
}
......@@ -35,11 +35,11 @@ public:
//! quiet defines whether a "not possible" message box is shown if link is not possible. Use
//! this e.g. for unit tests. The question for adjusting the instrument is not suppressed by
//! this flag.
bool canLinkDataToInstrument(const DatafileItem* dfile_item, const QString& identifier,
bool canLinkDataToInstrument(const DatafileItem* dfi, const QString& identifier,
QWidget* parent) const;
signals:
void linkToInstrumentChanged(const DatafileItem* dfile_item);
void linkToInstrumentChanged(const DatafileItem* dfi);
private:
void onInstrumentChanged(const InstrumentItem* instrument);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment