26 #if defined (HAVE_CONFIG_H)
32 #include <QDialogButtonBox>
33 #include <QDirIterator>
34 #include <QFileDialog>
35 #include <QFileDialog>
37 #include <QGridLayout>
39 #include <QHBoxLayout>
40 #include <QHeaderView>
46 #include <QPushButton>
48 #include <QTextStream>
50 #include <QVBoxLayout>
63 :
QDialog (parent), m_octave_qobj (oct_qobj)
65 setWindowTitle (tr (
"Set Path"));
69 m_info_label =
new QLabel (tr (
"All changes take effect immediately."));
71 m_add_folder_button =
new QPushButton (tr (
"Add Folder..."));
74 m_add_folder_button->setMenu (add_dir_menu);
75 add_dir_menu->addAction (tr (
"Single Folder"),
77 add_dir_menu->addAction (tr (
"Folder With Subfolders"),
80 m_move_to_top_button =
new QPushButton (tr (
"Move to Top"));
81 m_move_to_bottom_button =
new QPushButton (tr (
"Move to Bottom"));
82 m_move_up_button =
new QPushButton (tr (
"Move Up"));
83 m_move_down_button =
new QPushButton (tr (
"Move Down"));
92 m_revert_button->setMenu (revert_menu);
93 revert_menu->addAction (tr (
"Revert Last Change"),
95 revert_menu->addAction (tr (
"Revert All Changes"),
98 m_save_button->setFocus ();
100 connect (m_remove_button, &QPushButton::clicked,
103 connect (m_move_to_top_button, &QPushButton::clicked,
106 connect (m_move_to_bottom_button, &QPushButton::clicked,
109 connect (m_move_up_button, &QPushButton::clicked,
112 connect (m_move_down_button, &QPushButton::clicked,
115 connect (m_reload_button, &QPushButton::clicked,
118 connect (m_save_button, &QPushButton::clicked,
130 m_path_list =
new QListView (
this);
131 m_path_list->setWordWrap (
false);
132 m_path_list->setModel (model);
133 m_path_list->setSelectionBehavior (QAbstractItemView::SelectRows);
134 m_path_list->setSelectionMode (QAbstractItemView::ExtendedSelection);
135 m_path_list->setAlternatingRowColors (
true);
136 m_path_list->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
139 QDialogButtonBox *button_box =
new QDialogButtonBox (Qt::Horizontal);
140 button_box->addButton (m_save_button, QDialogButtonBox::ActionRole);
141 button_box->addButton (m_reload_button, QDialogButtonBox::ActionRole);
144 m_close_button = button_box->addButton (QDialogButtonBox::Close);
145 connect (button_box, &QDialogButtonBox::rejected,
146 this, &set_path_dialog::close);
148 button_box->addButton (m_revert_button, QDialogButtonBox::ActionRole);
151 QDialogButtonBox *path_edit_layout =
new QDialogButtonBox (Qt::Vertical);
152 path_edit_layout->addButton (m_add_folder_button, QDialogButtonBox::ActionRole);
153 path_edit_layout->addButton (m_move_to_top_button, QDialogButtonBox::ActionRole);
154 path_edit_layout->addButton (m_move_up_button, QDialogButtonBox::ActionRole);
155 path_edit_layout->addButton (m_move_down_button, QDialogButtonBox::ActionRole);
156 path_edit_layout->addButton (m_move_to_bottom_button, QDialogButtonBox::ActionRole);
157 path_edit_layout->addButton (m_remove_button, QDialogButtonBox::ActionRole);
160 QHBoxLayout *main_hboxlayout =
new QHBoxLayout;
161 main_hboxlayout->addWidget(path_edit_layout);
162 main_hboxlayout->addWidget(m_path_list);
164 QGridLayout *main_layout =
new QGridLayout;
165 main_layout->addWidget (m_info_label, 0, 0);
166 main_layout->addLayout (main_hboxlayout, 1, 0);
167 main_layout->addWidget (button_box, 2, 0);
169 setLayout (main_layout);
186 = QFileDialog::getExistingDirectory (
this, tr (
"Open Directory"),
188 (QFileDialog::ShowDirsOnly
189 | QFileDialog::DontResolveSymlinks));
191 if (! dir.isEmpty ())
221 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
222 QModelIndexList indexlist = selmodel->selectedIndexes();
223 m->rm_dir (indexlist);
225 selmodel->clearSelection ();
231 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
232 QModelIndexList indexlist = selmodel->selectedIndexes();
233 m->move_dir_up (indexlist);
236 selmodel->clearSelection ();
237 int min_row =
m->rowCount () - 1;
238 for (
int i = 0; i < indexlist.length (); i++)
240 int new_row =
std::max (indexlist.at (i).row () - 1, 0);
241 min_row =
std::min (min_row, new_row);
242 selmodel->select (
m->index (new_row), QItemSelectionModel::Select);
251 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
252 QModelIndexList indexlist = selmodel->selectedIndexes();
253 m->move_dir_down (indexlist);
256 selmodel->clearSelection ();
258 for (
int i = 0; i < indexlist.length (); i++)
260 int new_row =
std::min (indexlist.at (i).row () + 1,
m->rowCount () - 1);
261 max_row =
std::max (max_row, new_row);
262 selmodel->select (
m->index (new_row), QItemSelectionModel::Select);
271 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
272 QModelIndexList indexlist = selmodel->selectedIndexes();
273 m->move_dir_top (indexlist);
276 selmodel->clearSelection ();
277 for (
int i = 0; i < indexlist.length (); i++)
278 selmodel->select (
m->index (i), QItemSelectionModel::Select);
286 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
287 QModelIndexList indexlist = selmodel->selectedIndexes();
288 m->move_dir_bottom (indexlist);
291 selmodel->clearSelection ();
292 int row_count =
m->rowCount ();
293 for (
int i = 0; i < indexlist.length (); i++)
294 selmodel->select (
m->index (row_count - 1 - i),
295 QItemSelectionModel::Select);
311 QWidget::closeEvent (e);
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
gui_settings * get_settings(void) const
void closeEvent(QCloseEvent *e)
void move_dir_bottom(void)
base_qobject & m_octave_qobj
void add_dir_common(bool subdirs)
void interpreter_event(const fcn_callback &fcn)
void modify_path_signal(const QStringList &dir_list, bool rm, bool subdirs)
Emitted, when the path has to be modified.
void add_dir_subdirs(void)
void interpreter_event(const fcn_callback &fcn)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
const gui_pref pd_geometry("path_dlg_geometry", QVariant(QByteArray()))