From 61f59e72f66ea3ed83306e8eaad6dfd29bde5252 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 12 Jun 2024 10:32:04 +0200 Subject: [PATCH] Osdu Well Paths: add search field. --- .../RiuWellImportWizard.cpp | 32 ++++++++++++++++--- .../OsduImportCommands/RiuWellImportWizard.h | 10 ++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp index bbac7ec813..63e3632c46 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.cpp @@ -74,10 +74,10 @@ RiuWellImportWizard::~RiuWellImportWizard() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellImportWizard::downloadFields() +void RiuWellImportWizard::downloadFields( const QString& fieldName ) { // TODO: filter by user input - m_osduConnector->requestFieldsByName( "CASTBERG" ); + m_osduConnector->requestFieldsByName( fieldName ); } //-------------------------------------------------------------------------------------------------- @@ -238,6 +238,16 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs QVBoxLayout* layout = new QVBoxLayout; setLayout( layout ); + QHBoxLayout* searchLayout = new QHBoxLayout; + m_searchTextEdit = new QLineEdit( this ); + searchLayout->addWidget( m_searchTextEdit ); + + m_searchButton = new QPushButton( "Search", this ); + m_searchButton->setEnabled( false ); + searchLayout->addWidget( m_searchButton ); + + layout->addLayout( searchLayout ); + QLabel* label = new QLabel( "Select fields" ); layout->addWidget( label ); @@ -259,6 +269,10 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs m_osduConnector = osduConnector; connect( m_osduConnector, SIGNAL( fieldsFinished() ), SLOT( fieldsFinished() ) ); + connect( m_searchTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSearchTextChanged( const QString& ) ) ); + + connect( m_searchButton, SIGNAL( clicked() ), this, SLOT( searchForFields() ) ); + connect( m_tableView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), SLOT( selectField( const QItemSelection&, const QItemSelection& ) ) ); @@ -271,10 +285,20 @@ FieldSelectionPage::FieldSelectionPage( RimWellPathImport* wellPathImport, RiaOs //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void FieldSelectionPage::initializePage() +void FieldSelectionPage::onSearchTextChanged( const QString& text ) +{ + m_searchButton->setEnabled( text.length() >= MINIMUM_CHARACTERS_FOR_SEARCH ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void FieldSelectionPage::searchForFields() { RiuWellImportWizard* wiz = dynamic_cast( wizard() ); - wiz->downloadFields(); + + QString text = m_searchTextEdit->text(); + if ( text.length() >= MINIMUM_CHARACTERS_FOR_SEARCH ) wiz->downloadFields( text ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h index 4707f1de19..d6d2ff306d 100644 --- a/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/OsduImportCommands/RiuWellImportWizard.h @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include #include @@ -245,9 +246,14 @@ public: private slots: void fieldsFinished(); void selectField( const QItemSelection& newSelection, const QItemSelection& oldSelection ); + void onSearchTextChanged( const QString& ); + void searchForFields(); private: - // caf::PdmUiPropertyView* m_propertyView; + static const int MINIMUM_CHARACTERS_FOR_SEARCH = 3; + + QLineEdit* m_searchTextEdit; + QPushButton* m_searchButton; RiaOsduConnector* m_osduConnector; QTableView* m_tableView; OsduFieldTableModel* m_osduFieldsModel; @@ -336,7 +342,7 @@ public: public slots: void downloadWellPaths( const QString& wellboreId ); void downloadWells( const QString& fieldId ); - void downloadFields(); + void downloadFields( const QString& fieldName ); void slotAuthenticationRequired( QNetworkReply* networkReply, QAuthenticator* authenticator );