Write notes to local files for upcoming offline mode
This commit is contained in:
parent
f7bc0ed9b8
commit
385cdc4cca
2 changed files with 7 additions and 4 deletions
|
@ -136,10 +136,8 @@ void NotesApi::setPath(QString path) {
|
|||
void NotesApi::setDataFile(QString dataFile) {
|
||||
if (dataFile != m_jsonFile.fileName()) {
|
||||
m_jsonFile.close();
|
||||
if (!dataFile.isEmpty()) {
|
||||
if (!dataFile.isEmpty())
|
||||
m_jsonFile.setFileName(dataFile);
|
||||
m_jsonFile.open(QIODevice::ReadWrite | QIODevice::Text); // | QIODevice::Unbuffered
|
||||
}
|
||||
emit dataFileChanged(m_jsonFile.fileName());
|
||||
//qDebug() << m_jsonFile.fileName();
|
||||
}
|
||||
|
@ -259,5 +257,9 @@ void NotesApi::sslError(QNetworkReply *reply, const QList<QSslError> &errors) {
|
|||
}
|
||||
|
||||
void NotesApi::saveToFile(QModelIndex, QModelIndex, QVector<int>) {
|
||||
qDebug() << "Should write the data now to a file" << m_jsonFile.fileName();
|
||||
if (m_jsonFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
|
||||
qDebug() << "Writing data to file" << m_jsonFile.fileName();
|
||||
m_jsonFile.write(mp_model->toJsonDocument().toJson());
|
||||
m_jsonFile.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ bool NotesModel::removeNote(const Note ¬e) {
|
|||
beginRemoveRows(QModelIndex(), position, position);
|
||||
m_notes.removeAt(position);
|
||||
endRemoveRows();
|
||||
emit dataChanged(index(position), index(position));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue