NCL Composer  0.1.5
 All Classes Functions Variables Pages
NCLTreeWidget.h
1 /*
2  * Copyright 2011-2012 TeleMidia/PUC-Rio.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see
16  * <http://www.gnu.org/licenses/>.
17  */
18 #ifndef NCLTREEWIDGET_H
19 #define NCLTREEWIDGET_H
20 
21 #include <map>
22 using namespace std;
23 
24 #include <QDebug>
25 #include <QtXml>
26 #include <QHeaderView>
27 #include <QMenu>
28 #include <QAction>
29 #include <QTreeWidget>
30 #include <QShortcut>
31 #include <QKeyEvent>
32 #include <QWheelEvent>
33 
34 #include "NCLParser.h"
35 
42 class NCLTreeWidget: public QTreeWidget {
43  Q_OBJECT
44 
45 private:
46  QAction *insertNodeAct;
47  QAction *removeNodeAct;
48  QAction *expandAllAct;
49  QMenu *elementMenu;
51  QShortcut *shortcut_zoomout;
52  QShortcut *shortcut_zoomin;
53  bool isExpandedAll;
54 
55  int fontSize;
56  QFont defaultFont;
57 
61  void createActions();
65  void createMenus();
66 
67  /* User events */
74  void wheelEvent(QWheelEvent * event);
80  void keyPressEvent(QKeyEvent *event);
81 
82 public:
88  NCLTreeWidget(QWidget *parent = 0);
92  virtual ~NCLTreeWidget();
96  void setDefaultFont(const QFont &defaultFont);
100  void mouseMoveEvent(QMouseEvent *event);
101 
102  QSize sizeHint() const { return QSize(250, 400); }
103 
104 public slots:
111  bool updateFromText(QString text);
112 
126  QTreeWidgetItem* addElement ( QTreeWidgetItem *father,
127  int pos,
128  QString tagname,
129  QString id,
130  QMap <QString, QString> &attrs,
131  int line_in_text = -1,
132  int column_in_text = -1);
133 
141  QTreeWidgetItem* getItemById(QString itemId);
147  void removeItem(QString itemId);
155  void updateItem(QTreeWidgetItem* item, QString tagname,
156  QMap <QString, QString> &attrs);
157 
167  void errorNotification( QString message,
168  QString filename,
169  int line,
170  int column,
171  int severity);
172  void expandAll();
173 
174 
178  void resetFont();
182  void zoomIn();
186  void zoomOut();
190  void resetZoom();
191 
192 private slots:
196  void userAddNewElement();
200  void userRemoveElement();
204  void decreaseFont();
208  void increaseFont();
209 
210 signals:
219  void elementAddedByUser(QString, QString, QMap<QString,QString>&, bool);
225  void elementRemovedByUser (QString);
235  void parserErrorNotify( QString message,
236  QString filename,
237  int line,
238  int column,
239  int severity);
240 
241 };
242 
243 #endif