diff --git a/qml/pages/NotePage.qml b/qml/pages/NotePage.qml index 32450af..dd7944c 100644 --- a/qml/pages/NotePage.qml +++ b/qml/pages/NotePage.qml @@ -37,17 +37,6 @@ Dialog { noteID = note.id parseContent() } - Connections { - target: api - onNoteChanged: { - console.log("Some note changed") - if (id === noteID) { - console.log("This note changed") - reloadContent() - } - else console.log("Other note changed") - } - } function reloadContent() { api.getNoteFromApi(note.id) diff --git a/qml/pages/NotesPage.qml b/qml/pages/NotesPage.qml index a6c983f..1fc6d4b 100644 --- a/qml/pages/NotesPage.qml +++ b/qml/pages/NotesPage.qml @@ -70,7 +70,7 @@ Page { anchors.bottomMargin: Theme.paddingMedium color: Theme.secondaryHighlightColor font.pixelSize: Theme.fontSizeSmall - text: account.username + "@" + account.server + text: account.username + "@" + account.server.toString().split("://")[1] } BusyIndicator { anchors.verticalCenter: searchField.verticalCenter diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 144c159..fc5d420 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -123,6 +123,7 @@ Page { onCurrentIndexChanged: { appSettings.autoSyncInterval = autoSyncIntervalRepeater.model[currentIndex] if (autoSyncIntervalRepeater.model[currentIndex] === 42 && theAnswer.enabled) { + console.log(theAnswer.body) theAnswer.publish() } } diff --git a/src/note.cpp b/src/note.cpp index 955e38f..680e144 100644 --- a/src/note.cpp +++ b/src/note.cpp @@ -4,32 +4,40 @@ Note::Note(QObject *parent) : QObject(parent) { m_id = -1; m_modified = 0; m_error = true; + connect(this, SIGNAL(idChanged(int)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(modifiedChanged(uint)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(titleChanged(QString)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(categoryChanged(QString)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(contentChanged(QString)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(favoriteChanged(bool)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(etagChanged(QString)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(errorChanged(bool)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(errorMessageChanged(QString)), this, SIGNAL(noteChanged())); + connect(this, SIGNAL(dateStringChanged(QString)), this, SIGNAL(noteChanged())); } Note::Note(const Note& note, QObject *parent) : QObject(parent) { - m_id = note.id(); - m_modified = note.modified(); - m_title = note.title(); - m_category = note.category(); - m_content = note.content(); - m_favorite = note.favorite(); - m_etag = note.etag(); - m_error = note.error(); - m_errorMessage = note.errorMessage(); - m_date = note.date(); + setId(note.id()); + setModified(note.modified()); + setTitle(note.title()); + setCategory(note.category()); + setContent(note.content()); + setFavorite(note.favorite()); + setEtag(note.etag()); + setError(note.error()); + setErrorMessage(note.errorMessage()); } Note& Note::operator=(const Note& note) { - m_id = note.id(); - m_modified = note.modified(); - m_title = note.title(); - m_category = note.category(); - m_content = note.content(); - m_favorite = note.favorite(); - m_etag = note.etag(); - m_error = note.error(); - m_errorMessage = note.errorMessage(); - m_date = note.date(); + setId(note.id()); + setModified(note.modified()); + setTitle(note.title()); + setCategory(note.category()); + setContent(note.content()); + setFavorite(note.favorite()); + setEtag(note.etag()); + setError(note.error()); + setErrorMessage(note.errorMessage()); return *this; } diff --git a/src/note.h b/src/note.h index fff92dc..da0b9bf 100644 --- a/src/note.h +++ b/src/note.h @@ -18,7 +18,7 @@ class Note : public QObject { Q_PROPERTY(QString etag READ etag WRITE setEtag NOTIFY etagChanged) Q_PROPERTY(bool error READ error WRITE setError NOTIFY errorChanged) Q_PROPERTY(QString errorMessage READ errorMessage WRITE setErrorMessage NOTIFY errorMessageChanged) - Q_PROPERTY(QString date READ date NOTIFY dateChanged) + Q_PROPERTY(QString dateString READ dateString NOTIFY dateStringChanged) public: Note(QObject *parent = NULL); @@ -33,30 +33,26 @@ public: QString etag() const { return m_etag; } bool error() const { return m_error; } QString errorMessage() const { return m_errorMessage; } - QString date() const { return m_date; } + QString dateString() const { + QDateTime date; + QString dateString; + date.setTime_t(m_modified); + qint64 diff = date.daysTo(QDateTime::currentDateTime()); + if (diff == 0) + dateString = tr("Today"); + else if (diff == 1) + dateString = tr("Yesterday"); + else if (diff < 7) + dateString = date.toLocalTime().toString("dddd"); + else if (date.toLocalTime().toString("yyyy") == QDateTime::currentDateTime().toString("yyyy")) + dateString = date.toLocalTime().toString("MMMM"); + else + dateString = date.toLocalTime().toString("MMMM yyyy"); + return dateString; + } void setId(int id) { if (id != m_id) { m_id = id; emit idChanged(id); } } - void setModified(uint modified) { - if (modified != m_modified) { - m_modified = modified; - QDateTime date; - QString newDate; - date.setTime_t(modified); - qint64 diff = date.daysTo(QDateTime::currentDateTime()); - if (diff == 0) - newDate = "Today"; - else if (diff == 1) - newDate = "Yesterday"; - else if (diff < 7) - newDate = date.toLocalTime().toString("dddd"); - else if (date.toLocalTime().toString("yyyy") == QDateTime::currentDateTime().toString("yyyy")) - newDate = date.toLocalTime().toString("MMMM"); - else - newDate = date.toLocalTime().toString("MMMM yyyy"); - if (newDate != m_date) { m_date = newDate; emit dateChanged(newDate); } - emit modifiedChanged(modified); - } - } + void setModified(uint modified) { if (modified != m_modified) { m_modified = modified; emit modifiedChanged(modified); emit dateStringChanged(dateString()); } } void setTitle(QString title) { if (title != m_title) { m_title = title; emit titleChanged(title); } } void setCategory(QString category) { if (category != m_category) { m_category = category; emit categoryChanged(category); } } void setContent(QString content) { if (content != m_content) { m_content = content; emit contentChanged(content); } } @@ -64,7 +60,6 @@ public: void setEtag(QString etag) { if (etag != m_etag) { m_etag = etag; emit etagChanged(etag); } } void setError(bool error) { if (error != m_error) { m_error = error; emit errorChanged(error); } } void setErrorMessage(QString errorMessage) { if (errorMessage != m_errorMessage) { m_errorMessage = errorMessage; emit errorMessageChanged(errorMessage); } } - void setDate(QString date) { if (date != m_date) { m_date = date; emit dateChanged(date); } } Note& operator=(const Note& note); bool operator==(const Note& note) const { @@ -116,7 +111,8 @@ signals: void etagChanged(QString etag); void errorChanged(bool error); void errorMessageChanged(QString errorMessage); - void dateChanged(QString date); + void dateStringChanged(QString date); + void noteChanged(); private: int m_id; @@ -128,7 +124,6 @@ private: QString m_etag; bool m_error; QString m_errorMessage; - QString m_date; }; Q_DECLARE_OPERATORS_FOR_FLAGS(Note::SearchAttributes) diff --git a/src/notesmodel.cpp b/src/notesmodel.cpp index 846b564..7bab35b 100644 --- a/src/notesmodel.cpp +++ b/src/notesmodel.cpp @@ -214,7 +214,7 @@ QHash NotesModel::roleNames() const { {NotesModel::EtagRole, "etag"}, {NotesModel::ErrorRole, "error"}, {NotesModel::ErrorMessageRole, "errorMessage"}, - {NotesModel::DateRole, "date"} + {NotesModel::DateStringRole, "date"} }; } @@ -265,7 +265,7 @@ QVariant NotesModel::data(const QModelIndex &index, int role) const { else if (role == EtagRole) return m_notes[index.row()].note->etag(); else if (role == ErrorRole) return m_notes[index.row()].note->error(); else if (role == ErrorMessageRole) return m_notes[index.row()].note->errorMessage(); - else if (role == DateRole) return m_notes[index.row()].note->date(); + else if (role == DateStringRole) return m_notes[index.row()].note->dateString(); return QVariant(); } @@ -285,7 +285,7 @@ bool NotesModel::setData(const QModelIndex &index, const QVariant &value, int ro else if (role == ModifiedRole && m_notes[index.row()].note->modified() != value.toUInt()) { m_notes[index.row()].note->setModified(value.toInt()); emit dataChanged(this->index(index.row()), this->index(index.row()), QVector { 1, role } ); // TODO remove when signals from Note are connected - emit dataChanged(this->index(index.row()), this->index(index.row()), QVector { 1, DateRole} ); // TODO remove when signals from Note are connected + emit dataChanged(this->index(index.row()), this->index(index.row()), QVector { 1, DateStringRole} ); // TODO remove when signals from Note are connected sort(); return true; } @@ -331,9 +331,9 @@ void NotesModel::sort() { emit layoutAboutToBeChanged(QList (), VerticalSortHint); for (int i = 0; i < m_notes.size(); i++) { if (m_favoritesOnTop && m_notes[i].note->favorite()) - favorites.insert(QString::number(m_notes[i].note->modified()), m_notes[i]); + favorites.insert(QString::number(std::numeric_limits::max() - m_notes[i].note->modified()), m_notes[i]); else - map.insert(QString::number(m_notes[i].note->modified()), m_notes[i]); + map.insert(QString::number(std::numeric_limits::max() - m_notes[i].note->modified()), m_notes[i]); } notes = favorites.values(); notes.append(map.values()); diff --git a/src/notesmodel.h b/src/notesmodel.h index d184d98..79267f9 100644 --- a/src/notesmodel.h +++ b/src/notesmodel.h @@ -50,7 +50,7 @@ public: EtagRole = Qt::UserRole + 7, ErrorRole = Qt::UserRole + 8, ErrorMessageRole = Qt::UserRole + 9, - DateRole = Qt::UserRole + 10 + DateStringRole = Qt::UserRole + 10 }; QHash roleNames() const; diff --git a/translations/harbour-nextcloudnotes-de.ts b/translations/harbour-nextcloudnotes-de.ts index f0f51e8..5ad36d2 100644 --- a/translations/harbour-nextcloudnotes-de.ts +++ b/translations/harbour-nextcloudnotes-de.ts @@ -163,19 +163,30 @@ MIT Lizenz + + Note + + Today + Heute + + + Yesterday + Gestern + + NoteDelegateModel Modified - Geändert + Geändert Delete - Löschen + Löschen Deleting note - + Lösche Notiz @@ -232,75 +243,75 @@ NotesPage Settings - Einstellungen + Einstellungen Add note - + Notiz hinzufügen Reload - Neu laden + Neu laden Updating... - Aktualisiere... + Aktualisiere... Last update - Zuletzt aktualisiert + Zuletzt aktualisiert never - noch nie + noch nie No account yet - + Noch kein Konto eingerichtet Got to the settings to add an account - + Gehe in die Einstellungen um ein Konto hinzuzufügen No notes yet - + Keine Notizen vorhanden Pull down to add a note - + Ziehe nach unten um eine Notiz zu erstellen No result - + Nichts gefunden Try another query - + Probiere eine andere Suche An error occurred - + Ein Fehler ist aufgetreten Open the settings to configure your Nextcloud accounts - + Gehe in die Einstellungen um deine Nextcloud Konten zu verwalten Nextcloud Notes - Nextcloud Notizen + Nextcloud Notizen Modified - Geändert + Geändert Delete - Löschen + Löschen Deleting note - + Lösche Notiz diff --git a/translations/harbour-nextcloudnotes-sv.ts b/translations/harbour-nextcloudnotes-sv.ts index 817bc03..eac464a 100644 --- a/translations/harbour-nextcloudnotes-sv.ts +++ b/translations/harbour-nextcloudnotes-sv.ts @@ -163,6 +163,17 @@ MIT License + + Note + + Today + + + + Yesterday + + + NoteDelegateModel diff --git a/translations/harbour-nextcloudnotes.ts b/translations/harbour-nextcloudnotes.ts index 17a93ef..825b365 100644 --- a/translations/harbour-nextcloudnotes.ts +++ b/translations/harbour-nextcloudnotes.ts @@ -198,6 +198,19 @@ + + Note + + + Today + + + + + Yesterday + + + NoteDelegateModel @@ -219,52 +232,52 @@ NotePage - + Delete - + Reload - + Updating... - + Last update - + never - + Edit - + Notes - + No category - + Category - + Modified @@ -458,102 +471,102 @@ - + The Answer is 42 - + Congratulation you found the Answer to the Ultimate Question of Life, The Universe, and Everything! - + Appearance - + No sorting - + Favorites on top - + Show notes marked as favorite above the others - + Last edited - + Category - + Title alphabetically - + Sort notes by - + This will also change how the notes are grouped - + Show separator - + Show a separator line between the notes - + lines - + Number of lines in the preview - + Editing - + Monospaced font - + Use a monospeced font to edit a note - + Capital 'X' in checkboxes - + For interoperability with other apps such as Joplin