summaryrefslogtreecommitdiff
path: root/navit/gui/qml/skins/navit/PageBookmarks.qml
blob: 46da8d8651aa127f8323b10581051d701016bbec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import Qt 4.7
import "pagenavigation.js" as Navit

Rectangle {
    id: page

    width: gui.width; height: gui.height
    color: "Black"
    opacity: 0

    function bookmarkReload() {
	    listModel.xml=bookmarks.getBookmarks();
	    listModel.query="/bookmarks/bookmark";
	    listModel.reload();
    }

    function bookmarkClick(itemName,itemType,itemCoord) {
        if (itemType=="bookmark_folder") {
	    if ( itemName==".." ) {
		bookmarks.moveUp();
	    } else {
	        bookmarks.moveDown(itemName);
	    }
	    bookmarkReload();
	} else {
	   bookmarks.setPoint(itemName);
	   pageLoader.source="PageNavigate.qml";
	}
    }

    function pageOpen() {
        page.opacity = 1;
    }

    Component.onCompleted: pageOpen();

    Behavior on opacity {
        NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
    }

    ButtonIcon { id: folderBtn; text: "New folder"; icon: "gui_active.svg"; onClicked: folderDialog.opacity=1
		      anchors.top: parent.top; anchors.topMargin: page.height/16; anchors.left: parent.left; anchors.leftMargin: page.width/16
    }
    ButtonIcon { id: pasteBtn; text: "Paste"; icon: "gui_active.svg"; onClicked: { bookmarks.Paste(); bookmarkReload(); }
		      anchors.top: parent.top; anchors.topMargin: page.height/16; anchors.left: folderBtn.right; anchors.leftMargin: page.width/16
    }

    XmlListModel {
	id: listModel
	xml: bookmarks.getBookmarks("bookmarks")
	query: "/bookmarks/bookmark"
	XmlRole { name: "itemName"; query: "label/string()" }
	XmlRole { name: "itemType"; query: "type/string()" }
	XmlRole { name: "itemDistance"; query: "distance/string()" }
	XmlRole { name: "itemDirection"; query: "direction/string()" }
	XmlRole { name: "itemValue"; query: "coords/string()" }
    }
     Component {
         id: listDelegate
         Item {
             id: wrapper
             width: list.width; height: 20
                 Text { id: txtItem; text: itemName; color: {itemType== "bookmark" ? "White"  : "Yellow"}
		 font.bold: {itemType!= "bookmark" }
       	         width: list.width-imgDelete.width
		     MouseArea {
		         id:delegateMouse
			 anchors.fill: parent
			 onClicked: bookmarkClick(itemName,itemType,itemValue);
		     }
		 }
		 Image {
			id: imgCut; source: gui.iconPath+"zoom_out.svg"; anchors.right: imgCopy.left;anchors.rightMargin: 5;
			width: 20; height: 20;

			MouseArea {
				id:delegateMouseCut
				anchors.fill: parent
				onClicked: { bookmarks.Cut(itemName); bookmarkReload(); }
			}
		}
		 Image {
			id: imgCopy; source: gui.iconPath+"zoom_in.svg"; anchors.right: imgDelete.left;anchors.rightMargin: 5;
			width: 20; height: 20;

			MouseArea {
				id:delegateMouseCopy
				anchors.fill: parent
				onClicked: { bookmarks.Copy(itemName); bookmarkReload(); }
			}
		}
    	       Image {
			id: imgDelete; source: gui.iconPath+"gui_inactive.svg"; anchors.right: wrapper.right;anchors.rightMargin: 5;
			width: 20; height: 20;

			MouseArea {
				id:delegateMouseDelete
				anchors.fill: parent
				onClicked: { bookmarks.Delete(itemName); bookmarkReload(); }
			}
		}
         }
     }

    Component {
        id: listHighlight
        Rectangle {
	    opacity: 0
        }
    }

    ListSelector {
	id:layoutList; text: ""
	anchors.top: pasteBtn.bottom;
	anchors.left: parent.left;
	anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
	width: page.width; height: page.height*0.25
    }

    Cellar {id: cellar; anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width }

    Rectangle {
        id: folderDialog
        opacity:0
	anchors.horizontalCenter: page.horizontalCenter; anchors.verticalCenter: page.verticalCenter;
	width: page.width; height:page.height/3
        color: "Grey";

	TextInput{
     	    id: folderTxt; text: "Enter folder name here..."
	    anchors.top: parent.top;anchors.topMargin: 5;anchors.horizontalCenter:parent.horizontalCenter
	    width: page.width; font.pointSize: 14; color: "White";focus: true; readOnly: false
       }

	ButtonIcon {
            id: btnOk; text: "Add"; icon: "gui_active.svg"; onClicked: { bookmarks.AddFolder(folderTxt.text); bookmarkReload(); folderDialog.opacity=0 }
	    anchors.top: folderTxt.bottom;anchors.topMargin: 5;anchors.right:parent.horizontalCenter;anchors.rightMargin:10
        }
	ButtonIcon {
            id: btnCancel; text: "Cancel"; icon: "gui_inactive.svg"; onClicked: folderDialog.opacity=0;
	    anchors.top: folderTxt.bottom;anchors.topMargin: 5;anchors.left:parent.horizontalCenter;anchors.leftMargin:10
        }
    }
}