Skip to content

Commit

Permalink
WIP: add prototype code to project.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Mar 4, 2024
1 parent 409e816 commit dc3885d
Show file tree
Hide file tree
Showing 14 changed files with 586 additions and 426 deletions.
3 changes: 3 additions & 0 deletions ApplicationLibCode/Application/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand Down Expand Up @@ -74,6 +75,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.cpp
)

list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
Expand All @@ -87,6 +89,7 @@ set(QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaPlotWindowRedrawScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h
)

source_group(
Expand Down
52 changes: 52 additions & 0 deletions ApplicationLibCode/Application/RiaFileDownloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "RiaFileDownloader.h"

#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>

RiaFileDownloader::RiaFileDownloader( QObject* parent )
: QObject( parent )
{
}

void RiaFileDownloader::downloadFile( const QUrl& url, const QString& filePath )
{
QNetworkAccessManager* manager = new QNetworkAccessManager( this );
QNetworkRequest request( url );

qDebug() << "Downloading from:" << url;

QNetworkReply* reply = manager->get( request );

connect( reply,
&QNetworkReply::finished,
[=]()
{
if ( reply->error() )
{
qDebug() << "Download failed:" << reply->errorString();
emit done();
}
else
{
QFile file( filePath );
if ( file.open( QIODevice::WriteOnly ) )
{
file.write( reply->readAll() );
file.close();
qDebug() << "Download succeeded. File saved to" << filePath;
emit done();
}
else
{
qDebug() << "Failed to save file to" << filePath;
emit done();
}
}
reply->deleteLater();
manager->deleteLater();
} );
}
14 changes: 14 additions & 0 deletions ApplicationLibCode/Application/RiaFileDownloader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <QObject>
#include <QString>
#include <QUrl>

class RiaFileDownloader : public QObject
{
Q_OBJECT
public:
explicit RiaFileDownloader( QObject* parent = nullptr );

void downloadFile( const QUrl& url, const QString& filePath );
signals:
void done();
};
2 changes: 2 additions & 0 deletions ApplicationLibCode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if(Qt5Core_FOUND)
Gui
OpenGL
Network
NetworkAuth
Widgets
Xml
Concurrent
Expand All @@ -43,6 +44,7 @@ if(Qt5Core_FOUND)
Qt5::Core
Qt5::Gui
Qt5::Network
Qt5::NetworkAuth
Qt5::OpenGL
Qt5::Widgets
Qt5::Xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.h
${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand All @@ -14,14 +16,18 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.cpp
)

list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})

list(APPEND COMMAND_QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h
)

source_group(
Expand Down
Loading

0 comments on commit dc3885d

Please sign in to comment.