Commit d6e61bd9 authored by Murray Cumming's avatar Murray Cumming Committed by Murray Cumming
Browse files

on_menu_Mode_Find(): Start the Find mode on the same layout (Details or

2006-02-19  Murray Cumming  <murrayc@murrayc.com>

        * glom/frame_glom.cc: on_menu_Mode_Find(): Start the Find mode
        on the same layout (Details or List) as the Data mode was in.
        Add a little hack to make sure that we go back into Data mode in List
        view at first, to make sure that the first result will show up
        properly in the Details mode.
        * glom/mode_data/notebook_data.cc:
        * glom/mode_data/notebook_data.h: Added set_current_view().
        * glom/mode_find/notebook_find.cc:
        * glom/mode_find/notebook_find.h: Added set_current_view().
parent a56c4b1d
2006-02-19 Murray Cumming, <murrayc@murrayc.com>
2006-02-19 Murray Cumming <murrayc@murrayc.com>
* glom/frame_glom.cc: on_menu_Mode_Find(): Start the Find mode
on the same layout (Details or List) as the Data mode was in.
Add a little hack to make sure that we go back into Data mode in List
view at first, to make sure that the first result will show up
properly in the Details mode.
* glom/mode_data/notebook_data.cc:
* glom/mode_data/notebook_data.h: Added set_current_view().
* glom/mode_find/notebook_find.cc:
* glom/mode_find/notebook_find.h: Added set_current_view().
2006-02-19 Murray Cumming <murrayc@murrayc.com>
* glom/utility_widgets/imageglom.cc: scale(): Call Gtk::Image::get_storage_type()
before Gtk::Image::get_pixbuf(), to avoid a critical warning.
......
......@@ -657,8 +657,26 @@ void Frame_Glom::on_menu_Mode_Data()
void Frame_Glom::on_menu_Mode_Find()
{
const bool previously_in_data_mode = (m_Mode == MODE_Data);
const Notebook_Data::dataview list_or_details = m_Notebook_Data.get_current_view();
//A workaround hack to make sure that the list view will be active when the results are shown.
//Because the list doesn't refresh properly (to give the first result) when the Details view was active first.
//murrayc.
if(previously_in_data_mode && (list_or_details == Notebook_Data::DATA_VIEW_Details))
m_Notebook_Data.set_current_view(Notebook_Data::DATA_VIEW_List);
if(set_mode(MODE_Find))
{
show_table(m_table_name);
if(previously_in_data_mode)
{
//Show the same layout in Find mode as was just being viewed in Data mode:
m_Notebook_Find.set_current_view(list_or_details);
}
}
}
/*
......@@ -795,7 +813,10 @@ void Frame_Glom::on_notebook_find_criteria(const Glib::ustring& where_clause)
//std::cout << "Frame_Glom::on_notebook_find_criteria: where_clause=" << where_clause << std::endl;
const bool records_found = m_Notebook_Data.init_db_details(m_table_name, where_clause);
//std::cout << "Frame_Glom::on_notebook_find_criteria(): BEFORE m_Notebook_Data.select_page_for_find_results()" << std::endl;
m_Notebook_Data.select_page_for_find_results();
//std::cout << "Frame_Glom::on_notebook_find_criteria(): AFTER m_Notebook_Data.select_page_for_find_results()" << std::endl;
if(!records_found)
{
......
......@@ -135,6 +135,8 @@ Gnome::Gda::Value Box_Data_Details::get_primary_key_value() const
bool Box_Data_Details::init_db_details(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value)
{
//std::cout << "Box_Data_Details::init_db_details(): primary_key_value.to_string()=" << primary_key_value.to_string() << std::endl;
m_primary_key_value = primary_key_value;
m_field_primary_key = get_field_primary_key_for_table(table_name);
......@@ -144,6 +146,7 @@ bool Box_Data_Details::init_db_details(const Glib::ustring& table_name, const Gn
bool Box_Data_Details::refresh_data_from_database_with_primary_key(const Gnome::Gda::Value& primary_key_value)
{
//std::cout << "refresh_data_from_database_with_primary_key(): primary_key_value.to_string()=" << primary_key_value.to_string() << std::endl;
m_primary_key_value = primary_key_value;
return fill_from_database();
}
......@@ -180,6 +183,8 @@ void Box_Data_Details::create_layout()
bool Box_Data_Details::fill_from_database()
{
//std::cout << "Box_Data_Details::fill_from_database(): m_primary_key_value.to_string()=" << m_primary_key_value.to_string() << std::endl;
bool bResult = false;
Bakery::BusyCursor(*get_app_window());
......
......@@ -95,14 +95,13 @@ void Box_Data_List::enable_buttons()
void Box_Data_List::refresh_data_from_database_blank()
{
m_AddDel.set_where_clause(Glib::ustring());
m_AddDel.refresh_from_database_blank();
m_AddDel.set_where_clause("");
m_where_clause = Glib::ustring();
}
bool Box_Data_List::fill_from_database()
{
//std::cout << "Box_Data_List::fill_from_database(): where_clause=" << m_where_clause << std::endl;
bool result = false;
Bakery::BusyCursor(*get_app_window());
......@@ -622,6 +621,8 @@ Gnome::Gda::Value Box_Data_List::get_primary_key_value_selected()
Gnome::Gda::Value Box_Data_List::get_primary_key_value_first()
{
//std::cout << "Box_Data_List(): get_primary_key_value_first() records_count = " << m_AddDel.get_count() << std::endl;
Glib::RefPtr<Gtk::TreeModel> model = m_AddDel.get_model();
if(model)
{
......@@ -631,13 +632,18 @@ Gnome::Gda::Value Box_Data_List::get_primary_key_value_first()
Gnome::Gda::Value value = get_primary_key_value(iter);
if(GlomConversions::value_is_empty(value))
{
//std::cout << "Box_Data_List(): get_primary_key_value_first() iter val is NULL" << std::endl;
++iter;
}
else
{
//std::cout << "Box_Data_List(): get_primary_key_value_first() returning: " << value.to_string() << std::endl;
return value;
}
}
}
// std::cout << "Box_Data_List(): get_primary_key_value_first() return NULL" << std::endl;
return Gnome::Gda::Value();
}
......
......@@ -90,15 +90,25 @@ bool Notebook_Data::init_db_details(const Glib::ustring& table_name, const Glib:
if(!new_find_set)
{
//std::cout << "debug: no new_found_set" << std::endl;
primary_key_for_details = document->get_layout_record_viewed(m_table_name, m_Box_Details.get_layout_name());
}
else
{
//std::cout << "debug: new_found_set" << std::endl;
}
if(GlomConversions::value_is_empty(primary_key_for_details))
{
//Make sure that the details view is not empty, if there are any records to show:
primary_key_for_details = m_Box_List.get_primary_key_value_selected();
//std::cout << "debug: m_Box_List.get_primary_key_value_selected()=" << primary_key_for_details.to_string() << std::endl;
if(GlomConversions::value_is_empty(primary_key_for_details))
{
//std::cout << "debug: calling list.get_primary_key_value_first()" << std::endl;
primary_key_for_details = m_Box_List.get_primary_key_value_first();
//std::cout << " debug: result=" << primary_key_for_details.to_string() << std::endl;
}
}
m_Box_Details.init_db_details(m_table_name, primary_key_for_details);
......@@ -164,6 +174,14 @@ void Notebook_Data::on_Details_user_requested_related_details(const Glib::ustrin
*/
}
void Notebook_Data::set_current_view(dataview view)
{
if(view == DATA_VIEW_List)
set_current_page(m_iPage_List);
else
set_current_page(m_iPage_Details);
}
void Notebook_Data::select_page_for_find_results()
{
if(m_Box_List.get_showing_multiple_records())
......@@ -213,7 +231,7 @@ Notebook_Data::dataview Notebook_Data::get_current_view() const
const int current_page = get_current_page();
dataview result = DATA_VIEW_Details;
if(current_page == 1)
if(current_page == m_iPage_List)
result = DATA_VIEW_List;
return result;
......
......@@ -53,7 +53,8 @@ public:
DATA_VIEW_List
};
virtual dataview get_current_view() const;
dataview get_current_view() const;
void set_current_view(dataview view);
typedef sigc::signal<void, const Glib::ustring&, Gnome::Gda::Value> type_signal_record_details_requested;
type_signal_record_details_requested signal_record_details_requested();
......
......@@ -22,12 +22,17 @@
#include <glibmm/i18n.h>
Notebook_Find::Notebook_Find()
: m_iPage_Details(0),
m_iPage_List(0)
{
pages().push_back(Gtk::Notebook_Helpers::TabElem(m_Box_List, _("List")));
m_iPage_List = 0;
pages().push_back(Gtk::Notebook_Helpers::TabElem(m_Box_Details, _("Details")));
m_iPage_Details = 1;
set_current_page(1); //Show the details page by default. It's more obvious for a Find.
set_current_page(m_iPage_Details); //Show the details page by default. It's more obvious for a Find.
//TODO: Show the same layout that is being edited at the time that the mode was changed.
//Connect Signals:
......@@ -37,7 +42,7 @@ Notebook_Find::Notebook_Find()
//Fill composite view:
add_view(&m_Box_List);
add_view(&m_Box_Details);
show_all_children();
}
......@@ -61,3 +66,12 @@ void Notebook_Find::on_page_find_criteria(const Glib::ustring& where_clause)
//Pass it up to the application.
signal_find_criteria.emit(where_clause);
}
void Notebook_Find::set_current_view(Notebook_Data::dataview view)
{
if(view == Notebook_Data::DATA_VIEW_List)
set_current_page(m_iPage_List);
else
set_current_page(m_iPage_Details);
}
......@@ -34,6 +34,8 @@ public:
virtual bool init_db_details(const Glib::ustring& table_name);
void set_current_view(Notebook_Data::dataview view);
/** Emitted when the user has entered a find critera that
* should be used to find and display records.
* @param find_criteria The SQL where clause.
......@@ -42,6 +44,7 @@ public:
protected:
//Signal handlers:
virtual void on_page_find_criteria(const Glib::ustring& where_clause);
......@@ -49,6 +52,7 @@ protected:
Box_Data_List_Find m_Box_List;
Box_Data_Details_Find m_Box_Details;
guint m_iPage_Details, m_iPage_List;
};
#endif
......@@ -289,8 +289,8 @@ void ImageGlom::scale()
}
}
}
else
g_warning("ImageGlom::scale(): attempt to scale a null pixbuf.");
//else
// g_warning("ImageGlom::scale(): attempt to scale a null pixbuf.");
}
//static:
......
Supports Markdown
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