You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Display notes
This commit is contained in:
@ -20,6 +20,35 @@ bool Folder::trackChanges() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int Folder::noteCount() const {
|
||||
QSqlQuery q = jop::db().prepare(QString("SELECT count(*) AS row_count FROM %1 WHERE parent_id = :parent_id").arg(BaseModel::tableName(jop::NotesTable)));
|
||||
q.bindValue(":parent_id", id().toString());
|
||||
jop::db().execQuery(q);
|
||||
q.next();
|
||||
return q.value(0).toInt();
|
||||
}
|
||||
|
||||
QVector<Note> Folder::notes(const QString &orderBy, int limit, int offset) const {
|
||||
QVector<Note> output;
|
||||
|
||||
QSqlQuery q = jop::db().prepare(QString("SELECT %1 FROM notes WHERE parent_id = :parent_id ORDER BY %2 LIMIT %3 OFFSET %4")
|
||||
.arg(BaseModel::sqlTableFields(jop::NotesTable))
|
||||
.arg(orderBy)
|
||||
.arg(limit)
|
||||
.arg(offset));
|
||||
q.bindValue(":parent_id", id().toString());
|
||||
jop::db().execQuery(q);
|
||||
if (!jop::db().errorCheck(q)) return output;
|
||||
|
||||
while (q.next()) {
|
||||
Note note;
|
||||
note.loadSqlQuery(q);
|
||||
output.push_back(note);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
int Folder::count() {
|
||||
return BaseModel::count(jop::FoldersTable);
|
||||
}
|
||||
|
Reference in New Issue
Block a user