Mercurial > octave
annotate libgui/src/set-path-dialog.cc @ 27306:82ace1225a9c
update path dialog if path is changed from withtin the file browser
* files-dock-widget.cc (contextmenu_add_to_path): emit signal for changed path
after having chnged the path
* files-dock-widget.h: new signal path_changed_signal;
* main-window.cc (handle_set_path_dialog_request): connect path update signal
with the new slot in the path dialog
* set-path-dialog.cc (update_model): new slot for signals indicating an
external path update
* set-path-dialog.h: new public slot update_model
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Wed, 31 Jul 2019 16:46:02 +0200 |
parents | d20c31be3160 |
children | 7a7709bfb5af |
rev | line source |
---|---|
27298
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
1 /* |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
2 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
3 Copyright (C) 2019 JunWang |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
4 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
5 This file is part of Octave. |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
6 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
10 (at your option) any later version. |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
11 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
15 GNU General Public License for more details. |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
16 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
20 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
21 */ |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
22 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
24 # include "config.h" |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
25 #endif |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
26 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
27 #include <QPushButton> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
28 #include <QDialogButtonBox> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
29 #include <QGridLayout> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
30 #include <QVBoxLayout> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
31 #include <QHBoxLayout> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
32 #include <QLabel> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
33 #include <QLineEdit> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
34 #include <QComboBox> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
35 #include <QCheckBox> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
36 #include <QHeaderView> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
37 #include <QListView> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
38 #include <QFileDialog> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
39 #include <QStatusBar> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
40 #include <QIcon> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
41 #include <QFileInfo> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
42 #include <QTimer> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
43 #include <QDirIterator> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
44 #include <QTextStream> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
45 #include <QGroupBox> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
46 #include <QFileDialog> |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
47 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
48 #include "set-path-dialog.h" |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
49 #include "set-path-model.h" |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
50 #include "resource-manager.h" |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
51 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
52 namespace octave |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
53 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
54 set_path_dialog::set_path_dialog (QWidget *parent) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
55 : QDialog (parent) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
56 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
57 setWindowTitle (tr ("Set Path")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
58 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
59 m_info_label = new QLabel (tr ("All changes take effect immediately.")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
60 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
61 m_add_folder_button = new QPushButton (tr ("Add Folder...")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
62 m_move_to_top_button = new QPushButton (tr ("Move to Top")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
63 m_move_to_bottom_button = new QPushButton (tr ("Move to Bottom")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
64 m_move_up_button = new QPushButton (tr ("Move Up")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
65 m_move_down_button = new QPushButton (tr ("Move Down")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
66 m_remove_button = new QPushButton (tr ("Remove")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
67 |
27305
d20c31be3160
add a reload button to the gui path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27298
diff
changeset
|
68 m_reload_button = new QPushButton (tr ("Reload")); |
27298
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
69 m_save_button = new QPushButton (tr ("Save")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
70 m_revert_button = new QPushButton (tr ("Revert")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
71 m_revert_last_button = new QPushButton (tr ("Revert Last")); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
72 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
73 m_save_button->setFocus (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
74 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
75 connect (m_add_folder_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
76 this, SLOT (add_dir (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
77 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
78 connect (m_remove_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
79 this, SLOT (rm_dir (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
80 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
81 connect (m_move_to_top_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
82 this, SLOT (move_dir_top (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
83 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
84 connect (m_move_to_bottom_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
85 this, SLOT (move_dir_bottom (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
86 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
87 connect (m_move_up_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
88 this, SLOT (move_dir_up (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
89 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
90 connect (m_move_down_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
91 this, SLOT (move_dir_down (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
92 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
93 set_path_model *model = new set_path_model (this); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
94 |
27305
d20c31be3160
add a reload button to the gui path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27298
diff
changeset
|
95 connect (m_reload_button, SIGNAL (clicked (void)), |
d20c31be3160
add a reload button to the gui path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27298
diff
changeset
|
96 model, SLOT (path_to_model (void))); |
d20c31be3160
add a reload button to the gui path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27298
diff
changeset
|
97 |
27298
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
98 connect (m_save_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
99 model, SLOT (save (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
100 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
101 connect (m_revert_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
102 model, SLOT (revert (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
103 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
104 connect (m_revert_last_button, SIGNAL (clicked (void)), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
105 model, SLOT (revert_last (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
106 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
107 m_path_list = new QListView (this); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
108 m_path_list->setWordWrap (false); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
109 m_path_list->setModel (model); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
110 m_path_list->setSelectionBehavior (QAbstractItemView::SelectRows); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
111 m_path_list->setSelectionMode (QAbstractItemView::ExtendedSelection); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
112 m_path_list->setAlternatingRowColors (true); |
27305
d20c31be3160
add a reload button to the gui path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27298
diff
changeset
|
113 m_path_list->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
27298
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
114 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
115 // layout everything |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
116 QDialogButtonBox *button_box = new QDialogButtonBox (Qt::Horizontal); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
117 button_box->addButton (m_save_button, QDialogButtonBox::ActionRole); |
27305
d20c31be3160
add a reload button to the gui path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27298
diff
changeset
|
118 button_box->addButton (m_reload_button, QDialogButtonBox::ActionRole); |
27298
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
119 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
120 // add dialog close button |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
121 m_close_button = button_box->addButton (QDialogButtonBox::Close); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
122 connect (button_box, SIGNAL (rejected (void)), this, SLOT (close (void))); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
123 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
124 button_box->addButton (m_revert_last_button, QDialogButtonBox::ActionRole); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
125 button_box->addButton (m_revert_button, QDialogButtonBox::ActionRole); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
126 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
127 // path edit options |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
128 QDialogButtonBox *path_edit_layout = new QDialogButtonBox (Qt::Vertical); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
129 path_edit_layout->addButton (m_add_folder_button, QDialogButtonBox::ActionRole); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
130 path_edit_layout->addButton (m_move_to_top_button, QDialogButtonBox::ActionRole); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
131 path_edit_layout->addButton (m_move_up_button, QDialogButtonBox::ActionRole); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
132 path_edit_layout->addButton (m_move_down_button, QDialogButtonBox::ActionRole); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
133 path_edit_layout->addButton (m_move_to_bottom_button, QDialogButtonBox::ActionRole); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
134 path_edit_layout->addButton (m_remove_button, QDialogButtonBox::ActionRole); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
135 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
136 // main layout |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
137 QHBoxLayout *main_hboxlayout = new QHBoxLayout; |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
138 main_hboxlayout->addWidget(path_edit_layout); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
139 main_hboxlayout->addWidget(m_path_list); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
140 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
141 QGridLayout *main_layout = new QGridLayout; |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
142 main_layout->addWidget (m_info_label, 0, 0); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
143 main_layout->addLayout (main_hboxlayout, 1, 0); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
144 main_layout->addWidget (button_box,2, 0); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
145 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
146 setLayout (main_layout); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
147 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
148 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
149 set_path_dialog::~set_path_dialog (void) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
150 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
151 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
152 |
27306
82ace1225a9c
update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27305
diff
changeset
|
153 void set_path_dialog::update_model (void) |
82ace1225a9c
update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27305
diff
changeset
|
154 { |
82ace1225a9c
update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27305
diff
changeset
|
155 set_path_model *m = static_cast<set_path_model *> (m_path_list->model ()); |
82ace1225a9c
update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27305
diff
changeset
|
156 m->path_to_model (); |
82ace1225a9c
update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27305
diff
changeset
|
157 } |
82ace1225a9c
update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27305
diff
changeset
|
158 |
27298
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
159 void set_path_dialog::add_dir(void) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
160 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
161 QString dir |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
162 = QFileDialog::getExistingDirectory (this, tr ("Open Directory"), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
163 "", |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
164 (QFileDialog::ShowDirsOnly |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
165 | QFileDialog::DontResolveSymlinks)); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
166 set_path_model *m = static_cast<set_path_model *> (m_path_list->model ()); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
167 m->add_dir (dir); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
168 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
169 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
170 void set_path_dialog::rm_dir (void) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
171 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
172 set_path_model *m = static_cast<set_path_model *> (m_path_list->model ()); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
173 QItemSelectionModel *selmodel = m_path_list->selectionModel (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
174 QModelIndexList indexlist = selmodel->selectedIndexes(); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
175 m->rm_dir (indexlist); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
176 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
177 selmodel->clearSelection (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
178 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
179 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
180 void set_path_dialog::move_dir_up (void) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
181 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
182 set_path_model *m = static_cast<set_path_model *> (m_path_list->model ()); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
183 QItemSelectionModel *selmodel = m_path_list->selectionModel (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
184 QModelIndexList indexlist = selmodel->selectedIndexes(); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
185 m->move_dir_up (indexlist); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
186 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
187 // Update selection and view |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
188 selmodel->clearSelection (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
189 int min_row = m->rowCount () - 1; |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
190 for (int i = 0; i < indexlist.length (); i++) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
191 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
192 int new_row = std::max (indexlist.at (i).row () - 1, 0); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
193 min_row = std::min (min_row, new_row); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
194 selmodel->select (m->index (new_row), QItemSelectionModel::Select); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
195 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
196 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
197 m_path_list->scrollTo (m->index (min_row)); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
198 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
199 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
200 void set_path_dialog::move_dir_down (void) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
201 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
202 set_path_model *m = static_cast<set_path_model *> (m_path_list->model ()); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
203 QItemSelectionModel *selmodel = m_path_list->selectionModel (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
204 QModelIndexList indexlist = selmodel->selectedIndexes(); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
205 m->move_dir_down (indexlist); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
206 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
207 // Update selection and view |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
208 selmodel->clearSelection (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
209 int max_row = 0; |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
210 for (int i = 0; i < indexlist.length (); i++) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
211 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
212 int new_row = std::min (indexlist.at (i).row () + 1, m->rowCount () - 1); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
213 max_row = std::max (max_row, new_row); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
214 selmodel->select (m->index (new_row), QItemSelectionModel::Select); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
215 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
216 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
217 m_path_list->scrollTo (m->index (max_row)); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
218 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
219 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
220 void set_path_dialog::move_dir_top (void) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
221 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
222 set_path_model *m = static_cast<set_path_model *> (m_path_list->model ()); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
223 QItemSelectionModel *selmodel = m_path_list->selectionModel (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
224 QModelIndexList indexlist = selmodel->selectedIndexes(); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
225 m->move_dir_top (indexlist); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
226 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
227 // Update selection and view |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
228 selmodel->clearSelection (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
229 for (int i = 0; i < indexlist.length (); i++) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
230 selmodel->select (m->index (i), QItemSelectionModel::Select); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
231 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
232 m_path_list->scrollTo (m->index (0)); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
233 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
234 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
235 void set_path_dialog::move_dir_bottom (void) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
236 { |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
237 set_path_model *m = static_cast<set_path_model *> (m_path_list->model ()); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
238 QItemSelectionModel *selmodel = m_path_list->selectionModel (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
239 QModelIndexList indexlist = selmodel->selectedIndexes(); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
240 m->move_dir_bottom (indexlist); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
241 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
242 // Update selection and view |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
243 selmodel->clearSelection (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
244 int row_count = m->rowCount (); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
245 for (int i = 0; i < indexlist.length (); i++) |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
246 selmodel->select (m->index (row_count - 1 - i), |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
247 QItemSelectionModel::Select); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
248 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
249 m_path_list->scrollTo (m->index (row_count - 1)); |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
250 } |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
251 |
1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents:
diff
changeset
|
252 } |