tizenmanifesteditorwidget.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #ifndef TIZEN_TIZENMANIFESTEDITORWIDGET_H
  29. #define TIZEN_TIZENMANIFESTEDITORWIDGET_H
  30. #include <texteditor/basetexteditor.h>
  31. #include <texteditor/plaintexteditor.h>
  32. #include <texteditor/texteditoractionhandler.h>
  33. #include "ui_tizenmanifestxmleditorform.h"
  34. #include <QAbstractItemModel>
  35. QT_BEGIN_NAMESPACE
  36. class QDomDocument;
  37. class QDomElement;
  38. QT_END_NAMESPACE
  39. namespace Tizen {
  40. class TizenManifestEditorWidget : public TextEditor::PlainTextEditorWidget
  41. {
  42. Q_OBJECT
  43. public:
  44. enum EditorPage {
  45. GeneralPage,
  46. SourcePage
  47. };
  48. explicit TizenManifestEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler * ah);
  49. bool isModified() const;
  50. bool open(QString *errorString, const QString &fileName, const QString &realFileName);
  51. void preSave();
  52. EditorPage activePage() const;
  53. bool setActivePage(EditorPage page);
  54. private slots:
  55. void delayedParseCheck();
  56. void startParseCheck();
  57. void updateInfoBar();
  58. void setDirty(bool dirty = true);
  59. private slots:
  60. void addFeatureClicked();
  61. void removeFeatureClicked();
  62. void updateFeaturesButton();
  63. void featureValueIndexChanged(int);
  64. void generateAppId();
  65. void authorChanged(QString);
  66. void urlChanged(QString);
  67. protected:
  68. virtual TextEditor::BaseTextEditor *createEditor();
  69. virtual void resizeEvent(QResizeEvent *);
  70. private:
  71. void initializePage();
  72. bool checkDocument(QDomDocument doc, QString * errorMessage, int * errorLine, int * errorColumn);
  73. void updateInfoBar(QString errorMessage, int errorLine, int errorColumn);
  74. void hideInfoBar();
  75. bool syncToWidgets();
  76. void syncToWidgets(QDomDocument doc);
  77. void syncToEditor();
  78. void updateValue(QDomElement parent, const QString& element, const QString& value);
  79. private:
  80. struct TizenFeatureValue {
  81. QString value;
  82. QString description;
  83. bool isDefault;
  84. inline TizenFeatureValue() : isDefault(false) { }
  85. inline TizenFeatureValue(QString _value, QString _desc, bool _isDef) : value(_value), description(_desc), isDefault(_isDef) { }
  86. };
  87. QHash<QString, QList<TizenFeatureValue> > features();
  88. TextEditor::TextEditorActionHandler * m_actionHandler;
  89. QWidget * m_overlayWidget;
  90. EditorPage m_activePage;
  91. bool m_dirty;
  92. int m_errorLine;
  93. int m_errorColumn;
  94. QTimer * m_parseTimer;
  95. bool m_stayClean;
  96. Ui::TizenManifestXmlEditorForm m_form;
  97. QHash<QString, QList<TizenFeatureValue> > m_features;
  98. QHash<QString, QString> m_featureValues;
  99. // Actual widgets for XML values
  100. };
  101. } // namespace Tizen
  102. #endif // TIZEN_TIZENMANIFESTEDITORWIDGET_H