if (selectedIndex>=0) {
var feedTitle = searchDialog.model.get(searchDialog.selectedIndex).name;
var feedUrl = searchDialog.model.get(searchDialog.selectedIndex).url;
- container.addFeed(feedTitle,feedUrl,1);
+ //controller.addFeed(feedTitle,feedUrl,1);
+ categoryDialog.confirmCategory(feedTitle, feedUrl);
console.log("Adding feed "+feedTitle+" at " +feedUrl);
}
}
Button {
id: urlButton
text: "Add"
- checkable: true
onClicked: {
console.log("Adding "+urlInput.text)
- container.addFeed("",urlInput.text,1);
+ //controller.addFeed("",urlInput.text,1);
+ categoryDialog.confirmCategory("", urlInput.text);
}
}
}
}
}
}
-}
-
-
-//Dialog {
-// id: myDialog
-
-// title: Item {
-// height: myDialog.platformStyle.titleBarHeight
-// width: parent.width
-// Label {
-// id: titleLabel
-// anchors.left: supplement.right
-// anchors.verticalCenter: titleField.verticalCenter
-// font.capitalization: Font.MixedCase
-// color: "white"
-// text: "Add A Feed"
-// }
-
-// }
-
-// content:Item {
-// id: name
-// //height: childrenRect.height
-
-
-// TextInputClear {
-// id: urlInput
-// placeHolder: "Enter a feed URL"
-// }
-
-// }
-
-// buttons: ButtonRow {
-// platformStyle: ButtonStyle { }
-// anchors.horizontalCenter: parent.horizontalCenter
-// Button {id: b1; text: "OK"; onClicked: myDialog.accept()}
-// Button {id: b2; text: "Cancel"; onClicked: myDialog.reject()}
-// }
-//}
+ SelectionDialog {
+ id: categoryDialog
+ titleText: "Select category:"
+ property string feedTitle
+ property string feedUrl
+
+ //property variant listModel: ListModel {}
+
+ function createListModel() {
+ var listModel = Qt.createQmlObject('import QtQuick 1.0; ListModel {}', categoryDialog);
+ for (var i=0;i<categories.count;i++) {
+ listModel.append({"name": categories.get(i).title, "catid": categories.get(i).catid });
+ }
+ model = listModel
+ //console.log(listModel.count)
+ }
+
+ function confirmCategory(title, url) {
+ //categoryDialog.selectedIndex = -1;
+ createListModel();
+ feedTitle = title
+ feedUrl = url
+ open();
+ }
+
+ //model: []
+ //model: categories
+
+ XmlListModel {
+ id: categories
+ xml: controller.getCategoryXml()
+ query: "/xml/category"
+ XmlRole { name: "title"; query: "catname/string()" }
+ XmlRole { name: "catid"; query: "catid/string()"; isKey: true }
+ }
+
+ onSelectedIndexChanged: {
+ if (selectedIndex>=0) {
+ controller.addFeed(feedTitle,feedUrl,categoryDialog.model.get(categoryDialog.selectedIndex).catid);
+ console.log("Adding feed "+feedTitle+" at " +feedUrl + " in " + categoryDialog.model.get(categoryDialog.selectedIndex).catid);
+ }
+ categoryDialog.selectedIndex = -1;
+ }
+ }
+}