NCL Composer  0.1.5
 All Classes Functions Variables Pages
NCLTextualViewPlugin.h
1 /*
2  * Copyright 2011 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 NCLTEXTUALVIEWPLUGIN_H
19 #define NCLTEXTUALVIEWPLUGIN_H
20 
21 #include <QObject>
22 
23 #include "NCLTextEditor.h"
24 #include "NCLTextEditorMainWindow.h"
25 
26 #include "NCLTextualViewPlugin_global.h"
27 
28 #include <QShortcut>
29 #include <QKeySequence>
30 #include <QDomElement>
31 #include <QMutex>
32 
33 #include <core/extensions/IPlugin.h>
34 using namespace composer::extension;
35 
40  public IPlugin
41 {
42  Q_OBJECT
43 
44 private:
45  NCLTextEditorMainWindow *window;
46  NCLTextEditor *nclTextEditor;
47  NCLTextEditor *tmpNclTextEditor;
51  QMap <QString, int> startEntityOffset;
52  QMap <QString, int> endEntityOffset;
54  QShortcut *updateModelShortcut;
55 
56  bool isSyncing;
57  Entity *currentEntity;
58 
59  QDomDocument xmlDoc;
60  QMutex syncMutex;
61 
62 public:
66  explicit NCLTextualViewPlugin();
75  void init();
83  bool saveSubsession();
91  QWidget* getWidget();
92 
93 public slots:
101  void onEntityAdded(QString pluginID, Entity *);
110  void onEntityChanged(QString pluginID, Entity *);
118  void onEntityRemoved(QString pluginID, QString entityID);
125  void errorMessage(QString error);
133  void changeSelectedEntity(QString pluginID, void* param);
138  void updateFromModel();
139 
146  void incrementalUpdateFromModel();
147 
155  void nonIncrementalUpdateFromModel();
156 
161  void updateErrorMessages();
162 
163 // COMUNICATION WITH VALIDATION PLUGIN //
168  void clearValidationMessages(QString, void *param);
172  void validationError(QString pluginID, void *param);
173 // END COMMUNICATION WITH VALIDATION PLUGIN
174 
175 private slots:
180  void updateCoreModel();
181 
186  void incrementalUpdateCoreModel();
187 
192  void nonIncrementalUpdateCoreModel();
193 
197  void syncFinished();
198 
202  virtual void manageFocusLost(QFocusEvent *event);
203 
204 signals:
205  void TextualPluginHasAddedEntity(QString pluginID, Entity *entity);
206 
207 protected:
208  void updateEntitiesOffset(int startFrom = 0, int insertedChars = 0);
209  void printEntitiesOffset();
210 
214  bool isStartEndTag(Entity *entity);
215 
219  void openStartEndTag(Entity *entity);
220 
224  void fixIdentation(int offset, bool mustAddTab = false);
225 };
226 
227 #endif // DEBUGCONSOLEPLUGIN_H