tizenmanifesteditor.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2013 Jarek Pelczar <jpelczar@gmail.com>
  4. ** Copyright (C) 2014 Tomasz Olszak <olszak.tomasz@gmail.com>
  5. **
  6. ** This file is part of Qt Creator.
  7. **
  8. ** Commercial License Usage
  9. ** Licensees holding valid commercial Qt licenses may use this file in
  10. ** accordance with the commercial license agreement provided with the
  11. ** Software or, alternatively, in accordance with the terms contained in
  12. ** a written agreement between you and Digia. For licensing terms and
  13. ** conditions see http://qt.digia.com/licensing. For further information
  14. ** use the contact form at http://qt.digia.com/contact-us.
  15. **
  16. ** GNU Lesser General Public License Usage
  17. ** Alternatively, this file may be used under the terms of the GNU Lesser
  18. ** General Public License version 2.1 as published by the Free Software
  19. ** Foundation and appearing in the file LICENSE.LGPL included in the
  20. ** packaging of this file. Please review the following information to
  21. ** ensure the GNU Lesser General Public License version 2.1 requirements
  22. ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  23. **
  24. ** In addition, as a special exception, Digia gives you certain additional
  25. ** rights. These rights are described in the Digia Qt LGPL Exception
  26. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  27. **
  28. ****************************************************************************/
  29. #include "tizenmanifesteditor.h"
  30. #include "tizenconstants.h"
  31. #include "tizenmanifesteditorwidget.h"
  32. #include <texteditor/texteditorconstants.h>
  33. #include <QToolBar>
  34. #include <QActionGroup>
  35. namespace Tizen {
  36. namespace Internal {
  37. TizenManifestEditor::TizenManifestEditor(TizenManifestEditorWidget * editorWidget) :
  38. Core::IEditor(editorWidget), m_toolBar(0)
  39. {
  40. m_toolBar = new QToolBar(editorWidget);
  41. m_actionGroup = new QActionGroup(this);
  42. connect(m_actionGroup, SIGNAL(triggered(QAction*)), SLOT(changeEditorPage(QAction*)));
  43. QAction * generalAction = m_toolBar->addAction(tr("General"));
  44. generalAction->setCheckable(true);
  45. generalAction->setData(int(TizenManifestEditorWidget::General));
  46. m_actionGroup->addAction(generalAction);
  47. QAction * sourceAction = m_toolBar->addAction(tr("XML Source"));
  48. sourceAction->setCheckable(true);
  49. sourceAction->setData(int(TizenManifestEditorWidget::Source));
  50. m_actionGroup->addAction(sourceAction);
  51. generalAction->setChecked(true);
  52. setContext(Core::Context(Constants::TIZEN_MANIFEST_EDITOR_CONTEXT));
  53. setWidget(editorWidget);
  54. }
  55. Core::Id TizenManifestEditor::id() const
  56. {
  57. return Core::Id(Constants::TIZEN_MANIFEST_EDITOR_ID);
  58. }
  59. bool TizenManifestEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
  60. {
  61. return widget()->open(errorString, fileName, realFileName);
  62. }
  63. QWidget *TizenManifestEditor::toolBar()
  64. {
  65. return m_toolBar;
  66. }
  67. TizenManifestEditorWidget *TizenManifestEditor::widget() const
  68. {
  69. return static_cast<TizenManifestEditorWidget *>(Core::IEditor::widget());
  70. }
  71. Core::IDocument *TizenManifestEditor::document()
  72. {
  73. return textEditor()->baseTextDocument();
  74. }
  75. TextEditor::BaseTextEditorWidget *TizenManifestEditor::textEditor() const
  76. {
  77. return widget()->textEditorWidget();
  78. }
  79. void TizenManifestEditor::changeEditorPage(QAction * action)
  80. {
  81. if(!widget()->setActivePage(static_cast<TizenManifestEditorWidget::EditorPage>(action->data().toInt()))) {
  82. foreach(QAction * action, m_actionGroup->actions()) {
  83. if(action->data().toInt() == widget()->activePage()) {
  84. action->setChecked(true);
  85. break;
  86. }
  87. }
  88. }
  89. }
  90. } // namespace Internal
  91. } // namespace Tizen