mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use same pdm objects for field selection and well selection
p4#: 22346
This commit is contained in:
parent
76e2afb846
commit
e6386255e6
@ -40,8 +40,11 @@ RimOilFieldEntry::RimOilFieldEntry()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&name, "OilFieldName", "OilFieldName", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&edmId, "EdmId", "EdmId", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&selected, "Selected", true, "Selected", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wellsFilePath, "wellsFilePath", "wellsFilePath", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wells, "Wells", "", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -110,3 +113,39 @@ void RimOilFieldEntry::parseWellsResponse(const QString& absolutePath, const QSt
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimOilFieldEntry::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &selected)
|
||||
{
|
||||
updateEnabledState();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimOilFieldEntry::initAfterRead()
|
||||
{
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimOilFieldEntry::updateEnabledState()
|
||||
{
|
||||
bool wellsReadOnly = !selected;
|
||||
if (this->isUiReadOnly())
|
||||
{
|
||||
wellsReadOnly = true;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < wells.size(); i++)
|
||||
{
|
||||
wells[i]->setUiReadOnly(wellsReadOnly);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,9 @@ class RimOilFieldEntry : public caf::PdmObject
|
||||
public:
|
||||
RimOilFieldEntry();
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
||||
void parseWellsResponse(const QString& absolutePath, const QString& wsAddress);
|
||||
|
||||
|
||||
caf::PdmField<QString> name;
|
||||
caf::PdmField<QString> edmId;
|
||||
caf::PdmField<bool> selected;
|
||||
@ -45,6 +43,14 @@ public:
|
||||
caf::PdmPointersField<RimWellPathEntry*> wells;
|
||||
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
virtual void initAfterRead();
|
||||
|
||||
//private:
|
||||
void updateEnabledState();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,13 +61,20 @@ void RimOilRegionEntry::fieldChangedByUi(const caf::PdmFieldHandle* changedField
|
||||
{
|
||||
if (&selected == changedField)
|
||||
{
|
||||
for (size_t i = 0; i < fields.size(); i++)
|
||||
{
|
||||
fields[i]->selected = newValue.toBool();
|
||||
}
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
|
||||
// this->updateConnectedEditors();
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimOilRegionEntry::updateState()
|
||||
{
|
||||
for (size_t i = 0; i < fields.size(); i++)
|
||||
{
|
||||
fields[i]->setUiReadOnly(!selected);
|
||||
fields[i]->updateEnabledState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,6 +41,9 @@ public:
|
||||
caf::PdmField<QString> name;
|
||||
caf::PdmField<bool> selected;
|
||||
caf::PdmPointersField<RimOilFieldEntry*> fields;
|
||||
|
||||
private:
|
||||
void updateState();
|
||||
};
|
||||
|
||||
|
||||
|
@ -47,7 +47,6 @@ RiuWellImportWizard::RiuWellImportWizard(const QString& webServiceAddress, const
|
||||
|
||||
|
||||
m_progressDialog = new QProgressDialog(this);
|
||||
m_wellCollection = new caf::PdmObjectGroup;
|
||||
m_firstTimeRequestingAuthentication = true;
|
||||
|
||||
|
||||
@ -521,8 +520,6 @@ void RiuWellImportWizard::checkDownloadQueueAndIssueRequests()
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELLS)
|
||||
{
|
||||
m_wellCollection->objects.clear();
|
||||
|
||||
// Update UI with downloaded wells
|
||||
|
||||
for (size_t rIdx = 0; rIdx < m_wellPathImportObject->regions.size(); rIdx++)
|
||||
@ -536,17 +533,12 @@ void RiuWellImportWizard::checkDownloadQueueAndIssueRequests()
|
||||
if (oilField->selected)
|
||||
{
|
||||
oilField->parseWellsResponse(m_destinationFolder, m_webServiceAddress);
|
||||
|
||||
for (size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++)
|
||||
{
|
||||
m_wellCollection->objects.push_back(oilField->wells[wIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_wellCollection->updateConnectedEditors();
|
||||
m_wellPathImportObject->updateConnectedEditors();
|
||||
}
|
||||
else if (m_currentDownloadState == DOWNLOAD_WELL_PATH)
|
||||
{
|
||||
@ -562,22 +554,6 @@ void RiuWellImportWizard::checkDownloadQueueAndIssueRequests()
|
||||
m_progressDialog->hide();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellImportWizard::~RiuWellImportWizard()
|
||||
{
|
||||
delete m_wellCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectGroup* RiuWellImportWizard::wellCollection()
|
||||
{
|
||||
return m_wellCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -733,6 +709,8 @@ WellSelectionPage::WellSelectionPage(RimWellPathImport* wellPathImport, QWidget*
|
||||
|
||||
m_wellSelectionTreeView = new caf::PdmUiTreeView(this);
|
||||
layout->addWidget(m_wellSelectionTreeView);
|
||||
|
||||
m_wellSelectionTreeView->setPdmObject(wellPathImport);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -745,7 +723,7 @@ void WellSelectionPage::initializePage()
|
||||
|
||||
wiz->downloadWells();
|
||||
|
||||
m_wellSelectionTreeView->setPdmObject(wiz->wellCollection());
|
||||
// m_wellSelectionTreeView->setPdmObject(wiz->wellCollection());
|
||||
}
|
||||
|
||||
|
||||
|
@ -134,7 +134,6 @@ public:
|
||||
|
||||
public:
|
||||
RiuWellImportWizard(const QString& webServiceAddress, const QString& downloadFolder, RimWellPathImport* wellPathImportObject, QWidget *parent = 0);
|
||||
~RiuWellImportWizard();
|
||||
|
||||
void setWebServiceAddress(const QString& wsAdress);
|
||||
void setJsonDestinationFolder(const QString& folder);
|
||||
@ -188,8 +187,6 @@ private:
|
||||
RimWellPathImport* m_wellPathImportObject;
|
||||
caf::PdmUiTreeView* m_pdmTreeView;
|
||||
|
||||
caf::PdmObjectGroup* m_wellCollection;
|
||||
|
||||
QProgressDialog* m_progressDialog;
|
||||
|
||||
QUrl m_url;
|
||||
|
@ -322,6 +322,12 @@ Qt::ItemFlags UiTreeModelPdm::flags(const QModelIndex &index) const
|
||||
{
|
||||
flagMask = flagMask | Qt::ItemIsUserCheckable;
|
||||
}
|
||||
|
||||
if (pdmObject->isUiReadOnly())
|
||||
{
|
||||
flagMask = flagMask & (~Qt::ItemIsEnabled);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user