AddServiceDialog.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 WebFeeds 1.0
  22. import com.nokia.meego 1.0
  23. import com.nokia.extras 1.1
  24. SelectionDialog {
  25. id: serviceSelectionDialog
  26. ListModel {
  27. id: serviceListModel
  28. }
  29. function updateModel() {
  30. serviceListModel.clear();
  31. serviceSelectionDialog.selectedIndex = -1;
  32. var serviceList = webFeedsApp.services;
  33. for(var i = 0; i < serviceList.length; ++i) {
  34. if(!serviceList[i].isAuthenticationDataSet()) {
  35. serviceListModel.append({"name": serviceList[i].serviceName(), "serviceId": i,
  36. "icon": serviceList[i].serviceImageUrl()});
  37. }
  38. }
  39. serviceListModel.append({"name": "Tiny Tiny RSS (coming soon)", "serviceId": -1,
  40. "icon": "qrc:/shared/images/ttrss_account_64x64.png"})
  41. serviceSelectionDialog.titleText = "Add account";
  42. serviceSelectionDialog.model = undefined;
  43. serviceSelectionDialog.model = serviceListModel;
  44. }
  45. onStatusChanged: {
  46. if(serviceSelectionDialog.status == DialogStatus.Opening)
  47. serviceSelectionDialog.updateModel();
  48. }
  49. delegate: Qt.createComponent("SelectionDialogIconDelegate.qml");
  50. onAccepted: {
  51. if(selectedIndex >= 0) {
  52. authenticationSheetLoader.sourceComponent = undefined;
  53. authenticationSheetLoader.source =
  54. webFeedsApp.services[serviceSelectionDialog.model.get(selectedIndex).serviceId].authenticationSheet();
  55. if(authenticationSheetLoader.status == Loader.Ready) {
  56. authenticationSheetLoader.item.service = webFeedsApp.services[serviceSelectionDialog.model.get(selectedIndex).serviceId];
  57. authenticationSheetLoader.item.open();
  58. }
  59. }
  60. }
  61. Loader {
  62. id: authenticationSheetLoader
  63. }
  64. }