Commit 317c283b authored by Murray Cumming's avatar Murray Cumming
Browse files

DbAddDel use of TouchSelector instead of TreeView almost working.

parent ec1cca75
......@@ -42,7 +42,6 @@ Box_Data_List::Box_Data_List()
pack_start(m_AddDel);
add_view(&m_AddDel); //Give it access to the document.
m_AddDel.set_rules_hint(); //Use alternating row colors when the theme does that.
//Connect signals:
//The Add and Delete buttons are handled by the DbAddDel widget itself.
......
......@@ -33,7 +33,6 @@ Box_Data_List_Related::Box_Data_List_Related()
{
set_size_request(400, -1); //An arbitrary default.
m_AddDel.set_rules_hint(); //Use alternating row colors when the theme does that.
m_Alignment.add(m_AddDel);
add_view(&m_AddDel); //Give it access to the document.
m_AddDel.show();
......
......@@ -1000,11 +1000,6 @@ bool AddDel::get_allow_user_actions() const
return m_bAllowUserActions;
}
void AddDel::set_show_column_titles(bool bVal)
{
m_TreeView.set_headers_visible(bVal);
}
void AddDel::set_column_width(guint /* col */, guint /*width*/)
{
......@@ -1593,11 +1588,6 @@ guint AddDel::get_count_hidden_system_columns()
return hidden_count;
}
void AddDel::set_rules_hint(bool val)
{
m_TreeView.set_rules_hint(val);
}
void AddDel::prevent_duplicates(guint column_number)
{
if(column_number < m_ColumnTypes.size())
......
......@@ -162,8 +162,6 @@ public:
void construct_specified_columns(); //Delay actual use of set_column_*() stuff until this method is called.
void set_show_column_titles(bool bVal = true);
Gtk::TreeModel::iterator get_row(const Glib::ustring& key);
void finish_editing(); //Closes active edit controls and commits the data to the cell.
......@@ -179,8 +177,6 @@ public:
Glib::RefPtr<Gtk::TreeModel> get_model();
Glib::RefPtr<const Gtk::TreeModel> get_model() const;
void set_rules_hint(bool val = true);
//Signals:
//row number.
typedef sigc::signal<void, const Gtk::TreeModel::iterator&> type_signal_user_added;
......
......@@ -381,71 +381,7 @@ void DataWidget::set_child_size_by_field(const sharedptr<const LayoutItem_Field>
int DataWidget::get_suitable_width(const sharedptr<const LayoutItem_Field>& field_layout)
{
int result = 150;
const Field::glom_field_type field_type = field_layout->get_glom_type();
Glib::ustring example_text;
switch(field_type)
{
case(Field::TYPE_DATE):
{
Glib::Date date(31, Glib::Date::Month(12), 2000);
example_text = Conversions::get_text_for_gda_value(field_type, Gnome::Gda::Value(date));
break;
}
case(Field::TYPE_TIME):
{
Gnome::Gda::Time time = {0, 0, 0, 0, 0};
time.hour = 24;
time.minute = 59;
time.second = 59;
example_text = Conversions::get_text_for_gda_value(field_type, Gnome::Gda::Value(time));
break;
}
case(Field::TYPE_NUMERIC):
{
#ifdef GLOM_ENABLE_MAEMO
//Maemo's screen is not so big, so don't be so generous:
example_text = "EUR 9999999";
#else
example_text = "EUR 9999999999";
#endif
break;
}
case(Field::TYPE_TEXT):
case(Field::TYPE_IMAGE): //Give images the same width as text fields, so they will often line up.
{
//if(!field_layout->get_text_format_multiline()) //Use the full width for multi-line text.
#ifdef GLOM_ENABLE_MAEMO
//Maemo's screen is not so big, so don't be so generous:
example_text = "AAAAAAAAAAAAAAAA";
#else
example_text = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
#endif
break;
}
default:
{
break;
}
}
if(!example_text.empty())
{
//Get the width required for this string in the current font:
Glib::RefPtr<Pango::Layout> refLayout = create_pango_layout(example_text);
int width = 0;
int height = 0;
refLayout->get_pixel_size(width, height);
result = width;
//Add a bit more:
result += 10;
}
return result;
return Utils::get_suitable_field_width_for_widget(*this, field_layout);
}
void DataWidget::set_viewable(bool viewable)
......
This diff is collapsed.
......@@ -24,10 +24,15 @@
#include <gtkmm.h>
#include <libglom/data_structure/layout/layoutitem_field.h>
#include <libgdamm.h>
#include "glom_db_treemodel.h"
#include <glom/utility_widgets/db_adddel/glom_db_treemodel.h>
#include <libglom/document/document.h>
#include <glom/base_db_table_data.h>
#ifdef GLOM_ENABLE_MAEMO
#include <hildonmm/pannable-area.h>
#include <hildonmm/touch-selector.h>
#endif //GLOM_ENABLE_MAEMO
#include <vector>
#include <map>
......@@ -198,8 +203,6 @@ public:
bool refresh_from_database();
bool refresh_from_database_blank();
void set_show_column_titles(bool bVal = true);
Gtk::TreeModel::iterator get_row(const Gnome::Gda::Value& key);
void finish_editing(); //Closes active edit controls and commits the data to the cell.
......@@ -213,8 +216,6 @@ public:
Glib::RefPtr<Gtk::TreeModel> get_model();
Glib::RefPtr<const Gtk::TreeModel> get_model() const;
void set_rules_hint(bool val = true);
//Signals:
#ifndef GLOM_ENABLE_CLIENT_ONLY
......@@ -289,6 +290,9 @@ private:
protected:
virtual void setup_menu();
/// A common handler for the edit button, the context menu, etc.
void do_user_requested_edit();
private:
virtual Gnome::Gda::Value treeview_get_key(const Gtk::TreeModel::iterator& row) const;
......@@ -296,35 +300,53 @@ private:
//virtual Gtk::TreeModel::iterator get_next_available_row_with_add_if_necessary();
//Signal handlers:
#ifdef GLOM_ENABLE_MAEMO
void treeviewcolumn_on_cell_data(const Gtk::TreeModel::iterator& iter, int model_column_index, int data_model_column_index);
#else
void treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter, int model_column_index, int data_model_column_index);
#endif //GLOM_ENABLE_MAEMO
//TODO: Remove virtuals after checking that there are no method overrides:
#ifndef GLOM_ENABLE_MAEMO
virtual void on_treeview_cell_edited(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column_index, int data_model_column_index);
virtual void on_treeview_cell_edited_bool(const Glib::ustring& path_string, int model_column_index, int data_model_column_index);
virtual bool on_treeview_column_drop(Gtk::TreeView* treeview, Gtk::TreeViewColumn* column, Gtk::TreeViewColumn* prev_column, Gtk::TreeViewColumn* next_column);
virtual void on_treeview_columns_changed();
bool on_treeview_column_drop(Gtk::TreeView* treeview, Gtk::TreeViewColumn* column, Gtk::TreeViewColumn* prev_column, Gtk::TreeViewColumn* next_column);
void on_treeview_columns_changed();
virtual bool on_button_press_event_Popup(GdkEventButton* event);
virtual void on_treeview_button_press_event(GdkEventButton* event);
protected:
void on_MenuPopup_activate_Edit();
void on_MenuPopup_activate_Add();
void on_MenuPopup_activate_Delete();
private:
#endif //GLOM_ENABLE_MAEMO
#ifndef GLOM_ENABLE_CLIENT_ONLY
void on_MenuPopup_activate_layout();
#endif
virtual void on_treeview_button_press_event(GdkEventButton* event);
#ifndef GLOM_ENABLE_MAEMO
virtual bool on_treeview_columnheader_button_press_event(GdkEventButton* event);
virtual void on_treeview_column_clicked(int model_column_index);
void on_treeview_column_resized(int model_column_index, DbTreeViewColumnGlom* view_column);
virtual void on_cell_button_clicked(const Gtk::TreeModel::Path& path);
void on_cell_layout_button_clicked(const Gtk::TreeModel::Path& path, int model_column_index);
#endif //GLOM_ENABLE_MAEMO
#ifdef GLOM_ENABLE_MAEMO
void on_touch_selector_changed(int model_column_index);
#endif
#ifdef GLOM_ENABLE_MAEMO
/// Get the single column, adding it if necessary.
Glib::RefPtr<Hildon::TouchSelectorColumn> touch_selector_get_column();
Glib::RefPtr<const Hildon::TouchSelectorColumn> touch_selector_get_column() const;
#endif
#ifdef GLOM_ENABLE_CLIENT_ONLY
// Don't name it on_style_changed, otherwise we would override a virtual
......@@ -362,9 +384,14 @@ private:
typedef Gtk::VBox type_base;
//Member widgets:
#ifdef GLOM_ENABLE_MAEMO
Hildon::TouchSelector m_TreeView;
#else
Gtk::ScrolledWindow m_ScrolledWindow;
Gtk::TreeView m_TreeView;
#endif
Gtk::TreeModel::ColumnRecord m_ColumnRecord;
//typedef Gtk::ListStore type_model_store;
......@@ -384,11 +411,13 @@ protected:
Glib::ustring m_open_button_title; //Allow us to change "Open" to "Select".
private:
#ifndef GLOM_ENABLE_MAEMO
//TODO: Avoid repeating these in so many widgets:
Gtk::Menu* m_pMenuPopup;
Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
Glib::RefPtr<Gtk::UIManager> m_refUIManager;
Glib::RefPtr<Gtk::Action> m_refContextEdit, m_refContextAdd, m_refContextDelete;
#endif //GLOM_ENABLE_MAEMO
#ifndef GLOM_ENABLE_CLIENT_ONLY
Glib::RefPtr<Gtk::Action> m_refContextLayout;
......@@ -416,7 +445,10 @@ private:
bool m_columns_ready;
bool m_allow_view;
bool m_allow_view_details;
#ifndef GLOM_ENABLE_MAEMO
Gtk::TreeViewColumn* m_treeviewcolumn_button;
#endif
//Signals:
type_signal_user_requested_edit m_signal_user_requested_edit;
......
......@@ -53,17 +53,21 @@ DbAddDel_WithButtons::~DbAddDel_WithButtons()
void DbAddDel_WithButtons::on_button_add()
{
#ifndef GLOM_ENABLE_MAEMO
on_MenuPopup_activate_Add();
#endif
}
void DbAddDel_WithButtons::on_button_del()
{
#ifndef GLOM_ENABLE_MAEMO
on_MenuPopup_activate_Delete();
#endif
}
void DbAddDel_WithButtons::on_button_edit()
{
on_MenuPopup_activate_Edit();
do_user_requested_edit();
}
void DbAddDel_WithButtons::set_allow_add(bool val)
......
......@@ -319,4 +319,74 @@ Glib::RefPtr<Gdk::Pixbuf> Utils::get_pixbuf_for_gda_value(const Gnome::Gda::Valu
return result;
}
int Utils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const sharedptr<const LayoutItem_Field>& field_layout)
{
int result = 150;
const Field::glom_field_type field_type = field_layout->get_glom_type();
Glib::ustring example_text;
switch(field_type)
{
case(Field::TYPE_DATE):
{
Glib::Date date(31, Glib::Date::Month(12), 2000);
example_text = Conversions::get_text_for_gda_value(field_type, Gnome::Gda::Value(date));
break;
}
case(Field::TYPE_TIME):
{
Gnome::Gda::Time time = {0, 0, 0, 0, 0};
time.hour = 24;
time.minute = 59;
time.second = 59;
example_text = Conversions::get_text_for_gda_value(field_type, Gnome::Gda::Value(time));
break;
}
case(Field::TYPE_NUMERIC):
{
#ifdef GLOM_ENABLE_MAEMO
//Maemo's screen is not so big, so don't be so generous:
example_text = "EUR 9999999";
#else
example_text = "EUR 9999999999";
#endif
break;
}
case(Field::TYPE_TEXT):
case(Field::TYPE_IMAGE): //Give images the same width as text fields, so they will often line up.
{
//if(!field_layout->get_text_format_multiline()) //Use the full width for multi-line text.
#ifdef GLOM_ENABLE_MAEMO
//Maemo's screen is not so big, so don't be so generous:
example_text = "AAAAAAAAAAAAAAAA";
#else
example_text = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
#endif
break;
}
default:
{
break;
}
}
if(!example_text.empty())
{
//Get the width required for this string in the current font:
Glib::RefPtr<Pango::Layout> refLayout = widget.create_pango_layout(example_text);
int width = 0;
int height = 0;
refLayout->get_pixel_size(width, height);
result = width;
//Add a bit more:
result += 10;
}
return result;
}
} //namespace Glom
......@@ -66,6 +66,8 @@ Glib::ustring bold_message(const Glib::ustring& message);
Glib::RefPtr<Gdk::Pixbuf> get_pixbuf_for_gda_value(const Gnome::Gda::Value& value);
int get_suitable_field_width_for_widget(Gtk::Widget& widget, const sharedptr<const LayoutItem_Field>& field_layout);
} //namespace Utils
} //namespace Glom
......
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