diff --git a/src/layui/layui/MarkerBrowserDialog.ui b/src/layui/layui/MarkerBrowserDialog.ui index 298ac92a3..dc2e8e58a 100644 --- a/src/layui/layui/MarkerBrowserDialog.ui +++ b/src/layui/layui/MarkerBrowserDialog.ui @@ -376,6 +376,14 @@ to load a marker database QAction::NoRole + + + Apply Waiver DB + + + QAction::NoRole + + diff --git a/src/layui/layui/rdbMarkerBrowserDialog.cc b/src/layui/layui/rdbMarkerBrowserDialog.cc index e388ef7da..9f4b3d410 100644 --- a/src/layui/layui/rdbMarkerBrowserDialog.cc +++ b/src/layui/layui/rdbMarkerBrowserDialog.cc @@ -37,6 +37,7 @@ #include "dbLayoutUtils.h" #include "dbRecursiveShapeIterator.h" #include "dbStream.h" +#include "tlFileUtils.h" #include "ui_MarkerBrowserDialog.h" @@ -89,6 +90,7 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView connect (mp_ui->save_action, SIGNAL (triggered ()), this, SLOT (save_clicked ())); connect (mp_ui->saveas_action, SIGNAL (triggered ()), this, SLOT (saveas_clicked ())); connect (mp_ui->saveas_waiver_db_action, SIGNAL (triggered ()), this, SLOT (saveas_waiver_db_clicked ())); + connect (mp_ui->apply_waiver_db_action, SIGNAL (triggered ()), this, SLOT (apply_waiver_db_clicked ())); connect (mp_ui->export_action, SIGNAL (triggered ()), this, SLOT (export_clicked ())); connect (mp_ui->reload_action, SIGNAL (triggered ()), this, SLOT (reload_clicked ())); connect (mp_ui->info_action, SIGNAL (triggered ()), this, SLOT (info_clicked ())); @@ -99,6 +101,7 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView mp_ui->file_menu->addAction (mp_ui->save_action); mp_ui->file_menu->addAction (mp_ui->saveas_action); mp_ui->file_menu->addAction (mp_ui->saveas_waiver_db_action); + mp_ui->file_menu->addAction (mp_ui->apply_waiver_db_action); QAction *sep0 = new QAction (mp_ui->file_menu); sep0->setSeparator (true); mp_ui->file_menu->addAction (mp_ui->export_action); @@ -395,6 +398,49 @@ BEGIN_PROTECTED END_PROTECTED } +void +MarkerBrowserDialog::apply_waiver_db_clicked () +{ +BEGIN_PROTECTED + + rdb::Database *rdb = 0; + if (m_rdb_index < int (view ()->num_rdbs ()) && m_rdb_index >= 0) { + rdb = view ()->get_rdb (m_rdb_index); + } + if (! rdb) { + return; + } + + std::string wdb_filename; + if (! rdb->filename ().empty () && tl::file_exists (rdb->filename () + ".w")) { + + wdb_filename = rdb->filename () + ".w"; + + } else { + + // prepare and open the file dialog + lay::FileDialog open_dialog (this, tl::to_string (QObject::tr ("Apply Waiver DB File")), "Waiver DB files (*.w)"); + + if (! rdb->filename ().empty ()) { + wdb_filename = rdb->filename () + ".w"; + } + + if (! open_dialog.get_open (wdb_filename)) { + return; + } + + } + + rdb::Database wdb; + wdb.load (wdb_filename); + + mp_ui->browser_frame->set_rdb (0); + rdb->apply (wdb); + mp_ui->browser_frame->set_rdb (rdb); + +END_PROTECTED +} + void MarkerBrowserDialog::saveas_waiver_db_clicked () { @@ -785,6 +831,7 @@ MarkerBrowserDialog::update_content () mp_ui->save_action->setEnabled (rdb != 0); mp_ui->saveas_action->setEnabled (rdb != 0); mp_ui->saveas_waiver_db_action->setEnabled (rdb != 0); + mp_ui->apply_waiver_db_action->setEnabled (rdb != 0); mp_ui->export_action->setEnabled (rdb != 0); mp_ui->unload_action->setEnabled (rdb != 0); mp_ui->unload_all_action->setEnabled (rdb != 0); diff --git a/src/layui/layui/rdbMarkerBrowserDialog.h b/src/layui/layui/rdbMarkerBrowserDialog.h index a7844414e..a833d993d 100644 --- a/src/layui/layui/rdbMarkerBrowserDialog.h +++ b/src/layui/layui/rdbMarkerBrowserDialog.h @@ -78,6 +78,7 @@ public slots: void save_clicked (); void saveas_clicked (); void saveas_waiver_db_clicked (); + void apply_waiver_db_clicked (); void export_clicked (); void reload_clicked (); void open_clicked ();