2016-12-11 16:09:39 +00:00
|
|
|
#include "notemodel.h"
|
|
|
|
|
2016-12-12 22:33:33 +00:00
|
|
|
jop::NoteModel::NoteModel()
|
2016-12-11 16:09:39 +00:00
|
|
|
{
|
2016-12-12 22:33:33 +00:00
|
|
|
|
2016-12-11 16:09:39 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 22:33:33 +00:00
|
|
|
int jop::NoteModel::rowCount(const QModelIndex &parent) const {
|
2016-12-29 21:51:10 +01:00
|
|
|
Q_UNUSED(parent);
|
2016-12-12 22:33:33 +00:00
|
|
|
return collection_.count();
|
2016-12-11 16:09:39 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 22:33:33 +00:00
|
|
|
QVariant jop::NoteModel::data(const QModelIndex &index, int role) const {
|
|
|
|
if (index.row() < 0 || index.row() >= rowCount()) return QVariant();
|
|
|
|
|
2016-12-14 21:50:26 +00:00
|
|
|
Note note = collection_.at(index.row());
|
2016-12-12 22:33:33 +00:00
|
|
|
|
2016-12-14 21:50:26 +00:00
|
|
|
if (role == IdRole) {
|
|
|
|
return QVariant(note.id());
|
|
|
|
}
|
2016-12-12 22:33:33 +00:00
|
|
|
|
2016-12-14 21:50:26 +00:00
|
|
|
return QVariant(note.title());
|
2016-12-11 16:09:39 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 22:33:33 +00:00
|
|
|
void jop::NoteModel::setFolderId(const QString &v) {
|
|
|
|
folderId_ = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
void jop::NoteModel::setCollection(jop::NoteCollection ¬eCollection) {
|
|
|
|
beginResetModel();
|
|
|
|
collection_ = noteCollection;
|
|
|
|
endResetModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
QHash<int, QByteArray> jop::NoteModel::roleNames() const {
|
2016-12-11 16:09:39 +00:00
|
|
|
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
|
|
|
|
// roles[TitleRole] = "title";
|
|
|
|
// roles[UuidRole] = "uuid";
|
|
|
|
return roles;
|
|
|
|
|
|
|
|
}
|