Files
ResInsight/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.h
T

278 lines
7.9 KiB
C++
Raw Normal View History

2013-09-02 08:39:29 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
2013-09-02 08:39:29 +02:00
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
2013-09-02 08:39:29 +02:00
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
2013-09-02 08:39:29 +02:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
2015-08-12 18:44:03 +02:00
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
2013-09-02 08:39:29 +02:00
#include <QItemSelection>
2015-08-12 18:44:03 +02:00
#include <QNetworkAccessManager>
#include <QNetworkReply>
2015-08-12 18:44:03 +02:00
#include <QString>
#include <QUrl>
#include <QWizard>
2013-09-02 08:39:29 +02:00
class QFile;
class QProgressDialog;
class QLabel;
2013-09-04 08:03:11 +02:00
class QTextEdit;
2013-09-02 08:39:29 +02:00
class RimWellPathImport;
class RimOilFieldEntry;
2015-08-12 18:44:03 +02:00
class RimWellPathEntry;
2013-09-02 08:39:29 +02:00
namespace caf
{
class PdmUiTreeView;
class PdmUiListView;
class PdmUiPropertyView;
class PdmObjectCollection;
} // namespace caf
2013-09-02 08:39:29 +02:00
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
///
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
class AuthenticationPage : public QWizardPage
2013-09-02 08:39:29 +02:00
{
Q_OBJECT
public:
AuthenticationPage( const QString& webServiceAddress, QWidget* parent = nullptr );
2013-09-02 08:39:29 +02:00
void initializePage() override;
2013-09-02 08:39:29 +02:00
};
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
///
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
2013-09-02 08:39:29 +02:00
class FieldSelectionPage : public QWizardPage
{
Q_OBJECT
public:
FieldSelectionPage( RimWellPathImport* wellPathImport, QWidget* parent = nullptr );
~FieldSelectionPage() override;
2013-09-02 08:39:29 +02:00
void initializePage() override;
2015-08-12 18:44:03 +02:00
private:
caf::PdmUiPropertyView* m_propertyView;
2013-09-02 08:39:29 +02:00
};
2015-08-12 18:44:03 +02:00
//--------------------------------------------------------------------------------------------------
/// Container class used to define column headers
//--------------------------------------------------------------------------------------------------
class ObjectGroupWithHeaders : public caf::PdmObject
2015-08-12 18:44:03 +02:00
{
CAF_PDM_HEADER_INIT;
2015-08-12 18:44:03 +02:00
public:
ObjectGroupWithHeaders()
{
CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "" );
CAF_PDM_InitField( &m_isChecked, "IsChecked", true, "Active" );
m_isChecked.uiCapability()->setUiHidden( true );
};
2015-08-12 18:44:03 +02:00
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
public:
caf::PdmChildArrayField<PdmObjectHandle*> objects;
protected:
caf::PdmFieldHandle* objectToggleField() override { return &m_isChecked; }
protected:
caf::PdmField<bool> m_isChecked;
2015-08-12 18:44:03 +02:00
};
//--------------------------------------------------------------------------------------------------
///
2015-08-12 18:44:03 +02:00
//--------------------------------------------------------------------------------------------------
class DownloadEntity
{
public:
2015-08-13 15:09:43 +02:00
QString name;
2015-08-12 18:44:03 +02:00
QString requestUrl;
QString responseFilename;
};
//--------------------------------------------------------------------------------------------------
///
2015-08-12 18:44:03 +02:00
//--------------------------------------------------------------------------------------------------
class SummaryPageDownloadEntity : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
SummaryPageDownloadEntity();
2015-08-13 15:09:43 +02:00
caf::PdmField<QString> name;
2015-08-12 18:44:03 +02:00
caf::PdmField<QString> requestUrl;
caf::PdmField<QString> responseFilename;
};
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
///
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
2013-09-04 08:03:11 +02:00
class WellSelectionPage : public QWizardPage
{
Q_OBJECT
public:
WellSelectionPage( RimWellPathImport* wellPathImport, QWidget* parent = nullptr );
~WellSelectionPage() override;
2013-09-04 08:03:11 +02:00
void initializePage() override;
void buildWellTreeView();
void selectedWellPathEntries( std::vector<DownloadEntity>& downloadEntities, caf::PdmObjectHandle* objHandle );
2013-09-04 08:03:11 +02:00
private:
void sortObjectsByDescription( caf::PdmObjectCollection* objects );
2015-08-12 18:44:03 +02:00
private slots:
void customMenuRequested( const QPoint& pos );
2013-09-04 08:03:11 +02:00
private:
ObjectGroupWithHeaders* m_regionsWithVisibleWells;
RimWellPathImport* m_wellPathImportObject;
caf::PdmUiTreeView* m_wellSelectionTreeView;
2013-09-04 08:03:11 +02:00
};
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
///
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
2013-09-04 08:03:11 +02:00
class WellSummaryPage : public QWizardPage
{
Q_OBJECT
public:
WellSummaryPage( RimWellPathImport* wellPathImport, QWidget* parent = nullptr );
2013-09-04 08:03:11 +02:00
void initializePage() override;
2013-09-04 08:03:11 +02:00
void updateSummaryPage();
2013-09-08 10:05:24 +02:00
private slots:
void slotShowDetails();
2013-09-04 08:03:11 +02:00
private:
RimWellPathImport* m_wellPathImportObject;
QTextEdit* m_textEdit;
caf::PdmUiListView* m_listView;
caf::PdmObjectCollection* m_objectGroup;
2013-09-04 08:03:11 +02:00
};
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
///
2013-09-06 15:59:25 +02:00
//--------------------------------------------------------------------------------------------------
2013-09-02 08:39:29 +02:00
class RiuWellImportWizard : public QWizard
{
Q_OBJECT
public:
enum DownloadState
{
DOWNLOAD_FIELDS,
DOWNLOAD_WELLS,
DOWNLOAD_WELL_PATH,
DOWNLOAD_UNDEFINED
};
2013-09-02 08:39:29 +02:00
public:
RiuWellImportWizard( const QString& webServiceAddress,
const QString& downloadFolder,
RimWellPathImport* wellPathImportObject,
QWidget* parent = nullptr );
~RiuWellImportWizard() override;
2013-09-02 08:39:29 +02:00
void setCredentials( const QString& username, const QString& password );
QStringList absoluteFilePathsToWellPaths() const;
// Methods used from the wizard pages
void resetAuthenticationCount();
2013-09-04 08:03:11 +02:00
2013-09-02 08:39:29 +02:00
public slots:
void downloadWellPaths();
void downloadWells();
void downloadFields();
2013-09-02 08:39:29 +02:00
void checkDownloadQueueAndIssueRequests();
2013-09-02 08:39:29 +02:00
void issueHttpRequestToFile( QString completeUrlText, QString destinationFileName );
void cancelDownload();
void httpFinished();
void httpReadyRead();
2013-09-02 08:39:29 +02:00
void slotAuthenticationRequired( QNetworkReply* networkReply, QAuthenticator* authenticator );
int wellSelectionPageId();
2013-09-02 08:39:29 +02:00
#if !defined( QT_NO_OPENSSL ) && !defined( CVF_OSX )
void sslErrors( QNetworkReply*, const QList<QSslError>& errors );
2013-09-02 08:39:29 +02:00
#endif
private slots:
void slotCurrentIdChanged( int currentId );
2013-09-02 08:39:29 +02:00
private:
void startRequest( QUrl url );
void setUrl( const QString& httpAddress );
2013-09-06 15:59:25 +02:00
QString jsonFieldsFilePath();
QString jsonWellsFilePath();
void updateFieldsModel();
void parseWellsResponse( RimOilFieldEntry* oilFieldEntry );
2013-09-06 15:59:25 +02:00
QString getValue( const QString& key, const QString& stringContent );
2013-09-06 15:59:25 +02:00
QProgressDialog* progressDialog();
void hideProgressDialog();
2013-09-06 15:59:25 +02:00
private:
QString m_webServiceAddress;
QString m_destinationFolder;
2013-09-02 08:39:29 +02:00
RimWellPathImport* m_wellPathImportObject;
caf::PdmUiTreeView* m_pdmTreeView;
2013-09-02 08:39:29 +02:00
QProgressDialog* m_myProgressDialog;
2013-09-02 08:39:29 +02:00
QUrl m_url;
QNetworkAccessManager m_networkAccessManager;
QNetworkReply* m_reply;
QFile* m_file;
bool m_httpRequestAborted;
2013-09-02 08:39:29 +02:00
bool m_firstTimeRequestingAuthentication;
QList<DownloadEntity> m_wellRequestQueue;
2013-09-02 08:39:29 +02:00
DownloadState m_currentDownloadState;
2013-09-02 08:39:29 +02:00
int m_fieldSelectionPageId;
int m_wellSelectionPageId;
int m_wellSummaryPageId;
};