diff --git a/qml/pages/NotePage.qml b/qml/pages/NotePage.qml index 8826c3e..85f14f5 100644 --- a/qml/pages/NotePage.qml +++ b/qml/pages/NotePage.qml @@ -8,7 +8,7 @@ Dialog { property int id property var note - onIdChanged: note = notesModel.getNoteById(id) + onIdChanged: note = notesModel.note(id) onNoteChanged: { if (note["content"].split('\n')[0].indexOf(note["title"]) > 0) { dialogHeader.title = "" @@ -38,7 +38,7 @@ Dialog { } onStatusChanged: { if (status === PageStatus.Activating) { - notesModel.getNote(id) + notesModel.note(id) } } @@ -104,7 +104,7 @@ Dialog { MenuItem { text: enabled ? qsTr("Reload") : qsTr("Updating...") enabled: !notesApi.busy - onClicked: notesModel.getNote(note["id"]) + onClicked: notesModel.note(note["id"]) } /*MenuItem { text: qsTr("Edit") diff --git a/src/notesapi.cpp b/src/notesapi.cpp index dfefc68..afcde66 100644 --- a/src/notesapi.cpp +++ b/src/notesapi.cpp @@ -6,6 +6,8 @@ #include #include +QVersionNumber NotesApi::m_capabilities_implementedApiVersion = QVersionNumber(1, 1); + NotesApi::NotesApi(const QString statusEndpoint, const QString loginEndpoint, const QString ocsEndpoint, const QString notesEndpoint, QObject *parent) : m_statusEndpoint(statusEndpoint), m_loginEndpoint(loginEndpoint), m_ocsEndpoint(ocsEndpoint), m_notesEndpoint(notesEndpoint) { @@ -16,6 +18,7 @@ NotesApi::NotesApi(const QString statusEndpoint, const QString loginEndpoint, co setNcStatusStatus(NextcloudStatus::NextcloudUnknown); setLoginStatus(LoginStatus::LoginUnknown); m_ncStatusStatus = NextcloudStatus::NextcloudUnknown; + m_capabilities_notesInstalled = false; m_status_installed = false; m_status_maintenance = false; m_status_needsDbUpgrade = false; @@ -507,11 +510,19 @@ bool NotesApi::updateCapabilities(const QJsonObject &capabilities) { QJsonObject capabilitiesObject = capabilitiesValue.toObject(); QJsonValue notesValue = capabilitiesObject.value("notes"); if (!notesValue.isUndefined() && notesValue.isObject()) { + if (!m_capabilities_notesInstalled) { + m_capabilities_notesInstalled = true; + emit notesAppInstalledChanged(m_capabilities_notesInstalled); + } QJsonObject notesObject = notesValue.toObject(); QJsonValue api_versionsValue = notesObject.value("api_versions"); if (!api_versionsValue.isUndefined() && api_versionsValue.isArray()) { QJsonArray api_versions = api_versionsValue.toArray(); - // TODO + m_capabilities_notesApiVersions.clear(); + for (int i = 0; i < api_versions.size(); ++i) { + m_capabilities_notesApiVersions << api_versions.at(i).toString(); + } + emit notesAppApiVersionsChanged(m_capabilities_notesApiVersions); } } } diff --git a/src/notesapi.h b/src/notesapi.h index 8c513e8..2586dec 100644 --- a/src/notesapi.h +++ b/src/notesapi.h @@ -35,7 +35,7 @@ class NotesApi : public QObject Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged) Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) - // Status information + // Class status information Q_PROPERTY(bool urlValid READ urlValid NOTIFY urlValidChanged) Q_PROPERTY(bool networkAccessible READ networkAccessible NOTIFY networkAccessibleChanged) Q_PROPERTY(QDateTime lastSync READ lastSync NOTIFY lastSyncChanged) @@ -43,10 +43,9 @@ class NotesApi : public QObject // Nextcloud capabilities Q_PROPERTY(CapabilitiesStatus capabilitiesStatus READ capabilitiesStatus NOTIFY capabilitiesStatusChanged) - //Q_PROPERTY(bool notesAppInstalled READ notesAppInstalled NOTIFY notesAppInstalledChanged) - //Q_PROPERTY(QStringList notesAppApiVersions READ notesAppApiVersions NOTIFY notesAppApiVersionsChanged) - //Q_PROPERTY(QString notesAppApiMaxVersion READ notesAppApiMaxVersion NOTIFY notesAppApiMaxVersionChanged) - //Q_PROPERTY(QString notesAppApiMinVersion READ notesAppApiMinVersion NOTIFY notesAppApiMinVersionChanged) + Q_PROPERTY(bool notesAppInstalled READ notesAppInstalled NOTIFY notesAppInstalledChanged) + Q_PROPERTY(QStringList notesAppApiVersions READ notesAppApiVersions NOTIFY notesAppApiVersionsChanged) + Q_PROPERTY(QString notesAppApiUsedVersion READ notesAppApiUsedVersion NOTIFY notesAppApiUsedVersionChanged) // Nextcloud status (status.php) Q_PROPERTY(NextcloudStatus ncStatusStatus READ ncStatusStatus NOTIFY ncStatusStatusChanged) @@ -135,6 +134,9 @@ public: bool busy() const; CapabilitiesStatus capabilitiesStatus() const { return m_capabilitiesStatus; } + bool notesAppInstalled() const { return m_capabilities_notesInstalled; } + QStringList notesAppApiVersions() const { return m_capabilities_notesApiVersions; } + static QString notesAppApiUsedVersion() { return m_capabilities_implementedApiVersion.toString(); } NextcloudStatus ncStatusStatus() const { return m_ncStatusStatus; } bool statusInstalled() const { return m_status_installed; } @@ -195,6 +197,9 @@ signals: void busyChanged(bool busy); void capabilitiesStatusChanged(CapabilitiesStatus status); + void notesAppInstalledChanged(bool installed); + void notesAppApiVersionsChanged(QStringList versions); + void notesAppApiUsedVersionChanged(QString version); void ncStatusStatusChanged(NextcloudStatus status); void statusInstalledChanged(bool installed); @@ -234,6 +239,9 @@ private: bool updateCapabilities(const QJsonObject & capabilities); CapabilitiesStatus m_capabilitiesStatus; void setCababilitiesStatus(CapabilitiesStatus status, bool *changed = NULL); + bool m_capabilities_notesInstalled; + static QVersionNumber m_capabilities_implementedApiVersion; + QStringList m_capabilities_notesApiVersions; // Nextcloud status.php const QString m_statusEndpoint; @@ -245,7 +253,6 @@ private: bool m_status_maintenance; bool m_status_needsDbUpgrade; QVersionNumber m_status_version; - //QString m_status_version; QString m_status_versionstring; QString m_status_edition; QString m_status_productname;