Mercurial > octave-nkf
comparison gui/src/editor/FileEditorTab.h @ 14690:ca733a66be7a gui
Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk.
* MainWindow: Simplified opening file request calls.
* FileEditor: Added new slot that closes tabs without and index and made FileEditorTabs connect to it.
* FileEditorTab: Added QFileSystemWatcher and fixed bug with setting modified status on m_modified. Implemented message boxes for the cases that a file has been removed, renamed und modified from outside.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Fri, 25 May 2012 23:56:31 +0200 |
parents | 628eeaf879f7 |
children | c952f1e35e50 |
comparison
equal
deleted
inserted
replaced
14689:dd19de736ee4 | 14690:ca733a66be7a |
---|---|
19 #define FILEEDITORTAB_H | 19 #define FILEEDITORTAB_H |
20 | 20 |
21 #include <Qsci/qsciscintilla.h> | 21 #include <Qsci/qsciscintilla.h> |
22 #include <QWidget> | 22 #include <QWidget> |
23 #include <QCloseEvent> | 23 #include <QCloseEvent> |
24 #include <QFileSystemWatcher> | |
24 | 25 |
25 class FileEditor; | 26 class FileEditor; |
26 class FileEditorTab : public QWidget | 27 class FileEditorTab : public QWidget |
27 { | 28 { |
28 Q_OBJECT | 29 Q_OBJECT |
46 void undo (); | 47 void undo (); |
47 void redo (); | 48 void redo (); |
48 | 49 |
49 void setModified (bool modified); | 50 void setModified (bool modified); |
50 | 51 |
51 void openFile (); | 52 bool openFile(); |
52 void loadFile (QString fileName); | 53 void loadFile (QString fileName); |
53 void newFile (); | 54 void newFile (); |
54 void saveFile (); | 55 bool saveFile (); |
55 void saveFile (QString saveFileName); | 56 bool saveFile(QString saveFileName); |
56 void saveFileAs (); | 57 bool saveFileAs(); |
57 void runFile (); | 58 void runFile (); |
59 | |
60 void fileHasChanged (QString fileName); | |
58 | 61 |
59 signals: | 62 signals: |
60 void fileNameChanged (QString fileName); | 63 void fileNameChanged (QString fileName); |
61 void editorStateChanged (); | 64 void editorStateChanged (); |
65 void closeRequest (); | |
62 | 66 |
63 protected: | 67 protected: |
64 void closeEvent (QCloseEvent *event); | 68 void closeEvent (QCloseEvent *event); |
69 void setFileName (QString fileName); | |
65 | 70 |
66 private: | 71 private: |
72 void updateTrackedFile (); | |
67 int checkFileModified (QString msg, int cancelButton); | 73 int checkFileModified (QString msg, int cancelButton); |
68 void doCommentSelectedText (bool comment); | 74 void doCommentSelectedText (bool comment); |
69 | 75 |
70 FileEditor *m_fileEditor; | 76 FileEditor *m_fileEditor; |
71 QsciScintilla *m_editArea; | 77 QsciScintilla *m_editArea; |
72 | 78 |
73 QString m_fileName; | 79 QString m_fileName; |
74 QString m_fileNameShort; | 80 QString m_fileNameShort; |
75 | 81 |
76 bool m_modified; | |
77 bool m_longTitle; | 82 bool m_longTitle; |
78 bool m_copyAvailable; | 83 bool m_copyAvailable; |
79 | 84 |
80 // TODO: Use QFileSystemWatcher to sync with disc. | 85 QFileSystemWatcher m_fileSystemWatcher; |
81 }; | 86 }; |
82 | 87 |
83 #endif // FILEEDITORTAB_H | 88 #endif // FILEEDITORTAB_H |