Debian Codegraph @

src/xmpsolve/polfileeditorwindow.h

raw
1 #ifndef POLFILEEDITORWINDOW_H
2 #define POLFILEEDITORWINDOW_H
3
4 #include <QMainWindow>
5 #include <QList>
6 #include "polfileeditor.h"
7
8 namespace Ui {
9 class PolFileEditorWindow;
10 }
11
12 namespace xmpsolve {
13
14 class PolFileEditorWindow : public QMainWindow
15 {
16 Q_OBJECT
17
18 public:
19 explicit PolFileEditorWindow(QWidget *parent = 0);
20 ~PolFileEditorWindow();
21
22 /**
23 * @brief loadPolFile loads the file specified by path or simply
24 * focus the tab containing it if it's already loaded.
25 *
26 * @brief path is the path to the file
27 */
28 void loadPolFile(QString path = QString());
29
30 /**
31 * @brief savePolFile save the pol file in the currently selected tab.
32 */
33 void savePolFile();
34
35 /**
36 * @brief closePolFile closes the tab of the given .pol file
37 * @param path is the absolute path to the file to close.
38 */
39 void closePolFile(QString path);
40
41 /**
42 * @brief Close the given editor.
43 */
44 void closeEditor(PolFileEditor* editor);
45
46 /**
47 * @brief currentPolFile returns the path to the currently focused
48 * .pol file.
49 * @return A QString with the absolute path of the currently focused
50 * .pol file.
51 */
52 QString currentPolFile();
53
54 /**
55 * @brief currentEditor can be used to access the current PolFileEditor focused
56 * in the tabWidget.
57 * @return A pointer to the focused instance of PolFileEditor, or NULL if there is none.
58 */
59 PolFileEditor* currentEditor();
60
61 signals:
62 /**
63 * @brief solvePoly is emitted when the user asks to solve a .pol file.
64 * @param path is the path to the content of the file that the user wants to solve.
65 */
66 void solvePoly(QString content);
67
68 public slots:
69 /**
70 * @brief onEditorFilenameChanged handle the change of filename inside
71 * and editor tab.
72 */
73 void onEditorFilenameChanged(QString);
74
75 /**
76 * @brief onEditorStateChanged handle the state changed of the editor tab.
77 */
78 void onEditorStateChanged(PolFileEditor::State);
79
80 private slots:
81 void on_actionOpen_pol_file_triggered();
82
83 void on_actionSave_triggered();
84
85 void on_actionSolve_triggered();
86
87 void on_actionClose_triggered();
88
89 void on_actionClose_editor_triggered();
90
91 void on_actionNew_triggered();
92
93 private:
94 Ui::PolFileEditorWindow *ui;
95
96 /**
97 * @brief m_polFileEditors is a HashTable containing the associations
98 * between paths on the filesystem and tab of the tabWidget.
99 *
100 * This allows to not open more than one tab at a time for a given file.
101 */
102 QMap<QString, PolFileEditor*> m_polFileEditors;
103
104 /**
105 * @brief Overriden closeEvent that handle the saving of files that
106 * haven't been closed.
107 */
108 void closeEvent(QCloseEvent *);
109
110 /**
111 * @brief Close all opened tabs and prompt the user to save the unsaved ones.
112 */
113 void closeOpenedTabs();
114
115 void showEvent(QShowEvent *event);
116
117 /**
118 * @brief setupIcons loads the icons needed by the Window.
119 */
120 void setupIcons();
121 };
122
123 } // End of namespace xmpsolve
124
125 #endif // POLFILEEDITORWINDOW_H