Show more debug messages on the console
This commit is contained in:
parent
884a464a37
commit
34484748f5
8 changed files with 44 additions and 51 deletions
|
@ -29,9 +29,13 @@ ApplicationWindow
|
|||
property bool allowUnecrypted: account.value("allowUnecrypted", false, Boolean)
|
||||
property date update: value("update", "", Date)
|
||||
onServerChanged: notesApi.server = server
|
||||
onUsernameChanged: notesApi.username = username
|
||||
onUsernameChanged: {
|
||||
console.log("Username: " + username)
|
||||
notesApi.username = username
|
||||
}
|
||||
onPasswordChanged: notesApi.password = password
|
||||
onDoNotVerifySslChanged: notesApi.verifySsl = !doNotVerifySsl
|
||||
onNameChanged: console.log("Using account: " + name)
|
||||
}
|
||||
|
||||
// General settings of the app
|
||||
|
@ -50,7 +54,6 @@ ApplicationWindow
|
|||
property bool useCapitalX: value("useCapitalX", false, Boolean)
|
||||
|
||||
onCurrentAccountChanged: {
|
||||
//console.log("currentAccountChanged")
|
||||
notesModel.sourceModel.clear()
|
||||
account.path = "/apps/harbour-nextcloudnotes/accounts/" + currentAccount
|
||||
notesStore.account = currentAccount
|
||||
|
@ -154,22 +157,9 @@ ApplicationWindow
|
|||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: notesStore
|
||||
|
||||
onAccountChanged: {
|
||||
//console.log(notesStore.account)
|
||||
//notesStore.getAllNotes()
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: notesApi
|
||||
|
||||
onAccountChanged: {
|
||||
//console.log(notesStore.account)
|
||||
//notesApi.getAllNotes()
|
||||
}
|
||||
onNetworkAccessibleChanged: {
|
||||
console.log("Device is " + (accessible ? "online" : "offline"))
|
||||
accessible ? offlineNotification.close(Notification.Closed) : offlineNotification.publish()
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8afa1fff0e1de2481e0545be17a906e2a68bb4e2
|
||||
Subproject commit 483e51f7a624c94c95787a14cbf577c053f8076f
|
|
@ -1,6 +1,5 @@
|
|||
import QtQuick 2.2
|
||||
import Sailfish.Silica 1.0
|
||||
//import harbour.nextcloudnotes.notesmodel 1.0
|
||||
|
||||
Page {
|
||||
id: page
|
||||
|
|
|
@ -45,7 +45,7 @@ NotesApi::~NotesApi() {
|
|||
}
|
||||
|
||||
void NotesApi::setAccount(const QString &account) {
|
||||
//qDebug() << "Setting account: " << account;
|
||||
qDebug() << "Setting account: " << account;
|
||||
if (account != m_account) {
|
||||
m_account = account;
|
||||
// TODO reset the class
|
||||
|
@ -54,7 +54,7 @@ void NotesApi::setAccount(const QString &account) {
|
|||
}
|
||||
|
||||
void NotesApi::getAllNotes(Note::NoteField exclude) {
|
||||
//qDebug() << "Getting all notes";
|
||||
qDebug() << "Getting all notes";
|
||||
QUrl url = apiEndpointUrl(m_notesEndpoint);
|
||||
QStringList excludeFields;
|
||||
QList<Note::NoteField> noteFields = Note::noteFields();
|
||||
|
@ -77,7 +77,7 @@ void NotesApi::getAllNotes(Note::NoteField exclude) {
|
|||
}
|
||||
|
||||
void NotesApi::getNote(const int id, Note::NoteField exclude) {
|
||||
//qDebug() << "Getting note: " << id;
|
||||
qDebug() << "Getting note: " << id;
|
||||
QUrl url = apiEndpointUrl(m_notesEndpoint + QString("/%1").arg(id));
|
||||
QStringList excludeFields;
|
||||
QList<Note::NoteField> noteFields = Note::noteFields();
|
||||
|
@ -100,7 +100,7 @@ void NotesApi::getNote(const int id, Note::NoteField exclude) {
|
|||
}
|
||||
|
||||
void NotesApi::createNote(const Note ¬e) {
|
||||
//qDebug() << "Creating note: " << note.id();
|
||||
qDebug() << "Creating note";
|
||||
QUrl url = apiEndpointUrl(m_notesEndpoint);
|
||||
if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) {
|
||||
qDebug() << "POST" << url.toDisplayString();
|
||||
|
@ -111,9 +111,9 @@ void NotesApi::createNote(const Note ¬e) {
|
|||
}
|
||||
|
||||
void NotesApi::updateNote(const Note ¬e) {
|
||||
//qDebug() << "Updating note: " << note.id();
|
||||
qDebug() << "Updating note: " << note.id();
|
||||
QUrl url = apiEndpointUrl(m_notesEndpoint + QString("/%1").arg(note.id()));
|
||||
if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) {
|
||||
if (note.isValid() && url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) {
|
||||
qDebug() << "PUT" << url.toDisplayString();
|
||||
m_authenticatedRequest.setUrl(url);
|
||||
m_notesReplies << m_manager.put(m_authenticatedRequest, noteApiData(note));
|
||||
|
@ -122,7 +122,7 @@ void NotesApi::updateNote(const Note ¬e) {
|
|||
}
|
||||
|
||||
void NotesApi::deleteNote(const int id) {
|
||||
//qDebug() << "Deleting note: " << id;
|
||||
qDebug() << "Deleting note: " << id;
|
||||
QUrl url = apiEndpointUrl(m_notesEndpoint + QString("/%1").arg(id));
|
||||
if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) {
|
||||
qDebug() << "DELETE" << url.toDisplayString();
|
||||
|
|
|
@ -15,7 +15,7 @@ NotesProxyModel::~NotesProxyModel() {
|
|||
}
|
||||
|
||||
void NotesProxyModel::setFavoritesOnTop(bool favoritesOnTop) {
|
||||
//qDebug() << "Favorites on top:" << favoritesOnTop;
|
||||
qDebug() << "Favorites on top:" << favoritesOnTop;
|
||||
if (favoritesOnTop != m_favoritesOnTop) {
|
||||
m_favoritesOnTop = favoritesOnTop;
|
||||
emit favoritesOnTopChanged(m_favoritesOnTop);
|
||||
|
@ -38,7 +38,7 @@ bool NotesProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex
|
|||
}
|
||||
|
||||
void NotesProxyModel::sort() {
|
||||
invalidate();
|
||||
//invalidate();
|
||||
QSortFilterProxyModel::sort(0);
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,8 @@ NotesModel::~NotesModel() {
|
|||
clear();
|
||||
}
|
||||
|
||||
QVector<int> NotesModel::ids() const {
|
||||
QVector<int> ids;
|
||||
QList<int> NotesModel::ids() const {
|
||||
QList<int> ids;
|
||||
for (int i = 0; i < m_notes.size(); ++i) {
|
||||
ids.append(m_notes[i].id());
|
||||
}
|
||||
|
@ -59,22 +59,20 @@ QVector<int> NotesModel::ids() const {
|
|||
}
|
||||
|
||||
int NotesModel::insertNote(const Note ¬e) {
|
||||
//qDebug() << "Inserting note: " << note.id();
|
||||
qDebug() << "Inserting note: " << note.id();
|
||||
int position = m_notes.indexOf(note);
|
||||
if (position >= 0) {
|
||||
if (m_notes.at(position).equal(note)) {
|
||||
//qDebug() << "-- Note already present but unchanged.";
|
||||
qDebug() << "Note already present unchanged.";
|
||||
}
|
||||
else {
|
||||
//qDebug() << "-- Note already present, updating it.";
|
||||
qDebug() << "Note already present, updating it.";
|
||||
m_notes.replace(position, note);
|
||||
emit dataChanged(index(position), index(position));
|
||||
}
|
||||
}
|
||||
else {
|
||||
//if (note.id() < 0)
|
||||
// qDebug() << "-- Local only note!";
|
||||
//qDebug() << "-- New note, adding it";
|
||||
qDebug() << "New note, adding it";
|
||||
position = m_notes.size();
|
||||
beginInsertRows(QModelIndex(), position, position);
|
||||
m_notes.append(note);
|
||||
|
@ -85,7 +83,7 @@ int NotesModel::insertNote(const Note ¬e) {
|
|||
}
|
||||
|
||||
bool NotesModel::removeNote(const Note ¬e) {
|
||||
//qDebug() << "Removing note: " << note.id();
|
||||
qDebug() << "Removing note: " << note.id();
|
||||
int position = m_notes.indexOf(note);
|
||||
if (position >= 0 && position < m_notes.size()) {
|
||||
beginRemoveRows(QModelIndex(), position, position);
|
||||
|
@ -98,12 +96,12 @@ bool NotesModel::removeNote(const Note ¬e) {
|
|||
}
|
||||
|
||||
bool NotesModel::removeNote(int id) {
|
||||
//qDebug() << "Removing note: " << id;
|
||||
qDebug() << "Removing note: " << id;
|
||||
return removeNote(Note(QJsonObject{ {"id", id} } ));
|
||||
}
|
||||
|
||||
void NotesModel::clear() {
|
||||
//qDebug() << "Clearing model";
|
||||
qDebug() << "Clearing model";
|
||||
beginResetModel();
|
||||
m_notes.clear();
|
||||
endResetModel();
|
||||
|
|
|
@ -9,11 +9,12 @@
|
|||
|
||||
class NotesProxyModel : public QSortFilterProxyModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool favoritesOnTop READ favoritesOnTop WRITE setFavoritesOnTop NOTIFY favoritesOnTopChanged)
|
||||
|
||||
public:
|
||||
explicit NotesProxyModel(QObject *parent = 0);
|
||||
virtual ~NotesProxyModel();
|
||||
|
||||
Q_PROPERTY(bool favoritesOnTop READ favoritesOnTop WRITE setFavoritesOnTop NOTIFY favoritesOnTopChanged)
|
||||
bool favoritesOnTop() const { return m_favoritesOnTop; }
|
||||
void setFavoritesOnTop(bool favoritesOnTop);
|
||||
|
||||
|
@ -34,6 +35,9 @@ private:
|
|||
|
||||
class NotesModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QList<int> ids READ ids NOTIFY idsChanged)
|
||||
|
||||
public:
|
||||
explicit NotesModel(QObject *parent = 0);
|
||||
virtual ~NotesModel();
|
||||
|
@ -65,12 +69,11 @@ public slots:
|
|||
bool removeNote(const Note ¬e);
|
||||
bool removeNote(int id);
|
||||
Q_INVOKABLE void clear();
|
||||
|
||||
protected:
|
||||
QVector<int> ids() const;
|
||||
Q_INVOKABLE QList<int> ids() const;
|
||||
|
||||
signals:
|
||||
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int> ());
|
||||
void idsChanged(QList<int> ids);
|
||||
|
||||
private:
|
||||
QVector<Note> m_notes;
|
||||
|
|
|
@ -23,7 +23,7 @@ QString NotesStore::account() const {
|
|||
}
|
||||
|
||||
void NotesStore::setAccount(const QString& account) {
|
||||
//qDebug() << "Setting account: " << account;
|
||||
qDebug() << "Setting account: " << account;
|
||||
if (account != m_dir.path()) {
|
||||
if (m_dir != QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
|
||||
m_dir.cdUp();
|
||||
|
@ -40,7 +40,7 @@ void NotesStore::setAccount(const QString& account) {
|
|||
}
|
||||
|
||||
void NotesStore::getAllNotes(Note::NoteField exclude) {
|
||||
//qDebug() << "Getting all notes";
|
||||
qDebug() << "Getting all notes";
|
||||
QFileInfoList files = m_dir.entryInfoList();
|
||||
for (int i = 0; i < files.size(); ++i) {
|
||||
bool ok;
|
||||
|
@ -52,7 +52,7 @@ void NotesStore::getAllNotes(Note::NoteField exclude) {
|
|||
}
|
||||
|
||||
void NotesStore::getNote(const int id, Note::NoteField exclude) {
|
||||
//qDebug() << "Getting note: " << id;
|
||||
qDebug() << "Getting note: " << id;
|
||||
if (id >= 0) {
|
||||
Note note = readNoteFile(id, exclude);
|
||||
if (note.isValid())
|
||||
|
@ -61,7 +61,7 @@ void NotesStore::getNote(const int id, Note::NoteField exclude) {
|
|||
}
|
||||
|
||||
void NotesStore::createNote(const Note& note) {
|
||||
//qDebug() << "Creating note: " << note.id();
|
||||
qDebug() << "Creating note: " << note.id();
|
||||
if (!note.isValid()) {
|
||||
// TODO probably crate files with an '.json.<NUMBER>.new' extension
|
||||
qDebug() << "Creating notes without the server API is not supported yet!";
|
||||
|
@ -71,10 +71,13 @@ void NotesStore::createNote(const Note& note) {
|
|||
emit noteUpdated(note);
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "Note already exists";
|
||||
}
|
||||
}
|
||||
|
||||
void NotesStore::updateNote(const Note& note) {
|
||||
//qDebug() << "Updating note: " << note.id();
|
||||
qDebug() << "Updating note: " << note.id();
|
||||
if (note.isValid()) {
|
||||
Note file = readNoteFile(note.id());
|
||||
if (!file.equal(note) && note > file) {
|
||||
|
@ -86,7 +89,7 @@ void NotesStore::updateNote(const Note& note) {
|
|||
}
|
||||
|
||||
void NotesStore::deleteNote(const int id) {
|
||||
//qDebug() << "Deleting note: " << id;
|
||||
qDebug() << "Deleting note: " << id;
|
||||
if (removeNoteFile(id)) {
|
||||
emit noteDeleted(id);
|
||||
}
|
||||
|
|
|
@ -840,22 +840,22 @@ You can also use other markdown syntax inside them.</source>
|
|||
<context>
|
||||
<name>harbour-nextcloudnotes</name>
|
||||
<message>
|
||||
<location filename="../qml/harbour-nextcloudnotes.qml" line="122"/>
|
||||
<location filename="../qml/harbour-nextcloudnotes.qml" line="125"/>
|
||||
<source>Notes</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/harbour-nextcloudnotes.qml" line="123"/>
|
||||
<location filename="../qml/harbour-nextcloudnotes.qml" line="126"/>
|
||||
<source>Offline</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/harbour-nextcloudnotes.qml" line="124"/>
|
||||
<location filename="../qml/harbour-nextcloudnotes.qml" line="127"/>
|
||||
<source>Synced</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/harbour-nextcloudnotes.qml" line="131"/>
|
||||
<location filename="../qml/harbour-nextcloudnotes.qml" line="134"/>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in a new issue