1 #ifndef POLFILEEDITOR_H
2 #define POLFILEEDITOR_H
3 
4 #include <QWidget>
5 #include "polsyntaxhighlighter.h"
6 
7 namespace Ui {
8 class PolFileEditor;
9 }
10 
11 namespace xmpsolve {
12 
13 class PolFileEditor : public QWidget
14 {
15     Q_OBJECT
16 
17 public:
18 
19     /**
20      * @brief State of the document
21      */
22     enum State {
23         SAVED,
24         MODIFIED
25     };
26 
27     explicit PolFileEditor(QWidget *parent = 0, QString path = QString());
28 
29     /**
30      * @brief Save the file to the given path, or to the default one if path is
31      * an empty string.
32      */
33     void savePolFile(QString path = QString());
34 
35     /**
36      * @brief currentPolFile returns the currently opened .pol file
37      * @return a QString with the absolute path of the file
38      */
39     QString currentPolFile();
40 
41     /**
42      * @brief isEmpty returns true if the editor has no content in it.
43      * @return
44      */
45     bool isEmpty();
46 
47     /**
48      * @brief state returns the current state of the document
49      * @return the value of m_state.
50      */
51     State state();
52 
53     /**
54      * @brief content returns the content of the editor
55      * @return A QString with the current content of the Editor.
56      */
57     QString content();
58 
59     ~PolFileEditor();
60 
61 signals:
62     void filenameChanged(QString filename);
63     void stateChanged(PolFileEditor::State);
64 
65 private slots:
66     void onTextEditChanged(bool);
67 
68 private:
69     Ui::PolFileEditor *ui;
70     PolSyntaxHighlighter *m_syntaxHighlighter;
71     QString m_polFilePath;
72     State m_state;
73 
74 };
75 
76 } // End of namespace xmpsolve
77 
78 #endif // POLFILEEDITOR_H
79