mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-01 19:15:01 +02:00
Refactoring to make notemodel and foldermodel share the same base class
This commit is contained in:
parent
864eb2e49d
commit
c8c6b016cf
@ -10,6 +10,11 @@ Item {
|
||||
|
||||
function onShown() {}
|
||||
|
||||
function handleAddItem(list) {
|
||||
list.model.showVirtualItem();
|
||||
list.startEditing(list.model.rowCount() - 1);
|
||||
}
|
||||
|
||||
function handleItemListEditingAccepted(list, index, text) {
|
||||
if (list.model.virtualItemShown()) {
|
||||
list.model.hideVirtualItem();
|
||||
@ -106,11 +111,8 @@ Item {
|
||||
id: addButton
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
onAddFolderButtonClicked: {
|
||||
folderList.model.showVirtualItem();
|
||||
folderList.startEditing(folderList.model.rowCount() - 1);
|
||||
}
|
||||
onAddNoteButtonClicked: appRoot.addNoteButtonClicked()
|
||||
onAddFolderButtonClicked: handleAddItem(folderList)
|
||||
onAddNoteButtonClicked: handleAddItem(noteList)
|
||||
}
|
||||
|
||||
Button {
|
||||
|
@ -59,6 +59,7 @@ Application::Application(int &argc, char **argv) :
|
||||
connect(rootObject, SIGNAL(currentFolderChanged()), this, SLOT(view_currentFolderChanged()));
|
||||
connect(rootObject, SIGNAL(currentNoteChanged()), this, SLOT(view_currentNoteChanged()));
|
||||
connect(rootObject, SIGNAL(addFolderButtonClicked()), this, SLOT(view_addFolderButtonClicked()));
|
||||
connect(rootObject, SIGNAL(addNoteButtonClicked()), this, SLOT(view_addNoteButtonClicked()));
|
||||
connect(rootObject, SIGNAL(syncButtonClicked()), this, SLOT(view_syncButtonClicked()));
|
||||
connect(rootObject, SIGNAL(loginClicked(QString,QString,QString)), this, SLOT(dispatcher_loginClicked(QString,QString,QString)));
|
||||
connect(rootObject, SIGNAL(logoutClicked()), this, SLOT(dispatcher_logoutClicked()));
|
||||
@ -198,7 +199,7 @@ void Application::view_currentNoteChanged() {
|
||||
}
|
||||
|
||||
void Application::view_addNoteButtonClicked() {
|
||||
|
||||
qDebug() <<"ADDNOTE";
|
||||
}
|
||||
|
||||
void Application::view_addFolderButtonClicked() {
|
||||
|
@ -98,7 +98,6 @@ QHash<int, QByteArray> AbstractListModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
|
||||
roles[TitleRole] = "title";
|
||||
roles[IdRole] = "id";
|
||||
//roles[RawRole] = "raw";
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,7 @@ public:
|
||||
|
||||
enum ModelRoles {
|
||||
IdRole = Qt::UserRole + 1,
|
||||
TitleRole,
|
||||
RawRole
|
||||
TitleRole
|
||||
};
|
||||
|
||||
AbstractListModel();
|
||||
|
@ -15,12 +15,6 @@ class NoteModel : public AbstractListModel {
|
||||
|
||||
public:
|
||||
|
||||
enum ModelRoles {
|
||||
IdRole = Qt::UserRole + 1,
|
||||
TitleRole,
|
||||
RawRole
|
||||
};
|
||||
|
||||
NoteModel();
|
||||
Note* atIndex(int index) const;
|
||||
void setFolderId(const QString& v);
|
||||
|
Loading…
x
Reference in New Issue
Block a user