Mercurial > octave
diff libgui/src/m-editor/file-editor.h @ 20796:ed770c16a3e8
also store encoding and tab index with last editor session (bugs #46588, #45688)
* file-editor-tab.cc (file_name_query): send encoding, too
* file-editor-tab.h: signal add_filename_to_list contains encoding, toolTip
* file-editor.cc (check_closing): collect file name, ID and encoding of all
file editor tabs and write them into the settings file;
(request_open_file ()): reset _file_encoding to an empty string (default);
(find_tab_widget): new structure of the editor tab map;
(request_open_files): call request_open_file with encoding, do not reset
_file_encoding here;
(request_open_file (x)): encoding is new parameter, calls set_encoding ();
(handle_insert_debugger_pointer_request): empty encoding (default);
(handle_update_breakpoint_marker): empty encoding (default);
(handle_add_filename_to_list): new structure of the editor tab map
with additional entry for the encoding;
(construct): restore session in an extra function;
(restore_session): get file names, encodings and tab index from settings
file, sort depending on tab index and open the files in the desired order
with desired encodings; new parameters for add_filename_to_list signal;
(add_file_editor_tab): connect add_filename_to_list with extra parameter
for encoding
* file-editor.h: new structs for editor tab map and for the data of the
stored session, new parameters for slot for adding a file to the map,
new encoding parameter for request_open_file (QString)
* file-editor-interface.h: virtual function request_open_file with new
parameter for encoding
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 04 Dec 2015 22:05:07 +0100 |
parents | f7b0572fff6e |
children | 2da4058d65c7 |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.h Fri Dec 04 10:03:38 2015 -0800 +++ b/libgui/src/m-editor/file-editor.h Fri Dec 04 22:05:07 2015 +0100 @@ -56,8 +56,26 @@ public: - typedef std::map<QString, QWidget *>::iterator editor_tab_map_iterator; - typedef std::map<QString, QWidget *>::const_iterator editor_tab_map_const_iterator; + struct tab_info + { + QWidget *fet_ID; + QString encoding; + }; + + typedef std::map<QString, tab_info>::iterator editor_tab_map_iterator; + typedef std::map<QString, tab_info>::const_iterator editor_tab_map_const_iterator; + + // struct that allows to sort with respect to the tab index + struct session_data + { + QString index; + QString file_name; + QString encoding; + bool operator<(const session_data &other) const + { + return index < other.index; + } + }; file_editor (QWidget *p); ~file_editor (void); @@ -198,7 +216,8 @@ const QString& toolTip); void handle_tab_close_request (int index); void handle_tab_remove_request (void); - void handle_add_filename_to_list (const QString& fileName, QWidget *ID); + void handle_add_filename_to_list (const QString& fileName, + const QString& encoding, QWidget *ID); void active_tab_changed (int index); void handle_editor_state_changed (bool enableCopy, bool is_octave_file); void handle_mru_add_file (const QString& file_name); @@ -229,8 +248,9 @@ private slots: void request_open_files (const QStringList&); - void request_open_file (const QString& fileName, int line = -1, - bool debug_pointer = false, + void request_open_file (const QString& fileName, + const QString& encoding = QString (), + int line = -1, bool debug_pointer = false, bool breakpoint_marker = false, bool insert = true); void request_preferences (bool); void request_styles_preferences (bool); @@ -273,6 +293,8 @@ void switch_tab (int direction, bool movetab = false); + void restore_session (QSettings *settings); + bool editor_tab_has_focus (); QWidget *find_tab_widget (const QString& openFileName) const; @@ -281,7 +303,7 @@ QMenu* m_add_menu (QMenuBar *p, QString text); - std::map<QString, QWidget *> editor_tab_map; + std::map<QString, tab_info> editor_tab_map; QHash<QMenu*, QStringList> _hash_menu_text; QString ced;