Merge remote-tracking branch 'origin/internal' into internal

This commit is contained in:
Jacob Støren
2013-09-26 11:44:04 +02:00
9 changed files with 155 additions and 28 deletions

View File

@@ -38,12 +38,12 @@ public:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
void updateState();
caf::PdmField<QString> name; caf::PdmField<QString> name;
caf::PdmField<bool> selected; caf::PdmField<bool> selected;
caf::PdmPointersField<RimOilFieldEntry*> fields; caf::PdmPointersField<RimOilFieldEntry*> fields;
private:
void updateState();
}; };

View File

@@ -17,6 +17,7 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RimWellPathImport.h" #include "RimWellPathImport.h"
#include "cafPdmUiTreeViewEditor.h"
namespace caf { namespace caf {
@@ -186,3 +187,19 @@ void RimWellPathImport::fieldChangedByUi(const caf::PdmFieldHandle* changedField
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathImport::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast<caf::PdmUiTreeViewEditorAttribute*>(attribute);
if (myAttr)
{
QStringList colHeaders;
colHeaders << "Region";
myAttr->columnHeaders = colHeaders;
}
}

View File

@@ -57,9 +57,11 @@ public:
virtual void initAfterRead(); virtual void initAfterRead();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
virtual void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute * attribute );
//private:
void updateFieldVisibility(); void updateFieldVisibility();
}; };

View File

@@ -32,6 +32,7 @@
#include "RimWellPathImport.h" #include "RimWellPathImport.h"
#include "RifJsonEncodeDecode.h" #include "RifJsonEncodeDecode.h"
#include "cafPdmUiTreeViewEditor.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -385,6 +386,13 @@ void RiuWellImportWizard::updateFieldsModel()
} }
m_wellPathImportObject->updateRegions(regions, fields, edmIds); m_wellPathImportObject->updateRegions(regions, fields, edmIds);
for (size_t i = 0; i < m_wellPathImportObject->regions.size(); i++)
{
m_wellPathImportObject->regions[i]->updateState();
}
m_wellPathImportObject->updateConnectedEditors(); m_wellPathImportObject->updateConnectedEditors();
} }
} }
@@ -695,7 +703,7 @@ void RiuWellImportWizard::parseWellsResponse(RimOilFieldEntry* oilFieldEntry)
WellSelectionPage* wellSelectionPage = dynamic_cast<WellSelectionPage*>(page(m_wellSelectionPageId)); WellSelectionPage* wellSelectionPage = dynamic_cast<WellSelectionPage*>(page(m_wellSelectionPageId));
if (wellSelectionPage) if (wellSelectionPage)
wellSelectionPage->expandAllTreeNodes(); wellSelectionPage->buildWellTreeView();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -802,6 +810,31 @@ void FieldSelectionPage::initializePage()
//--------------------------------------------------------------------------------------------------
/// Helper class used to define column headers
//--------------------------------------------------------------------------------------------------
class ObjectGroupWithHeaders : public caf::PdmObjectGroup
{
public:
ObjectGroupWithHeaders() : caf::PdmObjectGroup()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
virtual void defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast<caf::PdmUiTreeViewEditorAttribute*>(attribute);
if (myAttr)
{
QStringList colHeaders;
colHeaders << "Wells";
myAttr->columnHeaders = colHeaders;
}
}
};
@@ -823,9 +856,7 @@ WellSelectionPage::WellSelectionPage(RimWellPathImport* wellPathImport, QWidget*
m_wellPathImportObject = wellPathImport; m_wellPathImportObject = wellPathImport;
m_regionsWithVisibleWells = new caf::PdmObjectGroup; m_regionsWithVisibleWells = new ObjectGroupWithHeaders;
//m_wellSelectionTreeView->setPdmObject(wellPathImport);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -837,12 +868,14 @@ void WellSelectionPage::initializePage()
if (!wiz) return; if (!wiz) return;
wiz->downloadWells(); wiz->downloadWells();
setButtonText(QWizard::NextButton, "Download");
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void WellSelectionPage::expandAllTreeNodes() void WellSelectionPage::buildWellTreeView()
{ {
m_regionsWithVisibleWells->objects.clear(); m_regionsWithVisibleWells->objects.clear();
@@ -857,7 +890,8 @@ void WellSelectionPage::expandAllTreeNodes()
m_wellSelectionTreeView->setPdmObject(m_regionsWithVisibleWells); m_wellSelectionTreeView->setPdmObject(m_regionsWithVisibleWells);
m_regionsWithVisibleWells->updateConnectedEditors(); m_regionsWithVisibleWells->updateConnectedEditors();
//m_wellSelectionTreeView->treeView()->expandAll();
m_wellSelectionTreeView->treeView()->expandAll();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -877,6 +911,7 @@ WellSelectionPage::~WellSelectionPage()
WellSummaryPage::WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* parent /*= 0*/) WellSummaryPage::WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* parent /*= 0*/)
{ {
m_wellPathImportObject = wellPathImport; m_wellPathImportObject = wellPathImport;
m_wellPathImportObject->setUiHidden(true);
QVBoxLayout* layout = new QVBoxLayout; QVBoxLayout* layout = new QVBoxLayout;
setLayout(layout); setLayout(layout);
@@ -894,6 +929,8 @@ WellSummaryPage::WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* par
m_listView->hide(); m_listView->hide();
m_objectGroup = new caf::PdmObjectGroup; m_objectGroup = new caf::PdmObjectGroup;
setButtonText(QWizard::FinishButton, "Import");
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -933,17 +970,19 @@ void WellSummaryPage::updateSummaryPage()
for (size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++) for (size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++)
{ {
RimWellPathEntry* wellPathEntry = oilField->wells[wIdx]; RimWellPathEntry* wellPathEntry = oilField->wells[wIdx];
if (wellPathEntry->selected)
if (QFile::exists(oilField->wells[wIdx]->wellPathFilePath))
{ {
wellPathCount++; if (QFile::exists(oilField->wells[wIdx]->wellPathFilePath))
} {
else wellPathCount++;
{ }
errorString += QString("Failed to get file '%1' from well '%2'\n").arg(oilField->wells[wIdx]->wellPathFilePath).arg(oilField->wells[wIdx]->name); else
} {
errorString += QString("Failed to get file '%1' from well '%2'\n").arg(oilField->wells[wIdx]->wellPathFilePath).arg(oilField->wells[wIdx]->name);
}
m_objectGroup->objects.push_back(wellPathEntry); m_objectGroup->objects.push_back(wellPathEntry);
}
} }
} }
} }
@@ -951,7 +990,7 @@ void WellSummaryPage::updateSummaryPage()
} }
m_textEdit->setText(QString("Downloaded successfully %1 well paths.\nPlease push 'Finish' button to import well paths into ResInsight.\n\n").arg(wellPathCount)); m_textEdit->setText(QString("Downloaded successfully %1 well paths.\nPlease push 'Import' button to import well paths into ResInsight.\n\n").arg(wellPathCount));
if (!errorString.isEmpty()) if (!errorString.isEmpty())
{ {
m_textEdit->append("Detected following errors during well path download. See details below."); m_textEdit->append("Detected following errors during well path download. See details below.");

View File

@@ -72,6 +72,10 @@ public:
}; };
class ObjectGroupWithHeaders;
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -84,10 +88,10 @@ public:
~WellSelectionPage(); ~WellSelectionPage();
virtual void initializePage(); virtual void initializePage();
void expandAllTreeNodes(); void buildWellTreeView();
private: private:
caf::PdmObjectGroup* m_regionsWithVisibleWells; ObjectGroupWithHeaders* m_regionsWithVisibleWells;
RimWellPathImport* m_wellPathImportObject; RimWellPathImport* m_wellPathImportObject;
caf::PdmUiTreeView* m_wellSelectionTreeView; caf::PdmUiTreeView* m_wellSelectionTreeView;

View File

@@ -45,6 +45,29 @@
#include <QWidget> #include <QWidget>
#include <QGridLayout> #include <QGridLayout>
#include <QTreeView> #include <QTreeView>
#include <QSortFilterProxyModel>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class MySortFilterProxyModel : public QSortFilterProxyModel
{
public:
MySortFilterProxyModel(QObject *parent = 0)
: QSortFilterProxyModel(parent)
{
}
void notifyModelChanged()
{
QModelIndex startModelIdx = index(0,0);
QModelIndex endModelIdx = index(rowCount(startModelIdx), 0);
emit dataChanged(startModelIdx, endModelIdx);
}
};
@@ -84,8 +107,14 @@ QWidget* PdmUiTreeViewEditor::createWidget(QWidget* parent)
m_treeModelPdm = new caf::UiTreeModelPdm(m_mainWidget); m_treeModelPdm = new caf::UiTreeModelPdm(m_mainWidget);
m_treeView = new QTreeView(m_mainWidget); m_treeView = new QTreeView(m_mainWidget);
m_treeView->setHeaderHidden(true);
m_treeView->setModel(m_treeModelPdm); m_proxyTreeModelPdm = new MySortFilterProxyModel(m_mainWidget);
m_proxyTreeModelPdm->setSourceModel(m_treeModelPdm);
m_treeView->setModel(m_proxyTreeModelPdm);
m_treeView->setSortingEnabled(true);
m_treeView->sortByColumn(1, Qt::AscendingOrder);
m_layout->addWidget(m_treeView); m_layout->addWidget(m_treeView);
@@ -125,12 +154,11 @@ void PdmUiTreeViewEditor::configureAndUpdateUi(const QString& uiConfigName)
} }
} }
m_treeModelPdm->setColumnHeaders(m_editorAttributes.columnHeaders);
PdmUiTreeViewEditorAttribute leab;
// Notify all connected views that the complete model is updated // Notify all connected views that the complete model is updated
m_treeModelPdm->notifyModelChanged(); m_treeModelPdm->notifyModelChanged();
m_proxyTreeModelPdm->notifyModelChanged();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -43,6 +43,8 @@
#include <QWidget> #include <QWidget>
#include <QPointer> #include <QPointer>
class MySortFilterProxyModel;
class QGridLayout; class QGridLayout;
class QVBoxLayout; class QVBoxLayout;
class QTreeView; class QTreeView;
@@ -66,6 +68,7 @@ public:
} }
public: public:
QStringList columnHeaders;
}; };
@@ -90,8 +93,9 @@ private:
QPointer<QWidget> m_mainWidget; QPointer<QWidget> m_mainWidget;
QVBoxLayout* m_layout; QVBoxLayout* m_layout;
QTreeView* m_treeView; QTreeView* m_treeView;
UiTreeModelPdm* m_treeModelPdm; UiTreeModelPdm* m_treeModelPdm;
MySortFilterProxyModel* m_proxyTreeModelPdm;
// Forward update events to the tree view editor connected to Pdm root object using a proxy editor // Forward update events to the tree view editor connected to Pdm root object using a proxy editor
PdmUiProxyEditorHandle* m_proxyEditor; PdmUiProxyEditorHandle* m_proxyEditor;

View File

@@ -498,6 +498,33 @@ void UiTreeModelPdm::notifyModelChanged()
emit dataChanged(startModelIdx, endModelIdx); emit dataChanged(startModelIdx, endModelIdx);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QVariant UiTreeModelPdm::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole */) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (section < m_columnHeaders.size())
{
return m_columnHeaders[section];
}
return QVariant();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void UiTreeModelPdm::setColumnHeaders(const QStringList& columnHeaders)
{
m_columnHeaders = columnHeaders;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -40,6 +40,8 @@
#include "cafUiTreeItem.h" #include "cafUiTreeItem.h"
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QStringList>
#include <assert.h> #include <assert.h>
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
@@ -71,6 +73,7 @@ public:
void updateUiSubTree(PdmObject* root); void updateUiSubTree(PdmObject* root);
void notifyModelChanged(); void notifyModelChanged();
void setColumnHeaders(const QStringList& columnHeaders);
public: public:
// Overrides from QAbstractItemModel // Overrides from QAbstractItemModel
@@ -79,10 +82,12 @@ public:
virtual int rowCount(const QModelIndex &parentIndex = QModelIndex( ) ) const; virtual int rowCount(const QModelIndex &parentIndex = QModelIndex( ) ) const;
virtual int columnCount(const QModelIndex &parentIndex = QModelIndex( ) ) const; virtual int columnCount(const QModelIndex &parentIndex = QModelIndex( ) ) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole ) const; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole ) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual bool removeRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); virtual bool removeRows_special(int position, int rows, const QModelIndex &parent = QModelIndex());
protected: protected:
@@ -91,6 +96,7 @@ private:
void updateModelSubTree(const QModelIndex& uiSubTreeRootModelIdx, PdmUiTreeItem* uiModelSubTreeRoot, PdmUiTreeItem* updatedPdmSubTreeRoot); void updateModelSubTree(const QModelIndex& uiSubTreeRootModelIdx, PdmUiTreeItem* uiModelSubTreeRoot, PdmUiTreeItem* updatedPdmSubTreeRoot);
PdmUiTreeItem* m_treeItemRoot; PdmUiTreeItem* m_treeItemRoot;
QStringList m_columnHeaders;
}; };