ScriptWidget.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled applications.
5 
6  TerraLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License,
9  or (at your option) any later version.
10 
11  TerraLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with TerraLib. See COPYING. If not, write to
18  TerraLib Team at <terralib-team@terralib.org>.
19  */
20 
21 /*!
22  \file terralib/qsci/ceditor/ScriptWidget.h
23 
24  \brief A widget that can be used to show and control he execution of a script.
25 */
26 
27 #ifndef __TERRALIB_QSCI_CEDITOR_SCRIPTWIDGET_H__
28 #define __TERRALIB_QSCI_CEDITOR_SCRIPTWIDGET_H__
29 
30 // TerraLib
31 #include "../Config.h"
32 
33 // Qt
34 #include <QWidget>
35 
36 // Forward declaration
37 class QString;
38 
39 // Forward declaration
40 class QsciLexer;
41 class QsciScintilla;
42 
43 namespace te
44 {
45  namespace ce
46  {
47  /*!
48  \class ScriptWidget
49 
50  \brief A widget that can be used to show and control the execution of a script.
51  */
52  class TECEDITOREXPORT ScriptWidget : public QWidget
53  {
54  Q_OBJECT
55 
56  public:
57 
58  /*!
59  \brief ScriptWidget
60 
61  \param parent
62  */
63  ScriptWidget(QWidget* parent);
64 
65  /*! \brief Destructor. */
66  ~ScriptWidget();
67 
68  /*!
69  \brief Returns the file name of the script.
70 
71  \return File name.
72  */
73  QString getFileName() const { return m_fileName; }
74 
75  /*!
76  \brief getScriptType
77 
78  \return Returns the type of the script based on its extension.
79  */
80  QString getScriptType() const;
81 
82  /*!
83  \brief getScriptName
84 
85  \return Return the script name.
86  */
87  QString getScriptName() const;
88 
89  /*!
90  \brief Open the code file and presents it on the screen.
91 
92  \param fileName File name.
93  */
94  void open(const QString& fileName);
95 
96  /*!
97  \brief Save the contents code in a file.
98 
99  \param fileName Name of the file.
100  */
101  void save(const QString& fileName);
102 
103  /*!
104  \brief Returns the flag that signals if the code was edited.
105 
106  \return Returns true or false.
107  */
108  bool hasChanged() const;
109 
110  public slots:
111 
112  /*!
113  \brief Saves the current file.
114  */
115  void save();
116 
117  /*!
118  \brief saveAs Saves the current file in a different file.
119  */
120  void saveAs();
121 
122  /*! \brief Closes the current script. */
123  void close();
124 
125  /*! \brief Executes the current script. */
126  void execute();
127 
128  /*! \brief Stops the execution of the script. */
129  void stop();
130 
131  /*! \brief Pauses the execution. */
132  void pause();
133 
134  /*! \brief Zoom in. */
135  void zoomIn();
136 
137  /*! \brief Zoom out. */
138  void zoomOut();
139 
140  /*! \brief Sets to true the textChanged flag. */
141  void setTextChanged();
142 
143  signals:
144 
145  void codeChanged();
146 
147  protected:
148 
149  /*!
150  \brief Saves the name of the file.
151 
152  \param fileName The complete path of the script.
153  */
154  void saveFile(const QString& fileName);
155 
156  /*! \brief setLexer. */
157  void setLexer();
158 
159  void setUnsaved(bool unsaved);
160 
161  private:
162 
163  QsciScintilla* m_txtEditor; //!< The editor with grammatical highlighted marks.
164  QsciLexer* m_lexer; //!< The text editor owns the lexer.
165  QString m_fileName; //!< File name.
166  bool m_unsaved; //!< Code has changed?
167  };
168 
169  } // end namespace ce
170 } // end namespace te
171 
172 #endif // __TERRALIB_QSCI_CEDITOR_SCRIPTWIDGET_H__
QsciLexer * m_lexer
The text editor owns the lexer.
Definition: ScriptWidget.h:164
#define TECEDITOREXPORT
Definition: Config.h:40
QString getFileName() const
Returns the file name of the script.
Definition: ScriptWidget.h:73
URI C++ Library.
bool m_unsaved
Code has changed?
Definition: ScriptWidget.h:166
QsciScintilla * m_txtEditor
The editor with grammatical highlighted marks.
Definition: ScriptWidget.h:163
QString m_fileName
File name.
Definition: ScriptWidget.h:165
A widget that can be used to show and control the execution of a script.
Definition: ScriptWidget.h:52