PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/ground/openpilotgcs/src/plugins/welcome/communitywelcomepagewidget.cpp

https://github.com/CorvusCorax/my_OpenPilot_mods
C++ | 85 lines | 44 code | 13 blank | 28 comment | 1 complexity | dfaf31fb78bd80be8a8db3a75b016aa8 MD5 | raw file
  1. /**
  2. ******************************************************************************
  3. *
  4. * @file communitywelcomepagewidget.cpp
  5. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
  6. * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
  7. * @addtogroup GCSPlugins GCS Plugins
  8. * @{
  9. * @addtogroup WelcomePlugin Welcome Plugin
  10. * @{
  11. * @brief The GCS Welcome plugin
  12. *****************************************************************************/
  13. /*
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful, but
  20. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  21. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  22. * for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License along
  25. * with this program; if not, write to the Free Software Foundation, Inc.,
  26. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. */
  28. #include "communitywelcomepagewidget.h"
  29. #include "ui_communitywelcomepagewidget.h"
  30. #include "rssfetcher.h"
  31. #include <QtCore/QMap>
  32. #include <QtGui/QDesktopServices>
  33. #include <QtGui/QTreeWidgetItem>
  34. namespace Welcome {
  35. namespace Internal {
  36. CommunityWelcomePageWidget::CommunityWelcomePageWidget(QWidget *parent) :
  37. QWidget(parent),
  38. m_rssFetcher(new RSSFetcher(7)),
  39. ui(new Ui::CommunityWelcomePageWidget)
  40. {
  41. ui->setupUi(this);
  42. ui->labsTitleLabel->setStyledText(tr("News From the OpenPilot Project"));
  43. ui->sitesTitleLabel->setStyledText(tr("OpenPilot Websites"));
  44. connect(ui->newsTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString)));
  45. connect(ui->sitesTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString)));
  46. connect(m_rssFetcher, SIGNAL(newsItemReady(QString, QString, QString)),
  47. ui->newsTreeWidget, SLOT(slotAddNewsItem(QString, QString, QString)));
  48. //: Add localized feed here only if one exists
  49. m_rssFetcher->fetch(QUrl(tr("http://newwww.openpilot.org/rss.xml")));
  50. QList<QPair<QString, QString> > sites;
  51. sites << qMakePair(tr("OpenPilot Home"), QString(QLatin1String("http://www.openpilot.org")));
  52. sites << qMakePair(tr("OpenPilot Wiki"), QString(QLatin1String("http://wiki.openpilot.org")));
  53. sites << qMakePair(tr("OpenPilot Store"), QString(QLatin1String("http://www.openpilot.org/store")));
  54. sites << qMakePair(tr("OpenPilot Forums"), QString(QLatin1String("http://forums.openpilot.org")));
  55. sites << qMakePair(tr("OpenPilot Progress Tracker"), QString(QLatin1String("http://progress.openpilot.org")));
  56. QListIterator<QPair<QString, QString> > it(sites);
  57. while (it.hasNext()) {
  58. QPair<QString, QString> pair = it.next();
  59. ui->sitesTreeWidget->addItem(pair.first, pair.second, pair.second);
  60. }
  61. }
  62. CommunityWelcomePageWidget::~CommunityWelcomePageWidget()
  63. {
  64. delete m_rssFetcher;
  65. delete ui;
  66. }
  67. void CommunityWelcomePageWidget::slotUrlClicked(const QString &data)
  68. {
  69. QDesktopServices::openUrl(QUrl(data));
  70. }
  71. } // namespace Internal
  72. } // namespace Welcome