tizenmanifesteditor.cpp 3.3 KB

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