tools/qcrmlgen/qcrmlgen.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    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, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 #include <QMainWindow>
       
    42 #include <QItemDelegate>
       
    43 
       
    44 QT_BEGIN_NAMESPACE
       
    45 class QTableWidget;
       
    46 class QLabel;
       
    47 class QLineEdit;
       
    48 class QTableWidget;
       
    49 class QPushButton;
       
    50 class QAbstractButton;
       
    51 class QRadioButton;
       
    52 QT_END_NAMESPACE
       
    53 
       
    54 class EditorWidget;
       
    55 class QCrmlGenerator : public QMainWindow
       
    56 {
       
    57     Q_OBJECT
       
    58 public:
       
    59     QCrmlGenerator();
       
    60 private slots:
       
    61     void newFile();
       
    62     void openFile();
       
    63     void saveFile();
       
    64     void saveFileAs();
       
    65 
       
    66 protected:
       
    67     void closeEvent(QCloseEvent *event);
       
    68 
       
    69 private:
       
    70     bool safeToClear();
       
    71     EditorWidget *m_editorWidget;
       
    72 
       
    73     QAction *newAction;
       
    74     QAction *openAction;
       
    75     QAction *saveAction;
       
    76     QAction *saveAsAction;
       
    77     QAction *exitAction;
       
    78 
       
    79     QString m_saveFile;
       
    80 };
       
    81 
       
    82 
       
    83 //#define INCL_TYPE 1
       
    84 
       
    85 #ifdef INCL_TYPE
       
    86 class TypeDelegate : public QItemDelegate
       
    87 {
       
    88     Q_OBJECT
       
    89 
       
    90 public:
       
    91     TypeDelegate(QTableWidget *parent);
       
    92     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
       
    93                             const QModelIndex &) const;
       
    94     void setEditorData(QWidget *editor, const QModelIndex &index) const;
       
    95     void setModelData(QWidget *editor, QAbstractItemModel *,
       
    96                         const QModelIndex &index) const;
       
    97 private:
       
    98     QTableWidget *m_parentTable;
       
    99 
       
   100 };
       
   101 #endif
       
   102 
       
   103 class KeyIdDelegate : public QItemDelegate
       
   104 {
       
   105     Q_OBJECT
       
   106 public:
       
   107     KeyIdDelegate(QTableWidget *parent);
       
   108     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
       
   109                             const QModelIndex &) const;
       
   110     void setModelData(QWidget *editor, QAbstractItemModel *,
       
   111                         const QModelIndex &index) const;
       
   112 private:
       
   113     QTableWidget *m_parentTable;
       
   114 
       
   115 };
       
   116 
       
   117 class PathDelegate : public QItemDelegate
       
   118 {
       
   119     Q_OBJECT
       
   120 public:
       
   121     PathDelegate(QTableWidget *parent);
       
   122     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
       
   123                             const QModelIndex &) const;
       
   124     void setEditorData(QWidget *editor, QAbstractItemModel *,
       
   125                         const QModelIndex &index) const;
       
   126     void setModelData(QWidget *editor, QAbstractItemModel *,
       
   127                         const QModelIndex &index) const;
       
   128 private:
       
   129     QTableWidget *m_parentTable;
       
   130 };
       
   131 
       
   132 class EditorWidget: public QWidget
       
   133 {
       
   134     Q_OBJECT
       
   135 public:
       
   136     enum Column{KeyId, Path, Type};
       
   137     EditorWidget();
       
   138 
       
   139 public slots:
       
   140     void addRow();
       
   141     void removeRow();
       
   142 
       
   143     void initNew();
       
   144     void save(const QString &);
       
   145     void open(const QString &);
       
   146 
       
   147     bool isModified();
       
   148     bool verifyContents();
       
   149 
       
   150 private slots:
       
   151     void setModified(bool b = true);
       
   152     void moveRowDown();
       
   153     void moveRowUp();
       
   154     void targetChanged(QAbstractButton *);
       
   155 
       
   156 private:
       
   157     QLabel *m_repoLabel;
       
   158     QLineEdit *m_repoUID;//repository or category ID
       
   159     QTableWidget *m_tableWidget;
       
   160     QPushButton *m_addRowButton;
       
   161     QPushButton *m_removeRowButton;
       
   162     QRadioButton *m_CRepRadio;
       
   163     QRadioButton *m_RPropRadio;
       
   164 #ifdef INCL_TYPE
       
   165     TypeDelegate *m_typeDelegate;
       
   166 #endif
       
   167     KeyIdDelegate *m_keyIdDelegate;
       
   168     PathDelegate *m_pathDelegate;
       
   169 
       
   170     bool m_isModified;
       
   171 };