Commit 40167771 authored by Murray Cumming's avatar Murray Cumming
Browse files

Box_Data_List/Calender_Related: Move some code into show_title_in_ui().

parent 7091ac56
......@@ -93,27 +93,11 @@ bool Box_Data_Calendar_Related::init_db_details(const Glib::ustring& parent_tabl
Base_DB_Table::m_table_name = LayoutWidgetBase::m_table_name;
//TODO: This is duplicated in box_data_related_list.cc and box_data_portal.cc. Just use code from the base class?
if(show_title)
{
Glib::ustring title;
if(portal)
title = item_get_title(portal);
m_Label.set_markup(UiUtils::bold_message(title));
m_Label.show();
m_calendar.set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
m_calendar.set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
}
else
{
m_Label.set_markup(Glib::ustring());
m_Label.hide();
//The box itself has padding of 6.
m_calendar.set_margin_start(0);
m_calendar.set_margin_top(0);
Glib::ustring title;
if(show_title && portal) {
title = item_get_title(portal);
}
show_title_in_ui(title);
if(portal)
{
......@@ -132,6 +116,25 @@ bool Box_Data_Calendar_Related::init_db_details(const Glib::ustring& parent_tabl
}
void Box_Data_Calendar_Related::show_title_in_ui(const Glib::ustring& title)
{
if (!title.empty()) {
m_Label.set_markup(UiUtils::bold_message(title));
m_Label.show();
m_calendar.set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
m_calendar.set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
}
else {
m_Label.set_markup(Glib::ustring());
m_Label.hide();
//The box itself has padding of 6.
m_calendar.set_margin_start(0);
m_calendar.set_margin_top(0);
}
}
void Box_Data_Calendar_Related::create_layout()
{
Box_Data::create_layout();
......
......@@ -53,8 +53,9 @@ private:
bool fill_from_database() override;
type_vecConstLayoutFields get_fields_to_show() const override;
void create_layout() override;
void show_title_in_ui(const Glib::ustring& title) override;
//Implementations of pure virtual methods from Base_DB_Table_Data:
void set_primary_key_value(const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& value) override;
......
......@@ -91,36 +91,14 @@ bool Box_Data_List_Related::init_db_details(const Glib::ustring& parent_table, b
{
std::cerr << G_STRFUNC << ": LayoutWidgetBase::m_table_name is null\n";
}
Base_DB_Table::m_table_name = LayoutWidgetBase::m_table_name;
if(show_title)
{
Glib::ustring title;
if(portal)
title = item_get_title(portal);
m_Label.set_markup(UiUtils::bold_message(title));
m_Label.show();
if(!(m_Frame.get_label_widget()))
m_Frame.set_label_widget(m_Label);
m_AddDel.set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
m_AddDel.set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
}
else
{
m_Label.set_markup(Glib::ustring());
m_Label.hide();
if(m_Frame.get_label_widget())
m_Frame.unset_label(); //Otherwise the allocation is calculated wrong due to GtkFrame bug: https://bugzilla.gnome.org/show_bug.cgi?id=662915
Base_DB_Table::m_table_name = LayoutWidgetBase::m_table_name;
//The box itself has padding of 6:
m_AddDel.set_margin_start(0);
m_AddDel.set_margin_top(0);
Glib::ustring title;
if(show_title && portal) {
title = item_get_title(portal);
}
show_title_in_ui(title);
if(portal)
{
......@@ -148,6 +126,32 @@ bool Box_Data_List_Related::init_db_details(const Glib::ustring& parent_table, b
return Box_Data_ManyRecords::init_db_details(found_set, "" /* layout_platform */); //Calls create_layout() and fill_from_database().
}
void Box_Data_List_Related::show_title_in_ui(const Glib::ustring& title)
{
if(!title.empty())
{
m_Label.set_markup(UiUtils::bold_message(title));
m_Label.show();
if(!(m_Frame.get_label_widget()))
m_Frame.set_label_widget(m_Label);
m_AddDel.set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
m_AddDel.set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
}
else
{
m_Label.set_markup(Glib::ustring());
m_Label.hide();
if(m_Frame.get_label_widget())
m_Frame.unset_label(); //Otherwise the allocation is calculated wrong due to GtkFrame bug: https://bugzilla.gnome.org/show_bug.cgi?id=662915
//The box itself has padding of 6:
m_AddDel.set_margin_start(0);
m_AddDel.set_margin_top(0);
}
}
bool Box_Data_List_Related::fill_from_database()
{
bool result = false;
......
......@@ -47,6 +47,8 @@ public:
protected:
bool fill_from_database() override;
void show_title_in_ui(const Glib::ustring& title) override;
//Signal handlers:
void on_adddel_record_changed();
void on_adddel_user_requested_edit(const Gtk::TreeModel::iterator& row);
......
......@@ -109,11 +109,12 @@ protected:
void on_dialog_layout_hide() override;
#endif // !GLOM_ENABLE_CLIENT_ONLY
protected:
virtual Document::type_list_layout_groups create_layout_get_layout();
void make_record_related(const Gnome::Gda::Value& related_record_primary_key_value);
virtual void show_title_in_ui(const Glib::ustring& title) = 0;
/** Get the title of the relationship used by the portal.
*/
Glib::ustring get_title(const Glib::ustring& locale) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment