CommonPage.qml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 "UIConstants.js" as UIConstants
  25. import "Utils.js" as Utils
  26. Page {
  27. id: root
  28. property bool contentsBusy: false
  29. property PageItem rootItem
  30. property Page parentPage
  31. property Component contents
  32. function pageForItem(item) {
  33. return "";
  34. }
  35. function showMessage(message) {
  36. serviceMessageBanner.text = message;
  37. serviceMessageBanner.show();
  38. }
  39. function createPageForItem(item) {
  40. var nextPageUrl = pageForItem(item);
  41. if(nextPageUrl) {
  42. var nextStackPage = Qt.createComponent(nextPageUrl);
  43. pageStack.push(nextStackPage, {parentPage: root, rootItem: item});
  44. }
  45. }
  46. function showContextMenuForItem(item) {
  47. var contextMenuItems = webFeedsApp.contextMenuItems(item);
  48. if(contextMenuItems.length > 0) {
  49. var menu = Utils.createMenu(contextMenuItems, true, item, root);
  50. menu.open();
  51. }
  52. }
  53. function changeRootItem(item) {
  54. if(item && (item != root.rootItem)) {
  55. var prevRootItem = root.rootItem;
  56. root.rootItem = item;
  57. root.rootItem.active = true;
  58. prevRootItem.active = false;
  59. }
  60. }
  61. onStatusChanged: {
  62. if(root.status == PageStatus.Active) {
  63. root.rootItem.active = true;
  64. }
  65. }
  66. Component.onDestruction: {
  67. if(root.rootItem)
  68. root.rootItem.active = false;
  69. }
  70. InfoBanner {
  71. id: serviceMessageBanner
  72. parent: root.pageStack ? root.pageStack.parent : root
  73. }
  74. Connections {
  75. target: root.rootItem
  76. onServiceMessage: {
  77. root.showMessage(message);
  78. }
  79. onAboutToBeRemovedFromParent: {
  80. if(root.status != PageStatus.Deactivating) {
  81. console.log("onAboutToBeRemovedFromParent " + root.rootItem.title);
  82. root.pageStack.pop(root.parentPage);
  83. }
  84. }
  85. }
  86. Loader {
  87. id: contentsLoader
  88. anchors.fill: parent
  89. sourceComponent: root.contents
  90. }
  91. }