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>
62 :
QDialog (parent), m_octave_qobj (oct_qobj)
64 setWindowTitle (tr (
"Set Path"));
68 m_info_label =
new QLabel (tr (
"All changes take effect immediately."));
74 add_dir_menu->addAction (tr (
"Single Folder"),
76 add_dir_menu->addAction (tr (
"Folder with Subfolders"),
92 revert_menu->addAction (tr (
"Revert Last Change"),
93 model, SLOT (revert_last (
void)));
94 revert_menu->addAction (tr (
"Revert All Changes"),
95 model, SLOT (revert (
void)));
100 this, SLOT (
rm_dir (
void)));
115 model, SLOT (path_to_model (
void)));
118 model, SLOT (save (
void)));
132 m_path_list->setSelectionBehavior (QAbstractItemView::SelectRows);
133 m_path_list->setSelectionMode (QAbstractItemView::ExtendedSelection);
135 m_path_list->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
138 QDialogButtonBox *button_box =
new QDialogButtonBox (Qt::Horizontal);
139 button_box->addButton (
m_save_button, QDialogButtonBox::ActionRole);
144 connect (button_box, SIGNAL (rejected (
void)),
this, SLOT (close (
void)));
149 QDialogButtonBox *path_edit_layout =
new QDialogButtonBox (Qt::Vertical);
152 path_edit_layout->addButton (
m_move_up_button, QDialogButtonBox::ActionRole);
155 path_edit_layout->addButton (
m_remove_button, QDialogButtonBox::ActionRole);
158 QHBoxLayout *main_hboxlayout =
new QHBoxLayout;
159 main_hboxlayout->addWidget(path_edit_layout);
162 QGridLayout *main_layout =
new QGridLayout;
164 main_layout->addLayout (main_hboxlayout, 1, 0);
165 main_layout->addWidget (button_box,2, 0);
167 setLayout (main_layout);
188 = QFileDialog::getExistingDirectory (
this, tr (
"Open Directory"),
190 (QFileDialog::ShowDirsOnly
191 | QFileDialog::DontResolveSymlinks));
193 if (! dir.isEmpty ())
200 dirlist.
append (dir.toStdString ());
225 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
226 QModelIndexList indexlist = selmodel->selectedIndexes();
227 m->rm_dir (indexlist);
229 selmodel->clearSelection ();
235 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
236 QModelIndexList indexlist = selmodel->selectedIndexes();
237 m->move_dir_up (indexlist);
240 selmodel->clearSelection ();
241 int min_row =
m->rowCount () - 1;
242 for (
int i = 0; i < indexlist.length (); i++)
244 int new_row =
std::max (indexlist.at (i).row () - 1, 0);
245 min_row =
std::min (min_row, new_row);
246 selmodel->select (
m->index (new_row), QItemSelectionModel::Select);
255 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
256 QModelIndexList indexlist = selmodel->selectedIndexes();
257 m->move_dir_down (indexlist);
260 selmodel->clearSelection ();
262 for (
int i = 0; i < indexlist.length (); i++)
264 int new_row =
std::min (indexlist.at (i).row () + 1,
m->rowCount () - 1);
265 max_row =
std::max (max_row, new_row);
266 selmodel->select (
m->index (new_row), QItemSelectionModel::Select);
275 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
276 QModelIndexList indexlist = selmodel->selectedIndexes();
277 m->move_dir_top (indexlist);
280 selmodel->clearSelection ();
281 for (
int i = 0; i < indexlist.length (); i++)
282 selmodel->select (
m->index (i), QItemSelectionModel::Select);
290 QItemSelectionModel *selmodel =
m_path_list->selectionModel ();
291 QModelIndexList indexlist = selmodel->selectedIndexes();
292 m->move_dir_bottom (indexlist);
295 selmodel->clearSelection ();
296 int row_count =
m->rowCount ();
297 for (
int i = 0; i < indexlist.length (); i++)
298 selmodel->select (
m->index (row_count - 1 - i),
299 QItemSelectionModel::Select);
315 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
virtual ~set_path_dialog(void)
void interpreter_event(const fcn_callback &fcn)
QPushButton * m_remove_button
set_path_dialog(QWidget *parent, base_qobject &oct_qobj)
QPushButton * m_move_to_top_button
void move_dir_bottom(void)
void add_dir_subdirs(void)
void add_dir_common(bool subdirs)
base_qobject & m_octave_qobj
QPushButton * m_save_button
QPushButton * m_move_up_button
QPushButton * m_revert_button
QPushButton * m_add_folder_button
QPushButton * m_close_button
void modify_path_signal(const octave_value_list &dir_list, bool rm, bool subdirs)
Emitted, when the path has to be modified.
QPushButton * m_move_to_bottom_button
QPushButton * m_reload_button
QPushButton * m_move_down_button
void closeEvent(QCloseEvent *e)
octave_value_list & append(const octave_value &val)
const gui_pref pd_geometry("path_dlg_geometry", QVariant(QByteArray()))
std::function< void(octave::interpreter &)> meth_callback
std::function< void(void)> fcn_callback
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.