Skip to content

Commit

Permalink
Add package and button to reset placed list to package window
Browse files Browse the repository at this point in the history
  • Loading branch information
frmdstryr committed Mar 9, 2024
1 parent ddd15df commit 4e4ba69
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/imp/parts_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ PartsWindow::PartsWindow(const Board &brd) : Gtk::Window(), board(brd), state_st
auto header = Gtk::manage(new Gtk::HeaderBar());
header->set_show_close_button(true);
header->set_title("Parts");
auto btn = Gtk::manage(new Gtk::Button("Reset"));
btn->set_tooltip_text("Reset placed components");
btn->signal_clicked().connect([this]() { reset_placed(); });
btn->show();
header->pack_start(*btn);
set_titlebar(*header);
header->show();
if (!state_store.get_default_set())
Expand Down Expand Up @@ -44,6 +49,7 @@ PartsWindow::PartsWindow(const Board &brd) : Gtk::Window(), board(brd), state_st
tree_view->get_column(1)->set_sort_column(list_columns.qty);
tree_view->append_column("Value", list_columns.value);
tree_view->append_column("MPN", list_columns.MPN);
tree_view->append_column("Package", list_columns.package);
tree_view_append_column_ellipsis(tree_view, "Refdes", list_columns.refdes, Pango::ELLIPSIZE_END)
->set_sort_column(list_columns.refdes);
store->set_sort_func(list_columns.refdes,
Expand Down Expand Up @@ -122,6 +128,7 @@ void PartsWindow::update()
row[list_columns.placed] = parts_placed.count(part->uuid);
row[list_columns.qty] = comps.size();
row[list_columns.components] = comp_uuids;
row[list_columns.package] = part->package->name;
}
}

Expand Down Expand Up @@ -152,5 +159,13 @@ void PartsWindow::load_from_json(const json &j)
}
}

void PartsWindow::reset_placed()
{
for (auto &it : store->children()) {
Gtk::TreeModel::Row row = *it;
row[list_columns.placed] = false;
}
}


} // namespace horizon
4 changes: 3 additions & 1 deletion src/imp/parts_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PartsWindow : public Gtk::Window {

json serialize() const;
void load_from_json(const json &j);

void reset_placed();

private:
const Board &board;
Expand All @@ -30,6 +30,7 @@ class PartsWindow : public Gtk::Window {
public:
ListColumns()
{
Gtk::TreeModelColumnRecord::add(package);
Gtk::TreeModelColumnRecord::add(MPN);
Gtk::TreeModelColumnRecord::add(value);
Gtk::TreeModelColumnRecord::add(refdes);
Expand All @@ -38,6 +39,7 @@ class PartsWindow : public Gtk::Window {
Gtk::TreeModelColumnRecord::add(placed);
Gtk::TreeModelColumnRecord::add(part);
}
Gtk::TreeModelColumn<Glib::ustring> package;
Gtk::TreeModelColumn<Glib::ustring> MPN;
Gtk::TreeModelColumn<Glib::ustring> value;
Gtk::TreeModelColumn<Glib::ustring> refdes;
Expand Down

0 comments on commit 4e4ba69

Please sign in to comment.