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"
HEADERS += \
qtmvvmdatasyncquick_plugin.h \
testdummy.h
qtmvvmdatasyncquick_plugin.h
SOURCES += \
qtmvvmdatasyncquick_plugin.cpp \
testdummy.cpp
qtmvvmdatasyncquick_plugin.cpp
QML_FILES += \
SubButton.qml \

6
src/imports/mvvmdatasyncquick/plugins.qmltypes

@ -18,12 +18,6 @@ Module {
"de.skycoder42.QtMvvm.DataSync.Core 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 {
prototype: "QQuickPlatformFileDialog"
name: "de.skycoder42.QtMvvm.Quick/FileDialog 1.0"

4
src/imports/mvvmdatasyncquick/qtmvvmdatasyncquick_plugin.cpp

@ -2,8 +2,6 @@
#include <QtQml>
#include "testdummy.h"
static void initResources()
{
#ifdef QT_STATIC
@ -22,7 +20,7 @@ void QtMvvmDataSyncQuickDeclarativeModule::registerTypes(const char *uri)
Q_ASSERT(qstrcmp(uri, "de.skycoder42.QtMvvm.DataSync.Quick") == 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
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_INITIAL_URI = [](){
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
return QAndroidJniObject();
}();
@ -264,7 +264,7 @@ void AndroidFileChooser::setupBasic(QAndroidJniObject &intent, bool asTree)
if(!_mimeTypes.isEmpty()) {
QAndroidJniEnvironment env;
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++) {
auto mimeStr = QAndroidJniObject::callStaticObjectMethod("android/content/Intent", "normalizeMimeType",
"(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",
"(Ljava/lang/String;)Landroid/net/Uri;",
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());
}
}

6
src/imports/mvvmquick/qqmlquickpresenter.cpp

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

2
src/mvvmcore/message.h

@ -125,7 +125,7 @@ public:
bool autoDelete() const;
//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 QMetaMethod &closeMethod);
Q_INVOKABLE void complete(QtMvvm::MessageConfig::StandardButton result);

16
src/mvvmdatasynccore/datasyncviewmodel.cpp

@ -15,6 +15,10 @@
#include <QtDataSync/SetupDoesNotExistException>
#ifdef Q_OS_ANDROID
#include <contentdevice.h>
#endif
#undef logDebug
#undef logInfo
#undef logWarning
@ -133,7 +137,11 @@ void DataSyncViewModel::startImport()
getOpenFile(this, [this](QUrl url) {
if(url.isValid()) {
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())
device.reset(new QFile(url.toLocalFile()));
else {
@ -382,7 +390,11 @@ void DataSyncViewModelPrivate::performExport(bool trusted, bool includeServer, c
getSaveFile(q, [this, trusted, includeServer, password](QUrl url) {
if(url.isValid()) {
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())
device.reset(new QFile(url.toLocalFile()));
else {

20
src/mvvmdatasynccore/mvvmdatasynccore.pro

@ -9,21 +9,21 @@ HEADERS += \
accountmodel.h \
accountmodel_p.h \
exportsetupviewmodel_p.h \
changeremoteviewmodel_p.h \
identityeditviewmodel_p.h \
networkexchangeviewmodel.h \
networkexchangeviewmodel_p.h \
exchangedevicesmodel.h \
exchangedevicesmodel_p.h
changeremoteviewmodel_p.h \
identityeditviewmodel_p.h \
networkexchangeviewmodel.h \
networkexchangeviewmodel_p.h \
exchangedevicesmodel.h \
exchangedevicesmodel_p.h
SOURCES += \
datasyncviewmodel.cpp \
accountmodel.cpp \
exportsetupviewmodel.cpp \
changeremoteviewmodel.cpp \
identityeditviewmodel.cpp \
networkexchangeviewmodel.cpp \
exchangedevicesmodel.cpp
changeremoteviewmodel.cpp \
identityeditviewmodel.cpp \
networkexchangeviewmodel.cpp \
exchangedevicesmodel.cpp
TRANSLATIONS += \
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": {
"file": "",
"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)
{
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) {
auto url = findViewUrl(viewModel->metaObject());
QMetaObject::invokeMethod(d->qmlPresenter, "present",
Q_ARG(QtMvvm::ViewModel*, viewModel),
Q_ARG(QVariantHash, params),
Q_ARG(QUrl, url),
Q_ARG(QPointer<QtMvvm::ViewModel>, parent)); //TODO invoke with result?
Q_ARG(QPointer<QtMvvm::ViewModel>, parent));
} else
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) {
QMetaObject::invokeMethod(d->qmlPresenter, "showDialog",
Q_ARG(QtMvvm::MessageConfig, config),
Q_ARG(QtMvvm::MessageResult*, result)); //TODO invoke with result?
Q_ARG(QtMvvm::MessageResult*, result));
} else
throw PresenterException("QML presenter not ready - cannot present yet");
}
@ -125,7 +122,6 @@ QUrl QuickPresenter::findViewUrl(const QMetaObject *viewModelType)
QUrl resUrl;
auto shortest = std::numeric_limits<int>::max();
for(auto dir : qAsConst(d->searchDirs)) {
logDebug() << QDir(dir).entryList();
QDir searchDir(dir,
QStringLiteral("%1*.qml").arg(QString::fromLatin1(cName)),
QDir::NoSort,
@ -155,7 +151,7 @@ QUrl QuickPresenter::findViewUrl(const QMetaObject *viewModelType)
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)

Loading…
Cancel
Save