FeedPage.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 GoogleReader 1.0
  25. import "../../../../shared/qml/UIConstants.js" as UIConstants
  26. import "../../../../shared/qml" as Shared
  27. import "../delegates" as Delegates
  28. import "../misc" as Misc
  29. import "../buttons" as Buttons
  30. GoogleReaderPage {
  31. id: root
  32. property variant rootIndex
  33. property bool contentsEnabled: false
  34. onStatusChanged: {
  35. if((root.status == PageStatus.Active)
  36. && !root.contentsEnabled) {
  37. root.rootIndex = webFeedsApp.pageItemModel.index(root.rootItem);
  38. root.contentsEnabled = true;
  39. }
  40. }
  41. Component {
  42. id: feedDelegate
  43. Delegates.FeedPageListDelegate {
  44. onReleased: createPageForItem(listPageContents.itemForRow(row));
  45. onHolded: showContextMenuForItem(listPageContents.itemForRow(row));
  46. }
  47. }
  48. Component {
  49. id: compoundFeedDelegate
  50. Delegates.CompoundFeedPageListDelegate {
  51. service: root.rootItem.service;
  52. onReleased: {
  53. if(!root.rootItem.editingBusy) {
  54. createPageForItem(listPageContents.itemForRow(row));
  55. }
  56. }
  57. onHolded: {
  58. if(!root.rootItem.editingBusy)
  59. showContextMenuForItem(listPageContents.itemForRow(row));
  60. }
  61. }
  62. }
  63. SelectionDialog {
  64. id: filterSelectionDialog
  65. titleText: qsTr("Show")
  66. model: ListModel {
  67. ListElement {name: "All items";}
  68. ListElement {name: "New items";}
  69. }
  70. onStatusChanged: {
  71. if((filterSelectionDialog.status == DialogStatus.Opening)
  72. || (filterSelectionDialog.status == DialogStatus.Open)) {
  73. filterSelectionDialog.selectedIndex = root.service.itemFilter;
  74. }
  75. }
  76. onAccepted: {
  77. if((filterSelectionDialog.selectedIndex >= 0)
  78. && (root.service.itemFilter != filterSelectionDialog.selectedIndex)) {
  79. root.service.itemFilter = filterSelectionDialog.selectedIndex;
  80. console.log(root.rootItem.title);
  81. root.service.refreshFeed(root.rootItem);
  82. }
  83. }
  84. }
  85. Component {
  86. id: countBubbleComponent
  87. Misc.HeaderCountBubble {
  88. busy: root.rootItem.busy
  89. unreadCount: (root.rootItem.itemType != GoogleReaderItem.ItStarredTagItem) ? root.rootItem.unreadCount : 0
  90. limit: service.unreadCountLimit
  91. }
  92. }
  93. contents: Shared.CommonListPageContents {
  94. id: listPageContents
  95. rootItem: root.rootItem
  96. rootIndex: root.rootIndex
  97. enabled: root.contentsEnabled
  98. busy: root.contentsBusy
  99. emptyListText: (root.service.itemFilter == GoogleReaderEnum.IftAllItems) ? qsTr("No items") : qsTr("No unread items")
  100. pageHeader: Shared.CommonPageHeader {
  101. filterEnabled: true
  102. onClicked: filterSelectionDialog.open();
  103. titleText: root.rootItem.title
  104. titleColor: "white"
  105. backgrounColor: UIConstants.HIGHLIGHT_COLOR
  106. titleFont: UIConstants.FONT_FAMILY_LIGHT
  107. rightHelperItem: countBubbleComponent
  108. Shared.Separator {
  109. id: separator
  110. anchors.bottom: parent.bottom
  111. }
  112. }
  113. delegate: (root.rootItem.itemType == GoogleReaderItem.ItFeedItem) ? feedDelegate : compoundFeedDelegate
  114. }
  115. tools: Shared.CommonToolBarLayout {
  116. enabled: root.userInteractionEnabled
  117. Shared.BackToolButton {pageItem: root.rootItem; page: root}
  118. Buttons.MarkEverythingAsReadToolButton {pageItem: root.rootItem}
  119. Buttons.MarkFeedAsReadToolButton {pageItem: root.rootItem}
  120. Buttons.RefreshFeedToolButton {pageItem: root.rootItem}
  121. Shared.MenuToolButton {pageItem: root.rootItem; page: root}
  122. }
  123. }