Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e68dc07
add future classes
tomasMizera Feb 18, 2021
62c3eef
address comments
tomasMizera Feb 19, 2021
b07c2d5
add API to list by names and requestId
tomasMizera Feb 18, 2021
3e95dee
address comments
tomasMizera Feb 19, 2021
2dd8024
merge projects onListProjectsFinished
tomasMizera Mar 9, 2021
c0ede01
polis list projects flow
tomasMizera Mar 16, 2021
bfff389
incorporate changes from previous pr
tomasMizera Mar 16, 2021
086de4e
remove models subfolder
tomasMizera Mar 16, 2021
169e9c3
move sync logic to cpp
tomasMizera Mar 17, 2021
859bd03
add several signals/slots
tomasMizera Mar 18, 2021
4613b93
LocalProjectManager revamp
tomasMizera Mar 18, 2021
e6e4221
MerginApi revamp
tomasMizera Mar 18, 2021
c402d8c
add local/remote projects
tomasMizera Mar 22, 2021
8442621
replace MerginProjectEntry with new structure
tomasMizera Mar 22, 2021
71ef485
implement model functions and slots
tomasMizera Mar 22, 2021
a881f39
add pagination
tomasMizera Mar 22, 2021
c43d72d
project status and remote error
tomasMizera Mar 22, 2021
0187537
Proxy models
tomasMizera Mar 23, 2021
5348e76
Make models instantiable from QML
tomasMizera Mar 24, 2021
ca479c5
refactor qml code
tomasMizera Mar 31, 2021
eb51a93
update c++ code according to qml refactor
tomasMizera Mar 31, 2021
7d91f1d
removed unused code
tomasMizera Mar 31, 2021
63fda47
rename symbols _future
tomasMizera Mar 31, 2021
0baef1c
remove more unused qml code
tomasMizera Mar 31, 2021
7d2f464
check all nit
tomasMizera Mar 31, 2021
5fc2c8f
revert description
tomasMizera Mar 31, 2021
b8fc78b
show only project name in created
tomasMizera Mar 31, 2021
5bbe531
address comments
tomasMizera Apr 6, 2021
3b67d69
fix tests and code accordingly (#1299)
tomasMizera Apr 7, 2021
3567b68
[Feature] Separate MerginAPI to core folder (#1295)
PeterPetrik Apr 9, 2021
39175a5
refresh project list on panel opened
tomasMizera Apr 9, 2021
8302341
bump versions to 0.9.3
tomasMizera Apr 9, 2021
e0c4c1b
clear created/shared models when user logs out
tomasMizera Apr 9, 2021
96e2d5d
remove last __merginapi qml call to list projects
tomasMizera Apr 9, 2021
1bd70b6
add ping mergin
tomasMizera Apr 9, 2021
3fac84b
add texts
tomasMizera Apr 9, 2021
889424d
redirections with user auth
tomasMizera Apr 9, 2021
46c01cb
move reload list to project list
tomasMizera Apr 9, 2021
2cd17bf
add download project dialog
tomasMizera Apr 9, 2021
21a0182
fill more menu dynamically
tomasMizera Apr 10, 2021
6c4b95c
handle storage permission
tomasMizera Apr 10, 2021
0baaff0
update no local projects screen
tomasMizera Apr 10, 2021
caf4103
show no projects only when model finished loading
tomasMizera Apr 10, 2021
9fafe02
move reload list to projectList
tomasMizera Apr 10, 2021
8440896
texts visibility order
tomasMizera Apr 10, 2021
64a1ce0
filtering on mergin projects
tomasMizera Apr 10, 2021
32e06ec
remove debug code
tomasMizera Apr 10, 2021
b437bf0
remove unused code
tomasMizera Apr 12, 2021
2c8c1f5
add code documentation
tomasMizera Apr 12, 2021
90ce606
nit, check all
tomasMizera Apr 12, 2021
ea24774
add diagrams
tomasMizera Apr 12, 2021
9241c28
resolve comments
tomasMizera Apr 12, 2021
f3fddc1
resolve QML comments
tomasMizera Apr 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
env:
MERGINSECRETS_DECRYPT_KEY: ${{ secrets.MERGINSECRETS_DECRYPT_KEY }}
run: |
openssl aes-256-cbc -k $MERGINSECRETS_DECRYPT_KEY -in app/merginsecrets.cpp.enc -out app/merginsecrets.cpp -d -md md5
openssl aes-256-cbc -k $MERGINSECRETS_DECRYPT_KEY -in core/merginsecrets.cpp.enc -out core/merginsecrets.cpp -d -md md5


- name: Extract GPS keystore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/autotests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
env:
MERGINSECRETS_DECRYPT_KEY: ${{ secrets.MERGINSECRETS_DECRYPT_KEY }}
run: |
cd input/app/
cd input/core/
/usr/local/opt/openssl@1.1/bin/openssl \
aes-256-cbc -d \
-in merginsecrets.cpp.enc \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
env:
MERGINSECRETS_DECRYPT_KEY: ${{ secrets.MERGINSECRETS_DECRYPT_KEY }}
run: |
cd app/
cd core/
/usr/local/opt/openssl@1.1/bin/openssl \
aes-256-cbc -d \
-in merginsecrets.cpp.enc \
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*.user
*build*/
app/config.pri
app/merginsecrets.cpp
core/merginsecrets.cpp
*.idea
test/temp_projects/
test/temp_extra_projects/
Expand Down
4 changes: 4 additions & 0 deletions app/input.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ include(linux.pri)
include(macx.pri)
include(win32.pri)
include(sources.pri)
include($$PWD/../core/core.pri)

INCLUDEPATH += $$PWD/../core

DEFINES += INPUT_APP
DEFINES += "QGIS_QUICK_DATA_PATH=$${QGIS_QUICK_DATA_PATH}"
CONFIG(debug, debug|release) {
DEFINES += "QGIS_PREFIX_PATH=$${QGIS_PREFIX_PATH}"
Expand Down
13 changes: 7 additions & 6 deletions app/inputhelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "merginsubscriptionstatus.h"
#include "merginapi.h"
#include "inpututils.h"
#include "coreutils.h"

#include "qgsquickutils.h"

Expand Down Expand Up @@ -91,7 +92,7 @@ QString InputHelp::fullLog( bool isHtml )
qint64 limit = 500000;
QVector<QString> retLines = logHeader( isHtml );

QFile file( InputUtils::logFilename() );
QFile file( CoreUtils::logFilename() );
if ( file.open( QIODevice::ReadOnly ) )
{
qint64 fileSize = file.size();
Expand All @@ -109,7 +110,7 @@ QString InputHelp::fullLog( bool isHtml )
}
else
{
retLines.push_back( QString( "Unable to open log file %1" ).arg( InputUtils::logFilename() ) );
retLines.push_back( QString( "Unable to open log file %1" ).arg( CoreUtils::logFilename() ) );
}

QString ret;
Expand All @@ -129,7 +130,7 @@ QString InputHelp::fullLog( bool isHtml )
QVector<QString> InputHelp::logHeader( bool isHtml )
{
QVector<QString> retLines;
retLines.push_back( QStringLiteral( "Input App: %1 - %2" ).arg( InputUtils::appVersion() ).arg( InputUtils::appPlatform() ) );
retLines.push_back( QStringLiteral( "Input App: %1 - %2" ).arg( CoreUtils::appVersion() ).arg( InputUtils::appPlatform() ) );
retLines.push_back( QStringLiteral( "System: %1" ).arg( QSysInfo::prettyProductName() ) );
retLines.push_back( QStringLiteral( "Mergin URL: %1" ).arg( mMerginApi->apiRoot() ) );
retLines.push_back( QStringLiteral( "Mergin User: %1" ).arg( mMerginApi->userAuth()->username() ) );
Expand Down Expand Up @@ -157,7 +158,7 @@ void InputHelp::submitReport()
// There is a limit of 1MB on the remote service, send less, let say half of that
QString log = fullLog( false );
QByteArray logArr = log.toUtf8();
QString app = QStringLiteral( "input-%1-%2" ).arg( InputUtils::appPlatform() ).arg( InputUtils::appVersion() );
QString app = QStringLiteral( "input-%1-%2" ).arg( InputUtils::appPlatform() ).arg( CoreUtils::appVersion() );
QString username = mMerginApi->userAuth()->username().toHtmlEscaped();
if ( username.isEmpty() )
username = "unknown";
Expand All @@ -183,12 +184,12 @@ void InputHelp::onSubmitReportReplyFinished()

if ( r->error() == QNetworkReply::NoError )
{
InputUtils::log( "submit report", "Report submitted!" );
CoreUtils::log( "submit report", "Report submitted!" );
emit mInputUtils->showNotification( tr( "Report submitted.%1Please contact us on%1%2" ).arg( "<br />" ).arg( helpDeskMail ) );
}
else
{
InputUtils::log( "submit report", QStringLiteral( "FAILED - %1" ).arg( r->errorString() ) );
CoreUtils::log( "submit report", QStringLiteral( "FAILED - %1" ).arg( r->errorString() ) );
emit mInputUtils->showNotification( tr( "Failed to submit report.%1Please check your internet connection." ).arg( "<br>" ) );
}
}
5 changes: 3 additions & 2 deletions app/inputprojutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QFileInfo>

#include "inpututils.h"
#include "coreutils.h"
#include "proj.h"
#include "qgsprojutils.h"
#include "inputhelp.h"
Expand All @@ -37,7 +38,7 @@ void InputProjUtils::logUser( const QString &message, bool &variable )
{
if ( !variable )
{
InputUtils::log( "InputPROJ", message );
CoreUtils::log( "InputPROJ", message );
variable = true;
}
}
Expand Down Expand Up @@ -151,7 +152,7 @@ void InputProjUtils::setProjDir( const QString &appBundleDir )
QFile projdb( projFilePath );
if ( !projdb.exists() )
{
InputUtils::log( QStringLiteral( "PROJ6 error" ), QStringLiteral( "The Input has failed to load PROJ6 database." ) + projFilePath );
CoreUtils::log( QStringLiteral( "PROJ6 error" ), QStringLiteral( "The Input has failed to load PROJ6 database." ) + projFilePath );
}
}

Expand Down
139 changes: 7 additions & 132 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "qgsquickutils.h"
#include "qgsquickmaptransform.h"
#include "inpututils.h"
#include "inputexpressionfunctions.h"
#include "coreutils.h"

#include <Qt>
#include <QDir>
Expand All @@ -29,7 +29,6 @@
#include <limits>
#include <math.h>

QString InputUtils::sLogFile = QStringLiteral();
static const QString DATE_TIME_FORMAT = QStringLiteral( "yyMMdd-hhmmss" );

InputUtils::InputUtils( QObject *parent ): QObject( parent )
Expand Down Expand Up @@ -306,26 +305,6 @@ QVector<double> InputUtils::extractGeometryCoordinates( const QgsQuickFeatureLay
return data;
}

void InputUtils::setLogFilename( const QString &value )
{
sLogFile = value;
}

QString InputUtils::logFilename()
{
return sLogFile;
}

bool InputUtils::createEmptyFile( const QString &filePath )
{
QFile newFile( filePath );
if ( !newFile.open( QIODevice::WriteOnly ) )
return false;

newFile.close();
return true;
}

QString InputUtils::filesToString( QList<MerginFile> files )
{
QStringList resultList;
Expand All @@ -336,12 +315,6 @@ QString InputUtils::filesToString( QList<MerginFile> files )
return resultList.join( ", " );
}

QString InputUtils::appInfo()
{
return QString( "%1/%2 (%3/%4)" ).arg( QCoreApplication::applicationName() ).arg( QCoreApplication::applicationVersion() )
.arg( QSysInfo::productType() ).arg( QSysInfo::productVersion() );
}

QString InputUtils::bytesToHumanSize( double bytes )
{
const int precision = 1;
Expand Down Expand Up @@ -399,43 +372,6 @@ void InputUtils::quitApp()
QCoreApplication::quit();
}

QString InputUtils::uuidWithoutBraces( const QUuid &uuid )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 11, 0 )
return uuid.toString( QUuid::WithoutBraces );
#else
QString str = uuid.toString();
str = str.mid( 1, str.length() - 2 ); // remove braces
return str;
#endif
}

QString InputUtils::localizedDateFromUTFString( QString timestamp )
{
if ( timestamp.isEmpty() )
return QString();

QDateTime dateTime = QDateTime::fromString( timestamp, Qt::ISODate );
if ( dateTime.isValid() )
{
return dateTime.date().toString( Qt::DefaultLocaleShortDate );
}
else
{
qDebug() << "Unable to convert UTF " << timestamp << " to QDateTime";
return QString();
}
}

QString InputUtils::appVersion()
{
QString version;
#ifdef INPUT_VERSION
version = STR( INPUT_VERSION );
#endif
return version;
}

QString InputUtils::appPlatform()
{
#if defined( ANDROID )
Expand All @@ -454,40 +390,6 @@ QString InputUtils::appPlatform()
return platform;
}


QString InputUtils::findUniquePath( const QString &path, bool isPathDir )
{
QFileInfo pathInfo( path );
if ( pathInfo.exists() )
{
int i = 0;
QFileInfo info( path + QString::number( i ) );
while ( info.exists() && ( info.isDir() || !isPathDir ) )
{
++i;
info.setFile( path + QString::number( i ) );
}
return path + QString::number( i );
}
else
{
return path;
}
}


QString InputUtils::createUniqueProjectDirectory( const QString &baseDataDir, const QString &projectName )
{
QString projectDirPath = findUniquePath( baseDataDir + "/" + projectName );
QDir projectDir( projectDirPath );
if ( !projectDir.exists() )
{
QDir dir( "" );
dir.mkdir( projectDirPath );
}
return projectDirPath;
}

void InputUtils::onQgsLogMessageReceived( const QString &message, const QString &tag, Qgis::MessageLevel level )
{
QString levelStr;
Expand All @@ -503,7 +405,7 @@ void InputUtils::onQgsLogMessageReceived( const QString &message, const QString
break;
}

log( "QGIS " + tag, levelStr + ": " + message );
CoreUtils::log( "QGIS " + tag, levelStr + ": " + message );
}

bool InputUtils::cpDir( const QString &srcPath, const QString &dstPath, bool onlyDiffable )
Expand All @@ -512,7 +414,7 @@ bool InputUtils::cpDir( const QString &srcPath, const QString &dstPath, bool onl
QDir parentDstDir( QFileInfo( dstPath ).path() );
if ( !parentDstDir.mkpath( dstPath ) )
{
log( "cpDir", QString( "Cannot make path %1" ).arg( dstPath ) );
CoreUtils::log( "cpDir", QString( "Cannot make path %1" ).arg( dstPath ) );
return false;
}

Expand All @@ -526,7 +428,7 @@ bool InputUtils::cpDir( const QString &srcPath, const QString &dstPath, bool onl
{
if ( !cpDir( srcItemPath, dstItemPath ) )
{
log( "cpDir", QString( "Cannot copy a dir from %1 to %2" ).arg( srcItemPath ).arg( dstItemPath ) );
CoreUtils::log( "cpDir", QString( "Cannot copy a dir from %1 to %2" ).arg( srcItemPath ).arg( dstItemPath ) );
result = false;
}
}
Expand All @@ -539,20 +441,20 @@ bool InputUtils::cpDir( const QString &srcPath, const QString &dstPath, bool onl
{
if ( !QFile::remove( dstItemPath ) )
{
log( "cpDir", QString( "Cannot remove a file from %1" ).arg( dstItemPath ) );
CoreUtils::log( "cpDir", QString( "Cannot remove a file from %1" ).arg( dstItemPath ) );
result = false;
}
if ( !QFile::copy( srcItemPath, dstItemPath ) )
{
log( "cpDir", QString( "Cannot overwrite a file %1 with %2" ).arg( dstItemPath ).arg( dstItemPath ) );
CoreUtils::log( "cpDir", QString( "Cannot overwrite a file %1 with %2" ).arg( dstItemPath ).arg( dstItemPath ) );
result = false;
}
}
QFile::setPermissions( dstItemPath, QFile::ReadUser | QFile::WriteUser | QFile::ReadOwner | QFile::WriteOwner );
}
else
{
log( "cpDir", QString( "Unhandled item %1 in cpDir" ).arg( info.filePath() ) );
CoreUtils::log( "cpDir", QString( "Unhandled item %1 in cpDir" ).arg( info.filePath() ) );
}
}
return result;
Expand All @@ -573,11 +475,6 @@ QString InputUtils::renameWithDateTime( const QString &srcPath, const QDateTime
return QString();
}

QString InputUtils::downloadInProgressFilePath( const QString &projectDir )
{
return projectDir + "/.mergin/.project.downloading";
}

void InputUtils::showNotification( const QString &message )
{
emit showNotificationRequested( message );
Expand All @@ -594,28 +491,6 @@ qreal InputUtils::groundSpeedFromSource( QgsQuickPositionKit *positionKit )
return 0;
}

void InputUtils::log( const QString &topic, const QString &info )
{
QString logFilePath;
QByteArray data;
data.append( QString( "%1 %2: %3\n" ).arg( QDateTime().currentDateTimeUtc().toString( Qt::ISODateWithMs ) ).arg( topic ).arg( info ) );

qDebug() << data;
appendLog( data, sLogFile );
}

void InputUtils::appendLog( const QByteArray &data, const QString &path )
{
QFile file( path );
if ( !file.open( QIODevice::Append ) )
{
return;
}

file.write( data );
file.close();
}

double InputUtils::ratherZeroThanNaN( double d )
{
return ( isnan( d ) ) ? 0.0 : d;
Expand Down
Loading