mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-01 19:15:01 +02:00
refactoring
This commit is contained in:
parent
31ded8c6a9
commit
91e74f024e
@ -106,3 +106,16 @@ QHash<int, QByteArray> AbstractListModel::roleNames() const {
|
||||
//roles[RawRole] = "raw";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QString AbstractListModel::indexToId(int index) const {
|
||||
return data(this->index(index), IdRole).toString();
|
||||
}
|
||||
|
||||
int AbstractListModel::idToIndex(const QString &id) const {
|
||||
qFatal("AbstractListModel::idToIndex() not implemented");
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString AbstractListModel::lastInsertId() const {
|
||||
return lastInsertId_;
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
QString lastInsertId_;
|
||||
|
||||
virtual int baseModelCount() const;
|
||||
|
||||
// All these methods are const because we want to be able to clear the
|
||||
@ -48,6 +50,9 @@ public slots:
|
||||
bool virtualItemShown() const;
|
||||
void hideVirtualItem();
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
virtual QString indexToId(int index) const;
|
||||
virtual int idToIndex(const QString& id) const;
|
||||
QString lastInsertId() const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -33,9 +33,9 @@ BaseModel* FolderModel::atIndex(int index) const {
|
||||
}
|
||||
}
|
||||
|
||||
QString FolderModel::indexToId(int index) const {
|
||||
return data(this->index(index), IdRole).toString();
|
||||
}
|
||||
//QString FolderModel::indexToId(int index) const {
|
||||
// return data(this->index(index), IdRole).toString();
|
||||
//}
|
||||
|
||||
int FolderModel::idToIndex(const QString &id) const {
|
||||
int count = this->rowCount();
|
||||
@ -46,9 +46,10 @@ int FolderModel::idToIndex(const QString &id) const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString FolderModel::lastInsertId() const {
|
||||
return lastInsertId_;
|
||||
}
|
||||
//QString FolderModel::lastInsertId() const {
|
||||
// return lastInsertId_;
|
||||
//}
|
||||
|
||||
|
||||
bool FolderModel::setTitle(int index, const QVariant &value, int role) {
|
||||
return setData(this->index(index), value, role);
|
||||
|
@ -35,16 +35,16 @@ private:
|
||||
QString orderBy_;
|
||||
mutable std::vector<std::unique_ptr<Folder>> cache_;
|
||||
|
||||
QString lastInsertId_;
|
||||
//QString lastInsertId_;
|
||||
|
||||
public slots:
|
||||
|
||||
void addData(const QString& title);
|
||||
void deleteData(const int index);
|
||||
bool setTitle(int index, const QVariant &value, int role = Qt::EditRole);
|
||||
QString indexToId(int index) const;
|
||||
//QString indexToId(int index) const;
|
||||
int idToIndex(const QString& id) const;
|
||||
QString lastInsertId() const;
|
||||
//QString lastInsertId() const;
|
||||
|
||||
void dispatcher_folderCreated(const QString& folderId);
|
||||
void dispatcher_folderUpdated(const QString& folderId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user