OSDN Git Service

[denncoCreator] fixed a crash bug.
[dennco/denncoCreator.git] / Source / codeeditor / dccellscriptseditorpagewidget.h
1 //  Copyright (c) 2012 Dennco Project
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 //
17 //  Created by tkawata on Nov-3, 2012.
18 //
19 #ifndef DCCELLCODEEDITORPAGEWIDGET_H
20 #define DCCELLCODEEDITORPAGEWIDGET_H
21
22 #include <QWidget>
23 #include <QSplitter>
24 #include <QPushButton>
25
26 #include "dceditscriptfolder.h"
27
28 class DCCell;
29 class DCCellCode;
30 class DCCodeEditor;
31 class DCVCPage;
32
33 class DCCellScriptsEditorPageWidget : public QWidget
34 {
35     Q_OBJECT
36
37     DCCell          *d_cell;
38     DCCellCode      *d_cellCodeOrg;
39     DCCodeEditor    *d_customScriptEditor;
40     DCCodeEditor    *d_cellCodeScriptEditor;
41
42     QSplitter       *d_splitter;
43
44     bool                d_modified;
45     DCEditScriptFolder  d_customScriptFolder;
46     DCEditScriptFolder  d_cellCodeScriptFolder;
47
48     QPushButton         *d_customScriptEditExternalButton;
49     QPushButton         *d_cellCodeScriptEditExternalButton;
50     bool                d_customScriptExternalMode;
51     bool                d_cellCodeScriptExternalMode;
52
53     bool            loadCustomScript(bool forceReload = false);
54     bool            loadCellCodeScript(bool forceReload = false);
55     bool            loadScripts();
56     void            updateModifiedStatus();
57
58 public:
59     DCCellScriptsEditorPageWidget(DCCell *targetCell, QWidget *parent = 0);
60     virtual ~DCCellScriptsEditorPageWidget();
61
62     bool            getIsModified() const;
63     bool            getIsCustomScriptModifiedByExternalEditor() const;
64     bool            getIsCellCodeModifiedByExternalEditor() const;
65     qint64          getCustomScriptLoadedTime() const;
66     qint64          getCellCodeScriptLoadedTime() const;
67     bool            getIsCustomScriptExternalMode() const { return d_customScriptExternalMode; }
68     bool            getIsCellCodeScriptExternalMode() const { return d_cellCodeScriptExternalMode; }
69
70     void            setReadOnly(bool readOnly);
71     QSet<DCVCPage*> saveScriptsToFile(bool saveModifiedOnly);
72     bool            saveCustomScriptOnlyToFile(bool saveModifiedOnly);
73     bool            saveCellCodeScriptOnlyToFile(bool saveModifiedOnly);
74
75     void            focusCustomScript();
76     void            focusCellCodeScript();
77
78     void            reloadCustomScript();
79     void            reloadCellCodeScript();
80
81 signals:
82     void editingCellDestroyed(DCCell *cell);
83     void cellScriptsModifiedStatusChanged(QWidget *self, bool modified);
84     void cellScriptsSaved(QWidget *self);
85     void customScriptModifiedByExternalEditor(QWidget *self, qint64 notifiedTime);
86     void cellCodeScriptModifiedByExternalEditor(QWidget *self, qint64 notifiedTime);
87
88 private slots:
89     void assignedCellCodeChanged();
90     void cellDestroyed();
91     void editorCustomScriptChanged();
92     void editorCellCodeScriptChanged();
93     void folderCustomScriptChanged();
94     void folderCellCodeScriptChanged();
95     void folderCustomScriptModifiedStatusChanged(bool modified);
96     void folderCellCodeScriptModifiedStatusChanged(bool modified);
97     void folderCustomScriptFileModifiedByExternalEditor(qint64 notifiedTime);
98     void folderCellCodeScriptFileModifiedByExternalEditor(qint64 notifiedTime);
99
100     void useExternalEditorForCustomScriptPressed();
101     void useExternalEditorForCellCodeScriptPressed();
102 };
103
104 #endif // DCCELLCODEEDITORPAGEWIDGET_H