// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5 import QtQuick 1.1 import com.nokia.symbian 1.1 import "UIConstants.js" as UI import "category.js" as Category Page { property string category property bool isSearch: false property XmlListModel mushroomModel: defaultModel property string base_query: "/mushrooms/mushroom" property bool isLoading: false function showEdible() { if (edibleModel.source == "") { edibleModel.source = "edible.xml"; edibleModel.query = "/mushrooms/mushroom"; } mushroomModel = edibleModel; descriptionpage.dModel = mushroomModel; } function showToxic() { if (toxicModel.source == "") { toxicModel.source = "toxic.xml"; toxicModel.query = "/mushrooms/mushroom"; } mushroomModel = toxicModel; descriptionpage.dModel = mushroomModel; } function showCondEdible() { if (condModel.source == "") { condModel.source = "cond_edible.xml"; condModel.query = "/mushrooms/mushroom"; } mushroomModel = condModel; descriptionpage.dModel = mushroomModel; } XmlListModel { id: defaultModel } XmlListModel { id: edibleModel XmlRole { name: "pic"; query: "image/string()" } XmlRole { name: "name"; query: "title/string()" } XmlRole { name: "lat_name"; query: "lat_title/string()" } XmlRole { name: "grow"; query: "grow/string()" } XmlRole { name: "cap"; query: "cap/string()" } XmlRole { name: "leg"; query: "leg/string()" } XmlRole { name: "meat"; query: "meat/string()" } XmlRole { name: "plates"; query: "plates/string()" } XmlRole { name: "thumb"; query: "id/string()" } XmlRole { name: "type"; query: "type/string()" } XmlRole { name: "text_begin"; query: "text_begin/string()" } XmlRole { name: "text_end"; query: "text_end/string()" } XmlRole { name: "m_category"; query: "category/string()" } onStatusChanged: { if (status === XmlListModel.Loading) listpage.isLoading = true; else listpage.isLoading = false; } } XmlListModel { id: toxicModel XmlRole { name: "pic"; query: "image/string()" } XmlRole { name: "name"; query: "title/string()" } XmlRole { name: "lat_name"; query: "lat_title/string()" } XmlRole { name: "grow"; query: "grow/string()" } XmlRole { name: "cap"; query: "cap/string()" } XmlRole { name: "leg"; query: "leg/string()" } XmlRole { name: "meat"; query: "meat/string()" } XmlRole { name: "plates"; query: "plates/string()" } XmlRole { name: "thumb"; query: "id/string()" } XmlRole { name: "type"; query: "type/string()" } XmlRole { name: "text_begin"; query: "text_begin/string()" } XmlRole { name: "text_end"; query: "text_end/string()" } XmlRole { name: "m_category"; query: "category/string()" } onStatusChanged: { if (status === XmlListModel.Loading) listpage.isLoading = true; else listpage.isLoading = false; } } XmlListModel { id: condModel XmlRole { name: "pic"; query: "image/string()" } XmlRole { name: "name"; query: "title/string()" } XmlRole { name: "lat_name"; query: "lat_title/string()" } XmlRole { name: "grow"; query: "grow/string()" } XmlRole { name: "cap"; query: "cap/string()" } XmlRole { name: "leg"; query: "leg/string()" } XmlRole { name: "meat"; query: "meat/string()" } XmlRole { name: "plates"; query: "plates/string()" } XmlRole { name: "thumb"; query: "id/string()" } XmlRole { name: "type"; query: "type/string()" } XmlRole { name: "text_begin"; query: "text_begin/string()" } XmlRole { name: "text_end"; query: "text_end/string()" } XmlRole { name: "m_category"; query: "category/string()" } onStatusChanged: { if (status === XmlListModel.Loading) listpage.isLoading = true; else listpage.isLoading = false; } } BusyIndicator { id: busy anchors.centerIn: parent visible: listpage.isLoading running: listpage.isLoading width: 150 height: width } Component { id: mushroom Item { width: gridview.cellWidth height: gridview.cellHeight Item { anchors.fill: parent anchors.margins: 3 Rectangle { border.width: 2 border.color: "white" anchors.fill: parent Image { source: "file:///" + applicationPath + "/thumbnails/thumb_" + thumb + ".jpg"; x: 1; y:1; anchors.fill: parent fillMode: Image.PreserveAspectCrop clip: true smooth: true Text { anchors.bottom: parent.bottom anchors.right: parent.right text: Category.getCategoryId(m_category) anchors.margins: 6 opacity: 0.7 color: "white" style: Text.Outline font.pixelSize: UI.FONT_XLARGE smooth: true visible: appWindow.showCategories } MouseArea { anchors.fill: parent onClicked: { descriptionpage.dIndex = index; pageStack.push(descriptionpage); } } } } } } } GridView { id: gridview cellWidth: (parent.width / parent.height > 1.5) ? 213 : 120; cellHeight: cellWidth model: mushroomModel anchors.fill: parent cacheBuffer: 2*height visible: !isLoading delegate: mushroom header: SearchField { id: searchField onNameFilterChanged: { if (filterName !== "") { mushroomModel.query = base_query; mushroomModel.query += "[contains(lower-case(title),lower-case('"+ filterName + "'))]"; } else { mushroomModel.query = base_query; } } Connections { target: mainPage onStatusChanged: { if (status === PageStatus.Activating ) { searchField.searchText = ""; gridview.focus = true; mushroomModel.query = base_query; } } } } } }