Skip to content

Commit

Permalink
'apply waiver DB' feature in marker browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koefferlein committed Apr 29, 2024
1 parent db0e9ef commit 14f9d57
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/layui/layui/MarkerBrowserDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ to load a marker database</string>
<enum>QAction::NoRole</enum>
</property>
</action>
<action name="apply_waiver_db_action">
<property name="text">
<string>Apply Waiver DB</string>
</property>
<property name="menuRole">
<enum>QAction::NoRole</enum>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
47 changes: 47 additions & 0 deletions src/layui/layui/rdbMarkerBrowserDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "dbLayoutUtils.h"
#include "dbRecursiveShapeIterator.h"
#include "dbStream.h"
#include "tlFileUtils.h"

#include "ui_MarkerBrowserDialog.h"

Expand Down Expand Up @@ -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 ()));
Expand All @@ -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);
Expand Down Expand Up @@ -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 ()
{
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/layui/layui/rdbMarkerBrowserDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down

0 comments on commit 14f9d57

Please sign in to comment.