1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Refactoring to make notemodel and foldermodel share the same base class

This commit is contained in:
Laurent Cozic 2017-01-13 22:43:23 +01:00
parent 5e0bd6830a
commit 864eb2e49d
2 changed files with 2 additions and 27 deletions

View File

@ -7,23 +7,6 @@ NoteModel::NoteModel() : AbstractListModel() {
orderBy_ = "title";
}
//int NoteModel::rowCount(const QModelIndex &parent) const {
// Q_UNUSED(parent);
// return folder().noteCount();
//}
//QVariant NoteModel::data(const QModelIndex &index, int role) const {
// Note* note = atIndex(index.row());
// if (!note) return "";
// if (role == IdRole) {
// return QVariant(note->idString());
// }
// return QVariant(note->value("title").toString());
//}
Note *NoteModel::atIndex(int index) const {
if (folderId_ == "") return NULL;
if (index < 0 || index >= rowCount()) return NULL;
@ -65,11 +48,6 @@ Folder NoteModel::folder() const {
return folder;
}
//QString NoteModel::indexToId(int index) const {
// Note* note = atIndex(index);
// return note->idString();
//}
int NoteModel::idToIndex(const QString &id) const {
Folder f = this->folder();
return f.noteIndexById(orderBy_, id);
@ -80,11 +58,11 @@ int NoteModel::baseModelCount() const {
}
BaseModel* NoteModel::cacheGet(int index) const {
return (BaseModel*)cache_.get(index);
return static_cast<BaseModel*>(cache_.get(index));
}
void NoteModel::cacheSet(int index, BaseModel *baseModel) const {
cache_.set(index, (Note*)baseModel);
cache_.set(index, static_cast<Note*>(baseModel));
}
bool NoteModel::cacheIsset(int index) const {

View File

@ -22,15 +22,12 @@ public:
};
NoteModel();
//int rowCount(const QModelIndex & parent = QModelIndex()) const;
//QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
Note* atIndex(int index) const;
void setFolderId(const QString& v);
Folder folder() const;
public slots:
//QString indexToId(int index) const;
int idToIndex(const QString& id) const;
protected: