diff --git a/qml/harbour-nextcloudnotes.qml b/qml/harbour-nextcloudnotes.qml index 9aea9c0..16903dd 100644 --- a/qml/harbour-nextcloudnotes.qml +++ b/qml/harbour-nextcloudnotes.qml @@ -181,7 +181,13 @@ ApplicationWindow onNetworkAccessibleChanged: { console.log("Device is " + (accessible ? "online" : "offline")) - accessible ? offlineNotification.close(Notification.Closed) : offlineNotification.publish() + if (accessible) { + offlineNotification.close(Notification.Closed) + getAllNotes() + } + else { + offlineNotification.publish() + } } onNoteError: { apiErrorNotification.close() diff --git a/qml/pages/NotesPage.qml b/qml/pages/NotesPage.qml index c9e06c3..68265d0 100644 --- a/qml/pages/NotesPage.qml +++ b/qml/pages/NotesPage.qml @@ -155,7 +155,7 @@ Page { Label { id: categoryLabel anchors.centerIn: parent - text: category + text: categoryLabel.text.length > 0 ? category : "" color: note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor font.pixelSize: Theme.fontSizeExtraSmall } diff --git a/src/harbour-nextcloudnotes.cpp b/src/harbour-nextcloudnotes.cpp index 7bccc3d..4a781f8 100644 --- a/src/harbour-nextcloudnotes.cpp +++ b/src/harbour-nextcloudnotes.cpp @@ -31,16 +31,15 @@ int main(int argc, char *argv[]) NotesApi* notesApi = new NotesApi; //QObject::connect(notesApi, SIGNAL(allNotesReceived(QList)), notesModel, SLOT()); - QObject::connect(notesApi, SIGNAL(noteCreated(int,QJsonObject)), notesModel, SLOT(insertNote(int,QJsonObject))); - QObject::connect(notesApi, SIGNAL(noteUpdated(int,QJsonObject)), notesModel, SLOT(updateNote(int,QJsonObject))); - QObject::connect(notesApi, SIGNAL(noteDeleted(int)), notesModel, SLOT(removeNote(int))); + QObject::connect(notesApi, SIGNAL(noteCreated(int,QJsonObject)), notesModel, SLOT(insertNoteFromApi(int,QJsonObject))); + QObject::connect(notesApi, SIGNAL(noteUpdated(int,QJsonObject)), notesModel, SLOT(updateNoteFromApi(int,QJsonObject))); + QObject::connect(notesApi, SIGNAL(noteDeleted(int)), notesModel, SLOT(removeNoteFromApi(int))); - QObject::connect(notesApi, SIGNAL(noteCreated(int,QJsonObject)), notesStore, SLOT(insertNote(int,QJsonObject))); - QObject::connect(notesApi, SIGNAL(noteUpdated(int,QJsonObject)), notesStore, SLOT(updateNote(int,QJsonObject))); - QObject::connect(notesApi, SIGNAL(noteDeleted(int)), notesStore, SLOT(removeNote(int))); + //QObject::connect(notesApi, SIGNAL(noteUpdated(int,QJsonObject)), notesStore, SLOT(updateNote(int,QJsonObject))); + //QObject::connect(notesApi, SIGNAL(noteDeleted(int)), notesStore, SLOT(deleteNote(int))); - QObject::connect(notesStore, SIGNAL(noteUpdated(int,QJsonObject)), notesModel, SLOT(updateNote(int,QJsonObject))); - QObject::connect(notesStore, SIGNAL(noteDeleted(int)), notesModel, SLOT(removeNote(int))); + //QObject::connect(notesStore, SIGNAL(noteUpdated(int,QJsonObject)), notesModel, SLOT(updateNoteFromStore(int,QJsonObject))); + //QObject::connect(notesStore, SIGNAL(noteDeleted(int)), notesModel, SLOT(removeNoteFromStore(int))); QQuickView* view = SailfishApp::createView(); #ifdef QT_DEBUG diff --git a/src/notesmodel.cpp b/src/notesmodel.cpp index f0a6c59..33b54c9 100644 --- a/src/notesmodel.cpp +++ b/src/notesmodel.cpp @@ -139,6 +139,30 @@ void NotesModel::removeNote(const int id) { } } +void NotesModel::insertNoteFromApi(const int id, const QJsonObject ¬e) { + insertNote(id, note); +} + +void NotesModel::updateNoteFromApi(const int id, const QJsonObject ¬e) { + updateNote(id, note); +} + +void NotesModel::removeNoteFromApi(const int id) { + removeNote(id); +} + +void NotesModel::insertNoteFromStore(const int id, const QJsonObject ¬e) { + insertNote(id, note); +} + +void NotesModel::updateNoteFromStore(const int id, const QJsonObject ¬e) { + updateNote(id, note); +} + +void NotesModel::removeNoteFromStore(const int id) { + removeNote(id); +} + void NotesModel::clear() { qDebug() << "Clearing model"; beginResetModel(); diff --git a/src/notesmodel.h b/src/notesmodel.h index e053bd1..e30486b 100644 --- a/src/notesmodel.h +++ b/src/notesmodel.h @@ -69,6 +69,12 @@ public slots: Q_INVOKABLE void insertNote(const int id, const QJsonObject& note); Q_INVOKABLE void updateNote(const int id, const QJsonObject& note); Q_INVOKABLE void removeNote(const int id); + Q_INVOKABLE void insertNoteFromApi(const int id, const QJsonObject& note); + Q_INVOKABLE void updateNoteFromApi(const int id, const QJsonObject& note); + Q_INVOKABLE void removeNoteFromApi(const int id); + Q_INVOKABLE void insertNoteFromStore(const int id, const QJsonObject& note); + Q_INVOKABLE void updateNoteFromStore(const int id, const QJsonObject& note); + Q_INVOKABLE void removeNoteFromStore(const int id); Q_INVOKABLE void clear(); Q_INVOKABLE int indexOfNoteById(int id) const;