Mercurial > octave
view libgui/src/set-path-model.h @ 27298:1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
Originally submitted by JunWang,
Edited by Rik, jwe, and Torsten.
* main-window.cc (main_window): initialize new m_settings_dlg class variable;
(~main_window): delete set path dialog;
(handle_set_path_dialog_request): new slot for opening the path dialog;
(set_global_shortcuts): set shortcut for opening new path dialog;
(construct_edit_menu): add and connect related action to the edit menu;
(configure_shortcuts): read the shortcut from the preferences file
* main-window.h: include path dialog header, new path variable and new action
for dialog
* module.mk: add new files
* set-path-dialog.cc: new file
(set_path_dialog): constructing the dialog with widgets and buttons,
connecting all action signals, adding model object;
(add_dir): open file dailog to select directory to be added to the path;
(rm_dir): call rm_dir method in model object for removing selected dirs;
(move_dir_up, move_dir_bottom, move_dir_top, move_dir_bottom):
call related model object for moving selected dirs and update selection
and view accordingly;
* set-path-dialog.h: new header for path dialog
* set-path-model.cc: new file for path dialog model
(set_path_model): data signal connections and calling construct method;
(to_string): make a string from the current list of directories;
(model_to_path): set the octave path to the current model data;
(clear): clear the current model data;
(save): save current model data using savepath;
(revert) reset the model data to the state from dialog start;
(revert_last): Reset the model data to the state before the latest change;
(add_dir): add a directory to the current model data and path;
(rm_dir): remoce a directory from current model data and path;
(move_dir_up, move_dir_down, move_dir_top, move_dir_bottom): move one ore
more directory entries wihtin the path;
(rowCount): retiurn the size if the current model data;
(data): reimplemeneted method for returning data from the model;
(construct): loading the current path into the model;
(update_data): slot for update data signal
* set-path-model.h: model header file
* shortcut-manager.cc (do_init_data): initialize shortcut for path dialog
with empty key sequence
author | JunWang <jstzwj@aliyun.com> |
---|---|
date | Mon, 22 Jul 2019 23:51:01 -0400 |
parents | |
children | d20c31be3160 |
line wrap: on
line source
/* Copyright (C) 2019 JunWang This file is part of Octave. Octave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Octave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, see <https://www.gnu.org/licenses/>. */ #if ! defined (octave_set_path_model_h) #define octave_set_path_model_h 1 #include <QAbstractListModel> #include <QStringList> #include <QList> #include <QFileInfo> #include <QIcon> namespace octave { class set_path_model : public QAbstractListModel { Q_OBJECT public: set_path_model (QObject *p = nullptr); ~set_path_model (void) = default; void clear (void); void add_dir (const QString& p); void rm_dir (const QModelIndexList& indices); void move_dir_up (const QModelIndexList& indices); void move_dir_down (const QModelIndexList& indices); void move_dir_top (const QModelIndexList& indices); void move_dir_bottom (const QModelIndexList& indices); std::string to_string (void); // Overloaded Qt methods void model_to_path (void); int rowCount (const QModelIndex& p = QModelIndex ()) const; QVariant data (const QModelIndex& idx, int role) const; public slots: void save (void); void revert (void); void revert_last (void); signals: void update_data_signal (const QStringList& dirs); private slots: void update_data (const QStringList& dirs); private: void construct (void); QStringList m_dirs; QStringList m_orig_dirs; QStringList m_last_dirs; }; } #endif