OSDN Git Service

524af2b843d113ee2396b19e814310cfcb01b000
[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 #include <QProcess>
26
27 #include "dceditscriptfolder.h"
28
29 class DCCell;
30 class DCCellCode;
31 class DCCodeEditor;
32 class DCVCPage;
33
34 class DCCellScriptsEditorPageWidget : public QWidget
35 {
36     Q_OBJECT
37
38     DCCell          *d_cell;
39     DCCellCode      *d_cellCodeOrg;
40     DCCodeEditor    *d_customScriptEditor;
41     DCCodeEditor    *d_cellCodeScriptEditor;
42
43     QSplitter       *d_splitter;
44
45     bool                d_modified;
46     DCEditScriptFolder  d_customScriptFolder;
47     DCEditScriptFolder  d_cellCodeScriptFolder;
48
49     QPushButton         *d_customScriptEditExternalButton;
50     QPushButton         *d_cellCodeScriptEditExternalButton;
51     bool                d_customScriptExternalMode;
52     bool                d_cellCodeScriptExternalMode;
53     QList<QProcess*>    d_processes;
54
55     bool            loadCustomScript(bool forceReload = false);
56     bool            loadCellCodeScript(bool forceReload = false);
57     bool            loadScripts();
58     void            updateModifiedStatus();
59     bool            openExternalEditor(const QString& path);
60
61 public:
62     DCCellScriptsEditorPageWidget(DCCell *targetCell, QWidget *parent = 0);
63     virtual ~DCCellScriptsEditorPageWidget();
64
65     bool            getIsModified() const;
66     bool            getIsCustomScriptModifiedByExternalEditor() const;
67     bool            getIsCellCodeModifiedByExternalEditor() const;
68     qint64          getCustomScriptLoadedTime() const;
69     qint64          getCellCodeScriptLoadedTime() const;
70     bool            getIsCustomScriptExternalMode() const { return d_customScriptExternalMode; }
71     bool            getIsCellCodeScriptExternalMode() const { return d_cellCodeScriptExternalMode; }
72
73     void            setReadOnly(bool readOnly);
74     QSet<DCVCPage*> saveScriptsToFile(bool saveModifiedOnly);
75     bool            saveCustomScriptOnlyToFile(bool saveModifiedOnly);
76     bool            saveCellCodeScriptOnlyToFile(bool saveModifiedOnly);
77
78     void            focusCustomScript();
79     void            focusCellCodeScript();
80
81     void            reloadCustomScript();
82     void            reloadCellCodeScript();
83
84 signals:
85     void editingCellDestroyed(DCCell *cell);
86     void cellScriptsModifiedStatusChanged(QWidget *self, bool modified);
87     void cellScriptsSaved(QWidget *self);
88     void customScriptModifiedByExternalEditor(QWidget *self, qint64 notifiedTime);
89     void cellCodeScriptModifiedByExternalEditor(QWidget *self, qint64 notifiedTime);
90
91 private slots:
92     void assignedCellCodeChanged();
93     void cellDestroyed();
94     void editorCustomScriptChanged();
95     void editorCellCodeScriptChanged();
96     void folderCustomScriptChanged();
97     void folderCellCodeScriptChanged();
98     void folderCustomScriptModifiedStatusChanged(bool modified);
99     void folderCellCodeScriptModifiedStatusChanged(bool modified);
100     void folderCustomScriptFileModifiedByExternalEditor(qint64 notifiedTime);
101     void folderCellCodeScriptFileModifiedByExternalEditor(qint64 notifiedTime);
102
103     void useExternalEditorForCustomScriptPressed();
104     void useExternalEditorForCellCodeScriptPressed();
105 };
106
107 #endif // DCCELLCODEEDITORPAGEWIDGET_H