Skip to content

Commit

Permalink
Fixed bugs discovered while testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Triantafillis committed Sep 11, 2013
1 parent a24c298 commit c69a5e8
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 82 deletions.
2 changes: 1 addition & 1 deletion CNotes.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Name=CNotes
Comment=My project description
Comment=Simple app for taking notes
Exec=/usr/bin/qmlscene $@ /usr/share/CNotes/CNotes.qml
Icon=./CNotes.png
Terminal=false
Expand Down
32 changes: 0 additions & 32 deletions CNotes.qml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import QtMultimedia 5.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import Ubuntu.Components.Popups 0.1
import Ubuntu.Layouts 0.1
import U1db 1.0 as U1db
import DirParser 1.0
import "Storage.js" as Storage
import "showdown.js" as Showdown
import "components"
import "view"
Expand Down Expand Up @@ -126,36 +124,6 @@ MainView {
}
}

// function loadNotes() {
// allNotes = Storage.fetchNotes('false')
// idCount = 0
// for (var i = 0; i < allNotes.length; i++) {
// var noteId = allNotes[i]
// mainView.notes.append({id:noteId, title:Storage.getTitle(noteId), body:Storage.getBody(noteId),
// category:Storage.getCategory(noteId), tag:Storage.getTags(noteId), archive:'false', view:"main"})

// if (noteId > idCount)
// idCount = noteId
// }

// }

// function loadArchiveNotes() {
// archiveNotes = Storage.fetchNotes('true')
// for (var i = 0; i < archiveNotes.length; i++) {
// var noteId = archiveNotes[i]
// archivesModel.append({id:noteId, title:Storage.getTitle(noteId), body:Storage.getBody(noteId),
// category:Storage.getCategory(noteId), tag:Storage.getTags(noteId), archive:'true', view:"archive"})
// }
// }

// function loadCategories() {
// var cat = Storage.fetchAllCategories()
// for (var i = 0; i < cat.length; i++) {
// categoriesModel.append({categoryName: cat[i]})
// }
// }

function containTag(t) {
for (var i = 0; i < tagsModel.count; i++) {
if (t === tagsModel.get(i).tag) {
Expand Down
3 changes: 2 additions & 1 deletion U1Backend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Item {
}
}

function replaceNote(pos, doc, title, body, category, tag, archive, view) {
function replaceNote(pos, doc, title, body, category, tag, archive, view, links) {
pos = parseInt(pos)
var values = getValues(doc)

Expand All @@ -36,6 +36,7 @@ Item {
values["notes"][pos].category = category
values["notes"][pos].archive = archive
values["notes"][pos].view = view
values["notes"][pos].links = links

setValues(values, doc)

Expand Down
41 changes: 28 additions & 13 deletions components/ImagesTab.qml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ Tab {
source: location
}

onPressAndHold: PopupUtils.open(imagePopoverComponent)
onPressAndHold: {
if (mainView.mode !== "view") {
PopupUtils.open(imagePopoverComponent)
}
}
}
}
}
Expand Down Expand Up @@ -95,17 +99,7 @@ Tab {
MouseArea {
anchors.fill: parent
onClicked: {
if (imageTitle.text.length == 0) {
imageTitle.focus = true
return
}

if (!dirParser.dirExists(path)) {
dirParser.createDirectory(path)
}

camera.imageCapture.captureToLocation(path + imageTitle.text)
location = '../pictures/' + mainView.id + '/' + imageTitle.text
captureImage()
}
}
}
Expand All @@ -120,6 +114,11 @@ Tab {
placeholderText: i18n.tr("Give title")
}

Label {
id: messageLabel
visible: false
}

Row {
spacing: units.gu(1)
Button {
Expand All @@ -143,6 +142,22 @@ Tab {
}
}
}

function captureImage() {
if (imageTitle.text.length == 0) {
imageTitle.focus = true
messageLabel.text = i18n.tr("You need to add a title")
messageLabel.visible = true
return
}

if (!dirParser.dirExists(path)) {
dirParser.createDirectory(path)
}

camera.imageCapture.captureToLocation(path + imageTitle.text)
location = '../pictures/' + mainView.id + '/' + imageTitle.text
}
}
}

Expand Down Expand Up @@ -171,7 +186,7 @@ Tab {

onClicked: {
var loc = imagesView.model.get(imagesView.currentIndex).location
dirParser.remove(loc.substring(1))
dirParser.remove(loc)
imagesView.model.remove(imagesView.currentIndex)
PopupUtils.close(imagePopover)
}
Expand Down
8 changes: 5 additions & 3 deletions components/LinksTab.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Popups 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import "../Storage.js" as Storage

Tab {
title: i18n.tr("Links")
Expand Down Expand Up @@ -67,7 +65,11 @@ Tab {
Qt.openUrlExternally(link)
}

onPressAndHold: PopupUtils.open(linkPopoverComponent)
onPressAndHold: {
if (mainView.mode !== "view") {
PopupUtils.open(linkPopoverComponent)
}
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions components/NoteItem.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1
import Ubuntu.Components.Popups 0.1
import "../Storage.js" as Storage
import "../view"

Subtitled {
Expand Down
2 changes: 0 additions & 2 deletions components/NoteViewRow.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import "../pages"
import "../view"
import "../Storage.js" as Storage

Row {
id: notesViewRow
Expand Down
2 changes: 0 additions & 2 deletions pages/CategoriesPage.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import Ubuntu.Components.Popups 0.1
import "../Storage.js" as Storage
import "../images"

Page {
Expand Down
2 changes: 0 additions & 2 deletions pages/CreateNotePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import Ubuntu.Components.Popups 0.1
import QtQuick.LocalStorage 2.0
import "../Storage.js" as Storage
import "../components"

Tabs {
Expand Down
33 changes: 16 additions & 17 deletions pages/EditNotePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import Ubuntu.Components.Popups 0.1
import QtQuick.LocalStorage 2.0
import "../Storage.js" as Storage
import "../components"

Tabs {
Tab {
Expand All @@ -26,12 +24,6 @@ Tabs {
iconSource: Qt.resolvedUrl("../images/select.svg")

onTriggered: {
// TODO fix it!
// Storage.setNote(inputTitleEdit.text, inputBodyEdit.text, categoriesSelectorEdit.values[categoriesSelectorEdit.selectedIndex], tag, 'false', 'main')
// mainView.notes.get(mainView.position).title = inputTitleEdit.text
// mainView.notes.get(mainView.position).body = inputBodyEdit.text
// mainView.notes.get(mainView.position).category = categoriesSelectorEdit.values[categoriesSelectorEdit.selectedIndex]
// mainView.notes.get(mainView.position).tag = tag

var doc
var archive
Expand All @@ -46,20 +38,27 @@ Tabs {

mainView.backend.replaceNote(mainView.id, doc, inputTitleEdit.text, inputBodyEdit.text,
categoriesSelectorEdit.values[categoriesSelectorEdit.selectedIndex],
tag, archive, 'main')

// mainView.tag = tag
// if (mainView.showArchive) {
// mainView.notesListView.model = mainView.database.getDoc("archive").notes
// }
// else {
// mainView.notesListView.model = mainView.database.getDoc("notes").notes
// }
tag, archive, 'main', mainView.getLinksForStorage())

pageStack.push(mainConditionalPage)
}
}
}

back: ToolbarButton {
action: Action {
id: back
objectName: "back"

iconSource: Qt.resolvedUrl("../images/back.svg")
text: i18n.tr("Back")

onTriggered: {
mainView.mode = "view"
pageStack.pop()
}
}
}
}

Flickable {
Expand Down
3 changes: 0 additions & 3 deletions pages/MainPage.qml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import Ubuntu.Components 0.1
import Ubuntu.Layouts 0.1
import "../Storage.js" as Storage
import "../components"
import "../view"
//import "U1Backend.qml" as U1Backend

Page {

Expand Down
3 changes: 1 addition & 2 deletions view/NoteView.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import Ubuntu.Components 0.1
import Ubuntu.Layouts 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import "../Storage.js" as Storage
import "../components"
import "../view"
import "../pages"
Expand Down Expand Up @@ -45,6 +43,7 @@ Tabs {
text: i18n.tr("Edit")

onTriggered: {
mainView.mode = "edit"
pageStack.push(Qt.resolvedUrl("../pages/EditNotePage.qml"))
}
}
Expand Down
2 changes: 0 additions & 2 deletions view/NotesListView.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import Ubuntu.Components.Popups 0.1
import DirParser 1.0
import "../Storage.js" as Storage
import "../components"
import "../pages"

Expand Down

0 comments on commit c69a5e8

Please sign in to comment.