tizenmanifesteditorwidget.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. #ifndef TIZEN_TIZENMANIFESTEDITORWIDGET_H
  30. #define TIZEN_TIZENMANIFESTEDITORWIDGET_H
  31. #include <texteditor/basetexteditor.h>
  32. #include <texteditor/plaintexteditor.h>
  33. #include <texteditor/texteditoractionhandler.h>
  34. #include "ui_tizenmanifestxmleditorform.h"
  35. #include <QAbstractItemModel>
  36. #include <QStackedWidget>
  37. QT_BEGIN_NAMESPACE
  38. class QDomDocument;
  39. class QDomElement;
  40. QT_END_NAMESPACE
  41. namespace Tizen {
  42. namespace Internal {
  43. class TizenManifestEditor;
  44. class TizenManifestEditorWidget;
  45. class TizenManifestTextEditorWidget : public TextEditor::PlainTextEditorWidget
  46. {
  47. public:
  48. TizenManifestTextEditorWidget(TizenManifestEditorWidget *parent = 0);
  49. protected:
  50. TizenManifestEditorWidget *m_parent;
  51. };
  52. class TizenManifestEditorWidget : public QWidget
  53. {
  54. Q_OBJECT
  55. public:
  56. enum EditorPage {
  57. General = 0,
  58. Source = 1
  59. };
  60. explicit TizenManifestEditorWidget();
  61. bool isModified() const;
  62. bool open(QString *errorString, const QString &fileName, const QString &realFileName);
  63. void preSave();
  64. Core::IEditor *editor() const;
  65. TextEditor::PlainTextEditorWidget *textEditorWidget() const;
  66. EditorPage activePage() const;
  67. bool setActivePage(EditorPage page);
  68. signals:
  69. void guiChanged();
  70. private slots:
  71. void delayedParseCheck();
  72. void startParseCheck();
  73. void updateInfoBar();
  74. void setDirty(bool dirty = true);
  75. private slots:
  76. void addFeatureClicked();
  77. void removeFeatureClicked();
  78. void updateFeaturesButton();
  79. void featureValueIndexChanged(int);
  80. void generateAppId();
  81. void authorChanged(QString);
  82. void urlChanged(QString);
  83. private:
  84. void initializePage();
  85. bool checkDocument(QDomDocument doc, QString * errorMessage, int * errorLine, int * errorColumn);
  86. void updateInfoBar(QString errorMessage, int errorLine, int errorColumn);
  87. void hideInfoBar();
  88. bool syncToWidgets();
  89. void syncToWidgets(QDomDocument doc);
  90. void syncToEditor();
  91. void updateValue(QDomElement parent, const QString& element, const QString& value);
  92. private:
  93. struct TizenFeatureValue {
  94. QString value;
  95. QString description;
  96. bool isDefault;
  97. inline TizenFeatureValue() : isDefault(false) { }
  98. inline TizenFeatureValue(QString _value, QString _desc, bool _isDef) : value(_value), description(_desc), isDefault(_isDef) { }
  99. };
  100. QHash<QString, QList<TizenFeatureValue> > features();
  101. TextEditor::PlainTextEditorWidget *m_textEditorWidget;
  102. QStackedWidget *m_stackedWidget;
  103. TizenManifestEditor *m_editor;
  104. bool m_dirty;
  105. int m_errorLine;
  106. int m_errorColumn;
  107. QTimer * m_parseTimer;
  108. bool m_stayClean;
  109. Ui::TizenManifestXmlEditorForm m_form;
  110. QHash<QString, QList<TizenFeatureValue> > m_features;
  111. QHash<QString, QString> m_featureValues;
  112. TizenManifestEditor *m_manifestEditor;
  113. // Actual widgets for XML values
  114. };
  115. } // namespace Internal
  116. } // namespace Tizen
  117. #endif // TIZEN_TIZENMANIFESTEDITORWIDGET_H