Skip to content

Commit

Permalink
Fixed move note to archive and back
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Triantafillis committed Sep 12, 2013
1 parent c69a5e8 commit 767c80b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 41 deletions.
62 changes: 31 additions & 31 deletions CNotes.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,36 @@ MainView {
property bool createNote: false
property string specificTag

property variant notes
property variant categoriesModel
property variant archivesModel
// property variant notes
// property variant categoriesModel
// property variant archivesModel
property variant filterNotesModel
property variant archiveNotes
property variant allNotes
// property variant archiveNotes
// property variant allNotes
property variant noteLinksModel
property variant imagesModel

property string focusedEntry: ""
property variant database
property variant backend

notes: ListModel {
onCountChanged: {
if (count > 0) {
notesListView.currentIndex = count - 1
}
}
}
// notes: ListModel {
// onCountChanged: {
// if (count > 0) {
// notesListView.currentIndex = count - 1
// }
// }
// }

categoriesModel: ListModel {}
// categoriesModel: ListModel {}

archivesModel: ListModel {
onCountChanged: {
if (count > 0) {
notesListView.currentIndex = count - 1
}
}
}
// archivesModel: ListModel {
// onCountChanged: {
// if (count > 0) {
// notesListView.currentIndex = count - 1
// }
// }
// }

filterNotesModel: ListModel {}

Expand Down Expand Up @@ -195,6 +195,14 @@ MainView {
defaults: {"categories": ["None", "Work", "Things to do"] }
}

U1db.Document {
id: tagsDocument
database: database
docId: "tags"
create: true
defaults: {"tags": []}
}

backend: U1Backend {
id: backend
}
Expand Down Expand Up @@ -267,13 +275,6 @@ MainView {
return
}

// mainView.title = model[currentIndex].title
// mainView.title = model.get(currentIndex).title
// mainView.body = model.get(currentIndex).body
// mainView.category = model.get(currentIndex).category
// mainView.tag = model.get(currentIndex).tag
// mainView.archive = model.get(currentIndex).archive

if (wideAspect) {
noteViewRow.visible = true
}
Expand All @@ -294,9 +295,9 @@ MainView {
Popover {
id: tagsPopover

property variant usedTags: Storage.getUsedTags()

Component.onCompleted: {
var usedTags= database.getDoc("tags").tags
var end = usedTags.length - 4
if (usedTags.length < 4) {
end = 0
Expand Down Expand Up @@ -391,11 +392,10 @@ MainView {
// Check if tag already exists!
if (!containTag(tagTextField.text.split(",")[i])) {
if (tagsModel.count == 3) {
Storage.addTag(tagsModel.get(0), tagTextField.text.split(",")[i])
tagsModel.remove(0)
mainView.backend.addTag(tagsModel.get(0), tagTextField.text.split(",")[i])
}
else {
Storage.addTag("", tagTextField.text.split(",")[i])
mainView.backend.addTag("", tagTextField.text.split(",")[i])
}

tagsModel.append({tag: tagTextField.text.split(",")[i]})
Expand Down
13 changes: 12 additions & 1 deletion U1Backend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Item {
j++
}
}

setValues(newValues, doc)
}

Expand Down Expand Up @@ -168,4 +167,16 @@ Item {

mainView.database.putDoc(newValues, "categories")
}

function addTag(old, newTag) {
var values = mainView.database.getDoc("tags")

if (old !== "") {
values["tags"][0] = values["tags"][1]
values["tags"][1] = values["tags"][2]
}

values["tags"][values["tags"].length] = newTag
mainView.database.putDoc(values, "tags")
}
}
8 changes: 3 additions & 5 deletions components/NoteItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ Subtitled {
subText: getHtmlText(_body)

onItemRemoved: {
var id

mainView.createNote = false

if (_view === "main") {
id = _id
mainView.backend.setNote(_id, _title, _body, _category, _tag, 'true', 'archive', _links, "archive")
mainView.backend.removeNote(id, "notes")
mainView.backend.removeNote(index, "notes")
}
else {
id = _id
mainView.backend.setNote(_id, _title, _body, _category, _tag, 'false', 'main', _links, "notes")
mainView.backend.removeNote(id, "archive")
mainView.backend.removeNote(index, "archive")
}
}

Expand Down
1 change: 0 additions & 1 deletion pages/CreateNotePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ Tabs {

ListItem.ValueSelector {
id: categoriesSelector
property variant categories: Storage.fetchAllCategories()

width: parent.width
text: i18n.tr("Category")
Expand Down
4 changes: 1 addition & 3 deletions view/NotesListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ ListView {

delegate: NoteItem {

_id: {
return idCount
}
_id: idCount

_title: getCorrectDoc().notes[index].title

Expand Down

0 comments on commit 767c80b

Please sign in to comment.