mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Removed obsolete prototype code
Cleaned up unused functions p4#: 22338
This commit is contained in:
@@ -119,6 +119,8 @@ void RimProject::close()
|
||||
casesObsolete.deleteAllChildObjects();
|
||||
caseGroupsObsolete.deleteAllChildObjects();
|
||||
|
||||
wellPathImport = new RimWellPathImport();
|
||||
|
||||
fileName = "";
|
||||
|
||||
nextValidCaseId = 0;
|
||||
|
||||
@@ -1620,10 +1620,10 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
|
||||
|
||||
wellPathsFolderPath += "/" + wellPathFolderName;
|
||||
|
||||
app->project()->wellPathImport;
|
||||
|
||||
RimWellPathImport* copyOfWellPathImport = dynamic_cast<RimWellPathImport*>(app->project()->wellPathImport->deepCopy());
|
||||
|
||||
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, app->project()->wellPathImport, this);
|
||||
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, copyOfWellPathImport, this);
|
||||
if (QDialog::Accepted == wellImportwizard.exec())
|
||||
{
|
||||
QStringList wellPaths = wellImportwizard.absoluteFilePathsToWellPaths();
|
||||
@@ -1632,59 +1632,9 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
|
||||
app->addWellPathsToModel(wellPaths);
|
||||
app->project()->createDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
app->project()->wellPathImport = copyOfWellPathImport;
|
||||
}
|
||||
|
||||
/*
|
||||
CVF_ASSERT(m_ssihubInterface);
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (!app->project())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QFile::exists(app->project()->fileName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString wellPathsFolderPath;
|
||||
QString projectFileName = app->project()->fileName();
|
||||
QFileInfo fileInfo(projectFileName);
|
||||
wellPathsFolderPath = fileInfo.canonicalPath();
|
||||
QString wellPathFolderName = fileInfo.completeBaseName() + "_wellpaths";
|
||||
|
||||
QDir projFolder(wellPathsFolderPath);
|
||||
projFolder.mkdir(wellPathFolderName);
|
||||
|
||||
wellPathsFolderPath += "/" + wellPathFolderName;
|
||||
|
||||
m_ssihubInterface->setWebServiceAddress(app->preferences()->ssihubAddress);
|
||||
m_ssihubInterface->setJsonDestinationFolder(wellPathsFolderPath);
|
||||
|
||||
double north = cvf::UNDEFINED_DOUBLE;
|
||||
double south = cvf::UNDEFINED_DOUBLE;
|
||||
double east = cvf::UNDEFINED_DOUBLE;
|
||||
double west = cvf::UNDEFINED_DOUBLE;
|
||||
|
||||
app->project()->computeUtmAreaOfInterest(&north, &south, &east, &west);
|
||||
|
||||
if (north != cvf::UNDEFINED_DOUBLE &&
|
||||
south != cvf::UNDEFINED_DOUBLE &&
|
||||
east != cvf::UNDEFINED_DOUBLE &&
|
||||
west != cvf::UNDEFINED_DOUBLE)
|
||||
{
|
||||
m_ssihubInterface->setRegion(north, south, east, west);
|
||||
}
|
||||
|
||||
QStringList wellPaths = m_ssihubInterface->jsonWellPaths();
|
||||
if (wellPaths.size() > 0)
|
||||
{
|
||||
app->addWellPathsToModel(wellPaths);
|
||||
if (app->project()) app->project()->createDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -34,8 +34,6 @@ add_library( ${PROJECT_NAME}
|
||||
RimOilFieldEntry.cpp
|
||||
RimWellsEntry.h
|
||||
RimWellsEntry.cpp
|
||||
RimWellCollection.h
|
||||
RimWellCollection.cpp
|
||||
RiuWellImportWizard.h
|
||||
RiuWellImportWizard.cpp
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellCollection, "RimWellCollection");
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellCollection::RimWellCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("OilFieldEntry", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wells, "Wells", "", "", "", "");
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellCollection::~RimWellCollection()
|
||||
{
|
||||
// Remove all objects in this container, but do not delete the objects
|
||||
wells.clear();
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
#include "RimWellsEntry.h"
|
||||
|
||||
|
||||
|
||||
class RimWellCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellCollection();
|
||||
~RimWellCollection();
|
||||
|
||||
caf::PdmPointersField<RimWellPathEntry*> wells;
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
#include "RimWellPathImport.h"
|
||||
|
||||
#include "ssihubDialog.h"
|
||||
#include "RifJsonEncodeDecode.h"
|
||||
|
||||
|
||||
@@ -47,6 +46,10 @@ RiuWellImportWizard::RiuWellImportWizard(const QString& webServiceAddress, const
|
||||
m_webServiceAddress = webServiceAddress;
|
||||
|
||||
|
||||
m_progressDialog = new QProgressDialog(this);
|
||||
m_wellCollection = new caf::PdmObjectGroup;
|
||||
m_firstTimeRequestingAuthentication = true;
|
||||
|
||||
|
||||
addPage(new AuthenticationPage(webServiceAddress, this));
|
||||
addPage(new FieldSelectionPage(m_wellPathImportObject, this));
|
||||
@@ -54,16 +57,6 @@ RiuWellImportWizard::RiuWellImportWizard(const QString& webServiceAddress, const
|
||||
m_wellSummaryPageId = addPage(new WellSummaryPage(m_wellPathImportObject, this));
|
||||
|
||||
|
||||
m_statusLabel = new QLabel(tr("Status : idle"));
|
||||
m_statusLabel->setWordWrap(true);
|
||||
|
||||
m_progressDialog = new QProgressDialog(this);
|
||||
|
||||
m_wellCollection = new caf::PdmObjectGroup;
|
||||
|
||||
m_firstTimeRequestingAuthentication = true;
|
||||
|
||||
|
||||
connect(&m_networkAccessManager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
|
||||
this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
|
||||
#ifndef QT_NO_OPENSSL
|
||||
@@ -115,7 +108,6 @@ QString RiuWellImportWizard::jsonWellsFilePath()
|
||||
return m_destinationFolder + "/wellpaths.json";
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -139,27 +131,6 @@ void RiuWellImportWizard::downloadFields()
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::checkDownloadQueueAndIssueRequests()
|
||||
{
|
||||
if (m_wellPathRequestQueue.size() > 0)
|
||||
{
|
||||
QString link = m_wellPathRequestQueue[0];
|
||||
m_wellPathRequestQueue.pop_front();
|
||||
|
||||
QString completeUrlText = m_webServiceAddress + link;
|
||||
|
||||
QUuid guid = QUuid::createUuid();
|
||||
QString singleWellPathFilePath = m_destinationFolder + QString("/wellpath_%1.json").arg(guid);
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_WELL_PATH;
|
||||
issueHttpRequestToFile(completeUrlText, singleWellPathFilePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -193,9 +164,6 @@ void RiuWellImportWizard::cancelDownload()
|
||||
//m_statusLabel->setText(tr("Download canceled."));
|
||||
m_httpRequestAborted = true;
|
||||
m_reply->abort();
|
||||
|
||||
refreshButtonStatus();
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -215,16 +183,9 @@ void RiuWellImportWizard::httpFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_wellPathRequestQueue.size() == 0)
|
||||
{
|
||||
m_progressDialog->hide();
|
||||
}
|
||||
|
||||
m_file->flush();
|
||||
m_file->close();
|
||||
|
||||
|
||||
|
||||
QVariant redirectionTarget = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
||||
if (m_reply->error()) {
|
||||
m_file->remove();
|
||||
@@ -244,18 +205,13 @@ void RiuWellImportWizard::httpFinished()
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
m_statusLabel->setText(tr("Downloaded data to %1.").arg(m_destinationFolder));
|
||||
//m_statusLabel->setText(tr("Downloaded data to %1.").arg(m_destinationFolder));
|
||||
}
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELL_PATH)
|
||||
{
|
||||
|
||||
qDebug() << "Downloaded " << m_file->fileName();
|
||||
|
||||
/*
|
||||
QString singleWellPathFilePath = m_file->fileName();
|
||||
|
||||
|
||||
QFile file(singleWellPathFilePath);
|
||||
if (file.open(QFile::ReadOnly))
|
||||
{
|
||||
@@ -276,16 +232,6 @@ void RiuWellImportWizard::httpFinished()
|
||||
QString wellPathName = getValue("name", singleWellPathContent);
|
||||
if (!singleWellPathContent.isEmpty() && !wellPathName.isEmpty())
|
||||
{
|
||||
// int currentRowCount = m_wellPathsModel->rowCount();
|
||||
// m_wellPathsModel->setRowCount(m_wellPathsModel->rowCount() + 1);
|
||||
//
|
||||
// QModelIndex miName = m_wellPathsModel->index(currentRowCount, 0);
|
||||
// m_wellPathsModel->setData(miName, wellPathName);
|
||||
//
|
||||
// QModelIndex miFileName = m_wellPathsModel->index(currentRowCount, 1);
|
||||
// m_wellPathsModel->setData(miFileName, singleWellPathFilePath);
|
||||
|
||||
|
||||
// Write out the content without leading/trailing []
|
||||
file.close();
|
||||
file.remove(singleWellPathFilePath);
|
||||
@@ -297,12 +243,8 @@ void RiuWellImportWizard::httpFinished()
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
refreshButtonStatus();
|
||||
|
||||
m_reply->deleteLater();
|
||||
m_reply = 0;
|
||||
delete m_file;
|
||||
@@ -310,18 +252,13 @@ void RiuWellImportWizard::httpFinished()
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELLS || m_currentDownloadState == DOWNLOAD_WELL_PATH)
|
||||
{
|
||||
checkDownloadQueueAndIssueRequests_v2();
|
||||
checkDownloadQueueAndIssueRequests();
|
||||
}
|
||||
else if (m_currentDownloadState == DOWNLOAD_FIELDS)
|
||||
{
|
||||
updateFieldsModel();
|
||||
m_currentDownloadState = DOWNLOAD_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
checkDownloadQueueAndIssueRequests();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -337,16 +274,6 @@ void RiuWellImportWizard::httpReadyRead()
|
||||
m_file->write(m_reply->readAll());
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::httpError(QNetworkReply::NetworkError code)
|
||||
{
|
||||
// QMessageBox::information(this, tr("HTTP Error"), tr("Download failed: %1.").arg(m_reply->errorString()));
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -360,13 +287,6 @@ void RiuWellImportWizard::updateDataReadProgress(qint64 bytesRead, qint64 totalB
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::refreshButtonStatus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// This slot will be called for the first network reply that will need authentication.
|
||||
@@ -411,23 +331,12 @@ void RiuWellImportWizard::sslErrors(QNetworkReply*,const QList<QSslError> &error
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::setUrl(const QString& httpAddress)
|
||||
{
|
||||
// m_urlLineEdit->setText(httpAddress);
|
||||
|
||||
m_url = httpAddress;
|
||||
}
|
||||
|
||||
@@ -441,11 +350,8 @@ void RiuWellImportWizard::startRequest(QUrl url)
|
||||
this, SLOT(httpFinished()));
|
||||
connect(m_reply, SIGNAL(readyRead()),
|
||||
this, SLOT(httpReadyRead()));
|
||||
connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||
this, SLOT(httpError(QNetworkReply::NetworkError)));
|
||||
connect(m_reply, SIGNAL(downloadProgress(qint64,qint64)),
|
||||
this, SLOT(updateDataReadProgress(qint64,qint64)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -473,61 +379,6 @@ QString RiuWellImportWizard::getValue(const QString& key, const QString& stringC
|
||||
return QString();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::getWellPathLinks(QStringList* surveyLinks, QStringList* planLinks)
|
||||
{
|
||||
QStringList entities;
|
||||
|
||||
QString filename = jsonWellsFilePath();
|
||||
if (QFile::exists(filename))
|
||||
{
|
||||
JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filename);
|
||||
|
||||
QMapIterator<QString, QVariant> it(jsonMap);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
|
||||
QString key = it.key();
|
||||
if (key[0].isDigit())
|
||||
{
|
||||
QMap<QString, QVariant> slotMap = it.value().toMap();
|
||||
QMap<QString, QVariant> linkMap = slotMap["links"].toMap();
|
||||
|
||||
QString surveyLink = linkMap["survey"].toString();
|
||||
surveyLinks->push_back(surveyLink);
|
||||
|
||||
QString planLink = linkMap["plans"].toString();
|
||||
planLinks->push_back(planLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::issueDownloadOfWellPaths(const QStringList& surveyLinks, const QStringList& planLinks)
|
||||
{
|
||||
m_wellPathRequestQueue.clear();
|
||||
|
||||
// if (m_importSurveyCheckBox->isChecked())
|
||||
{
|
||||
m_wellPathRequestQueue += surveyLinks;
|
||||
}
|
||||
|
||||
// if (m_importPlansCheckBox->isChecked())
|
||||
{
|
||||
m_wellPathRequestQueue += planLinks;
|
||||
}
|
||||
|
||||
checkDownloadQueueAndIssueRequests();
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -609,7 +460,7 @@ void RiuWellImportWizard::downloadWells()
|
||||
}
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_WELLS;
|
||||
checkDownloadQueueAndIssueRequests_v2();
|
||||
checkDownloadQueueAndIssueRequests();
|
||||
}
|
||||
|
||||
|
||||
@@ -649,14 +500,14 @@ void RiuWellImportWizard::downloadWellPaths()
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_WELL_PATH;
|
||||
|
||||
checkDownloadQueueAndIssueRequests_v2();
|
||||
checkDownloadQueueAndIssueRequests();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellImportWizard::checkDownloadQueueAndIssueRequests_v2()
|
||||
void RiuWellImportWizard::checkDownloadQueueAndIssueRequests()
|
||||
{
|
||||
if (m_wellRequestQueue.size() > 0)
|
||||
{
|
||||
@@ -671,7 +522,6 @@ void RiuWellImportWizard::checkDownloadQueueAndIssueRequests_v2()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELLS)
|
||||
{
|
||||
m_wellCollection->objects.clear();
|
||||
@@ -711,6 +561,8 @@ void RiuWellImportWizard::checkDownloadQueueAndIssueRequests_v2()
|
||||
}
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_UNDEFINED;
|
||||
|
||||
m_progressDialog->hide();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -32,7 +32,6 @@ class QTextEdit;
|
||||
|
||||
|
||||
class RimWellPathImport;
|
||||
class RimWellCollection;
|
||||
|
||||
|
||||
namespace caf
|
||||
@@ -44,6 +43,9 @@ namespace caf
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class AuthenticationPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -55,6 +57,9 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class FieldSelectionPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -66,6 +71,9 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class WellSelectionPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -80,6 +88,10 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class WellSummaryPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -99,6 +111,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class DownloadEntity
|
||||
{
|
||||
public:
|
||||
@@ -106,6 +121,10 @@ public:
|
||||
QString responseFilename;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiuWellImportWizard : public QWizard
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -128,6 +147,27 @@ public:
|
||||
caf::PdmObjectGroup* wellCollection();
|
||||
void resetAuthenticationCount();
|
||||
|
||||
public slots:
|
||||
void downloadWellPaths();
|
||||
void downloadWells();
|
||||
void downloadFields();
|
||||
|
||||
void checkDownloadQueueAndIssueRequests();
|
||||
|
||||
void issueHttpRequestToFile( QString completeUrlText, QString destinationFileName );
|
||||
void cancelDownload();
|
||||
|
||||
void httpFinished();
|
||||
void httpReadyRead();
|
||||
|
||||
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
void slotAuthenticationRequired(QNetworkReply* networkReply, QAuthenticator* authenticator);
|
||||
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void startRequest(QUrl url);
|
||||
void setUrl(const QString& httpAddress);
|
||||
@@ -139,48 +179,18 @@ private:
|
||||
|
||||
QString getValue(const QString& key, const QString& stringContent);
|
||||
|
||||
void getWellPathLinks(QStringList* surveyLinks, QStringList* planLinks);
|
||||
void issueDownloadOfWellPaths(const QStringList& surveyLinks, const QStringList& planLinks);
|
||||
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
void downloadWellPaths();
|
||||
void downloadWells();
|
||||
void downloadFields();
|
||||
void checkDownloadQueueAndIssueRequests();
|
||||
|
||||
void checkDownloadQueueAndIssueRequests_v2();
|
||||
|
||||
void issueHttpRequestToFile( QString completeUrlText, QString destinationFileName );
|
||||
void cancelDownload();
|
||||
|
||||
void httpFinished();
|
||||
void httpReadyRead();
|
||||
void httpError(QNetworkReply::NetworkError code);
|
||||
|
||||
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
void refreshButtonStatus();
|
||||
void slotAuthenticationRequired(QNetworkReply* networkReply, QAuthenticator* authenticator);
|
||||
|
||||
void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
|
||||
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QString m_webServiceAddress;
|
||||
QString m_destinationFolder;
|
||||
QString m_webServiceAddress;
|
||||
QString m_destinationFolder;
|
||||
|
||||
RimWellPathImport* m_wellPathImportObject;
|
||||
caf::PdmUiTreeView* m_pdmTreeView;
|
||||
RimWellPathImport* m_wellPathImportObject;
|
||||
caf::PdmUiTreeView* m_pdmTreeView;
|
||||
|
||||
caf::PdmObjectGroup* m_wellCollection;
|
||||
caf::PdmObjectGroup* m_wellCollection;
|
||||
|
||||
QProgressDialog* m_progressDialog;
|
||||
QProgressDialog* m_progressDialog;
|
||||
|
||||
QUrl m_url;
|
||||
QNetworkAccessManager m_networkAccessManager;
|
||||
@@ -190,25 +200,9 @@ private:
|
||||
|
||||
bool m_firstTimeRequestingAuthentication;
|
||||
|
||||
|
||||
QStringList m_wellPathRequestQueue;
|
||||
QList<DownloadEntity> m_wellRequestQueue;
|
||||
|
||||
DownloadState m_currentDownloadState;
|
||||
|
||||
|
||||
// To be deleted
|
||||
QLabel* m_statusLabel;
|
||||
|
||||
int m_wellSummaryPageId;
|
||||
|
||||
DownloadState m_currentDownloadState;
|
||||
int m_wellSummaryPageId;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
<ui version="4.0" >
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>389</width>
|
||||
<height>243</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Http authentication required</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>You need to supply a Username and a Password to access this site</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLineEdit" name="userEdit" />
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QLineEdit" name="passwordEdit" />
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2" >
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Site:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLabel" name="siteDescription" >
|
||||
<property name="font" >
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>%1 at %2</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -1,298 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtNetwork>
|
||||
|
||||
#include "httpwindow.h"
|
||||
#include "ui_authenticationdialog.h"
|
||||
|
||||
HttpWindow::HttpWindow(QWidget *parent)
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
: QWidget(parent)
|
||||
#else
|
||||
: QDialog(parent)
|
||||
#endif
|
||||
{
|
||||
#ifndef QT_NO_OPENSSL
|
||||
urlLineEdit = new QLineEdit("https://qt.nokia.com/");
|
||||
#else
|
||||
urlLineEdit = new QLineEdit("http://qt.nokia.com/");
|
||||
#endif
|
||||
|
||||
urlLabel = new QLabel(tr("&URL:"));
|
||||
urlLabel->setBuddy(urlLineEdit);
|
||||
statusLabel = new QLabel(tr("Please enter the URL of a file you want to "
|
||||
"download."));
|
||||
statusLabel->setWordWrap(true);
|
||||
|
||||
downloadButton = new QPushButton(tr("Download"));
|
||||
downloadButton->setDefault(true);
|
||||
quitButton = new QPushButton(tr("Quit"));
|
||||
quitButton->setAutoDefault(false);
|
||||
|
||||
buttonBox = new QDialogButtonBox;
|
||||
buttonBox->addButton(downloadButton, QDialogButtonBox::ActionRole);
|
||||
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
|
||||
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
progressDialog = new QProgressDialog(this);
|
||||
#endif
|
||||
|
||||
connect(urlLineEdit, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(enableDownloadButton()));
|
||||
|
||||
connect(&qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
|
||||
this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
|
||||
#ifndef QT_NO_OPENSSL
|
||||
connect(&qnam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
|
||||
#endif
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));
|
||||
#endif
|
||||
connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile()));
|
||||
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
QHBoxLayout *topLayout = new QHBoxLayout;
|
||||
topLayout->addWidget(urlLabel);
|
||||
topLayout->addWidget(urlLineEdit);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addWidget(statusLabel);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
setLayout(mainLayout);
|
||||
|
||||
setWindowTitle(tr("HTTP"));
|
||||
urlLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void HttpWindow::startRequest(QUrl url)
|
||||
{
|
||||
reply = qnam.get(QNetworkRequest(url));
|
||||
connect(reply, SIGNAL(finished()),
|
||||
this, SLOT(httpFinished()));
|
||||
connect(reply, SIGNAL(readyRead()),
|
||||
this, SLOT(httpReadyRead()));
|
||||
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
|
||||
this, SLOT(updateDataReadProgress(qint64,qint64)));
|
||||
}
|
||||
|
||||
void HttpWindow::downloadFile()
|
||||
{
|
||||
url = urlLineEdit->text();
|
||||
|
||||
QFileInfo fileInfo(url.path());
|
||||
QString fileName = fileInfo.fileName();
|
||||
if (fileName.isEmpty())
|
||||
fileName = "index.html";
|
||||
|
||||
if (QFile::exists(fileName)) {
|
||||
if (QMessageBox::question(this, tr("HTTP"),
|
||||
tr("There already exists a file called %1 in "
|
||||
"the current directory. Overwrite?").arg(fileName),
|
||||
QMessageBox::Yes|QMessageBox::No, QMessageBox::No)
|
||||
== QMessageBox::No)
|
||||
return;
|
||||
QFile::remove(fileName);
|
||||
}
|
||||
|
||||
file = new QFile(fileName);
|
||||
if (!file->open(QIODevice::WriteOnly)) {
|
||||
QMessageBox::information(this, tr("HTTP"),
|
||||
tr("Unable to save the file %1: %2.")
|
||||
.arg(fileName).arg(file->errorString()));
|
||||
delete file;
|
||||
file = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
progressDialog->setWindowTitle(tr("HTTP"));
|
||||
progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
|
||||
#endif
|
||||
downloadButton->setEnabled(false);
|
||||
|
||||
// schedule the request
|
||||
httpRequestAborted = false;
|
||||
startRequest(url);
|
||||
}
|
||||
|
||||
void HttpWindow::cancelDownload()
|
||||
{
|
||||
statusLabel->setText(tr("Download canceled."));
|
||||
httpRequestAborted = true;
|
||||
reply->abort();
|
||||
downloadButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void HttpWindow::httpFinished()
|
||||
{
|
||||
if (httpRequestAborted) {
|
||||
if (file) {
|
||||
file->close();
|
||||
file->remove();
|
||||
delete file;
|
||||
file = 0;
|
||||
}
|
||||
reply->deleteLater();
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
progressDialog->hide();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
progressDialog->hide();
|
||||
#endif
|
||||
file->flush();
|
||||
file->close();
|
||||
|
||||
|
||||
QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
||||
if (reply->error()) {
|
||||
file->remove();
|
||||
QMessageBox::information(this, tr("HTTP"),
|
||||
tr("Download failed: %1.")
|
||||
.arg(reply->errorString()));
|
||||
downloadButton->setEnabled(true);
|
||||
} else if (!redirectionTarget.isNull()) {
|
||||
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
|
||||
if (QMessageBox::question(this, tr("HTTP"),
|
||||
tr("Redirect to %1 ?").arg(newUrl.toString()),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
url = newUrl;
|
||||
reply->deleteLater();
|
||||
file->open(QIODevice::WriteOnly);
|
||||
file->resize(0);
|
||||
startRequest(url);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
QString fileName = QFileInfo(QUrl(urlLineEdit->text()).path()).fileName();
|
||||
statusLabel->setText(tr("Downloaded %1 to %2.").arg(fileName).arg(QDir::currentPath()));
|
||||
downloadButton->setEnabled(true);
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
reply = 0;
|
||||
delete file;
|
||||
file = 0;
|
||||
}
|
||||
|
||||
void HttpWindow::httpReadyRead()
|
||||
{
|
||||
// this slot gets called every time the QNetworkReply has new data.
|
||||
// We read all of its new data and write it into the file.
|
||||
// That way we use less RAM than when reading it at the finished()
|
||||
// signal of the QNetworkReply
|
||||
if (file)
|
||||
file->write(reply->readAll());
|
||||
}
|
||||
|
||||
void HttpWindow::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
if (httpRequestAborted)
|
||||
return;
|
||||
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
progressDialog->setMaximum(totalBytes);
|
||||
progressDialog->setValue(bytesRead);
|
||||
#else
|
||||
Q_UNUSED(bytesRead);
|
||||
Q_UNUSED(totalBytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
void HttpWindow::enableDownloadButton()
|
||||
{
|
||||
downloadButton->setEnabled(!urlLineEdit->text().isEmpty());
|
||||
}
|
||||
|
||||
void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator)
|
||||
{
|
||||
QDialog dlg;
|
||||
Ui::Dialog ui;
|
||||
ui.setupUi(&dlg);
|
||||
dlg.adjustSize();
|
||||
ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(url.host()));
|
||||
|
||||
// Did the URL have information? Fill the UI
|
||||
// This is only relevant if the URL-supplied credentials were wrong
|
||||
ui.userEdit->setText(url.userName());
|
||||
ui.passwordEdit->setText(url.password());
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
authenticator->setUser(ui.userEdit->text());
|
||||
authenticator->setPassword(ui.passwordEdit->text());
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
|
||||
{
|
||||
QString errorString;
|
||||
foreach (const QSslError &error, errors) {
|
||||
if (!errorString.isEmpty())
|
||||
errorString += ", ";
|
||||
errorString += error.errorString();
|
||||
}
|
||||
|
||||
if (QMessageBox::warning(this, tr("HTTP"),
|
||||
tr("One or more SSL errors has occurred: %1").arg(errorString),
|
||||
QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
|
||||
reply->ignoreSslErrors();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void HttpWindow::setUrl(const QString& httpAddress)
|
||||
{
|
||||
urlLineEdit->setText(httpAddress);
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef HTTPWINDOW_H
|
||||
#define HTTPWINDOW_H
|
||||
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
#include <QWidget>
|
||||
#else
|
||||
#include <QDialog>
|
||||
#endif
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QUrl>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDialogButtonBox;
|
||||
class QFile;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QProgressDialog;
|
||||
class QPushButton;
|
||||
class QSslError;
|
||||
class QAuthenticator;
|
||||
class QNetworkReply;
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
class HttpWindow : public QWidget
|
||||
#else
|
||||
class HttpWindow : public QDialog
|
||||
#endif
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HttpWindow(QWidget *parent = 0);
|
||||
|
||||
void setUrl(const QString& httpAddress);
|
||||
|
||||
void startRequest(QUrl url);
|
||||
|
||||
private slots:
|
||||
void downloadFile();
|
||||
void cancelDownload();
|
||||
void httpFinished();
|
||||
void httpReadyRead();
|
||||
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
void enableDownloadButton();
|
||||
void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *);
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QLabel *statusLabel;
|
||||
QLabel *urlLabel;
|
||||
QLineEdit *urlLineEdit;
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
QProgressDialog *progressDialog;
|
||||
#endif
|
||||
QPushButton *downloadButton;
|
||||
QPushButton *quitButton;
|
||||
QDialogButtonBox *buttonBox;
|
||||
|
||||
QUrl url;
|
||||
QNetworkAccessManager qnam;
|
||||
QNetworkReply *reply;
|
||||
QFile *file;
|
||||
int httpGetId;
|
||||
bool httpRequestAborted;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,807 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "ssihubDialog.h"
|
||||
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtNetwork>
|
||||
|
||||
#include "httpwindow.h"
|
||||
#include "ui_authenticationdialog.h"
|
||||
#include "RifJsonEncodeDecode.h"
|
||||
|
||||
|
||||
namespace ssihub {
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
FetchWellPathsDialog::FetchWellPathsDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
m_urlSsiHubLineEdit = new QLineEdit;
|
||||
m_urlSsiHubLineEdit->setReadOnly(true);
|
||||
m_urlSsiHubLabel = new QLabel(tr("SSIHUB address:"));
|
||||
m_urlSsiHubLabel->setBuddy(m_urlSsiHubLineEdit);
|
||||
|
||||
m_urlLineEdit = new QLineEdit;
|
||||
m_urlLineEdit->setReadOnly(true);
|
||||
m_urlLabel = new QLabel(tr("SSIHUB complete request:"));
|
||||
m_urlLabel->setBuddy(m_urlLineEdit);
|
||||
|
||||
m_statusLabel = new QLabel(tr("Status : idle"));
|
||||
m_statusLabel->setWordWrap(true);
|
||||
|
||||
m_downloadFieldsButton = new QPushButton(tr("Get fields"));
|
||||
connect(m_downloadFieldsButton, SIGNAL(clicked()), this, SLOT(downloadFields()));
|
||||
|
||||
// Fields data model and view
|
||||
m_fieldListView = new QListView(this);
|
||||
m_fieldModel = new QStringListModel;
|
||||
m_fieldListView->setModel(m_fieldModel);
|
||||
connect(m_fieldListView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection& )), this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection& )));
|
||||
|
||||
// Well paths data model and view
|
||||
m_wellPathsModel = new QStandardItemModel;
|
||||
m_wellPathsModel->setColumnCount(2);
|
||||
m_wellPathsView = new QListView(this);
|
||||
m_wellPathsView->setModel(m_wellPathsModel);
|
||||
|
||||
// Filter by Utm coordinates
|
||||
m_filterWellsByUtmArea = new QCheckBox("Filter by UTM area");
|
||||
connect(m_filterWellsByUtmArea, SIGNAL(clicked()), this, SLOT(refreshButtonStatus()));
|
||||
|
||||
m_northLineEdit = new QLineEdit;
|
||||
m_southLineEdit = new QLineEdit;
|
||||
m_eastLineEdit = new QLineEdit;
|
||||
m_westLineEdit = new QLineEdit;
|
||||
|
||||
|
||||
|
||||
QGroupBox* utmAreaGropBox = new QGroupBox("UTM filter by area");
|
||||
QGridLayout *utmAreaLayout = new QGridLayout;
|
||||
utmAreaLayout->addWidget(m_filterWellsByUtmArea, 0, 1);
|
||||
utmAreaLayout->addWidget(new QLabel("North"), 1, 0);
|
||||
utmAreaLayout->addWidget(m_northLineEdit, 1, 1);
|
||||
utmAreaLayout->addWidget(new QLabel("South"), 1, 2);
|
||||
utmAreaLayout->addWidget(m_southLineEdit, 1, 3);
|
||||
utmAreaLayout->addWidget(new QLabel("East"), 2, 0);
|
||||
utmAreaLayout->addWidget(m_eastLineEdit, 2, 1);
|
||||
utmAreaLayout->addWidget(new QLabel("West"), 2, 2);
|
||||
utmAreaLayout->addWidget(m_westLineEdit, 2, 3);
|
||||
utmAreaGropBox->setLayout(utmAreaLayout);
|
||||
|
||||
|
||||
// Well types
|
||||
|
||||
m_importSurveyCheckBox = new QCheckBox("Survey");
|
||||
m_importSurveyCheckBox->setChecked(true);
|
||||
m_importPlansCheckBox = new QCheckBox("Plans");
|
||||
m_importPlansCheckBox->setChecked(true);
|
||||
|
||||
QGroupBox* wellTypeGropBox = new QGroupBox("Include well types");
|
||||
QHBoxLayout* wellTypeLayout = new QHBoxLayout;
|
||||
wellTypeLayout->addWidget(m_importSurveyCheckBox);
|
||||
wellTypeLayout->addWidget(m_importPlansCheckBox);
|
||||
wellTypeGropBox->setLayout(wellTypeLayout);
|
||||
|
||||
|
||||
|
||||
m_downloadWellPathsButton = new QPushButton(tr("Get well paths"));
|
||||
m_downloadWellPathsButton->setDefault(true);
|
||||
|
||||
m_buttonBox = new QDialogButtonBox;
|
||||
m_buttonBox->addButton(m_downloadFieldsButton, QDialogButtonBox::ActionRole);
|
||||
m_buttonBox->addButton(m_downloadWellPathsButton, QDialogButtonBox::ActionRole);
|
||||
|
||||
QDialogButtonBox* buttonBox1 = new QDialogButtonBox;
|
||||
buttonBox1->addButton(QDialogButtonBox::Cancel);
|
||||
buttonBox1->addButton("Import well paths", QDialogButtonBox::AcceptRole);
|
||||
|
||||
connect(buttonBox1, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox1, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
m_progressDialog = new QProgressDialog(this);
|
||||
|
||||
connect(m_urlLineEdit, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(refreshButtonStatus()));
|
||||
|
||||
connect(&m_networkAccessManager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
|
||||
this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
|
||||
#ifndef QT_NO_OPENSSL
|
||||
connect(&m_networkAccessManager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
|
||||
#endif
|
||||
|
||||
connect(m_progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));
|
||||
connect(m_downloadWellPathsButton, SIGNAL(clicked()), this, SLOT(downloadWellPaths()));
|
||||
|
||||
QVBoxLayout *topLayout1 = new QVBoxLayout;
|
||||
QVBoxLayout *topLayout2 = new QVBoxLayout;
|
||||
topLayout1->addWidget(m_urlSsiHubLabel);
|
||||
topLayout1->addWidget(m_urlSsiHubLineEdit);
|
||||
topLayout2->addWidget(m_urlLabel);
|
||||
topLayout2->addWidget(m_urlLineEdit);
|
||||
QHBoxLayout *topLayout = new QHBoxLayout;
|
||||
topLayout->addLayout(topLayout1);
|
||||
topLayout->addLayout(topLayout2);
|
||||
|
||||
|
||||
QHBoxLayout *ssihubLayout = new QHBoxLayout;
|
||||
ssihubLayout->addWidget(m_fieldListView);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addLayout(ssihubLayout);
|
||||
mainLayout->addWidget(m_statusLabel);
|
||||
mainLayout->addWidget(utmAreaGropBox);
|
||||
mainLayout->addWidget(wellTypeGropBox);
|
||||
mainLayout->addWidget(m_buttonBox);
|
||||
mainLayout->addWidget(m_wellPathsView);
|
||||
mainLayout->addWidget(buttonBox1);
|
||||
setLayout(mainLayout);
|
||||
|
||||
setWindowTitle(tr("Import Well Paths"));
|
||||
m_urlLineEdit->setFocus();
|
||||
|
||||
refreshButtonStatus();
|
||||
|
||||
resize(600, 400);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::startRequest(QUrl url)
|
||||
{
|
||||
m_reply = m_networkAccessManager.get(QNetworkRequest(url));
|
||||
connect(m_reply, SIGNAL(finished()),
|
||||
this, SLOT(httpFinished()));
|
||||
connect(m_reply, SIGNAL(readyRead()),
|
||||
this, SLOT(httpReadyRead()));
|
||||
connect(m_reply, SIGNAL(downloadProgress(qint64,qint64)),
|
||||
this, SLOT(updateDataReadProgress(qint64,qint64)));
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::cancelDownload()
|
||||
{
|
||||
m_statusLabel->setText(tr("Download canceled."));
|
||||
m_httpRequestAborted = true;
|
||||
m_reply->abort();
|
||||
|
||||
refreshButtonStatus();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::httpFinished()
|
||||
{
|
||||
if (m_httpRequestAborted) {
|
||||
if (m_file) {
|
||||
m_file->close();
|
||||
m_file->remove();
|
||||
delete m_file;
|
||||
m_file = 0;
|
||||
}
|
||||
m_reply->deleteLater();
|
||||
m_progressDialog->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_wellPathRequestQueue.size() == 0)
|
||||
{
|
||||
m_progressDialog->hide();
|
||||
}
|
||||
|
||||
m_file->flush();
|
||||
m_file->close();
|
||||
|
||||
|
||||
QVariant redirectionTarget = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
||||
if (m_reply->error()) {
|
||||
m_file->remove();
|
||||
QMessageBox::information(this, tr("HTTP"),
|
||||
tr("Download failed: %1.")
|
||||
.arg(m_reply->errorString()));
|
||||
} else if (!redirectionTarget.isNull()) {
|
||||
QUrl newUrl = m_url.resolved(redirectionTarget.toUrl());
|
||||
if (QMessageBox::question(this, tr("HTTP"),
|
||||
tr("Redirect to %1 ?").arg(newUrl.toString()),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
m_url = newUrl;
|
||||
m_reply->deleteLater();
|
||||
m_file->open(QIODevice::WriteOnly);
|
||||
m_file->resize(0);
|
||||
startRequest(m_url);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
m_statusLabel->setText(tr("Downloaded data to %1.").arg(m_destinationFolder));
|
||||
}
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELL_PATH)
|
||||
{
|
||||
QString singleWellPathFilePath = m_file->fileName();
|
||||
|
||||
QFile file(singleWellPathFilePath);
|
||||
if (file.open(QFile::ReadOnly))
|
||||
{
|
||||
QString singleWellPathContent = file.readAll();
|
||||
|
||||
// Strip leading and trailing []
|
||||
|
||||
if (singleWellPathContent.indexOf('{') > 0)
|
||||
{
|
||||
singleWellPathContent = singleWellPathContent.right(singleWellPathContent.size() - singleWellPathContent.indexOf('{'));
|
||||
}
|
||||
|
||||
if (singleWellPathContent[singleWellPathContent.size() - 1] == ']')
|
||||
{
|
||||
singleWellPathContent = singleWellPathContent.left(singleWellPathContent.size() - 1);
|
||||
}
|
||||
|
||||
QString wellPathName = getValue("name", singleWellPathContent);
|
||||
if (!singleWellPathContent.isEmpty() && !wellPathName.isEmpty())
|
||||
{
|
||||
int currentRowCount = m_wellPathsModel->rowCount();
|
||||
m_wellPathsModel->setRowCount(m_wellPathsModel->rowCount() + 1);
|
||||
|
||||
QModelIndex miName = m_wellPathsModel->index(currentRowCount, 0);
|
||||
m_wellPathsModel->setData(miName, wellPathName);
|
||||
|
||||
QModelIndex miFileName = m_wellPathsModel->index(currentRowCount, 1);
|
||||
m_wellPathsModel->setData(miFileName, singleWellPathFilePath);
|
||||
|
||||
|
||||
// Write out the content without leading/trailing []
|
||||
file.close();
|
||||
file.remove(singleWellPathFilePath);
|
||||
|
||||
if (file.open(QFile::WriteOnly))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
out << singleWellPathContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
refreshButtonStatus();
|
||||
|
||||
m_reply->deleteLater();
|
||||
m_reply = 0;
|
||||
delete m_file;
|
||||
m_file = 0;
|
||||
|
||||
if (m_currentDownloadState == DOWNLOAD_WELLS)
|
||||
{
|
||||
QStringList survey;
|
||||
QStringList plans;
|
||||
|
||||
getWellPathLinks(&survey, &plans);
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_UNDEFINED;
|
||||
|
||||
issueDownloadOfWellPaths(survey, plans);
|
||||
}
|
||||
else if (m_currentDownloadState == DOWNLOAD_FIELDS)
|
||||
{
|
||||
updateFieldsModel();
|
||||
m_currentDownloadState = DOWNLOAD_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
checkDownloadQueueAndIssueRequests();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::httpReadyRead()
|
||||
{
|
||||
// this slot gets called every time the QNetworkReply has new data.
|
||||
// We read all of its new data and write it into the file.
|
||||
// That way we use less RAM than when reading it at the finished()
|
||||
// signal of the QNetworkReply
|
||||
if (m_file)
|
||||
m_file->write(m_reply->readAll());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
if (m_httpRequestAborted)
|
||||
return;
|
||||
|
||||
m_progressDialog->setMaximum(totalBytes);
|
||||
m_progressDialog->setValue(bytesRead);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::refreshButtonStatus()
|
||||
{
|
||||
if (m_fieldListView->selectionModel()->selectedIndexes().size() > 0)
|
||||
{
|
||||
m_downloadWellPathsButton->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_downloadWellPathsButton->setEnabled(false);
|
||||
}
|
||||
|
||||
m_downloadFieldsButton->setEnabled(!m_urlSsiHubLineEdit->text().isEmpty());
|
||||
|
||||
bool enableUtmEditors = m_filterWellsByUtmArea->isChecked();
|
||||
|
||||
m_northLineEdit->setEnabled(enableUtmEditors);
|
||||
m_southLineEdit->setEnabled(enableUtmEditors);
|
||||
m_eastLineEdit->setEnabled(enableUtmEditors);
|
||||
m_westLineEdit->setEnabled(enableUtmEditors);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator)
|
||||
{
|
||||
QDialog dlg;
|
||||
Ui::Dialog ui;
|
||||
ui.setupUi(&dlg);
|
||||
dlg.adjustSize();
|
||||
ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(m_url.host()));
|
||||
|
||||
// Did the URL have information? Fill the UI
|
||||
// This is only relevant if the URL-supplied credentials were wrong
|
||||
ui.userEdit->setText(m_url.userName());
|
||||
ui.passwordEdit->setText(m_url.password());
|
||||
ui.passwordEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
authenticator->setUser(ui.userEdit->text());
|
||||
authenticator->setPassword(ui.passwordEdit->text());
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void FetchWellPathsDialog::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
|
||||
{
|
||||
QString errorString;
|
||||
foreach (const QSslError &error, errors) {
|
||||
if (!errorString.isEmpty())
|
||||
errorString += ", ";
|
||||
errorString += error.errorString();
|
||||
}
|
||||
|
||||
if (QMessageBox::warning(this, tr("HTTP"),
|
||||
tr("One or more SSL errors has occurred: %1").arg(errorString),
|
||||
QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
|
||||
m_reply->ignoreSslErrors();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::setUrl(const QString& httpAddress)
|
||||
{
|
||||
m_urlLineEdit->setText(httpAddress);
|
||||
|
||||
m_url = httpAddress;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::downloadWellPaths()
|
||||
{
|
||||
QString fileName = jsonWellsFilePath();
|
||||
if (QFile::exists(fileName))
|
||||
{
|
||||
QFile::remove(fileName);
|
||||
|
||||
m_wellPathsModel->clear();
|
||||
m_wellPathsModel->setColumnCount(2);
|
||||
}
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_WELLS;
|
||||
|
||||
QModelIndex mi = m_fieldListView->currentIndex();
|
||||
QString fieldName = m_fieldModel->data(mi, Qt::DisplayRole).toString();
|
||||
|
||||
QString completeUrlText = m_urlSsiHubLineEdit->text() + "/resinsight/projects/" + fieldName;
|
||||
|
||||
if (m_filterWellsByUtmArea->isChecked())
|
||||
{
|
||||
completeUrlText += "/wellsInArea";
|
||||
|
||||
int north = m_northLineEdit->text().toInt();
|
||||
int south = m_southLineEdit->text().toInt();
|
||||
int east = m_eastLineEdit->text().toInt();
|
||||
int west = m_westLineEdit->text().toInt();
|
||||
|
||||
completeUrlText += QString("?north=%1").arg(north);
|
||||
completeUrlText += QString("&south=%1").arg(south);
|
||||
completeUrlText += QString("&east=%1").arg(east);
|
||||
completeUrlText += QString("&west=%1").arg(west);
|
||||
completeUrlText += QString("&utmZone=32S&format=json");
|
||||
}
|
||||
else
|
||||
{
|
||||
completeUrlText += "/wells";
|
||||
}
|
||||
|
||||
issueHttpRequestToFile(completeUrlText, fileName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::downloadFields()
|
||||
{
|
||||
QString wellFileName = jsonWellsFilePath();
|
||||
if (QFile::exists(wellFileName))
|
||||
{
|
||||
QFile::remove(wellFileName);
|
||||
|
||||
m_wellPathsModel->clear();
|
||||
m_wellPathsModel->setColumnCount(2);
|
||||
}
|
||||
|
||||
QString completeUrlText = m_urlSsiHubLineEdit->text() + "/resinsight/projects";
|
||||
QString destinationFileName = jsonFieldsFilePath();
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_FIELDS;
|
||||
issueHttpRequestToFile(completeUrlText, destinationFileName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::setDestinationFolder(const QString& folder)
|
||||
{
|
||||
m_destinationFolder = folder;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::setSsiHubUrl(const QString& httpAddress)
|
||||
{
|
||||
QString validAddress(httpAddress);
|
||||
if (validAddress.endsWith('/'))
|
||||
{
|
||||
validAddress = validAddress.left(validAddress.size() - 1);
|
||||
}
|
||||
|
||||
m_urlSsiHubLineEdit->setText(validAddress);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
|
||||
{
|
||||
QModelIndexList idxList = selected.indexes();
|
||||
|
||||
if (idxList.size() == 1)
|
||||
{
|
||||
QString fieldName = m_fieldModel->data(idxList[0], Qt::DisplayRole).toString();
|
||||
|
||||
QString completeUrlText = m_urlSsiHubLineEdit->text() + "/resinsight/projects/" + fieldName;
|
||||
setUrl(completeUrlText);
|
||||
}
|
||||
else
|
||||
{
|
||||
setUrl("");
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::updateFieldsModel()
|
||||
{
|
||||
QString fileName = jsonFieldsFilePath();
|
||||
|
||||
if (QFile::exists(fileName))
|
||||
{
|
||||
JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(fileName);
|
||||
|
||||
QStringList regions;
|
||||
QStringList fields;
|
||||
QStringList edmIds;
|
||||
QMapIterator<QString, QVariant> it(jsonMap);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
|
||||
QString key = it.key();
|
||||
if (key[0].isDigit())
|
||||
{
|
||||
QMap<QString, QVariant> fieldMap = it.value().toMap();
|
||||
|
||||
regions.push_back(fieldMap["region"].toString());
|
||||
fields.push_back(fieldMap["name"].toString());
|
||||
edmIds.push_back(fieldMap["edmId"].toString());
|
||||
}
|
||||
}
|
||||
|
||||
m_fieldModel->setStringList(fields);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString FetchWellPathsDialog::jsonFieldsFilePath()
|
||||
{
|
||||
return m_destinationFolder + "/fields.json";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString FetchWellPathsDialog::jsonWellsFilePath()
|
||||
{
|
||||
return m_destinationFolder + "/wellpaths.json";
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString FetchWellPathsDialog::jsonWellsInArea()
|
||||
{
|
||||
return m_destinationFolder + "/wellsInArea.json";
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList FetchWellPathsDialog::downloadedJsonWellPathFiles()
|
||||
{
|
||||
QStringList fileNames;
|
||||
|
||||
for (int i = 0; i < m_wellPathsModel->rowCount(); i++)
|
||||
{
|
||||
QModelIndex mi = m_wellPathsModel->index(i, 1);
|
||||
fileNames.push_back(m_wellPathsModel->data(mi).toString());
|
||||
}
|
||||
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::showEvent(QShowEvent* event)
|
||||
{
|
||||
refreshButtonStatus();
|
||||
|
||||
QDialog::showEvent(event);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Search for string, and find the associated value inside the next quoted string
|
||||
// text content : "A" : "B"
|
||||
// A search for key "A" returns B
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString FetchWellPathsDialog::getValue(const QString& key, const QString& stringContent)
|
||||
{
|
||||
QString quotedKey = "\"" + key + "\"";
|
||||
|
||||
int pos = stringContent.indexOf(quotedKey);
|
||||
if (pos >=0)
|
||||
{
|
||||
int valueStartPos = stringContent.indexOf("\"", pos + quotedKey.size());
|
||||
int valueEndPos = stringContent.indexOf("\"", valueStartPos + 1);
|
||||
|
||||
if (valueStartPos >= 0 && valueEndPos > valueStartPos)
|
||||
{
|
||||
return stringContent.mid(valueStartPos + 1, valueEndPos - valueStartPos - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::setRegion(int north, int south, int east, int west)
|
||||
{
|
||||
m_northLineEdit->setText(QString::number(north));
|
||||
m_southLineEdit->setText(QString::number(south));
|
||||
m_eastLineEdit->setText(QString::number(east));
|
||||
m_westLineEdit->setText(QString::number(west));
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::issueHttpRequestToFile(QString completeUrlText, QString destinationFileName)
|
||||
{
|
||||
setUrl(completeUrlText);
|
||||
m_file = new QFile(destinationFileName);
|
||||
if (!m_file->open(QIODevice::WriteOnly)) {
|
||||
QMessageBox::information(this, tr("HTTP"),
|
||||
tr("Unable to save the file %1: %2.")
|
||||
.arg(destinationFileName).arg(m_file->errorString()));
|
||||
delete m_file;
|
||||
m_file = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
m_progressDialog->setWindowTitle(tr("HTTP"));
|
||||
m_progressDialog->setLabelText(tr("Downloading %1.").arg(destinationFileName));
|
||||
|
||||
// schedule the request
|
||||
m_httpRequestAborted = false;
|
||||
startRequest(m_url);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::getWellPathLinks(QStringList* surveyLinks, QStringList* planLinks)
|
||||
{
|
||||
QStringList entities;
|
||||
|
||||
QString filename = jsonWellsFilePath();
|
||||
if (QFile::exists(filename))
|
||||
{
|
||||
JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filename);
|
||||
|
||||
QMapIterator<QString, QVariant> it(jsonMap);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
|
||||
QString key = it.key();
|
||||
if (key[0].isDigit())
|
||||
{
|
||||
QMap<QString, QVariant> slotMap = it.value().toMap();
|
||||
QMap<QString, QVariant> linkMap = slotMap["links"].toMap();
|
||||
|
||||
QString surveyLink = linkMap["survey"].toString();
|
||||
surveyLinks->push_back(surveyLink);
|
||||
|
||||
QString planLink = linkMap["plans"].toString();
|
||||
planLinks->push_back(planLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::issueDownloadOfWellPaths(const QStringList& surveyLinks, const QStringList& planLinks)
|
||||
{
|
||||
m_wellPathRequestQueue.clear();
|
||||
|
||||
if (m_importSurveyCheckBox->isChecked())
|
||||
{
|
||||
m_wellPathRequestQueue += surveyLinks;
|
||||
}
|
||||
|
||||
if (m_importPlansCheckBox->isChecked())
|
||||
{
|
||||
m_wellPathRequestQueue += planLinks;
|
||||
}
|
||||
|
||||
checkDownloadQueueAndIssueRequests();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::checkDownloadQueueAndIssueRequests()
|
||||
{
|
||||
if (m_wellPathRequestQueue.size() > 0)
|
||||
{
|
||||
QString link = m_wellPathRequestQueue[0];
|
||||
m_wellPathRequestQueue.pop_front();
|
||||
|
||||
QString completeUrlText = m_urlSsiHubLineEdit->text() + link;
|
||||
|
||||
QUuid guid = QUuid::createUuid();
|
||||
QString singleWellPathFilePath = m_destinationFolder + QString("/wellpath_%1.json").arg(guid);
|
||||
|
||||
m_currentDownloadState = DOWNLOAD_WELL_PATH;
|
||||
issueHttpRequestToFile(completeUrlText, singleWellPathFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void FetchWellPathsDialog::requestFieldData(QStringList& regions, QStringList& fields, QStringList& edmIds)
|
||||
{
|
||||
downloadFields();
|
||||
|
||||
QString fileName = jsonFieldsFilePath();
|
||||
|
||||
if (QFile::exists(fileName))
|
||||
{
|
||||
JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(fileName);
|
||||
|
||||
QStringList regions;
|
||||
QStringList fields;
|
||||
QStringList edmIds;
|
||||
QMapIterator<QString, QVariant> it(jsonMap);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
|
||||
QString key = it.key();
|
||||
if (key[0].isDigit())
|
||||
{
|
||||
QMap<QString, QVariant> fieldMap = it.value().toMap();
|
||||
|
||||
regions.push_back(fieldMap["region"].toString());
|
||||
fields.push_back(fieldMap["name"].toString());
|
||||
edmIds.push_back(fieldMap["edmId"].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace ssihub
|
||||
|
||||
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QUrl>
|
||||
|
||||
#include <QItemSelection>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDialogButtonBox;
|
||||
class QFile;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QProgressDialog;
|
||||
class QPushButton;
|
||||
class QSslError;
|
||||
class QAuthenticator;
|
||||
class QNetworkReply;
|
||||
class QStringListModel;
|
||||
class QListView;
|
||||
class QStandardItemModel;
|
||||
class QCheckBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ssihub {
|
||||
|
||||
|
||||
class FetchWellPathsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum DownloadState{ DOWNLOAD_FIELDS, DOWNLOAD_WELLS, DOWNLOAD_WELL_PATH, DOWNLOAD_UNDEFINED};
|
||||
|
||||
public:
|
||||
FetchWellPathsDialog(QWidget *parent = 0);
|
||||
|
||||
void setSsiHubUrl(const QString& httpAddress);
|
||||
void setDestinationFolder(const QString& folder);
|
||||
void setRegion(int north, int south, int east, int west);
|
||||
|
||||
QStringList downloadedJsonWellPathFiles();
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
|
||||
public:
|
||||
void startRequest(QUrl url);
|
||||
void setUrl(const QString& httpAddress);
|
||||
|
||||
QString jsonFieldsFilePath();
|
||||
QString jsonWellsFilePath();
|
||||
QString jsonWellsInArea();
|
||||
|
||||
void updateFieldsModel();
|
||||
|
||||
QString getValue(const QString& key, const QString& stringContent);
|
||||
|
||||
void getWellPathLinks(QStringList* surveyLinks, QStringList* planLinks);
|
||||
void issueDownloadOfWellPaths(const QStringList& surveyLinks, const QStringList& planLinks);
|
||||
|
||||
void requestFieldData(QStringList& regions, QStringList& fields, QStringList& edmIds);
|
||||
|
||||
signals:
|
||||
void signalFieldsDownloaded();
|
||||
|
||||
|
||||
private slots:
|
||||
void downloadWellPaths();
|
||||
void downloadFields();
|
||||
void checkDownloadQueueAndIssueRequests();
|
||||
|
||||
void issueHttpRequestToFile( QString completeUrlText, QString fieldsFileName );
|
||||
void cancelDownload();
|
||||
void httpFinished();
|
||||
|
||||
void httpReadyRead();
|
||||
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
void refreshButtonStatus();
|
||||
void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *);
|
||||
|
||||
void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
|
||||
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
QLabel* m_statusLabel;
|
||||
QLabel* m_urlLabel;
|
||||
QLineEdit* m_urlLineEdit;
|
||||
QLabel* m_urlSsiHubLabel;
|
||||
QLineEdit* m_urlSsiHubLineEdit;
|
||||
|
||||
QPushButton* m_downloadFieldsButton;
|
||||
QListView* m_fieldListView;
|
||||
|
||||
QListView* m_wellPathsView;
|
||||
QStandardItemModel* m_wellPathsModel;
|
||||
|
||||
|
||||
QCheckBox* m_filterWellsByUtmArea;
|
||||
QLineEdit* m_northLineEdit;
|
||||
QLineEdit* m_southLineEdit;
|
||||
QLineEdit* m_eastLineEdit;
|
||||
QLineEdit* m_westLineEdit;
|
||||
|
||||
QCheckBox* m_importSurveyCheckBox;
|
||||
QCheckBox* m_importPlansCheckBox;
|
||||
|
||||
QProgressDialog* m_progressDialog;
|
||||
QPushButton* m_downloadWellPathsButton;
|
||||
QDialogButtonBox* m_buttonBox;
|
||||
|
||||
QUrl m_url;
|
||||
QNetworkAccessManager m_networkAccessManager;
|
||||
QNetworkReply* m_reply;
|
||||
QFile* m_file;
|
||||
bool m_httpRequestAborted;
|
||||
|
||||
|
||||
QString m_destinationFolder;
|
||||
QStringListModel* m_fieldModel;
|
||||
|
||||
QStringList m_wellPathRequestQueue;
|
||||
|
||||
DownloadState m_currentDownloadState;
|
||||
};
|
||||
|
||||
} // namespace ssihub
|
||||
@@ -1,93 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ssihubInterface.h"
|
||||
#include "ssihubDialog.h"
|
||||
#include "ssihubWebServiceInterface.h"
|
||||
|
||||
#include <math.h>
|
||||
#include "RiuWellImportWizard.h"
|
||||
|
||||
namespace ssihub {
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Interface::Interface()
|
||||
{
|
||||
m_north = HUGE_VAL;
|
||||
m_south = HUGE_VAL;
|
||||
m_east = HUGE_VAL;
|
||||
m_west = HUGE_VAL;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Interface::setWebServiceAddress(const QString wsAdress)
|
||||
{
|
||||
m_webServiceAddress = wsAdress;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Interface::setJsonDestinationFolder(const QString folder)
|
||||
{
|
||||
m_jsonDestinationFolder = folder;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Interface::setRegion(int north, int south, int east, int west)
|
||||
{
|
||||
m_east = east;
|
||||
m_west = west;
|
||||
m_north = north;
|
||||
m_south = south;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList Interface::jsonWellPaths()
|
||||
{
|
||||
/*
|
||||
RuiWellImportWizard::showImportWizard(m_webServiceAddress, m_jsonDestinationFolder);
|
||||
|
||||
FetchWellPathsDialog fetchWellPaths;
|
||||
fetchWellPaths.setSsiHubUrl(m_webServiceAddress);
|
||||
fetchWellPaths.setDestinationFolder(m_jsonDestinationFolder);
|
||||
fetchWellPaths.setRegion(m_north, m_south, m_east, m_west);
|
||||
|
||||
QStringList importedWellPathFiles;
|
||||
if (fetchWellPaths.exec() == QDialog::Accepted)
|
||||
{
|
||||
importedWellPathFiles = fetchWellPaths.downloadedJsonWellPathFiles();
|
||||
}
|
||||
|
||||
return importedWellPathFiles;
|
||||
*/
|
||||
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
}; // namespace ssihub
|
||||
@@ -1,48 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
namespace ssihub {
|
||||
|
||||
class Interface
|
||||
{
|
||||
public:
|
||||
Interface();
|
||||
|
||||
void setWebServiceAddress(const QString wsAdress);
|
||||
void setJsonDestinationFolder(const QString folder);
|
||||
void setRegion(int north, int south, int east, int west);
|
||||
|
||||
QStringList jsonWellPaths();
|
||||
|
||||
private:
|
||||
QString m_webServiceAddress;
|
||||
QString m_jsonDestinationFolder;
|
||||
|
||||
int m_east;
|
||||
int m_west;
|
||||
int m_north;
|
||||
int m_south;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ssihubWebServiceInterface.h"
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QStringList>
|
||||
#include "ssihubDialog.h"
|
||||
//#include <QObject>
|
||||
|
||||
|
||||
namespace ssihub {
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
WebServiceInterface::WebServiceInterface(QObject *parent /*= 0*/)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_networkManager = new QNetworkAccessManager(this);
|
||||
//connect(m_openProjectAction, SIGNAL(triggered()), SLOT(slotOpenProject()));
|
||||
|
||||
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onResult(QNetworkReply*)));
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
WebServiceInterface::~WebServiceInterface()
|
||||
{
|
||||
//if (m_networkManager) delete m_networkManager;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void WebServiceInterface::setUrl(const QString& url)
|
||||
{
|
||||
m_httpAddress = url;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList WebServiceInterface::fetchData(const QString& method, const QMap<QString, QVariant>& arguments)
|
||||
{
|
||||
|
||||
FetchWellPathsDialog httpWin;
|
||||
httpWin.setSsiHubUrl(m_httpAddress);
|
||||
httpWin.exec();
|
||||
|
||||
|
||||
/*
|
||||
QNetworkReply* reply = m_networkManager->get(QNetworkRequest(QUrl("http://qt.nokia.com")));
|
||||
|
||||
while (!reply->isFinished())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
QString data = (QString) reply->readAll();
|
||||
|
||||
/*
|
||||
QUrl url(m_httpAddress);
|
||||
// url.setPath(QString("%1%2").arg(url.path()).arg(method));
|
||||
//
|
||||
// foreach(QString param, arguments.keys()) {
|
||||
// url.addQueryItem(param, arguments[param].toString());
|
||||
// }
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setUrl(url);
|
||||
|
||||
QNetworkReply* reply = m_networkManager->get(request);
|
||||
|
||||
QString data = (QString) reply->readAll();
|
||||
|
||||
|
||||
QStringList fileContent;
|
||||
fileContent.push_back(data);
|
||||
|
||||
return fileContent;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
QStringList strings;
|
||||
return strings;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void WebServiceInterface::onResult(QNetworkReply* reply)
|
||||
{
|
||||
if (reply->error() != QNetworkReply::NoError)
|
||||
return; // ...only in a blog post
|
||||
|
||||
QString data = (QString) reply->readAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}; // namespace ssihub
|
||||
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QMap>
|
||||
|
||||
class QNetworkReply;
|
||||
class QNetworkAccessManager;
|
||||
|
||||
namespace ssihub {
|
||||
|
||||
class WebServiceInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WebServiceInterface(QObject *parent = 0);
|
||||
~WebServiceInterface();
|
||||
|
||||
void setUrl(const QString& url);
|
||||
|
||||
QStringList fetchData(const QString& method, const QMap<QString, QVariant>& arguments);
|
||||
|
||||
|
||||
private slots:
|
||||
void onResult(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
QString m_httpAddress;
|
||||
|
||||
QNetworkAccessManager* m_networkManager;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user