FeedPage.qml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 Róbert Márki
  4. **
  5. ** This file is part of Web Feeds.
  6. **
  7. ** Web Feeds is free software: you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation, either version 3 of the License, or
  10. ** (at your option) any later version.
  11. **
  12. ** Web Feeds is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with Web Feeds. If not, see <http://www.gnu.org/licenses/>.
  19. ****************************************************************************/
  20. import QtQuick 1.1
  21. import com.nokia.meego 1.0
  22. import com.nokia.extras 1.1
  23. import WebFeeds 1.0
  24. import NewsBlur 1.0
  25. import "../../../../shared/qml" as Shared
  26. import "../../../../shared/qml/UIConstants.js" as UIConstants
  27. import "../delegates" as Delegates
  28. import "../misc" as Misc
  29. import "../buttons" as Buttons
  30. NewsBlurPage {
  31. id: root
  32. Component {
  33. id: feedDelegate
  34. Delegates.FeedPageListDelegate {
  35. onReleased: createPageForItem(listPageContents.itemForRow(row));
  36. onHolded: showContextMenuForItem(listPageContents.itemForRow(row));
  37. }
  38. }
  39. Component {
  40. id: starredAndEverythingDelegate
  41. Delegates.StarredPageListDelegate {
  42. service: root.rootItem.service;
  43. onReleased: {
  44. if(!root.rootItem.movingBusy && !root.rootItem.deletingBusy) {
  45. var item = webFeedsApp.pageItemModel.item(listPageContents.indexForRow(row));
  46. createPageForItem(listPageContents.itemForRow(row));
  47. }
  48. }
  49. onHolded: {
  50. if(!root.rootItem.movingBusy && !root.rootItem.deletingBusy)
  51. showContextMenuForItem(listPageContents.itemForRow(row));
  52. }
  53. }
  54. }
  55. SelectionDialog {
  56. id: filterSelectionDialog
  57. titleText: qsTr("Show me")
  58. model: ListModel {
  59. ListElement {name: "Everything"; icon: "qrc:/plugins/newsblur/images/count_bubble/no_filter.png"}
  60. ListElement {name: "Everything I don't dislike"; icon: "qrc:/plugins/newsblur/images/count_bubble/non_negative_filter.png"}
  61. ListElement {name: "Just the stuff I like"; icon: "qrc:/plugins/newsblur/images/count_bubble/positive_filter.png"}
  62. }
  63. delegate: Qt.createComponent("/shared/qml/SelectionDialogIconDelegate.qml");
  64. onStatusChanged: {
  65. if((filterSelectionDialog.status == DialogStatus.Opening)
  66. || (filterSelectionDialog.status == DialogStatus.Open)) {
  67. filterSelectionDialog.selectedIndex = root.service.filterType;
  68. }
  69. }
  70. onAccepted: {
  71. if(filterSelectionDialog.selectedIndex >= 0) {
  72. root.service.setFilterType(filterSelectionDialog.selectedIndex,
  73. root.rootItem);
  74. }
  75. }
  76. }
  77. contents: Shared.CommonListPageContents {
  78. id: listPageContents
  79. rootItem: root.rootItem
  80. rootIndex: webFeedsApp.pageItemModel.index(root.rootItem);
  81. busy: root.contentsBusy
  82. emptyListText: qsTr("No stories")
  83. pageHeader: Shared.CommonPageHeader {
  84. filterEnabled: (root.rootItem.itemType != NewsBlurItem.StarredGroup);
  85. onClicked: filterSelectionDialog.open();
  86. titleText: root.rootItem.title
  87. titleColor: "white"
  88. backgrounColor: UIConstants.HIGHLIGHT_COLOR
  89. titleFont: UIConstants.FONT_FAMILY_LIGHT
  90. rightHelperItem: Misc.HeaderCountBubble {
  91. busy: root.rootItem.busy
  92. neutralCount: root.rootItem.unreadCount
  93. negativeCount: root.rootItem.negUnreadCount
  94. positiveCount: root.rootItem.posUnreadCount
  95. filterType: root.service.filterType
  96. hideNullSegments: (root.rootItem.itemType == NewsBlurItem.StarredGroup)
  97. }
  98. Shared.Separator {
  99. id: separator
  100. anchors.bottom: parent.bottom
  101. }
  102. }
  103. delegate: (root.rootItem.itemType == NewsBlurItem.FeedItem) ? feedDelegate : starredAndEverythingDelegate
  104. }
  105. tools: Shared.CommonToolBarLayout {
  106. enabled: root.userInteractionEnabled
  107. Shared.BackToolButton {pageItem: root.rootItem; page: root}
  108. Buttons.MarkFeedAsReadToolButton {pageItem: root.rootItem}
  109. Buttons.MarkEverythingAsReadToolButton {pageItem: root.rootItem}
  110. Buttons.RefreshEverythingGoupToolButton {pageItem: root.rootItem}
  111. Shared.MenuToolButton {pageItem: root.rootItem; page: root}
  112. }
  113. }