Browse Source

fixed todos

pull/2/head
Skycoder42 7 years ago
parent
commit
75f13956bb
  1. 6
      src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro
  2. 6
      src/imports/mvvmdatasyncquick/plugins.qmltypes
  3. 4
      src/imports/mvvmdatasyncquick/qtmvvmdatasyncquick_plugin.cpp
  4. 6
      src/imports/mvvmdatasyncquick/testdummy.cpp
  5. 17
      src/imports/mvvmdatasyncquick/testdummy.h
  6. 6
      src/imports/mvvmquick/androidfilechooser.cpp
  7. 6
      src/imports/mvvmquick/qqmlquickpresenter.cpp
  8. 2
      src/mvvmcore/message.h
  9. 16
      src/mvvmdatasynccore/datasyncviewmodel.cpp
  10. 20
      src/mvvmdatasynccore/mvvmdatasynccore.pro
  11. 8
      src/mvvmdatasynccore/qpmx.json
  12. 12
      src/mvvmquick/quickpresenter.cpp

6
src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro

@ -7,12 +7,10 @@ DEFINES += "VERSION_MAJOR=$$MODULE_VERSION_MAJOR"
DEFINES += "VERSION_MINOR=$$MODULE_VERSION_MINOR" DEFINES += "VERSION_MINOR=$$MODULE_VERSION_MINOR"
HEADERS += \ HEADERS += \
qtmvvmdatasyncquick_plugin.h \ qtmvvmdatasyncquick_plugin.h
testdummy.h
SOURCES += \ SOURCES += \
qtmvvmdatasyncquick_plugin.cpp \ qtmvvmdatasyncquick_plugin.cpp
testdummy.cpp
QML_FILES += \ QML_FILES += \
SubButton.qml \ SubButton.qml \

6
src/imports/mvvmdatasyncquick/plugins.qmltypes

@ -18,12 +18,6 @@ Module {
"de.skycoder42.QtMvvm.DataSync.Core 1.0", "de.skycoder42.QtMvvm.DataSync.Core 1.0",
"de.skycoder42.QtMvvm.Quick 1.0" "de.skycoder42.QtMvvm.Quick 1.0"
] ]
Component {
name: "TestDummy"
prototype: "QObject"
exports: ["de.skycoder42.QtMvvm.DataSync.Quick/TestDummy 1.0"]
exportMetaObjectRevisions: [0]
}
Component { Component {
prototype: "QQuickPlatformFileDialog" prototype: "QQuickPlatformFileDialog"
name: "de.skycoder42.QtMvvm.Quick/FileDialog 1.0" name: "de.skycoder42.QtMvvm.Quick/FileDialog 1.0"

4
src/imports/mvvmdatasyncquick/qtmvvmdatasyncquick_plugin.cpp

@ -2,8 +2,6 @@
#include <QtQml> #include <QtQml>
#include "testdummy.h"
static void initResources() static void initResources()
{ {
#ifdef QT_STATIC #ifdef QT_STATIC
@ -22,7 +20,7 @@ void QtMvvmDataSyncQuickDeclarativeModule::registerTypes(const char *uri)
Q_ASSERT(qstrcmp(uri, "de.skycoder42.QtMvvm.DataSync.Quick") == 0); Q_ASSERT(qstrcmp(uri, "de.skycoder42.QtMvvm.DataSync.Quick") == 0);
//Version 1.0 //Version 1.0
qmlRegisterType<TestDummy>(uri, 1, 0, "TestDummy"); //no c++ types. plugin is only needed for the resources
// Check to make shure no module update is forgotten // Check to make shure no module update is forgotten
static_assert(VERSION_MAJOR == 1 && VERSION_MINOR == 0, "QML module version needs to be updated"); static_assert(VERSION_MAJOR == 1 && VERSION_MINOR == 0, "QML module version needs to be updated");

6
src/imports/mvvmdatasyncquick/testdummy.cpp

@ -1,6 +0,0 @@
#include "testdummy.h"
TestDummy::TestDummy(QObject *parent) : QObject(parent)
{
}

17
src/imports/mvvmdatasyncquick/testdummy.h

@ -1,17 +0,0 @@
#ifndef TESTDUMMY_H
#define TESTDUMMY_H
#include <QObject>
class TestDummy : public QObject //TODO remove again
{
Q_OBJECT
public:
explicit TestDummy(QObject *parent = nullptr);
signals:
public slots:
};
#endif // TESTDUMMY_H

6
src/imports/mvvmquick/androidfilechooser.cpp

@ -247,7 +247,7 @@ void AndroidFileChooser::setupBasic(QAndroidJniObject &intent, bool asTree)
static const auto EXTRA_MIME_TYPES = QAndroidJniObject::getStaticObjectField<jstring>("android/content/Intent", "EXTRA_MIME_TYPES"); static const auto EXTRA_MIME_TYPES = QAndroidJniObject::getStaticObjectField<jstring>("android/content/Intent", "EXTRA_MIME_TYPES");
static const auto EXTRA_INITIAL_URI = [](){ static const auto EXTRA_INITIAL_URI = [](){
if(QtAndroid::androidSdkVersion() >= 26) //Android Oreo if(QtAndroid::androidSdkVersion() >= 26) //Android Oreo
return QAndroidJniObject::getStaticObjectField<jstring>("android/content/Intent", "EXTRA_INITIAL_URI"); return QAndroidJniObject::getStaticObjectField<jstring>("android/provider/DocumentsContract", "EXTRA_INITIAL_URI");
else else
return QAndroidJniObject(); return QAndroidJniObject();
}(); }();
@ -264,7 +264,7 @@ void AndroidFileChooser::setupBasic(QAndroidJniObject &intent, bool asTree)
if(!_mimeTypes.isEmpty()) { if(!_mimeTypes.isEmpty()) {
QAndroidJniEnvironment env; QAndroidJniEnvironment env;
auto strClass = env->FindClass("java/lang/String"); auto strClass = env->FindClass("java/lang/String");
QAndroidJniObject strArray(env->NewObjectArray(_mimeTypes.size(), strClass, nullptr)); auto strArray = QAndroidJniObject::fromLocalRef(env->NewObjectArray(_mimeTypes.size(), strClass, nullptr));
for(auto i = 0; i < _mimeTypes.size(); i++) { for(auto i = 0; i < _mimeTypes.size(); i++) {
auto mimeStr = QAndroidJniObject::callStaticObjectMethod("android/content/Intent", "normalizeMimeType", auto mimeStr = QAndroidJniObject::callStaticObjectMethod("android/content/Intent", "normalizeMimeType",
"(Ljava/lang/String;)Ljava/lang/String;", "(Ljava/lang/String;)Ljava/lang/String;",
@ -298,7 +298,7 @@ void AndroidFileChooser::setupBasic(QAndroidJniObject &intent, bool asTree)
auto uri = QAndroidJniObject::callStaticObjectMethod("android/net/Uri", "parse", auto uri = QAndroidJniObject::callStaticObjectMethod("android/net/Uri", "parse",
"(Ljava/lang/String;)Landroid/net/Uri;", "(Ljava/lang/String;)Landroid/net/Uri;",
QAndroidJniObject::fromString(_folderUrl.toString()).object()); QAndroidJniObject::fromString(_folderUrl.toString()).object());
intent.callObjectMethod("putExtra", "(Ljava/lang/String;Z)Landroid/content/Intent;", intent.callObjectMethod("putExtra", "(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;",
EXTRA_INITIAL_URI.object(), uri.object()); EXTRA_INITIAL_URI.object(), uri.object());
} }
} }

6
src/imports/mvvmquick/qqmlquickpresenter.cpp

@ -157,11 +157,15 @@ void QQmlQuickPresenter::statusChanged(QQmlComponent::Status status)
break; break;
} }
case QQmlComponent::Error: case QQmlComponent::Error:
{
qmlWarning(this, component->errors()) << "Failed to load component"; qmlWarning(this, component->errors()) << "Failed to load component";
component->deleteLater(); component->deleteLater();
auto loadInfo = _loadCache.value(component);
std::get<0>(loadInfo)->deleteLater();
break; break;
}
default: default:
return; return; //not break. code after must not be executed in this case
} }
_loadCache.remove(component); _loadCache.remove(component);

2
src/mvvmcore/message.h

@ -125,7 +125,7 @@ public:
bool autoDelete() const; bool autoDelete() const;
//USE IN GUI ONLY //USE IN GUI ONLY
//TODO USE IN GUI ONLY in doc //TODO document USE IN GUI ONLY in doc
Q_INVOKABLE void setCloseTarget(QObject *closeObject, const QString &closeMethod); Q_INVOKABLE void setCloseTarget(QObject *closeObject, const QString &closeMethod);
Q_INVOKABLE void setCloseTarget(QObject *closeObject, const QMetaMethod &closeMethod); Q_INVOKABLE void setCloseTarget(QObject *closeObject, const QMetaMethod &closeMethod);
Q_INVOKABLE void complete(QtMvvm::MessageConfig::StandardButton result); Q_INVOKABLE void complete(QtMvvm::MessageConfig::StandardButton result);

16
src/mvvmdatasynccore/datasyncviewmodel.cpp

@ -15,6 +15,10 @@
#include <QtDataSync/SetupDoesNotExistException> #include <QtDataSync/SetupDoesNotExistException>
#ifdef Q_OS_ANDROID
#include <contentdevice.h>
#endif
#undef logDebug #undef logDebug
#undef logInfo #undef logInfo
#undef logWarning #undef logWarning
@ -133,7 +137,11 @@ void DataSyncViewModel::startImport()
getOpenFile(this, [this](QUrl url) { getOpenFile(this, [this](QUrl url) {
if(url.isValid()) { if(url.isValid()) {
QSharedPointer<QIODevice> device; QSharedPointer<QIODevice> device;
//TODO add support for android content device #ifdef Q_OS_ANDROID
if(url.scheme() == QStringLiteral("content"))
device.reset(new ContentDevice(url));
else
#endif
if(url.isLocalFile()) if(url.isLocalFile())
device.reset(new QFile(url.toLocalFile())); device.reset(new QFile(url.toLocalFile()));
else { else {
@ -382,7 +390,11 @@ void DataSyncViewModelPrivate::performExport(bool trusted, bool includeServer, c
getSaveFile(q, [this, trusted, includeServer, password](QUrl url) { getSaveFile(q, [this, trusted, includeServer, password](QUrl url) {
if(url.isValid()) { if(url.isValid()) {
QSharedPointer<QIODevice> device; QSharedPointer<QIODevice> device;
//TODO add support for android content device #ifdef Q_OS_ANDROID
if(url.scheme() == QStringLiteral("content"))
device.reset(new ContentDevice(url));
else
#endif
if(url.isLocalFile()) if(url.isLocalFile())
device.reset(new QFile(url.toLocalFile())); device.reset(new QFile(url.toLocalFile()));
else { else {

20
src/mvvmdatasynccore/mvvmdatasynccore.pro

@ -9,21 +9,21 @@ HEADERS += \
accountmodel.h \ accountmodel.h \
accountmodel_p.h \ accountmodel_p.h \
exportsetupviewmodel_p.h \ exportsetupviewmodel_p.h \
changeremoteviewmodel_p.h \ changeremoteviewmodel_p.h \
identityeditviewmodel_p.h \ identityeditviewmodel_p.h \
networkexchangeviewmodel.h \ networkexchangeviewmodel.h \
networkexchangeviewmodel_p.h \ networkexchangeviewmodel_p.h \
exchangedevicesmodel.h \ exchangedevicesmodel.h \
exchangedevicesmodel_p.h exchangedevicesmodel_p.h
SOURCES += \ SOURCES += \
datasyncviewmodel.cpp \ datasyncviewmodel.cpp \
accountmodel.cpp \ accountmodel.cpp \
exportsetupviewmodel.cpp \ exportsetupviewmodel.cpp \
changeremoteviewmodel.cpp \ changeremoteviewmodel.cpp \
identityeditviewmodel.cpp \ identityeditviewmodel.cpp \
networkexchangeviewmodel.cpp \ networkexchangeviewmodel.cpp \
exchangedevicesmodel.cpp exchangedevicesmodel.cpp
TRANSLATIONS += \ TRANSLATIONS += \
translations/qtmvvmdatasynccore_de.ts \ translations/qtmvvmdatasynccore_de.ts \

8
src/mvvmdatasynccore/qpmx.json

@ -1,5 +1,11 @@
{ {
"dependencies": [], "dependencies": [
{
"package": "de.skycoder42.android-contentdevice",
"provider": "qpm",
"version": "1.0.1"
}
],
"license": { "license": {
"file": "", "file": "",
"name": "" "name": ""

12
src/mvvmquick/quickpresenter.cpp

@ -55,16 +55,13 @@ void QuickPresenter::registerViewExplicitly(const QMetaObject *viewModelType, co
void QuickPresenter::present(QtMvvm::ViewModel *viewModel, const QVariantHash &params, QPointer<QtMvvm::ViewModel> parent) void QuickPresenter::present(QtMvvm::ViewModel *viewModel, const QVariantHash &params, QPointer<QtMvvm::ViewModel> parent)
{ {
auto url = findViewUrl(viewModel->metaObject());
if(!url.isValid())
throw PresenterException(QByteArrayLiteral("No Url to a QML View found for ") + viewModel->metaObject()->className());
if(d->qmlPresenter) { if(d->qmlPresenter) {
auto url = findViewUrl(viewModel->metaObject());
QMetaObject::invokeMethod(d->qmlPresenter, "present", QMetaObject::invokeMethod(d->qmlPresenter, "present",
Q_ARG(QtMvvm::ViewModel*, viewModel), Q_ARG(QtMvvm::ViewModel*, viewModel),
Q_ARG(QVariantHash, params), Q_ARG(QVariantHash, params),
Q_ARG(QUrl, url), Q_ARG(QUrl, url),
Q_ARG(QPointer<QtMvvm::ViewModel>, parent)); //TODO invoke with result? Q_ARG(QPointer<QtMvvm::ViewModel>, parent));
} else } else
throw PresenterException("QML presenter not ready - cannot present yet"); throw PresenterException("QML presenter not ready - cannot present yet");
} }
@ -74,7 +71,7 @@ void QuickPresenter::showDialog(const QtMvvm::MessageConfig &config, QtMvvm::Mes
if(d->qmlPresenter) { if(d->qmlPresenter) {
QMetaObject::invokeMethod(d->qmlPresenter, "showDialog", QMetaObject::invokeMethod(d->qmlPresenter, "showDialog",
Q_ARG(QtMvvm::MessageConfig, config), Q_ARG(QtMvvm::MessageConfig, config),
Q_ARG(QtMvvm::MessageResult*, result)); //TODO invoke with result? Q_ARG(QtMvvm::MessageResult*, result));
} else } else
throw PresenterException("QML presenter not ready - cannot present yet"); throw PresenterException("QML presenter not ready - cannot present yet");
} }
@ -125,7 +122,6 @@ QUrl QuickPresenter::findViewUrl(const QMetaObject *viewModelType)
QUrl resUrl; QUrl resUrl;
auto shortest = std::numeric_limits<int>::max(); auto shortest = std::numeric_limits<int>::max();
for(auto dir : qAsConst(d->searchDirs)) { for(auto dir : qAsConst(d->searchDirs)) {
logDebug() << QDir(dir).entryList();
QDir searchDir(dir, QDir searchDir(dir,
QStringLiteral("%1*.qml").arg(QString::fromLatin1(cName)), QStringLiteral("%1*.qml").arg(QString::fromLatin1(cName)),
QDir::NoSort, QDir::NoSort,
@ -155,7 +151,7 @@ QUrl QuickPresenter::findViewUrl(const QMetaObject *viewModelType)
currentMeta = currentMeta->superClass(); currentMeta = currentMeta->superClass();
} }
return QUrl(); throw PresenterException(QByteArrayLiteral("No Url to a QML View found for ") + viewModelType->className());
} }
int QuickPresenter::presentMethodIndex(const QMetaObject *presenterMetaObject, QObject *viewObject) int QuickPresenter::presentMethodIndex(const QMetaObject *presenterMetaObject, QObject *viewObject)

Loading…
Cancel
Save