399 lines
14 KiB
QML
399 lines
14 KiB
QML
/*
|
|
* Copyright 2012-2018 Morgan McMillian <gilag@monkeystew.com>
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import bb.cascades 1.0
|
|
import com.monkeystew.taskmodel 1.0
|
|
|
|
NavigationPane {
|
|
id: navi
|
|
property string appversion
|
|
property variant coverpage
|
|
Menu.definition: MenuDefinition {
|
|
helpAction: HelpActionItem {
|
|
onTriggered: {
|
|
var page = helpPage.createObject()
|
|
navi.push(page)
|
|
}
|
|
}
|
|
settingsAction: SettingsActionItem {
|
|
onTriggered: {
|
|
var page = settingsPage.createObject();
|
|
page.modifySetting.connect(taskModel.modifySetting)
|
|
page.datenew = taskModel.setting("datenew", false)
|
|
page.windowsbreak = taskModel.setting("windowsbreak", false)
|
|
page.autoarchive = taskModel.setting("autoarchive", false)
|
|
page.sort = taskModel.setting("sort", 0)
|
|
page.path = taskModel.setting("path", "data/todo")
|
|
page.sync = taskModel.setting("sync", "local")
|
|
page.dboxpath = taskModel.setting("dbox_path", "/todo/todo.txt")
|
|
navi.push(page)
|
|
}
|
|
}
|
|
actions: [
|
|
ActionItem {
|
|
title: "About"
|
|
imageSource: "asset:///icons/Info.png"
|
|
onTriggered: {
|
|
var page = aboutPage.createObject()
|
|
navi.push(page)
|
|
}
|
|
}
|
|
// ActionItem {
|
|
// title: "Invite"
|
|
// imageSource: "asset:///icons/ic_bbm.png"
|
|
// onTriggered: {
|
|
// _Taskslayer.sendBBMInvite()
|
|
// }
|
|
// }
|
|
]
|
|
}
|
|
Page {
|
|
id: mainPage
|
|
titleBar: TitleBar {
|
|
id: titleBar
|
|
title: " Renamed Todo"
|
|
visibility: ChromeVisibility.Default
|
|
}
|
|
Container {
|
|
Container {
|
|
id: searchContainer
|
|
visible: false
|
|
layout: StackLayout {
|
|
orientation: LayoutOrientation.LeftToRight
|
|
}
|
|
preferredHeight: 120.0
|
|
//background: Color.create("#0098F0")
|
|
background: mainPage.getSearchBackground()
|
|
Container {
|
|
verticalAlignment: VerticalAlignment.Center
|
|
leftPadding: 15.0
|
|
rightPadding: 10.0
|
|
TextField {
|
|
id: searchField
|
|
hintText: "Search"
|
|
onTextChanging: {
|
|
taskModel.search(searchField.text);
|
|
}
|
|
}
|
|
}
|
|
Container {
|
|
maxWidth: 220.0
|
|
verticalAlignment: VerticalAlignment.Center
|
|
leftPadding: 10.0
|
|
rightPadding: 15.0
|
|
Button {
|
|
text: "Cancel"
|
|
onClicked: {
|
|
titleBar.visibility = ChromeVisibility.Default
|
|
searchContainer.visible = false
|
|
searchField.text = ""
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Container {
|
|
horizontalAlignment: HorizontalAlignment.Fill
|
|
Container {
|
|
id: appliedFilters
|
|
layout: DockLayout {
|
|
}
|
|
visible: false
|
|
horizontalAlignment: HorizontalAlignment.Fill
|
|
Container {
|
|
background: Color.create("#333333")
|
|
horizontalAlignment: HorizontalAlignment.Fill
|
|
Label {
|
|
id: filterList
|
|
text: taskModel.activeFilters()
|
|
textStyle.color: Color.White
|
|
textStyle.fontSize: FontSize.XSmall
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Container {
|
|
id: sortdropdown
|
|
horizontalAlignment: HorizontalAlignment.Center
|
|
visible: false
|
|
DropDown {
|
|
id: sortselection
|
|
title: "Sort"
|
|
onSelectedIndexChanged: {
|
|
if (selectedValue != undefined) {
|
|
taskModel.sort = selectedValue
|
|
sortdropdown.visible = false
|
|
}
|
|
}
|
|
Option {
|
|
text: "Priority"
|
|
value: 0
|
|
}
|
|
Option {
|
|
text: "Due date"
|
|
value: 3
|
|
}
|
|
Option {
|
|
text: "Line number"
|
|
value: 1
|
|
}
|
|
Option {
|
|
text: "Text A>Z"
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
ListView {
|
|
id: listView
|
|
dataModel: taskModel
|
|
listItemComponents: [
|
|
ListItemComponent {
|
|
TaskItem {
|
|
// see TaskItem.qml
|
|
}
|
|
}
|
|
]
|
|
onTriggered: {
|
|
var chosenItem = taskModel.data(indexPath)
|
|
var page = taskPage.createObject();
|
|
page.itemUpdate.connect(taskModel.updateTask)
|
|
page.setValue.connect(taskModel.setValue)
|
|
page.delTask.connect(taskModel.promptDelete)
|
|
page.itemtext = chosenItem.text
|
|
page.complete = chosenItem.complete
|
|
page.idx = indexPath
|
|
navi.push(page)
|
|
}
|
|
/*leadingVisual: TextField {
|
|
* id: searchField
|
|
* onTextChanging: {
|
|
* //
|
|
* }
|
|
* }*/
|
|
}
|
|
}
|
|
attachedObjects: [
|
|
TaskModel {
|
|
id: taskModel
|
|
},
|
|
EditSheet {
|
|
id: addNew
|
|
onSaveTask: {
|
|
taskModel.addFullTask(text)
|
|
}
|
|
},
|
|
ComponentDefinition {
|
|
id: taskPage
|
|
source: "asset:///TaskPage.qml"
|
|
},
|
|
ComponentDefinition {
|
|
id: filterPage
|
|
source: "asset:///FilterPage.qml"
|
|
},
|
|
ComponentDefinition {
|
|
id: settingsPage
|
|
source: "asset:///SettingsPage.qml"
|
|
},
|
|
ComponentDefinition {
|
|
id: aboutPage
|
|
source: "asset:///AboutPage.qml"
|
|
},
|
|
ComponentDefinition {
|
|
id: helpPage
|
|
source: "asset:///HelpPage.qml"
|
|
},
|
|
ComponentDefinition {
|
|
id: appCover
|
|
source: "asset:///AppCover.qml"
|
|
},
|
|
ComponentDefinition {
|
|
id: opt
|
|
Option {}
|
|
}
|
|
]
|
|
actions: [
|
|
ActionItem {
|
|
title: "Add"
|
|
imageSource: "asset:///icons/Add.png"
|
|
ActionBar.placement: ActionBarPlacement.OnBar
|
|
onTriggered: {
|
|
addNew.open();
|
|
addNew.newtask = true;
|
|
addNew.datenew = taskModel.setting("datenew", false);
|
|
addNew.modifySetting.connect(taskModel.modifySetting);
|
|
addNew.text = "";
|
|
addNew.labels.removeAll();
|
|
for (var i=0; i < taskModel.filters.length; i++) {
|
|
var o = opt.createObject();
|
|
o.text = taskModel.filters[i].title;
|
|
o.value = taskModel.filters[i].title;
|
|
addNew.labels.add(o);
|
|
}
|
|
addNew.textfield.requestFocus();
|
|
}
|
|
},
|
|
ActionItem {
|
|
id: searchButton
|
|
title: "Search"
|
|
imageSource: "asset:///icons/Search.png"
|
|
ActionBar.placement: ActionBarPlacement.OnBar
|
|
onTriggered: {
|
|
if (searchContainer.visible) {
|
|
titleBar.visibility = ChromeVisibility.Default
|
|
searchContainer.visible = false
|
|
searchField.text = ""
|
|
} else {
|
|
searchContainer.visible = true
|
|
searchField.requestFocus()
|
|
titleBar.visibility = ChromeVisibility.Hidden
|
|
}
|
|
}
|
|
},
|
|
ActionItem {
|
|
title: "Filter"
|
|
imageSource: "asset:///icons/Funnel.png"
|
|
ActionBar.placement: ActionBarPlacement.OnBar
|
|
onTriggered: {
|
|
var page = filterPage.createObject();
|
|
if (taskModel.filters.length <= 0) {
|
|
if (appliedFilters.visible) {
|
|
taskModel.resetFilter()
|
|
} else {
|
|
page.warningtext.visible = true
|
|
}
|
|
}
|
|
page.filterModel.insertList(taskModel.filters);
|
|
page.filterModel.changeFilter.connect(taskModel.changeFilter);
|
|
page.resetFilter.connect(taskModel.resetFilter);
|
|
navi.push(page);
|
|
}
|
|
},
|
|
ActionItem {
|
|
title: "Sort"
|
|
imageSource: "asset:///icons/Sort.png"
|
|
onTriggered: {
|
|
sortdropdown.visible = sortdropdown.visible ? false : true
|
|
sortselection.resetSelectedIndex()
|
|
}
|
|
},
|
|
// ActionItem {
|
|
// title: "Sort by priority"
|
|
// imageSource: "icons/Capitalize.png"
|
|
// onTriggered: {
|
|
// taskModel.sort = 0;
|
|
// }
|
|
// },
|
|
// ActionItem {
|
|
// title: "Sort by line"
|
|
// imageSource: "icons/123.png"
|
|
// onTriggered: {
|
|
// taskModel.sort = 1;
|
|
// }
|
|
// },
|
|
// ActionItem {
|
|
// title: "Sort by text (a>z)"
|
|
// imageSource: "icons/abc.png"
|
|
// onTriggered: {
|
|
// taskModel.sort = 2;
|
|
// }
|
|
// },
|
|
// ActionItem {
|
|
// title: "Sort by due date"
|
|
// onTriggered: {
|
|
// taskModel.sort = 3;
|
|
// }
|
|
// },
|
|
ActionItem {
|
|
title: "Archive"
|
|
imageSource: "asset:///icons/DownBox.png"
|
|
onTriggered: {
|
|
taskModel.archive();
|
|
}
|
|
},
|
|
ActionItem {
|
|
title: "Reload"
|
|
imageSource: "asset:///icons/Recycle.png"
|
|
onTriggered: {
|
|
taskModel.refresh();
|
|
taskModel.setView();
|
|
}
|
|
}
|
|
]
|
|
onCreationCompleted: {
|
|
taskModel.refresh();
|
|
taskModel.setView();
|
|
_Taskslayer.addNewTask.connect(newTask)
|
|
_Taskslayer.searchTaskList.connect(searchTasks)
|
|
taskModel.listUpdated.connect(listUpdated)
|
|
coverpage = appCover.createObject();
|
|
coverpage.topList.append(taskModel.tododata)
|
|
if (taskModel.tododata.length > 0) {
|
|
coverpage.empty = false
|
|
} else {
|
|
coverpage.empty = true
|
|
}
|
|
Application.cover = coverpage
|
|
console.log(themeStyleToString(Application.themeSupport.theme.colorTheme.style))
|
|
}
|
|
function searchTasks(data) {
|
|
searchContainer.visible = true
|
|
searchField.requestFocus()
|
|
searchField.text = data
|
|
titleBar.visibility = ChromeVisibility.Hidden
|
|
}
|
|
function newTask(data) {
|
|
addNew.open();
|
|
addNew.newtask = true;
|
|
addNew.datenew = taskModel.setting("datenew", false);
|
|
addNew.modifySetting.connect(taskModel.modifySetting);
|
|
addNew.text = data;
|
|
addNew.textfield.requestFocus();
|
|
}
|
|
function listUpdated() {
|
|
coverpage.topList.clear()
|
|
coverpage.topList.append(taskModel.tododata)
|
|
if (taskModel.tododata.length > 0) {
|
|
coverpage.empty = false
|
|
} else {
|
|
coverpage.empty = true
|
|
}
|
|
}
|
|
function themeStyleToString(style) {
|
|
switch (style) {
|
|
case VisualStyle.Bright:
|
|
return "Theme: Bright"
|
|
case VisualStyle.Dark:
|
|
return "Theme: Dark"
|
|
}
|
|
return "Theme: UNKNOWN :("
|
|
}
|
|
function getSearchBackground() {
|
|
switch (Application.themeSupport.theme.colorTheme.style) {
|
|
case VisualStyle.Bright:
|
|
return Color.create("#0098F0")
|
|
case VisualStyle.Dark:
|
|
return Color.create("#262626")
|
|
}
|
|
return Color.Gray;
|
|
}
|
|
}
|
|
onPopTransitionEnded: {
|
|
page.destroy()
|
|
taskModel.setView()
|
|
filterList.text = taskModel.activeFilters()
|
|
appliedFilters.visible = taskModel.activeFilters().length > 0 ? true : false
|
|
}
|
|
}
|