Browse Source

add wasm support

master
Skycoder42 6 years ago
parent
commit
bdeef06f95
No known key found for this signature in database GPG Key ID: 8E01AD9EF0578D2B
  1. 3
      .travis.yml
  2. 2
      examples/mvvmdatasynccore/DataSyncSampleCore/samplecoreapp.cpp
  3. 3
      src/imports/mvvmquick/settingsentrymodel.cpp
  4. 4
      src/mvvmcore/coreapp.cpp
  5. 16
      src/mvvmcore/exception.h
  6. 2
      src/mvvmcore/ipresenter.cpp
  7. 9
      src/mvvmcore/ipresenter.h
  8. 3
      src/mvvmcore/mvvmcore.pro
  9. 6
      src/mvvmcore/serviceregistry.cpp
  10. 16
      src/mvvmcore/serviceregistry.h
  11. 2
      src/mvvmcore/settingsconfigloader.cpp
  12. 5
      src/mvvmcore/settingsconfigloader_p.h
  13. 4
      src/mvvmcore/settingssetup.h
  14. 9
      src/mvvmdatasynccore/datasyncsettingsaccessor.cpp
  15. 10
      src/mvvmquick/quickpresenter.cpp
  16. 12
      src/mvvmwidgets/widgetspresenter.cpp

3
.travis.yml

@ -23,6 +23,9 @@ matrix:
- PLATFORM=gcc_64
- BUILD_DOC=true
- BUILD_EXAMPLES=true
- os: linux
env:
- PLATFORM=emscripten
- os: linux
env:
- PLATFORM=android_arm64_v8a

2
examples/mvvmdatasynccore/DataSyncSampleCore/samplecoreapp.cpp

@ -29,7 +29,7 @@ int SampleCoreApp::startApp(const QStringList &arguments)
.create();
show<SampleViewModel>();
return EXIT_SUCCESS;
} catch (QException &e) {
} catch (std::exception &e) {
qCritical() << e.what();
return EXIT_FAILURE;
}

3
src/imports/mvvmquick/settingsentrymodel.cpp

@ -168,8 +168,7 @@ SettingsEntryModel::EntryInfo::EntryInfo(SettingsElements::Entry entry, QUrl del
group(std::move(group))
{
static const QRegularExpression nameRegex(QStringLiteral("&(?!&)"),
QRegularExpression::DontCaptureOption |
QRegularExpression::OptimizeOnFirstUsageOption);
QRegularExpression::DontCaptureOption);
title.remove(nameRegex);
this->group.entries.clear();
}

4
src/mvvmcore/coreapp.cpp

@ -251,7 +251,7 @@ void CoreAppPrivate::showDialog(const MessageConfig &config, MessageResult *resu
try {
presenter->showDialog(config, result);
logDebug() << "Successfully presented dialog of type" << config.type();
} catch(QException &e) {
} catch(QTMVVM_EXCEPTION_BASE &e) {
logCritical() << "Failed to show dialog for type"
<< config.type() << ":" << config.subType()
<< "with error:"
@ -368,7 +368,7 @@ QPointer<ViewModel> CoreAppPrivate::showViewModelWithReturn(const QMetaObject *m
if(isSingle)
singleInstances.insert(metaObject, vm);
return vm;
} catch(QException &e) {
} catch(QTMVVM_EXCEPTION_BASE &e) {
logCritical() << "Failed to present viewmodel of type"
<< metaObject->className()
<< "with error:"

16
src/mvvmcore/exception.h

@ -0,0 +1,16 @@
#ifndef QTMVVM_EXCEPTION_H
#define QTMVVM_EXCEPTION_H
#include "QtMvvmCore/qtmvvmcore_global.h"
#if !defined(QT_NO_EXCEPTIONS) && QT_CONFIG(future)
#include <QtCore/QException>
#define QTMVVM_EXCEPTION_BASE QException
#define QTMVVM_EXCEPTION_OR override
#else
#include <exception>
#define QTMVVM_EXCEPTION_BASE std::exception
#define QTMVVM_EXCEPTION_OR
#endif
#endif // QTMVVM_EXCEPTION_H

2
src/mvvmcore/ipresenter.cpp

@ -19,7 +19,7 @@ void PresenterException::raise() const
throw (*this);
}
QException *PresenterException::clone() const
QTMVVM_EXCEPTION_BASE *PresenterException::clone() const
{
return new PresenterException(this);
}

9
src/mvvmcore/ipresenter.h

@ -1,16 +1,15 @@
#ifndef QTMVVM_IPRESENTER_H
#define QTMVVM_IPRESENTER_H
#include <QtCore/qexception.h>
#include "QtMvvmCore/qtmvvmcore_global.h"
#include "QtMvvmCore/viewmodel.h"
#include "QtMvvmCore/message.h"
#include "QtMvvmCore/exception.h"
namespace QtMvvm {
//! An exception to be thrown from the presenter if presenting fails
class Q_MVVMCORE_EXPORT PresenterException : public QException
class Q_MVVMCORE_EXPORT PresenterException : public QTMVVM_EXCEPTION_BASE
{
public:
//! Constructor with an error message
@ -20,9 +19,9 @@ public:
const char *what() const noexcept override;
//! @inherit{QException::raise}
void raise() const override;
virtual void raise() const QTMVVM_EXCEPTION_OR;
//! @inherit{QException::clone}
QException *clone() const override;
virtual QTMVVM_EXCEPTION_BASE *clone() const QTMVVM_EXCEPTION_OR;
protected:
//! @private

3
src/mvvmcore/mvvmcore.pro

@ -25,7 +25,8 @@ HEADERS += \
isettingsaccessor.h \
qsettingsaccessor.h \
settingsentry.h \
settingsconfigloader_p.h
settingsconfigloader_p.h \
exception.h
SOURCES += \
viewmodel.cpp \

6
src/mvvmcore/serviceregistry.cpp

@ -335,7 +335,7 @@ void ServiceExistsException::raise() const
throw (*this);
}
QException *ServiceExistsException::clone() const
QTMVVM_EXCEPTION_BASE *ServiceExistsException::clone() const
{
return new ServiceExistsException(this);
}
@ -360,7 +360,7 @@ void ServiceConstructionException::raise() const
throw (*this);
}
QException *ServiceConstructionException::clone() const
QTMVVM_EXCEPTION_BASE *ServiceConstructionException::clone() const
{
return new ServiceConstructionException(this);
}
@ -380,7 +380,7 @@ void ServiceDependencyException::raise() const
throw (*this);
}
QException *ServiceDependencyException::clone() const
QTMVVM_EXCEPTION_BASE *ServiceDependencyException::clone() const
{
return new ServiceDependencyException(this);
}

16
src/mvvmcore/serviceregistry.h

@ -5,10 +5,10 @@
#include <QtCore/qscopedpointer.h>
#include <QtCore/qvariant.h>
#include <QtCore/qexception.h>
#include "QtMvvmCore/qtmvvmcore_global.h"
#include "QtMvvmCore/injection.h"
#include "QtMvvmCore/exception.h"
namespace QtMvvm {
@ -108,7 +108,7 @@ private:
};
//! Is thrown if a service is beeing registered that is already registered
class Q_MVVMCORE_EXPORT ServiceExistsException : public QException
class Q_MVVMCORE_EXPORT ServiceExistsException : public QTMVVM_EXCEPTION_BASE
{
public:
//! @private
@ -118,9 +118,9 @@ public:
const char *what() const noexcept override;
//! @inherit{QException::raise}
void raise() const override;
virtual void raise() const QTMVVM_EXCEPTION_OR;
//! @inherit{QException::clone}
QException *clone() const override;
virtual QTMVVM_EXCEPTION_BASE *clone() const QTMVVM_EXCEPTION_OR;
protected:
//! @private
@ -131,7 +131,7 @@ protected:
};
//! Is thrown in case the construction of a service has failed
class Q_MVVMCORE_EXPORT ServiceConstructionException : public QException
class Q_MVVMCORE_EXPORT ServiceConstructionException : public QTMVVM_EXCEPTION_BASE
{
public:
//! @private
@ -141,9 +141,9 @@ public:
const char *what() const noexcept override;
//! @inherit{QException::raise}
void raise() const override;
virtual void raise() const QTMVVM_EXCEPTION_OR;
//! @inherit{QException::clone}
QException *clone() const override;
virtual QTMVVM_EXCEPTION_BASE *clone() const QTMVVM_EXCEPTION_OR;
protected:
//! @private
@ -161,7 +161,7 @@ public:
ServiceDependencyException(const QByteArray &iid);
void raise() const override;
QException *clone() const override;
QTMVVM_EXCEPTION_BASE *clone() const override;
protected:
//! @private

2
src/mvvmcore/settingsconfigloader.cpp

@ -226,7 +226,7 @@ void SettingsConfigException::raise() const
throw *this;
}
QException *SettingsConfigException::clone() const
QTMVVM_EXCEPTION_BASE *SettingsConfigException::clone() const
{
return new SettingsConfigException{_what};
}

5
src/mvvmcore/settingsconfigloader_p.h

@ -6,6 +6,7 @@
#include "qtmvvmcore_global.h"
#include "settingssetup.h"
#include "exception.h"
#include <settingsconfigimpl_p.h>
@ -57,8 +58,8 @@ public:
const char *what() const noexcept override;
void raise() const override;
QException *clone() const override;
void raise() const QTMVVM_EXCEPTION_OR;
QTMVVM_EXCEPTION_BASE *clone() const QTMVVM_EXCEPTION_OR;
private:
const QByteArray _what;

4
src/mvvmcore/settingssetup.h

@ -6,9 +6,9 @@
#include <QtCore/qurl.h>
#include <QtCore/qobject.h>
#include <QtCore/qfileselector.h>
#include <QtCore/qexception.h>
#include "QtMvvmCore/qtmvvmcore_global.h"
#include "QtMvvmCore/exception.h"
namespace QtMvvm {
@ -109,7 +109,7 @@ struct Setup
}
//! An exception throw in case loading a settings setup went wrong
class SettingsLoaderException : public QException {};
class SettingsLoaderException : public QTMVVM_EXCEPTION_BASE {};
//! An interface for a generic settings setup loader
class ISettingsSetupLoader

9
src/mvvmdatasynccore/datasyncsettingsaccessor.cpp

@ -1,6 +1,7 @@
#include "datasyncsettingsaccessor.h"
#include "datasyncsettingsaccessor_p.h"
#include <QtCore/QRegularExpression>
#include <QtMvvmCore/exception.h>
#undef logDebug
#undef logInfo
@ -40,7 +41,7 @@ bool DataSyncSettingsAccessor::contains(const QString &key) const
{
try {
return d->store->keys().contains(key);
} catch(QException &e) {
} catch (QTMVVM_EXCEPTION_BASE &e) {
logCritical() << "Failed to check if entry" << key << "exists with error:"
<< e.what();
return false;
@ -54,7 +55,7 @@ QVariant DataSyncSettingsAccessor::load(const QString &key, const QVariant &defa
} catch (QtDataSync::NoDataException &e) {
Q_UNUSED(e)
return defaultValue;
} catch (QException &e) {
} catch (QTMVVM_EXCEPTION_BASE &e) {
logCritical() << "Failed to load entry" << key << "from datasync settings with error:"
<< e.what();
return defaultValue;
@ -65,7 +66,7 @@ void DataSyncSettingsAccessor::save(const QString &key, const QVariant &value)
{
try {
d->store->save({key, value});
} catch (QException &e) {
} catch (QTMVVM_EXCEPTION_BASE &e) {
logCritical() << "Failed to save entry" << key << "to datasync settings with error:"
<< e.what();
}
@ -81,7 +82,7 @@ void DataSyncSettingsAccessor::remove(const QString &key)
for(const auto &rmKey : rmKeys)
d->store->remove(rmKey);
d->store->remove(key);
} catch (QException &e) {
} catch (QTMVVM_EXCEPTION_BASE &e) {
logCritical() << "Failed to remove entry" << key << "from datasync settings with error:"
<< e.what();
}

10
src/mvvmquick/quickpresenter.cpp

@ -7,21 +7,22 @@
#include <QtCore/QDirIterator>
#include <QtCore/QMetaMethod>
#include <QtMvvmCore/exception.h>
#include <QtQml/qqml.h>
#include <QtMvvmCore/private/qtmvvm_logging_p.h>
#include <qurlvalidator.h>
namespace {
void qtMvvmQuickInit()
static void qtMvvmQuickInit()
{
qmlRegisterType<QUrlValidator>("de.skycoder42.QtMvvm.Quick.Private", 1, 0, "UrlValidator");
QtMvvm::ServiceRegistry::instance()->registerObject<QtMvvm::InputViewFactory>(QtMvvm::ServiceRegistry::DestroyOnAppDestroy, true);
QtMvvm::ServiceRegistry::instance()->registerInterface<QtMvvm::IPresenter, QtMvvm::QuickPresenter>(QtMvvm::ServiceRegistry::DestroyOnAppDestroy, true);
}
void initResources()
static void initResources()
{
#ifdef QT_STATIC
qtMvvmQuickInit();
@ -29,7 +30,6 @@ void initResources()
#endif
}
}
Q_COREAPP_STARTUP_FUNCTION(qtMvvmQuickInit)
using namespace QtMvvm;
@ -223,7 +223,7 @@ QuickPresenter *QuickPresenterPrivate::currentPresenter()
"Cannot register views if the current presenter does not extend QtMvvm::QuickPresenter");
#endif
return static_cast<QuickPresenter*>(ServiceRegistry::instance()->service<IPresenter>());
} catch(QException &e) {
} catch (QTMVVM_EXCEPTION_BASE &e) {
qFatal("%s", e.what());
}
}

12
src/mvvmwidgets/widgetspresenter.cpp

@ -22,28 +22,26 @@
#include <QtWidgets/QColorDialog>
#include <QtMvvmCore/CoreApp>
#include <QtMvvmCore/exception.h>
#include <QtMvvmCore/private/qtmvvm_logging_p.h>
#include <dialogmaster.h>
#include <qurlvalidator.h>
namespace {
void qtMvvmWidgetsInit()
static void qtMvvmWidgetsInit()
{
QtMvvm::ServiceRegistry::instance()->registerObject<QtMvvm::InputWidgetFactory>(QtMvvm::ServiceRegistry::DestroyOnAppDestroy, true);
QtMvvm::ServiceRegistry::instance()->registerInterface<QtMvvm::IPresenter, QtMvvm::WidgetsPresenter>(QtMvvm::ServiceRegistry::DestroyOnAppDestroy, true);
}
void initResources()
static void initResources()
{
#ifdef QT_STATIC
qtMvvmWidgetsInit();
Q_INIT_RESOURCE(qtmvvmsettingswidgets_module);
Q_INIT_RESOURCE(qtmvvmwidgets_module);
#endif
}
}
Q_COREAPP_STARTUP_FUNCTION(qtMvvmWidgetsInit)
using namespace QtMvvm;
@ -508,7 +506,7 @@ WidgetsPresenter *WidgetsPresenterPrivate::currentPresenter()
"Cannot register widgets if the current presenter does not extend QtMvvm::WidgetsPresenter");
#endif
return static_cast<WidgetsPresenter*>(ServiceRegistry::instance()->service<IPresenter>());
} catch(QException &e) {
} catch (QTMVVM_EXCEPTION_BASE &e) {
qFatal("%s", e.what());
}
}

Loading…
Cancel
Save