Mercurial > octave-libtiff
comparison libgui/src/octave-qt-link.cc @ 21158:65827e9cccb8
Gui support for enhancement of dbstop.
* octave-qscintilla.cc (contextMenuEvent): Capture right-click in the
left margins to show a context menu for "dbstop if...".
* octave-qscintilla.{cc,h} (contextmenu_break_condition): new function
* file-editor-interface.h: pass condition to
handle_update_breakpoint_marker_request
* file-editor-tab.{cc,h}: (file_editor_tab, bp_info,
handle_request_add_breakpoint, next_breakpoint,
previous_breakpoint, do_breakpoint_marker,
add_breakpoint_callback):
Allow conditional breakpoint markers
* file-editor-tab.cc (handle_context_menu_break_condition): new function
* file-editor.{cc,h} (request_open_file, add_file_editor_tab,
handle_delete_debugger_pointer_request): pass bp conditions.
* marker.{cc,h} (marker, construct, handle_report_editor_linenr):
pass breakpoint conditions
* main-window.{cc,h} (handle_update_breakpoint_marker_request):
pass breakpoint condition.
* octave-link.h (update_breakpoint): pass breakpoint condition.
* octave-qt-link.{cc,h} (do_update_breakpoint): pass breakpoint condition.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Sat, 30 Jan 2016 10:13:34 +1100 |
parents | e8c3590da9ff |
children | 710e700cdd7f |
comparison
equal
deleted
inserted
replaced
21157:94fc5f13d51b | 21158:65827e9cccb8 |
---|---|
27 #endif | 27 #endif |
28 | 28 |
29 #include <QStringList> | 29 #include <QStringList> |
30 #include <QDialog> | 30 #include <QDialog> |
31 #include <QDir> | 31 #include <QDir> |
32 #include <QPushButton> | |
32 | 33 |
33 #include "str-vec.h" | 34 #include "str-vec.h" |
34 #include "dialog.h" | 35 #include "dialog.h" |
35 #include "error.h" | 36 #include "error.h" |
36 #include "workspace-element.h" | 37 #include "workspace-element.h" |
370 uiwidget_creator.mutex.unlock (); | 371 uiwidget_creator.mutex.unlock (); |
371 | 372 |
372 return retval; | 373 return retval; |
373 } | 374 } |
374 | 375 |
376 // Prompt to allow file to be run by setting cwd (or if addpath_option==true, | |
377 // alternatively setting the path). | |
378 // This uses a QMessageBox unlike other functions in this file, | |
379 // because uiwidget_creator.waitcondition.wait hangs when called from | |
380 // file_editor_tab::handle_context_menu_break_condition(). (FIXME -- why hang?) | |
375 int | 381 int |
376 octave_qt_link::do_debug_cd_or_addpath_error (const std::string& file, | 382 octave_qt_link::do_debug_cd_or_addpath_error (const std::string& file, |
377 const std::string& dir, | 383 const std::string& dir, |
378 bool addpath_option) | 384 bool addpath_option) |
379 { | 385 { |
380 int retval = -1; | 386 int retval = -1; |
381 | 387 |
382 QString qdir = QString::fromStdString (dir); | 388 QString qdir = QString::fromStdString (dir); |
383 QString qfile = QString::fromStdString (file); | 389 QString qfile = QString::fromStdString (file); |
384 | 390 |
385 QString msg | 391 QMessageBox msgBox; |
386 = (addpath_option | 392 |
387 ? tr ("The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.").arg (qfile).arg (qdir) | 393 msgBox.setText ("File not in load path"); |
388 : tr ("The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2.").arg (qfile).arg (qdir)); | 394 QPushButton *cd_btn = msgBox.addButton (tr ("Change Directory"), |
389 | 395 QMessageBox::YesRole); |
390 QString title = tr ("Change Directory or Add Directory to Load Path"); | 396 |
391 | 397 QPushButton *addpath_btn = 0; |
392 QString cd_txt = tr ("Change Directory"); | |
393 QString addpath_txt = tr ("Add Directory to Load Path"); | |
394 QString cancel_txt = tr ("Cancel"); | |
395 | |
396 QStringList btn; | |
397 QStringList role; | |
398 btn << cd_txt; | |
399 role << "YesRole"; | |
400 if (addpath_option) | 398 if (addpath_option) |
401 { | 399 { |
402 btn << addpath_txt; | 400 msgBox.setInformativeText (tr ("The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.").arg (qfile).arg (qdir)); |
403 role << "AcceptRole"; | 401 addpath_btn = msgBox.addButton (tr ("Add Directory to Load Path"), |
404 } | 402 QMessageBox::AcceptRole); |
405 btn << cancel_txt; | 403 } |
406 role << "RejectRole"; | 404 else |
407 | 405 { |
408 // Lock mutex before signaling. | 406 msgBox.setInformativeText (tr ("The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2.").arg (qfile).arg (qdir)); |
409 uiwidget_creator.mutex.lock (); | 407 } |
410 | 408 msgBox.setStandardButtons (QMessageBox::Cancel); |
411 uiwidget_creator.signal_dialog (msg, title, "quest", btn, cancel_txt, role); | 409 |
412 | 410 msgBox.exec (); |
413 // Wait while the user is responding to message box. | 411 |
414 uiwidget_creator.waitcondition.wait (&uiwidget_creator.mutex); | 412 if (msgBox.clickedButton () == cd_btn) |
415 | |
416 // The GUI has sent a signal and the thread has been awakened. | |
417 | |
418 QString result = uiwidget_creator.get_dialog_button (); | |
419 | |
420 uiwidget_creator.mutex.unlock (); | |
421 | |
422 if (result == cd_txt) | |
423 retval = 1; | 413 retval = 1; |
424 else if (result == addpath_txt) | 414 else if (msgBox.clickedButton () == addpath_btn) |
425 retval = 2; | 415 retval = 2; |
426 | 416 |
427 return retval; | 417 return retval; |
428 } | 418 } |
429 | 419 |
536 octave_qt_link::do_exit_debugger_event (void) | 526 octave_qt_link::do_exit_debugger_event (void) |
537 { | 527 { |
538 emit exit_debugger_signal (); | 528 emit exit_debugger_signal (); |
539 } | 529 } |
540 | 530 |
531 // Display (if @insert true) or remove the appropriate symbol for a breakpoint | |
532 // in @file at @line with condition @cond. | |
541 void | 533 void |
542 octave_qt_link::do_update_breakpoint (bool insert, | 534 octave_qt_link::do_update_breakpoint (bool insert, |
543 const std::string& file, int line) | 535 const std::string& file, int line, |
536 const std::string& cond) | |
544 { | 537 { |
545 emit update_breakpoint_marker_signal (insert, QString::fromStdString (file), | 538 emit update_breakpoint_marker_signal (insert, QString::fromStdString (file), |
546 line); | 539 line, QString::fromStdString (cond)); |
547 } | 540 } |
548 | 541 |
549 void | 542 void |
550 octave_qt_link::do_set_default_prompts (std::string& ps1, std::string& ps2, | 543 octave_qt_link::do_set_default_prompts (std::string& ps1, std::string& ps2, |
551 std::string& ps4) | 544 std::string& ps4) |