From 864eb2e49d72c112d505a6f8dc57405d0befa90e Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 13 Jan 2017 22:43:23 +0100 Subject: [PATCH] Refactoring to make notemodel and foldermodel share the same base class --- QtClient/JoplinQtClient/models/notemodel.cpp | 26 ++------------------ QtClient/JoplinQtClient/models/notemodel.h | 3 --- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/QtClient/JoplinQtClient/models/notemodel.cpp b/QtClient/JoplinQtClient/models/notemodel.cpp index 0faa31d0a..5eec57876 100755 --- a/QtClient/JoplinQtClient/models/notemodel.cpp +++ b/QtClient/JoplinQtClient/models/notemodel.cpp @@ -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(cache_.get(index)); } void NoteModel::cacheSet(int index, BaseModel *baseModel) const { - cache_.set(index, (Note*)baseModel); + cache_.set(index, static_cast(baseModel)); } bool NoteModel::cacheIsset(int index) const { diff --git a/QtClient/JoplinQtClient/models/notemodel.h b/QtClient/JoplinQtClient/models/notemodel.h index c0e302d33..9e1258e2f 100755 --- a/QtClient/JoplinQtClient/models/notemodel.h +++ b/QtClient/JoplinQtClient/models/notemodel.h @@ -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: