[glom] C++11: Use scoped enums (enum class).
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] C++11: Use scoped enums (enum class).
- Date: Fri, 21 Aug 2015 19:08:11 +0000 (UTC)
commit 2bafe10c98af6e0147bb8ada6c748825af1f23e9
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Aug 21 18:11:48 2015 +0200
C++11: Use scoped enums (enum class).
This showed a real problem with a || check in csv_parser.cc.
(not my code.)
glom/appwindow.cc | 100 +++++++-------
glom/bakery/appwindow_withdoc.cc | 8 +-
glom/bakery/appwindow_withdoc.h | 8 +-
glom/bakery/dialog_offersave.cc | 6 +-
glom/bakery/dialog_offersave.h | 8 +-
glom/base_db.cc | 2 +-
glom/box_reports.cc | 10 +-
glom/box_withbuttons.cc | 14 +-
glom/dialog_connection.cc | 8 +-
glom/dialog_existing_or_new.cc | 30 ++--
glom/dialog_existing_or_new.h | 2 +-
glom/dialog_invalid_data.cc | 8 +-
glom/filechooser_export.cc | 2 +-
glom/frame_glom.cc | 98 +++++++-------
glom/frame_glom.h | 8 +-
glom/glom_create_from_example.cc | 16 +-
glom/glom_test_connection.cc | 4 +-
glom/import_csv/csv_parser.cc | 25 ++--
glom/import_csv/csv_parser.h | 10 +-
glom/import_csv/dialog_import_csv.cc | 5 +-
glom/import_csv/dialog_import_csv_progress.cc | 8 +-
glom/libglom/appstate.cc | 2 +-
glom/libglom/appstate.h | 6 +-
glom/libglom/connectionpool.cc | 20 ++--
glom/libglom/connectionpool_backends/backend.cc | 4 +-
glom/libglom/connectionpool_backends/backend.h | 34 +++---
glom/libglom/connectionpool_backends/mysql.cc | 18 ++--
.../connectionpool_backends/mysql_central.cc | 8 +-
glom/libglom/connectionpool_backends/mysql_self.cc | 46 +++---
glom/libglom/connectionpool_backends/postgres.cc | 18 ++--
.../connectionpool_backends/postgres_central.cc | 8 +-
.../connectionpool_backends/postgres_self.cc | 32 ++--
glom/libglom/connectionpool_backends/sqlite.cc | 22 ++--
glom/libglom/data_structure/choicevalue.cc | 2 +-
glom/libglom/data_structure/database_title.cc | 2 +-
glom/libglom/data_structure/field.cc | 152 ++++++++++----------
glom/libglom/data_structure/field.h | 22 ++--
glom/libglom/data_structure/fieldtypes.cc | 14 +-
glom/libglom/data_structure/glomconversions.cc | 44 +++---
glom/libglom/data_structure/layout/custom_title.cc | 2 +-
glom/libglom/data_structure/layout/formatting.cc | 2 +-
glom/libglom/data_structure/layout/formatting.h | 8 +-
glom/libglom/data_structure/layout/layoutitem.cc | 2 +-
.../data_structure/layout/layoutitem_button.cc | 2 +-
.../data_structure/layout/layoutitem_field.cc | 8 +-
.../data_structure/layout/layoutitem_field.h | 6 +-
.../data_structure/layout/layoutitem_image.cc | 2 +-
.../data_structure/layout/layoutitem_line.cc | 2 +-
.../data_structure/layout/layoutitem_portal.cc | 14 +-
.../data_structure/layout/layoutitem_portal.h | 8 +-
.../data_structure/layout/layoutitem_text.cc | 2 +-
.../layout/layoutitem_withformatting.cc | 4 +-
.../layout/layoutitem_withformatting.h | 4 +-
.../layout/report_parts/layoutitem_fieldsummary.cc | 28 ++--
.../layout/report_parts/layoutitem_fieldsummary.h | 10 +-
glom/libglom/data_structure/layout/static_text.cc | 2 +-
glom/libglom/data_structure/print_layout.cc | 2 +-
glom/libglom/data_structure/relationship.cc | 2 +-
glom/libglom/data_structure/report.cc | 2 +-
glom/libglom/data_structure/system_prefs.h | 2 +-
glom/libglom/data_structure/tableinfo.cc | 2 +-
glom/libglom/data_structure/translatable_item.cc | 58 ++++----
glom/libglom/data_structure/translatable_item.h | 30 ++--
glom/libglom/db_utils.cc | 80 +++++-----
glom/libglom/document/bakery/document.cc | 6 +-
glom/libglom/document/bakery/document.h | 10 +-
glom/libglom/document/document.cc | 140 +++++++++---------
glom/libglom/document/document.h | 32 ++--
glom/libglom/privs.cc | 4 +-
glom/libglom/privs.h | 5 +-
glom/libglom/report_builder.cc | 8 +-
glom/libglom/test_avahi_publisher.cc | 2 +-
glom/libglom/utils.cc | 2 +-
glom/libglom/xml_utils.cc | 2 +-
glom/mode_data/box_data.cc | 2 +-
glom/mode_data/box_data_calendar_related.cc | 10 +-
glom/mode_data/box_data_details.cc | 12 +-
glom/mode_data/box_data_list_related.cc | 6 +-
glom/mode_data/box_data_portal.cc | 4 +-
glom/mode_data/buttonglom.cc | 2 +-
glom/mode_data/datawidget/cellcreation.cc | 6 +-
glom/mode_data/datawidget/cellrenderer_dblist.cc | 2 +-
glom/mode_data/datawidget/checkbutton.cc | 2 +-
glom/mode_data/datawidget/combo.cc | 8 +-
.../mode_data/datawidget/combo_as_radio_buttons.cc | 6 +-
.../datawidget/combochoiceswithtreemodel.cc | 10 +-
glom/mode_data/datawidget/datawidget.cc | 20 ++--
glom/mode_data/datawidget/dialog_choose_id.cc | 14 +-
glom/mode_data/datawidget/dialog_choose_id.h | 8 +-
glom/mode_data/datawidget/entry.cc | 10 +-
glom/mode_data/datawidget/entry.h | 2 +-
glom/mode_data/datawidget/label.cc | 2 +-
glom/mode_data/datawidget/textview.cc | 4 +-
glom/mode_data/datawidget/textview.h | 2 +-
glom/mode_data/datawidget/treemodel_db.cc | 2 +-
glom/mode_data/db_adddel/db_adddel.cc | 16 +-
glom/mode_data/db_adddel/db_adddel_withbuttons.cc | 2 +-
glom/mode_data/flowtablewithfields.cc | 38 +++---
glom/mode_data/notebook_data.cc | 30 ++--
glom/mode_data/notebook_data.h | 6 +-
glom/mode_design/box_db_table_relationships.cc | 10 +-
glom/mode_design/dialog_database_preferences.cc | 6 +-
glom/mode_design/fields/box_db_table_definition.cc | 18 ++--
glom/mode_design/fields/combo_fieldtype.cc | 2 +-
glom/mode_design/fields/dialog_fieldcalculation.cc | 2 +-
glom/mode_design/layout/dialog_choose_field.cc | 2 +-
.../layout/dialog_layout_calendar_related.cc | 4 +-
.../layout/dialog_layout_list_related.cc | 12 +-
.../layout/layout_item_dialogs/box_formatting.cc | 14 +-
.../layout_item_dialogs/combo_summarytype.cc | 14 +-
.../mode_design/print_layouts/box_print_layouts.cc | 10 +-
.../print_layouts/print_layout_toolbar.cc | 12 +-
.../print_layouts/print_layout_toolbar_button.cc | 2 +-
.../print_layouts/print_layout_toolbar_button.h | 16 +-
.../print_layouts/window_print_layout_edit.cc | 28 ++--
glom/mode_design/users/dialog_groups_list.cc | 22 ++--
glom/mode_design/users/dialog_groups_list.h | 10 +-
glom/mode_find/box_data_list_find.cc | 2 +-
glom/mode_find/notebook_find.cc | 2 +-
glom/navigation/box_tables.cc | 18 ++--
glom/print_layout/canvas_layout_item.cc | 18 ++--
glom/print_layout/canvas_print_layout.cc | 2 +-
glom/python_embed/glom_python.cc | 4 +-
glom/utility_widgets/adddel/adddel.cc | 46 +++---
glom/utility_widgets/adddel/adddel.h | 14 +-
glom/utility_widgets/adddel/adddel_withbuttons.cc | 8 +-
.../utility_widgets/canvas/canvas_group_movable.cc | 10 +-
glom/utility_widgets/canvas/canvas_group_movable.h | 12 +-
.../canvas/canvas_group_resizable.cc | 80 +++++-----
.../canvas/canvas_group_resizable.h | 36 +++---
.../utility_widgets/canvas/canvas_image_movable.cc | 12 +-
glom/utility_widgets/canvas/canvas_image_movable.h | 10 +-
glom/utility_widgets/canvas/canvas_rect_movable.cc | 16 +-
glom/utility_widgets/canvas/canvas_rect_movable.h | 14 +-
.../utility_widgets/canvas/canvas_table_movable.cc | 10 +-
glom/utility_widgets/canvas/canvas_table_movable.h | 12 +-
glom/utility_widgets/canvas/canvas_text_movable.cc | 10 +-
glom/utility_widgets/canvas/canvas_text_movable.h | 10 +-
.../filechooserdialog_saveextras.cc | 32 ++--
glom/utility_widgets/imageglom.cc | 2 +-
glom/utility_widgets/layouttoolbar.cc | 14 +-
glom/utility_widgets/layoutwidgetbase.cc | 4 +-
glom/utility_widgets/layoutwidgetbase.h | 16 +-
glom/utility_widgets/layoutwidgetmenu.cc | 14 +-
glom/utility_widgets/notebook_noframe.cc | 6 +-
glom/utility_widgets/notebooklabelglom.cc | 2 +-
glom/utils_ui.cc | 36 +++---
glom/utils_ui.h | 6 +-
glom/window_boxholder.cc | 2 +-
tests/import/utils.cc | 4 +-
tests/python/test_python_execute_func.cc | 2 +-
.../python/test_python_execute_func_bad_syntax.cc | 2 +-
.../test_python_execute_func_change_result_type.cc | 2 +-
tests/python/test_python_execute_func_date.cc | 6 +-
.../python/test_python_execute_func_with_record.cc | 8 +-
tests/test_conversions.cc | 6 +-
tests/test_document_autosave.cc | 4 +-
tests/test_document_load.cc | 8 +-
tests/test_field_file_format.cc | 8 +-
tests/test_parsing_time.cc | 4 +-
tests/test_selfhosting_new_empty_then_users.cc | 6 +-
.../test_selfhosting_new_from_example_operator.cc | 4 +-
...est_selfhosting_new_from_example_strangepath.cc | 2 +-
tests/test_selfhosting_new_then_backup_restore.cc | 4 +-
tests/test_selfhosting_new_then_change_columns.cc | 6 +-
tests/test_selfhosting_new_then_get_privs.cc | 4 +-
tests/test_selfhosting_new_then_report_summary.cc | 4 +-
tests/test_selfhosting_sqlinjection.cc | 2 +-
tests/test_selfhosting_utils.cc | 44 +++---
tests/test_selfhosting_utils.h | 12 +-
tests/test_xml_utils.cc | 8 +-
171 files changed, 1184 insertions(+), 1185 deletions(-)
---
diff --git a/glom/appwindow.cc b/glom/appwindow.cc
index 57eb6ec..91ccfe9 100644
--- a/glom/appwindow.cc
+++ b/glom/appwindow.cc
@@ -95,7 +95,7 @@ AppWindow::AppWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>&
#endif // !GLOM_ENABLE_CLIENT_ONLY
#ifndef GLOM_ENABLE_CLIENT_ONLY
m_ui_save_extra_showextras(false),
- m_ui_save_extra_newdb_hosting_mode(Document::HOSTING_MODE_DEFAULT),
+ m_ui_save_extra_newdb_hosting_mode(Document::HostingMode::DEFAULT),
m_avahi_progress_dialog(nullptr),
#endif // !GLOM_ENABLE_CLIENT_ONLY
m_show_sql_debug(false)
@@ -348,7 +348,7 @@ void AppWindow::init_menus()
m_action_menu_developer_usermode =
m_refActionGroup_Developer->add_action_radio_integer("usermode",
sigc::mem_fun(*this, &AppWindow::on_menu_developer_usermode),
- AppState::USERLEVEL_OPERATOR );
+ static_cast<int>(AppState::userlevels::OPERATOR) );
action = m_refActionGroup_Developer->add_action("database-preferences",
sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_developer_database_preferences) );
@@ -524,7 +524,7 @@ void AppWindow::on_menu_developer_usermode(int parameter)
if(!m_pFrame)
return;
- const bool developer = parameter == AppState::USERLEVEL_DEVELOPER;
+ const bool developer = parameter == static_cast<int>(AppState::userlevels::DEVELOPER);
bool changed = false;
if(developer)
@@ -570,7 +570,7 @@ static bool hostname_is_localhost(const Glib::ustring& hostname)
void AppWindow::ui_warning_load_failed(int failure_code)
{
- if(failure_code == Document::LOAD_FAILURE_CODE_NOT_FOUND)
+ if(failure_code == static_cast<int>(Document::LoadFailureCodes::NOT_FOUND))
{
//TODO: Put this in the generic bakery code.
ui_warning(_("Open Failed"),
@@ -580,7 +580,7 @@ void AppWindow::ui_warning_load_failed(int failure_code)
//but the initial/welcome dialog doesn't yet update its list when the
//recent history changes.
}
- else if(failure_code == Document::LOAD_FAILURE_CODE_FILE_VERSION_TOO_NEW)
+ else if(failure_code == static_cast<int>(Document::load_failure_codes::FILE_VERSION_TOO_NEW))
{
ui_warning(_("Open Failed"),
_("The document could not be opened because it was created or modified by a newer version of Glom."));
@@ -672,8 +672,8 @@ void AppWindow::open_browsed_document(const EpcServiceInfo* server, const Glib::
#ifndef GLOM_ENABLE_CLIENT_ONLY
#ifdef GLOM_ENABLE_POSTGRESQL
//Stop the document from being self-hosted (it's already hosted by the other networked Glom instance):
- if(document_temp.get_hosting_mode() == Document::HOSTING_MODE_POSTGRES_SELF)
- document_temp.set_hosting_mode(Document::HOSTING_MODE_POSTGRES_CENTRAL);
+ if(document_temp.get_hosting_mode() == Document::HostingMode::POSTGRES_SELF)
+ document_temp.set_hosting_mode(Document::HostingMode::POSTGRES_CENTRAL);
#endif //GLOM_ENABLE_POSTGRESQL
#endif // !GLOM_ENABLE_CLIENT_ONLY
// TODO: Error out in case this is a sqlite database, since we probably
@@ -711,7 +711,7 @@ void AppWindow::open_browsed_document(const EpcServiceInfo* server, const Glib::
if(document)
{
document->set_opened_from_browse();
- document->set_userlevel(AppState::USERLEVEL_OPERATOR); //TODO: This should happen automatically.
+ document->set_userlevel(AppState::userlevels::OPERATOR); //TODO: This should happen automatically.
document->set_network_shared(true); //It is shared by the computer that we opened this from.
update_network_shared_ui();
@@ -804,7 +804,7 @@ bool AppWindow::check_document_hosting_mode_is_supported(Document* document)
Glib::ustring error_message;
switch(document->get_hosting_mode())
{
- case Document::HOSTING_MODE_POSTGRES_SELF:
+ case Document::HostingMode::POSTGRES_SELF:
{
#ifdef GLOM_ENABLE_CLIENT_ONLY
error_message = _("The file cannot be opened because this version of Glom does not support
self-hosting of databases.");
@@ -818,7 +818,7 @@ bool AppWindow::check_document_hosting_mode_is_supported(Document* document)
break;
}
- case Document::HOSTING_MODE_POSTGRES_CENTRAL:
+ case Document::HostingMode::POSTGRES_CENTRAL:
{
#ifndef GLOM_ENABLE_POSTGRESQL
error_message = _("The file cannot be opened because this version of Glom does not support PostgreSQL
databases.");
@@ -826,7 +826,7 @@ bool AppWindow::check_document_hosting_mode_is_supported(Document* document)
break;
}
- case Document::HOSTING_MODE_SQLITE:
+ case Document::HostingMode::SQLITE:
{
#ifndef GLOM_ENABLE_SQLITE
error_message = _("The file cannot be opened because this version of Glom does not support SQLite
databases.");
@@ -837,7 +837,7 @@ bool AppWindow::check_document_hosting_mode_is_supported(Document* document)
default:
{
//on_document_load() should have checked for this already, informing the user.
- std::cerr << G_STRFUNC << ": Unhandled hosting mode: " << document->get_hosting_mode() << std::endl;
+ std::cerr << G_STRFUNC << ": Unhandled hosting mode: " <<
static_cast<int>(document->get_hosting_mode()) << std::endl;
g_assert_not_reached();
break;
}
@@ -923,7 +923,7 @@ bool AppWindow::on_document_load()
}
m_ui_save_extra_newdb_title = "TODO";
- m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT;
+ m_ui_save_extra_newdb_hosting_mode = Document::HostingMode::DEFAULT;
// Reinit cancelled state
@@ -940,7 +940,7 @@ bool AppWindow::on_document_load()
//Get the results from the extended save dialog:
pDocument->set_database_title_original(m_ui_save_extra_newdb_title);
pDocument->set_hosting_mode(m_ui_save_extra_newdb_hosting_mode);
- m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT;
+ m_ui_save_extra_newdb_hosting_mode = Document::HostingMode::DEFAULT;
pDocument->set_is_example_file(false);
pDocument->set_is_backup_file(false);
@@ -976,9 +976,9 @@ bool AppWindow::on_document_load()
#ifndef GLOM_ENABLE_CLIENT_ONLY
//Warn about read-only files, because users will otherwise wonder why they can't use Developer mode:
- Document::userLevelReason reason = Document::USER_LEVEL_REASON_UNKNOWN;
+ Document::userLevelReason reason = Document::userLevelReason::UNKNOWN;
const auto userlevel = pDocument->get_userlevel(reason);
- if( (userlevel == AppState::USERLEVEL_OPERATOR) && (reason ==
Document::USER_LEVEL_REASON_FILE_READ_ONLY) )
+ if( (userlevel == AppState::userlevels::OPERATOR) && (reason ==
Document::userLevelReason::FILE_READ_ONLY) )
{
Gtk::MessageDialog dialog(UiUtils::bold_message(_("Opening Read-Only File.")), true,
Gtk::MESSAGE_INFO, Gtk::BUTTONS_NONE);
dialog.set_secondary_text(_("This file is read only, so you will not be able to enter Developer mode
to make design changes."));
@@ -1028,7 +1028,7 @@ bool AppWindow::on_document_load()
// username or password, because we don't. The user will enter
// the login credentials in a dialog.
const auto hosting_mode = pDocument->get_hosting_mode();
- if(hosting_mode != Document::HOSTING_MODE_POSTGRES_CENTRAL)
+ if(hosting_mode != Document::HostingMode::POSTGRES_CENTRAL)
m_temp_username = Privs::get_default_developer_user_name(m_temp_password, hosting_mode);
}
@@ -1090,7 +1090,7 @@ bool AppWindow::on_document_load()
//Make sure that the changes (mark as non example, and save the new database name) are really
saved:
//Change the user level temporarily so that save_changes() actually saves:
const auto user_level = pDocument->get_userlevel();
- pDocument->set_userlevel(AppState::USERLEVEL_DEVELOPER);
+ pDocument->set_userlevel(AppState::userlevels::DEVELOPER);
pDocument->set_modified(true);
pDocument->set_allow_autosave(true); //Turn this back on.
pDocument->set_userlevel(user_level); //Change it back.
@@ -1099,7 +1099,7 @@ bool AppWindow::on_document_load()
#endif // !GLOM_ENABLE_CLIENT_ONLY
//Switch to operator mode when opening new documents:
- pDocument->set_userlevel(AppState::USERLEVEL_OPERATOR);
+ pDocument->set_userlevel(AppState::userlevels::OPERATOR);
//Make sure that it's saved in history, even if it was saved from an example file:
document_history_add(pDocument->get_file_uri());
@@ -1208,8 +1208,8 @@ void AppWindow::update_network_shared_ui()
//Do not allow impossible changes:
const auto hosting_mode = document->get_hosting_mode();
- if( (hosting_mode == Document::HOSTING_MODE_POSTGRES_CENTRAL) //Central hosting means that it must be
shared on the network.
- || (hosting_mode == Document::HOSTING_MODE_SQLITE) ) //sqlite does not allow network sharing.
+ if( (hosting_mode == Document::HostingMode::POSTGRES_CENTRAL) //Central hosting means that it must be
shared on the network.
+ || (hosting_mode == Document::HostingMode::SQLITE) ) //sqlite does not allow network sharing.
{
m_toggleaction_network_shared->set_enabled(false);
}
@@ -1239,7 +1239,7 @@ void AppWindow::update_table_sensitive_ui()
const bool is_developer_item =
(std::find(m_listDeveloperActions.begin(), m_listDeveloperActions.end(), action) !=
m_listDeveloperActions.end());
if(is_developer_item)
- sensitive = sensitive && (userlevel == AppState::USERLEVEL_DEVELOPER);
+ sensitive = sensitive && (userlevel == AppState::userlevels::DEVELOPER);
action->set_enabled(sensitive);
}
@@ -1252,7 +1252,7 @@ void AppWindow::update_userlevel_ui()
//Disable/Enable developer actions:
for(const auto& action : m_listDeveloperActions)
{
- action->set_enabled( userlevel == AppState::USERLEVEL_DEVELOPER );
+ action->set_enabled( userlevel == AppState::userlevels::DEVELOPER );
}
//Ensure table sensitive menus stay disabled if necessary.
@@ -1260,7 +1260,7 @@ void AppWindow::update_userlevel_ui()
// Hide users entry from developer menu for connections that don't
// support users
- if(userlevel == AppState::USERLEVEL_DEVELOPER)
+ if(userlevel == AppState::userlevels::DEVELOPER)
{
if(ConnectionPool::get_instance_is_ready())
{
@@ -1274,12 +1274,12 @@ void AppWindow::update_userlevel_ui()
//We only need to set/unset one, because the others are in the same radio group.
//TODO:
/*
- if(userlevel == AppState::USERLEVEL_DEVELOPER)
+ if(userlevel == AppState::userlevels::DEVELOPER)
{
if(!m_action_menu_developer_developer->get_active())
m_action_menu_developer_developer->set_active();
}
- else if(userlevel == AppState::USERLEVEL_OPERATOR)
+ else if(userlevel == AppState::userlevels::OPERATOR)
{
if(!m_action_menu_developer_operator->get_active())
m_action_menu_developer_operator->set_active();
@@ -1313,22 +1313,22 @@ bool AppWindow::offer_new_or_existing()
switch(dialog->get_action())
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
- case Dialog_ExistingOrNew::NEW_EMPTY:
+ case Dialog_ExistingOrNew::Action::NEW_EMPTY:
existing_or_new_new();
break;
- case Dialog_ExistingOrNew::NEW_FROM_TEMPLATE:
+ case Dialog_ExistingOrNew::Action::NEW_FROM_TEMPLATE:
#endif // !GLOM_ENABLE_CLIENT_ONLY
- case Dialog_ExistingOrNew::OPEN_URI:
+ case Dialog_ExistingOrNew::Action::OPEN_URI:
open_document(dialog->get_uri());
break;
#ifndef G_OS_WIN32
- case Dialog_ExistingOrNew::OPEN_REMOTE:
+ case Dialog_ExistingOrNew::Action::OPEN_REMOTE:
open_browsed_document(dialog->get_service_info(), dialog->get_service_name());
break;
#endif
- case Dialog_ExistingOrNew::NONE:
+ case Dialog_ExistingOrNew::Action::NONE:
default:
- std::cerr << G_STRFUNC << ": Unhandled action: " << dialog->get_action() << std::endl;
+ std::cerr << G_STRFUNC << ": Unhandled action: " << static_cast<int>(dialog->get_action()) <<
std::endl;
g_assert_not_reached();
break;
}
@@ -1373,7 +1373,7 @@ void AppWindow::existing_or_new_new()
//Each document must have a location, so ask the user for one.
//This will use an extended save dialog that also asks for the database title and some hosting details:
m_ui_save_extra_showextras = true; //Offer self-hosting or central hosting, and offer the database title.
- m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT; /* Default to self-hosting */
+ m_ui_save_extra_newdb_hosting_mode = Document::HostingMode::DEFAULT; /* Default to self-hosting */
m_ui_save_extra_newdb_title.clear();
offer_saveas();
@@ -1391,13 +1391,13 @@ void AppWindow::existing_or_new_new()
const Glib::ustring db_title = m_ui_save_extra_newdb_title;
Document::HostingMode hosting_mode = m_ui_save_extra_newdb_hosting_mode;
m_ui_save_extra_newdb_title.clear();
- m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT;
+ m_ui_save_extra_newdb_hosting_mode = Document::HostingMode::DEFAULT;
//Make sure that the user can do something with his new document:
- document->set_userlevel(AppState::USERLEVEL_DEVELOPER);
+ document->set_userlevel(AppState::userlevels::DEVELOPER);
// Try various ports if connecting to an existing database server instead
// of self-hosting one:
- document->set_connection_try_other_ports(m_ui_save_extra_newdb_hosting_mode ==
Document::HOSTING_MODE_DEFAULT);
+ document->set_connection_try_other_ports(m_ui_save_extra_newdb_hosting_mode ==
Document::HostingMode::DEFAULT);
//Each new document must have an associated new database,
//so choose a name
@@ -1545,7 +1545,7 @@ bool AppWindow::recreate_database_from_example(bool& user_cancelled)
{
const ExceptionConnection& ex = *exptr;
#endif // GLIBMM_EXCEPTIONS_ENABLED
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_SERVER)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_SERVER)
{
user_cancelled = true; //Eventually, the user will cancel after retrying.
std::cerr << G_STRFUNC << ": Failed because connection to server failed, without specifying a
database." << std::endl;
@@ -1727,7 +1727,7 @@ bool AppWindow::recreate_database_from_backup(const std::string& backup_data_fil
{
const ExceptionConnection& ex = *exptr;
#endif // GLIBMM_EXCEPTIONS_ENABLED
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_SERVER)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_SERVER)
{
user_cancelled = true; //Eventually, the user will cancel after retrying.
std::cerr << G_STRFUNC << ": Failed because connection to server failed, without specifying a
database." << std::endl;
@@ -1816,7 +1816,7 @@ AppState::userlevels AppWindow::get_userlevel() const
}
else
g_assert_not_reached();
- //return AppState::USERLEVEL_DEVELOPER; //This should never happen.
+ //return AppState::userlevels::DEVELOPER; //This should never happen.
}
#ifndef GLOM_ENABLE_CLIENT_ONLY
@@ -2064,7 +2064,7 @@ void AppWindow::on_menu_file_save_as_example()
m_ui_save_extra_title.clear();
m_ui_save_extra_message.clear();
m_ui_save_extra_newdb_title.clear();
- m_ui_save_extra_newdb_hosting_mode = Document::HOSTING_MODE_DEFAULT;
+ m_ui_save_extra_newdb_hosting_mode = Document::HostingMode::DEFAULT;
Glib::ustring file_uri = ui_file_select_save(file_uriOld); //Also asks for overwrite confirmation.
if(!file_uri.empty())
@@ -2270,17 +2270,17 @@ Glib::ustring AppWindow::ui_file_select_save(const Glib::ustring& old_file_uri)
bool is_self_hosted = false;
#ifdef GLOM_ENABLE_POSTGRESQL
- if(m_ui_save_extra_newdb_hosting_mode == Document::HOSTING_MODE_POSTGRES_SELF)
+ if(m_ui_save_extra_newdb_hosting_mode == Document::HostingMode::POSTGRES_SELF)
is_self_hosted = true;
#endif //GLOM_ENABLE_POSTGRESQL
#ifdef GLOM_ENABLE_MYSQL
- if(m_ui_save_extra_newdb_hosting_mode == Document::HOSTING_MODE_MYSQL_SELF)
+ if(m_ui_save_extra_newdb_hosting_mode == Document::HostingMode::MYSQL_SELF)
is_self_hosted = true;
#endif // GLOM_ENABLE_MYSQL
#ifdef GLOM_ENABLE_SQLITE
- if(m_ui_save_extra_newdb_hosting_mode == Document::HOSTING_MODE_SQLITE)
+ if(m_ui_save_extra_newdb_hosting_mode == Document::HostingMode::SQLITE)
is_self_hosted = true;
#endif // GLOM_ENABLE_SQLITE
@@ -2588,7 +2588,7 @@ void AppWindow::update_window_title()
if(!table_label.empty())
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
- if(document->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(document->get_userlevel() == AppState::userlevels::DEVELOPER)
table_label += " (" + table_name + ")"; //Show the table name as well, if in developer mode.
#endif // GLOM_ENABLE_CLIENT_ONLY
}
@@ -2876,7 +2876,7 @@ void AppWindow::ui_show_modification_status()
AppWindow::enumSaveChanges AppWindow::ui_offer_to_save_changes()
{
- GlomBakery::AppWindow_WithDoc::enumSaveChanges result = GlomBakery::AppWindow_WithDoc::SAVECHANGES_Cancel;
+ GlomBakery::AppWindow_WithDoc::enumSaveChanges result =
GlomBakery::AppWindow_WithDoc::enumSaveChanges::Cancel;
if(!m_pDocument)
return result;
@@ -2892,12 +2892,12 @@ AppWindow::enumSaveChanges AppWindow::ui_offer_to_save_changes()
delete pDialogQuestion;
pDialogQuestion = nullptr;
- if(buttonClicked == GlomBakery::Dialog_OfferSave::BUTTON_Save)
- result = GlomBakery::AppWindow_WithDoc::SAVECHANGES_Save;
- else if(buttonClicked == GlomBakery::Dialog_OfferSave::BUTTON_Discard)
- result = GlomBakery::AppWindow_WithDoc::SAVECHANGES_Discard;
+ if(buttonClicked == GlomBakery::Dialog_OfferSave::enumButtons::Save)
+ result = GlomBakery::AppWindow_WithDoc::enumSaveChanges::Save;
+ else if(buttonClicked == GlomBakery::Dialog_OfferSave::enumButtons::Discard)
+ result = GlomBakery::AppWindow_WithDoc::enumSaveChanges::Discard;
else
- result = GlomBakery::AppWindow_WithDoc::SAVECHANGES_Cancel;
+ result = GlomBakery::AppWindow_WithDoc::enumSaveChanges::Cancel;
return result;
}
diff --git a/glom/bakery/appwindow_withdoc.cc b/glom/bakery/appwindow_withdoc.cc
index 207004b..d902df9 100644
--- a/glom/bakery/appwindow_withdoc.cc
+++ b/glom/bakery/appwindow_withdoc.cc
@@ -150,7 +150,7 @@ bool AppWindow_WithDoc::open_document(const Glib::ustring& file_uri)
ui_warning_load_failed(failure_code);
//Make sure that non-existant files are removed from the history list:
- if(failure_code == Document::LOAD_FAILURE_CODE_NOT_FOUND)
+ if(failure_code == static_cast<int>(Document::LoadFailureCodes::NOT_FOUND))
document_history_remove(file_uri);
//re-initialize document.
@@ -342,13 +342,13 @@ void AppWindow_WithDoc::offer_to_save_changes()
//Respond to button that was clicked:
switch(buttonClicked)
{
- case(SAVECHANGES_Save):
+ case(enumSaveChanges::Save):
{
on_menu_file_save(); //If File|Exit is in progress, this could cancel it.
break;
}
- case(SAVECHANGES_Discard):
+ case(enumSaveChanges::Discard):
{
//Close if this save offer was a result of a FileClose (It probably always is):
//close_mark_or_destroy();
@@ -356,7 +356,7 @@ void AppWindow_WithDoc::offer_to_save_changes()
break;
}
- case(SAVECHANGES_Cancel): //Cancel.
+ case(enumSaveChanges::Cancel): //Cancel.
{
cancel_close_or_exit();
break;
diff --git a/glom/bakery/appwindow_withdoc.h b/glom/bakery/appwindow_withdoc.h
index ee71627..a4b569c 100644
--- a/glom/bakery/appwindow_withdoc.h
+++ b/glom/bakery/appwindow_withdoc.h
@@ -62,11 +62,11 @@ public:
virtual void init() override; //overridden to create document.
- enum enumSaveChanges
+ enum class enumSaveChanges
{
- SAVECHANGES_Save,
- SAVECHANGES_Cancel,
- SAVECHANGES_Discard
+ Save,
+ Cancel,
+ Discard
};
static bool file_exists(const Glib::ustring& uri);
diff --git a/glom/bakery/dialog_offersave.cc b/glom/bakery/dialog_offersave.cc
index cbbd2c5..9b9934f 100644
--- a/glom/bakery/dialog_offersave.cc
+++ b/glom/bakery/dialog_offersave.cc
@@ -52,9 +52,9 @@ Dialog_OfferSave::Dialog_OfferSave(const Glib::ustring& file_uri)
set_secondary_text(get_confirmation_message(file_uri));
- add_button(_("Discard"), BUTTON_Discard);
- auto cancel_button = add_button(_("_Cancel"), BUTTON_Cancel);
- add_button(_("_Save"), BUTTON_Save);
+ add_button(_("Discard"), static_cast<int>(enumButtons::Discard));
+ auto cancel_button = add_button(_("_Cancel"), static_cast<int>(enumButtons::Cancel));
+ add_button(_("_Save"), static_cast<int>(enumButtons::Save));
// Otherwise Discard has focus initially which seems inconvenient:
cancel_button->grab_focus();
diff --git a/glom/bakery/dialog_offersave.h b/glom/bakery/dialog_offersave.h
index 10ac0eb..a438a55 100644
--- a/glom/bakery/dialog_offersave.h
+++ b/glom/bakery/dialog_offersave.h
@@ -34,11 +34,11 @@ public:
virtual ~Dialog_OfferSave();
///Return values:
- enum enumButtons
+ enum class enumButtons
{
- BUTTON_Save,
- BUTTON_Discard,
- BUTTON_Cancel
+ Save,
+ Discard,
+ Cancel
};
};
diff --git a/glom/base_db.cc b/glom/base_db.cc
index dda5c34..a2b023c 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -166,7 +166,7 @@ AppState::userlevels Base_DB::get_userlevel() const
else
{
std::cerr << G_STRFUNC << ": document not found." << std::endl;
- return AppState::USERLEVEL_OPERATOR;
+ return AppState::userlevels::OPERATOR;
}
}
diff --git a/glom/box_reports.cc b/glom/box_reports.cc
index 1b97687..e418ad2 100644
--- a/glom/box_reports.cc
+++ b/glom/box_reports.cc
@@ -78,7 +78,7 @@ bool Box_Reports::fill_from_database()
bool result = Box_DB_Table::fill_from_database();
//Enable/Disable extra widgets:
- bool developer_mode = (get_userlevel() == AppState::USERLEVEL_DEVELOPER);
+ bool developer_mode = (get_userlevel() == AppState::userlevels::DEVELOPER);
//Developers see more columns, so make it bigger:
if(developer_mode)
@@ -93,11 +93,11 @@ bool Box_Reports::fill_from_database()
const bool editable = developer_mode;
const bool visible_extras = developer_mode;
- m_colReportName = m_AddDel.add_column(_("Name"), AddDelColumnInfo::STYLE_Text, editable, visible_extras);
+ m_colReportName = m_AddDel.add_column(_("Name"), AddDelColumnInfo::enumStyles::Text, editable,
visible_extras);
m_AddDel.prevent_duplicates(m_colReportName); //Don't allow a relationship to be added twice.
m_AddDel.set_prevent_duplicates_warning(_("This report already exists. Please choose a different report
name"));
- m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::STYLE_Text, editable, true);
+ m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::enumStyles::Text, editable, true);
std::vector<Glib::ustring> listTableReports;
Document* document = get_document();
@@ -175,7 +175,7 @@ void Box_Reports::on_adddel_Edit(const Gtk::TreeModel::iterator& row)
#ifndef GLOM_ENABLE_CLIENT_ONLY
void Box_Reports::save_to_document()
{
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() == AppState::userlevels::DEVELOPER)
{
//Add any reports that are not in the document:
std::vector<Glib::ustring> listReports = get_document()->get_report_names(m_table_name);
@@ -205,7 +205,7 @@ void Box_Reports::save_to_document()
void Box_Reports::on_adddel_changed(const Gtk::TreeModel::iterator& row, guint column)
{
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() == AppState::userlevels::DEVELOPER)
{
const auto report_name = m_AddDel.get_value_key(row);
Document* document = get_document();
diff --git a/glom/box_withbuttons.cc b/glom/box_withbuttons.cc
index 2fbb01f..79924b3 100644
--- a/glom/box_withbuttons.cc
+++ b/glom/box_withbuttons.cc
@@ -32,13 +32,13 @@ namespace Glom
Box_WithButtons::Box_WithButtons()
: Gtk::Box(Gtk::ORIENTATION_VERTICAL),
- m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, UiUtils::DEFAULT_SPACING_SMALL),
+ m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
m_Button_Cancel(_("_Cancel"))
{
//m_pDocument = nullptr;
- //set_border_width(UiUtils::DEFAULT_SPACING_SMALL);
- set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ //set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+ set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
//Connect signals:
m_Button_Cancel.signal_clicked().connect(sigc::mem_fun(*this, &Box_WithButtons::on_Button_Cancel));
@@ -46,13 +46,13 @@ Box_WithButtons::Box_WithButtons()
Box_WithButtons::Box_WithButtons(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& /* builder */)
: Gtk::Box(cobject),
- m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, UiUtils::DEFAULT_SPACING_SMALL),
+ m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
m_Button_Cancel(_("_Cancel"))
{
//m_pDocument = nullptr;
- //set_border_width(UiUtils::DEFAULT_SPACING_SMALL);
- set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ //set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+ set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
//Connect signals:
m_Button_Cancel.signal_clicked().connect(sigc::mem_fun(*this, &Box_WithButtons::on_Button_Cancel));
@@ -60,7 +60,7 @@ Box_WithButtons::Box_WithButtons(BaseObjectType* cobject, const Glib::RefPtr<Gtk
Box_WithButtons::Box_WithButtons(BaseObjectType* cobject)
: Gtk::Box(cobject),
- m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, UiUtils::DEFAULT_SPACING_SMALL),
+ m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
m_Button_Cancel(_("_Cancel"))
{
}
diff --git a/glom/dialog_connection.cc b/glom/dialog_connection.cc
index 3efec00..c3e902e 100644
--- a/glom/dialog_connection.cc
+++ b/glom/dialog_connection.cc
@@ -79,7 +79,7 @@ std::shared_ptr<SharedConnection> Dialog_Connection::connect_to_server_with_conn
connection_pool->set_database(m_database_name);
#ifdef GLOM_ENABLE_POSTGRESQL
- if(document->get_hosting_mode() == Document::HOSTING_MODE_POSTGRES_CENTRAL)
+ if(document->get_hosting_mode() == Document::HostingMode::POSTGRES_CENTRAL)
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
ConnectionPoolBackends::PostgresCentralHosted* central =
dynamic_cast<ConnectionPoolBackends::PostgresCentralHosted*>(backend);
@@ -101,7 +101,7 @@ std::shared_ptr<SharedConnection> Dialog_Connection::connect_to_server_with_conn
//and so we can tell connecting clients (using browse network) what port to use:
Document* unconst = const_cast<Document*>(document);
- if(document->get_hosting_mode() == Document::HOSTING_MODE_POSTGRES_CENTRAL)
+ if(document->get_hosting_mode() == Document::HostingMode::POSTGRES_CENTRAL)
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
ConnectionPoolBackends::PostgresCentralHosted* central =
dynamic_cast<ConnectionPoolBackends::PostgresCentralHosted*>(backend);
@@ -114,7 +114,7 @@ std::shared_ptr<SharedConnection> Dialog_Connection::connect_to_server_with_conn
}
#ifndef GLOM_ENABLE_CLIENT_ONLY
- else if(document->get_hosting_mode() == Document::HOSTING_MODE_POSTGRES_SELF)
+ else if(document->get_hosting_mode() == Document::HostingMode::POSTGRES_SELF)
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
ConnectionPoolBackends::PostgresSelfHosted* self =
dynamic_cast<ConnectionPoolBackends::PostgresSelfHosted*>(backend);
@@ -138,7 +138,7 @@ void Dialog_Connection::load_from_document()
#ifndef GLOM_ENABLE_CLIENT_ONLY
#ifdef GLOM_ENABLE_POSTGRESQL
//Load server and user:
- if(document->get_hosting_mode() != Document::HOSTING_MODE_POSTGRES_CENTRAL)
+ if(document->get_hosting_mode() != Document::HostingMode::POSTGRES_CENTRAL)
{
m_entry_host->set_text("(self hosted)");
m_entry_host->set_sensitive(false);
diff --git a/glom/dialog_existing_or_new.cc b/glom/dialog_existing_or_new.cc
index 5d5241e..cf9614e 100644
--- a/glom/dialog_existing_or_new.cc
+++ b/glom/dialog_existing_or_new.cc
@@ -336,37 +336,37 @@ Dialog_ExistingOrNew::Action Dialog_ExistingOrNew::get_action_impl(Gtk::TreeMode
if(m_notebook->get_current_page() == 0)
{
if(m_existing_view->get_selection()->count_selected_rows() == 0)
- return NONE;
+ return Action::NONE;
iter = m_existing_view->get_selection()->get_selected();
if(m_existing_model->is_ancestor(m_iter_existing_recent, iter))
- return OPEN_URI;
+ return Action::OPEN_URI;
#ifndef G_OS_WIN32
if(m_existing_model->is_ancestor(m_iter_existing_network, iter))
- return OPEN_REMOTE;
+ return Action::OPEN_REMOTE;
#endif
if(iter == m_iter_existing_other)
- return OPEN_URI;
+ return Action::OPEN_URI;
- return NONE;
+ return Action::NONE;
}
else
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
if(m_new_view->get_selection()->count_selected_rows() == 0)
- return NONE;
+ return Action::NONE;
iter = m_new_view->get_selection()->get_selected();
if(m_new_model->is_ancestor(m_iter_new_template, iter))
- return NEW_FROM_TEMPLATE;
+ return Action::NEW_FROM_TEMPLATE;
else if(iter == m_iter_new_empty)
- return NEW_EMPTY;
+ return Action::NEW_EMPTY;
else
- return NONE;
+ return Action::NONE;
#endif //GLOM_ENABLE_CLIENT_ONLY
}
- return NONE;
+ return Action::NONE;
}
Dialog_ExistingOrNew::Action Dialog_ExistingOrNew::get_action() const
@@ -381,13 +381,13 @@ Glib::ustring Dialog_ExistingOrNew::get_uri() const
const auto action = get_action_impl(iter);
#ifndef GLOM_ENABLE_CLIENT_ONLY
- if(action == NEW_FROM_TEMPLATE)
+ if(action == Action::NEW_FROM_TEMPLATE)
{
return (*iter)[m_new_columns.m_col_template_uri];
}
else
#endif //GLOM_ENABLE_CLIENT_ONLY
- if(action == OPEN_URI)
+ if(action == Action::OPEN_URI)
{
if(iter == m_iter_existing_other)
{
@@ -411,7 +411,7 @@ EpcServiceInfo* Dialog_ExistingOrNew::get_service_info() const
Gtk::TreeModel::iterator iter;
Action action = get_action_impl(iter);
- if(action == OPEN_REMOTE)
+ if(action == Action::OPEN_REMOTE)
return (*iter)[m_existing_columns.m_col_service_info];
else
throw std::logic_error("Dialog_ExistingOrNew::get_service_info: action is not OPEN_REMOTE");
@@ -424,7 +424,7 @@ Glib::ustring Dialog_ExistingOrNew::get_service_name() const
Gtk::TreeModel::iterator iter;
Action action = get_action_impl(iter);
- if(action == OPEN_REMOTE)
+ if(action == Action::OPEN_REMOTE)
return (*iter)[m_existing_columns.m_col_service_name];
else
throw std::logic_error("Dialog_ExistingOrNew::get_service_name: action is not OPEN_REMOTE");
@@ -796,7 +796,7 @@ void Dialog_ExistingOrNew::on_select_clicked()
Gtk::TreeModel::iterator iter;
Action action = get_action_impl(iter);
- if(action == OPEN_URI && iter == m_iter_existing_other)
+ if(action == Action::OPEN_URI && iter == m_iter_existing_other)
{
Gtk::FileChooserDialog dialog(*this, "Open Glom File");
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
diff --git a/glom/dialog_existing_or_new.h b/glom/dialog_existing_or_new.h
index 4020794..37860c7 100644
--- a/glom/dialog_existing_or_new.h
+++ b/glom/dialog_existing_or_new.h
@@ -49,7 +49,7 @@ public:
static const char glade_id[];
static const bool glade_developer;
- enum Action {
+ enum class Action {
NONE,
NEW_EMPTY,
NEW_FROM_TEMPLATE,
diff --git a/glom/dialog_invalid_data.cc b/glom/dialog_invalid_data.cc
index e7e6f1a..2e225e8 100644
--- a/glom/dialog_invalid_data.cc
+++ b/glom/dialog_invalid_data.cc
@@ -63,13 +63,13 @@ void Dialog_InvalidData::set_example_data(Field::glom_field_type glom_type)
Glib::ustring example_text;
switch(glom_type)
{
- case(Field::TYPE_DATE):
+ case(Field::glom_field_type::DATE):
{
Glib::Date date(31, Glib::Date::JANUARY, 2005);
example_text = Conversions::get_text_for_gda_value(glom_type, Gnome::Gda::Value(date));
break;
}
- case(Field::TYPE_TIME):
+ case(Field::glom_field_type::TIME):
{
Gnome::Gda::Time time = {0, 0, 0, 0, 0};
time.hour = 13;
@@ -78,14 +78,14 @@ void Dialog_InvalidData::set_example_data(Field::glom_field_type glom_type)
example_text = Conversions::get_text_for_gda_value(glom_type, Gnome::Gda::Value(time));
break;
}
- case(Field::TYPE_NUMERIC):
+ case(Field::glom_field_type::NUMERIC):
{
Gnome::Gda::Value gda_value;
gda_value.set_double(12345678.91L);
example_text = Conversions::get_text_for_gda_value(glom_type, gda_value);
break;
}
- case(Field::TYPE_TEXT):
+ case(Field::glom_field_type::TEXT):
default:
{
example_text = "Abcdefghi jklmnopq lmnopqr";
diff --git a/glom/filechooser_export.cc b/glom/filechooser_export.cc
index 66544de..1a86538 100644
--- a/glom/filechooser_export.cc
+++ b/glom/filechooser_export.cc
@@ -29,7 +29,7 @@ namespace Glom
FileChooser_Export::FileChooser_Export()
: Gtk::FileChooserDialog(_("Export to File"), Gtk::FILE_CHOOSER_ACTION_SAVE),
- m_extra_widget(Gtk::ORIENTATION_HORIZONTAL, UiUtils::DEFAULT_SPACING_SMALL),
+ m_extra_widget(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
#ifndef GLOM_ENABLE_CLIENT_ONLY
m_button_format(_("Define Data _Format"), true /* use mnenomic */),
m_pDialogLayout(nullptr),
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 6c34fdb..9f317e8 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -75,7 +75,7 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
: PlaceHolder(cobject, builder),
m_pLabel_Table_DataMode(nullptr),
m_pLabel_Table_FindMode(nullptr),
- m_Box_RecordsCount(Gtk::ORIENTATION_HORIZONTAL, UiUtils::DEFAULT_SPACING_SMALL),
+ m_Box_RecordsCount(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
m_Button_FindAll(_("Find All")),
m_stack_mode(nullptr),
m_pBox_Tables(nullptr),
@@ -107,7 +107,7 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
//QuickFind widgets:
//We don't use Glade for these, so it easier to modify them for the Maemo port.
- m_pBox_QuickFind = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, UiUtils::DEFAULT_SPACING_SMALL));
+ m_pBox_QuickFind = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL,
static_cast<int>(UiUtils::DefaultSpacings::SMALL)));
Gtk::Label* label = Gtk::manage(new Gtk::Label(_("Quick _search:"), true));
m_pBox_QuickFind->pack_start(*label, Gtk::PACK_SHRINK);
@@ -154,8 +154,8 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
m_Notebook_Data.set_enable_layout_drag_and_drop(false);
}
- m_Mode = MODE_None;
- m_Mode_Previous = MODE_None;
+ m_Mode = enumModes::NONE;
+ m_Mode_Previous = enumModes::NONE;
m_Notebook_Find.signal_find_criteria.connect(sigc::mem_fun(*this, &Frame_Glom::on_notebook_find_criteria));
@@ -171,7 +171,7 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
add_view(&m_Notebook_Data); //Also a composite view.
add_view(&m_Notebook_Find); //Also a composite view.
- on_userlevel_changed(AppState::USERLEVEL_OPERATOR); //A default to show before a document is created or
loaded.
+ on_userlevel_changed(AppState::userlevels::OPERATOR); //A default to show before a document is created or
loaded.
}
Frame_Glom::~Frame_Glom()
@@ -274,14 +274,14 @@ bool Frame_Glom::set_mode(enumModes mode)
const bool changed = (m_Mode != mode);
//Choose a default mode, if necessary:
- if(mode == MODE_None)
- mode = MODE_Data;
+ if(mode == enumModes::NONE)
+ mode = enumModes::DATA;
m_Mode_Previous = m_Mode;
m_Mode = mode;
//Hide the Quick Find widgets if we are not in Find mode.
- const bool show_quickfind = (m_Mode == MODE_Find);
+ const bool show_quickfind = (m_Mode == enumModes::FIND);
if(show_quickfind)
{
m_pBox_QuickFind->show();
@@ -302,7 +302,7 @@ bool Frame_Glom::set_mode(enumModes mode)
//Show the main part of the UI:
- if(m_Mode == MODE_Find)
+ if(m_Mode == enumModes::FIND)
set_mode_widget(m_Notebook_Find);
else
set_mode_widget(m_Notebook_Data);
@@ -335,7 +335,7 @@ void Frame_Glom::show_table_allow_empty(const Glib::ustring& table_name, const G
BusyCursor busy_cursor(pApp);
//Choose a default mode, if necessary:
- if(m_Mode == MODE_None)
+ if(m_Mode == enumModes::NONE)
set_mode(m_Mode);
//Show the table:
@@ -354,7 +354,7 @@ void Frame_Glom::show_table_allow_empty(const Glib::ustring& table_name, const G
switch(m_Mode)
{
- case(MODE_Data):
+ case(enumModes::DATA):
{
FoundSet found_set;
@@ -409,7 +409,7 @@ void Frame_Glom::show_table_allow_empty(const Glib::ustring& table_name, const G
break;
}
- case(MODE_Find):
+ case(enumModes::FIND):
{
m_Notebook_Find.init_db_details(m_table_name, get_active_layout_platform(get_document()));
set_mode_widget(m_Notebook_Find);
@@ -476,10 +476,10 @@ bool Frame_Glom::attempt_change_usermode_to_developer()
{
std::cout << "DEBUG: User=" << connection_pool->get_user() << " _is_ in the developer group on the
server." << std::endl;
//Avoid double signals:
- //if(document->get_userlevel() != AppState::USERLEVEL_DEVELOPER)
- test = document->set_userlevel(AppState::USERLEVEL_DEVELOPER);
+ //if(document->get_userlevel() != AppState::userlevels::DEVELOPER)
+ test = document->set_userlevel(AppState::userlevels::DEVELOPER);
if(!test)
- std::cout << " DEBUG: But document->set_userlevel(AppState::USERLEVEL_DEVELOPER) failed." <<
std::endl;
+ std::cout << " DEBUG: But document->set_userlevel(AppState::userlevels::DEVELOPER) failed." <<
std::endl;
}
else
{
@@ -525,7 +525,7 @@ bool Frame_Glom::attempt_change_usermode_to_operator()
if(!document)
return false;
- document->set_userlevel(AppState::USERLEVEL_OPERATOR);
+ document->set_userlevel(AppState::userlevels::OPERATOR);
return true;
}
@@ -618,13 +618,13 @@ void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector,
const auto value = result->get_value_at(col_index, row_index);
std::shared_ptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
- //if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
+ //if(layout_item->m_field.get_glom_type() != Field::glom_field_type::IMAGE) //This is too much
data.
//{
//Output data in canonical SQL format, ignoring the user's locale, and ignoring the layout
formatting:
row_data.push_back(value); //TODO_Performance: reserve the size.
- //if(layout_item->m_field.get_glom_type() == Field::TYPE_IMAGE) //This is too much data.
+ //if(layout_item->m_field.get_glom_type() == Field::glom_field_type::IMAGE) //This is too much
data.
//{
//std::cout << " field name=" << layout_item->get_name() << ", value=" <<
layout_item->m_field.sql(value) << std::endl;
//}
@@ -668,7 +668,7 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
const auto value = result->get_value_at(col_index, row_index);
std::shared_ptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
- //if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
+ //if(layout_item->m_field.get_glom_type() != Field::glom_field_type::IMAGE) //This is too much
data.
//{
if(!row_string.empty())
row_string += ",";
@@ -683,7 +683,7 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
const auto field_text = field->to_file_format(value);
- if(layout_item->get_glom_type() == Field::TYPE_IMAGE) //This is too much data.
+ if(layout_item->get_glom_type() == Field::glom_field_type::IMAGE) //This is too much data.
{
// Some extra debug checks,
// though we believe that all these problems are now fixed in File::to_file_format():
@@ -705,7 +705,7 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
}
}
- if(layout_item->get_glom_type() == Field::TYPE_TEXT)
+ if(layout_item->get_glom_type() == Field::glom_field_type::TEXT)
{
//The CSV RFC says text may be quoted and should be if it has newlines:
//TODO: Escape the text?
@@ -801,7 +801,7 @@ bool Frame_Glom::attempt_toggle_shared(bool shared)
//Prevent this change if not in developer mode,
//though the menu item should be disabled then anyway.
Document* document = dynamic_cast<Document*>(get_document());
- if(!document || document->get_userlevel() != AppState::USERLEVEL_DEVELOPER)
+ if(!document || document->get_userlevel() != AppState::userlevels::DEVELOPER)
return false;
if(shared == document->get_network_shared())
@@ -984,7 +984,7 @@ bool Frame_Glom::attempt_toggle_shared(bool shared)
connectionpool->set_network_shared(sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress),
shared);
const ConnectionPool::StartupErrors started =
connectionpool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
- if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
+ if(started != ConnectionPool::Backend::StartupErrors::NONE)
{
//TODO: Output more exact details of the error message.
//TODO: Recover somehow?
@@ -1033,17 +1033,17 @@ void Frame_Glom::set_mode_find()
//It shouldn't, but until we fix that, let's show the busy cursor while it's working:
BusyCursor busy_cursor(get_app_window());
- const bool previously_in_data_mode = (m_Mode == MODE_Data);
+ const bool previously_in_data_mode = (m_Mode == enumModes::DATA);
const auto 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(previously_in_data_mode && (list_or_details == Notebook_Data::dataview::DETAILS))
+ m_Notebook_Data.set_current_view(Notebook_Data::dataview::LIST);
- if(!set_mode(MODE_Find))
+ if(!set_mode(enumModes::FIND))
return;
show_table(m_table_name);
@@ -1058,7 +1058,7 @@ void Frame_Glom::set_mode_find()
void Frame_Glom::set_mode_data()
{
//Switch to data mode
- if(!set_mode(MODE_Data))
+ if(!set_mode(enumModes::DATA))
return;
//This would lose the current found set, if any:
@@ -1400,7 +1400,7 @@ void Frame_Glom::show_table_title()
Glib::ustring table_label = document->get_table_title(m_table_name, AppWindow::get_current_locale());
if(!table_label.empty())
{
- if(document->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(document->get_userlevel() == AppState::userlevels::DEVELOPER)
table_label += " (" + m_table_name + ")"; //Show the table name as well, if in developer mode.
}
else //Use the table name if there is no table title.
@@ -1575,7 +1575,7 @@ void Frame_Glom::do_menu_developer_fields(Gtk::Window& parent, const Glib::ustri
// be in use when changing the records, so we stop the database usage
// here. We reshow everything in on_developer_dialog_hide() anyway.
Document* document = dynamic_cast<Document*>(get_document());
- if(document && document->get_hosting_mode() == Document::HOSTING_MODE_SQLITE)
+ if(document && document->get_hosting_mode() == Document::HostingMode::SQLITE)
show_no_table();
// Remember the old table name so that we re-show the previous table as
@@ -1896,19 +1896,19 @@ bool Frame_Glom::handle_connection_initialize_errors(ConnectionPool::InitErrors
Glib::ustring title;
Glib::ustring message;
- if(error == ConnectionPool::Backend::INITERROR_NONE)
+ if(error == ConnectionPool::Backend::InitErrors::NONE)
return true;
- else if(error == ConnectionPool::Backend::INITERROR_DIRECTORY_ALREADY_EXISTS)
+ else if(error == ConnectionPool::Backend::InitErrors::DIRECTORY_ALREADY_EXISTS)
{
title = _("Directory Already Exists");
message = _("There is an existing directory with the same name as the directory that should be created
for the new database files. You should specify a different filename to use a new directory instead.");
}
- else if(error == ConnectionPool::Backend::INITERROR_COULD_NOT_CREATE_DIRECTORY)
+ else if(error == ConnectionPool::Backend::InitErrors::COULD_NOT_CREATE_DIRECTORY)
{
title = _("Could Not Create Directory");
message = _("There was an error when attempting to create the directory for the new database files.");
}
- else if(error == ConnectionPool::Backend::INITERROR_COULD_NOT_START_SERVER)
+ else if(error == ConnectionPool::Backend::InitErrors::COULD_NOT_START_SERVER)
{
title = _("Could Not Start Database Server");
message = _("There was an error when attempting to start the database server.");
@@ -1931,7 +1931,7 @@ bool Frame_Glom::connection_request_initial_password(Glib::ustring& user, Glib::
return false;
//This is only useful for self-hosted postgres:
- if(document->get_hosting_mode() != Document::HOSTING_MODE_POSTGRES_SELF)
+ if(document->get_hosting_mode() != Document::HostingMode::POSTGRES_SELF)
return false;
//Ask for a new username and password to specify when creating a new self-hosted database.
@@ -2000,8 +2000,8 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
const auto hosting_mode = document->get_hosting_mode();
switch(hosting_mode)
{
- case Document::HOSTING_MODE_POSTGRES_SELF:
- case Document::HOSTING_MODE_MYSQL_SELF:
+ case Document::HostingMode::POSTGRES_SELF:
+ case Document::HostingMode::MYSQL_SELF:
{
Glib::ustring user, password;
@@ -2040,8 +2040,8 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
break;
- case Document::HOSTING_MODE_POSTGRES_CENTRAL:
- case Document::HOSTING_MODE_MYSQL_CENTRAL:
+ case Document::HostingMode::POSTGRES_CENTRAL:
+ case Document::HostingMode::MYSQL_CENTRAL:
{
//Ask for connection details:
m_pDialogConnection->load_from_document(); //Get good defaults.
@@ -2073,7 +2073,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
break;
#ifdef GLOM_ENABLE_SQLITE
- case Document::HOSTING_MODE_SQLITE:
+ case Document::HostingMode::SQLITE:
{
// SQLite:
ConnectionPool::SlotProgress slot_ignored;
@@ -2095,7 +2095,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
ShowProgressMessage progress_message(_("Starting Database Server"));
const ConnectionPool::StartupErrors started =
connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
- if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
+ if(started != ConnectionPool::Backend::StartupErrors::NONE)
{
std::cerr << G_STRFUNC << ": startup() failed." << std::endl;
//TODO: Output more exact details of the error message.
@@ -2145,7 +2145,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
{
//std::cerr << G_STRFUNC << ": caught exception." << std::endl;
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_SERVER)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_SERVER)
{
//Warn the user, and let him try again:
UiUtils::show_ok_dialog(_("Connection Failed"), _("Glom could not connect to the database server.
Maybe you entered an incorrect user name or password, or maybe the postgres database server is not
running."), *(get_app_window()), Gtk::MESSAGE_ERROR); //TODO: Add help button.
@@ -2162,7 +2162,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
// Remember host and port if the document is not self hosted
#ifdef GLOM_ENABLE_POSTGRESQL
- if(document->get_hosting_mode() == Document::HOSTING_MODE_POSTGRES_CENTRAL)
+ if(document->get_hosting_mode() == Document::HostingMode::POSTGRES_CENTRAL)
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
ConnectionPoolBackends::PostgresCentralHosted* central =
dynamic_cast<ConnectionPoolBackends::PostgresCentralHosted*>(backend);
@@ -2179,7 +2179,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
// connect_to_server_with_connection_settings, which is just not
// executed because it failed with no database present. We should
// somehow avoid this code duplication.
- else if(document->get_hosting_mode() == Document::HOSTING_MODE_POSTGRES_SELF)
+ else if(document->get_hosting_mode() == Document::HostingMode::POSTGRES_SELF)
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
ConnectionPoolBackends::PostgresSelfHosted* self =
dynamic_cast<ConnectionPoolBackends::PostgresSelfHosted*>(backend);
@@ -2216,13 +2216,13 @@ bool Frame_Glom::handle_request_password_connection_error(bool asked_for_passwor
//Initialize input parameter:
database_not_found = false;
- if(asked_for_password && ex.get_failure_type() == ExceptionConnection::FAILURE_NO_SERVER)
+ if(asked_for_password && ex.get_failure_type() == ExceptionConnection::failure_type::NO_SERVER)
{
//Warn the user, and let him try again:
UiUtils::show_ok_dialog(_("Connection Failed"), _("Glom could not connect to the database server. Maybe
you entered an incorrect user name or password, or maybe the postgres database server is not running."),
*(get_app_window()), Gtk::MESSAGE_ERROR); //TODO: Add help button.
return true;
}
- else if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_DATABASE)
+ else if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_DATABASE)
{
cleanup_connection();
@@ -2255,7 +2255,7 @@ bool Frame_Glom::connection_request_password_and_attempt(bool& database_not_foun
connection_pool->setup_from_document(document);
const ConnectionPool::StartupErrors started =
connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
- if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
+ if(started != ConnectionPool::Backend::StartupErrors::NONE)
{
std::cerr << G_STRFUNC << ": startup() failed." << std::endl;
return false;
@@ -2274,7 +2274,7 @@ bool Frame_Glom::connection_request_password_and_attempt(bool& database_not_foun
//Only ask for the password if we are shared on the network, or we are using a centrally hosted server.
//Otherwise, no password question is necessary, due to how our self-hosted database server is configured.
if(document->get_network_shared()
- || document->get_hosting_mode() == Document::HOSTING_MODE_POSTGRES_CENTRAL)
+ || document->get_hosting_mode() == Document::HostingMode::POSTGRES_CENTRAL)
{
//We recreate the dialog each time to make sure it is clean of any changes:
delete m_pDialogConnection;
@@ -2519,7 +2519,7 @@ void Frame_Glom::on_dialog_tables_hide()
// This is never true in client only mode, so we can as well save the
// code size.
#ifndef GLOM_ENABLE_CLIENT_ONLY
- if(document->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(document->get_userlevel() == AppState::userlevels::DEVELOPER)
{
AppWindow* pApp = dynamic_cast<AppWindow*>(get_app_window());
if(pApp)
diff --git a/glom/frame_glom.h b/glom/frame_glom.h
index 131017c..6019c4b 100644
--- a/glom/frame_glom.h
+++ b/glom/frame_glom.h
@@ -140,11 +140,11 @@ public:
virtual void set_document(Document* pDocument) override; //View override
virtual void load_from_document() override; //View override
- enum enumModes
+ enum class enumModes
{
- MODE_None, //at the start.
- MODE_Data,
- MODE_Find
+ NONE, //at the start.
+ DATA,
+ FIND
};
enumModes m_Mode;
enumModes m_Mode_Previous; // see comments in set_mode_widget().
diff --git a/glom/glom_create_from_example.cc b/glom/glom_create_from_example.cc
index d19cd87..b7ed492 100644
--- a/glom/glom_create_from_example.cc
+++ b/glom/glom_create_from_example.cc
@@ -411,11 +411,11 @@ int main(int argc, char* argv[])
#if GLOM_ENABLE_MYSQL
if(group.m_arg_use_mysql)
- document.set_hosting_mode(Glom::Document::HOSTING_MODE_MYSQL_SELF);
+ document.set_hosting_mode(Glom::Document::HostingMode::MYSQL_SELF);
else
#endif //GLOM_ENABLE_MYSQL
{
- document.set_hosting_mode(Glom::Document::HOSTING_MODE_POSTGRES_SELF);
+ document.set_hosting_mode(Glom::Document::HostingMode::POSTGRES_SELF);
}
}
else
@@ -424,11 +424,11 @@ int main(int argc, char* argv[])
#if GLOM_ENABLE_MYSQL
if(group.m_arg_use_mysql)
- document.set_hosting_mode(Glom::Document::HOSTING_MODE_MYSQL_CENTRAL);
+ document.set_hosting_mode(Glom::Document::HostingMode::MYSQL_CENTRAL);
else
#endif //GLOM_ENABLE_MYSQL
{
- document.set_hosting_mode(Glom::Document::HOSTING_MODE_POSTGRES_CENTRAL);
+ document.set_hosting_mode(Glom::Document::HostingMode::POSTGRES_CENTRAL);
}
}
@@ -499,17 +499,17 @@ int main(int argc, char* argv[])
//Startup. For instance, create the self-hosting files if necessary:
const Glom::ConnectionPool::InitErrors initialized_errors =
connection_pool->initialize( sigc::ptr_fun(&on_initialize_progress) );
- g_assert(initialized_errors == Glom::ConnectionPool::Backend::INITERROR_NONE);
+ g_assert(initialized_errors == Glom::ConnectionPool::Backend::InitErrors::NONE);
//Start self-hosting:
//TODO: Let this happen automatically on first connection?
const auto started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
- if(started != Glom::ConnectionPool::Backend::STARTUPERROR_NONE)
+ if(started != Glom::ConnectionPool::Backend::StartupErrors::NONE)
{
- std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << started << std::endl;
+ std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << static_cast<int>(started) <<
std::endl;
cleanup();
}
- g_assert(started == Glom::ConnectionPool::Backend::STARTUPERROR_NONE);
+ g_assert(started == Glom::ConnectionPool::Backend::StartupErrors::NONE);
const auto recreated = Glom::DbUtils::recreate_database_from_document(&document, &on_recreate_progress);
if(!recreated)
diff --git a/glom/glom_test_connection.cc b/glom/glom_test_connection.cc
index e3aa8bb..ff3618b 100644
--- a/glom/glom_test_connection.cc
+++ b/glom/glom_test_connection.cc
@@ -259,12 +259,12 @@ int main(int argc, char* argv[])
}
catch(const Glom::ExceptionConnection& ex)
{
- if(ex.get_failure_type() == Glom::ExceptionConnection::FAILURE_NO_SERVER)
+ if(ex.get_failure_type() == Glom::ExceptionConnection::failure_type::NO_SERVER)
{
std::cerr << _("Error: Could not connect to the server even without specifying a database.") <<
std::endl;
return EXIT_FAILURE;
}
- else if(ex.get_failure_type() == Glom::ExceptionConnection::FAILURE_NO_DATABASE)
+ else if(ex.get_failure_type() == Glom::ExceptionConnection::failure_type::NO_DATABASE)
{
//We expect this exception if we did not specify a database:
if(!(group.m_arg_server_database.empty()))
diff --git a/glom/import_csv/csv_parser.cc b/glom/import_csv/csv_parser.cc
index ee72425..6dbc0b1 100644
--- a/glom/import_csv/csv_parser.cc
+++ b/glom/import_csv/csv_parser.cc
@@ -59,7 +59,7 @@ CsvParser::CsvParser(const std::string& encoding_charset)
m_input_position(0),
m_in_quotes(false),
m_line_number(0),
- m_state(STATE_NONE),
+ m_state(State::NONE),
m_row_index(0)
{
}
@@ -71,7 +71,7 @@ void CsvParser::set_file_and_start_parsing(const std::string& file_uri)
auto file = Gio::File::create_for_uri(file_uri);
- set_state(CsvParser::STATE_PARSING);
+ set_state(CsvParser::State::PARSING);
//TODO Get a rough estimate of the number of rows (for showing progress),
//by counting the number of lines:
@@ -129,17 +129,18 @@ const CsvParser::type_row_strings CsvParser::fetch_next_row()
{
const type_row_strings empty;
- g_return_val_if_fail(m_state == (CsvParser::STATE_PARSING | CsvParser::STATE_PARSED), empty);
+ g_return_val_if_fail(m_state == CsvParser::State::PARSING, empty);
+ g_return_val_if_fail(m_state == CsvParser::State::PARSED, empty);
// We cannot fetch the next row, but since we are still parsing we might just have to parse a bit more!
- if(m_state == CsvParser::STATE_PARSING && m_row_index >= m_rows.size())
+ if(m_state == CsvParser::State::PARSING && m_row_index >= m_rows.size())
{
on_idle_parse();
- // The final recursion guard is m_state == CsvParser::STATE_PARSING
+ // The final recursion guard is m_state == CsvParser::State::PARSING
return fetch_next_row();
}
- if(m_state == CsvParser::STATE_PARSED && m_row_index >= m_rows.size())
+ if(m_state == CsvParser::State::PARSED && m_row_index >= m_rows.size())
{
return empty;
}
@@ -197,7 +198,7 @@ void CsvParser::set_encoding(const Glib::ustring& encoding_charset)
//Stop parsing if the encoding changes.
//The caller should restart the parsing when wanted.
clear();
- set_state(STATE_NONE);
+ set_state(State::NONE);
}
// Parse the field in a comma-separated line, returning the field including the quotes:
@@ -275,7 +276,7 @@ void CsvParser::clear()
// Disconnect signal handlers, too.
m_idle_connection.disconnect();
m_line_number = 0;
- set_state(STATE_NONE);
+ set_state(State::NONE);
}
bool CsvParser::on_idle_parse()
@@ -303,7 +304,7 @@ bool CsvParser::on_idle_parse()
if(errno == EILSEQ)
{
// Invalid text in the current encoding.
- set_state(STATE_ENCODING_ERROR);
+ set_state(State::ENCODING_ERROR);
signal_encoding_error().emit();
return false; //Stop calling the idle handler.
}
@@ -317,7 +318,7 @@ bool CsvParser::on_idle_parse()
{
// This means that we already reached the end of the file. The file
// should not end with an incomplete multibyte sequence.
- set_state(STATE_ENCODING_ERROR);
+ set_state(State::ENCODING_ERROR);
signal_encoding_error().emit();
return false; //Stop calling the idle handler.
}
@@ -370,7 +371,7 @@ bool CsvParser::on_idle_parse()
// file from ISO-8859-1 to UTF-8 (note that the UTF-16 file is valid ISO-8859-1 -
// it just contains lots of nullbytes). We therefore produce an error here.
//std::cerr << G_STRFUNC << ": on_idle_parse(): Encoding error" << std::endl;
- set_state(STATE_ENCODING_ERROR);
+ set_state(State::ENCODING_ERROR);
signal_encoding_error().emit();
return false; //Stop calling the idle handler.
}
@@ -449,7 +450,7 @@ bool CsvParser::on_idle_parse()
// We have parsed the whole file. We have finished.
// TODO: To only emit signal_finished_parsing here is *not* enough.
- set_state(STATE_PARSED);
+ set_state(State::PARSED);
signal_finished_parsing().emit();
}
else
diff --git a/glom/import_csv/csv_parser.h b/glom/import_csv/csv_parser.h
index 5dd55c7..f662c0e 100644
--- a/glom/import_csv/csv_parser.h
+++ b/glom/import_csv/csv_parser.h
@@ -63,11 +63,11 @@ public:
~CsvParser();
- enum State {
- STATE_NONE,
- STATE_PARSING, /**< Parsing is in progress. */
- STATE_ENCODING_ERROR, /**< An error happened while parsing. */
- STATE_PARSED /**< Finished parsing. */
+ enum class State {
+ NONE,
+ PARSING, /**< Parsing is in progress. */
+ ENCODING_ERROR, /**< An error happened while parsing. */
+ PARSED /**< Finished parsing. */
};
/// Get the current state of the parser.
diff --git a/glom/import_csv/dialog_import_csv.cc b/glom/import_csv/dialog_import_csv.cc
index 64c10f8..f90a8ce 100644
--- a/glom/import_csv/dialog_import_csv.cc
+++ b/glom/import_csv/dialog_import_csv.cc
@@ -592,7 +592,7 @@ void Dialog_Import_CSV::field_data_func(Gtk::CellRenderer* renderer, const Gtk::
if(field)
{
- if(field->get_glom_type() != Field::TYPE_IMAGE)
+ if(field->get_glom_type() != Field::glom_field_type::IMAGE)
{
/* Exported data is always stored in postgres format */
bool success = false;
@@ -676,7 +676,8 @@ void Dialog_Import_CSV::on_field_edited(const Glib::ustring& path, const Glib::u
void Dialog_Import_CSV::validate_primary_key()
{
- if(get_parser_state() == (CsvParser::STATE_NONE | CsvParser::STATE_ENCODING_ERROR))
+ if(get_parser_state() == CsvParser::State::NONE
+ || get_parser_state() == CsvParser::State::ENCODING_ERROR)
{
m_error_label->hide();
set_response_sensitive(Gtk::RESPONSE_ACCEPT, false);
diff --git a/glom/import_csv/dialog_import_csv_progress.cc b/glom/import_csv/dialog_import_csv_progress.cc
index ccbe6a6..947bec0 100644
--- a/glom/import_csv/dialog_import_csv_progress.cc
+++ b/glom/import_csv/dialog_import_csv_progress.cc
@@ -68,7 +68,7 @@ void Dialog_Import_CSV_Progress::import(Dialog_Import_CSV& data_source)
switch(data_source.get_parser_state())
{
- case CsvParser::STATE_PARSING:
+ case CsvParser::State::PARSING:
{
// Wait for the parsing to finish. We do not start importing before the file has been
// parsed completely since we would not to rollback our changes in case of a
@@ -88,7 +88,7 @@ void Dialog_Import_CSV_Progress::import(Dialog_Import_CSV& data_source)
m_ready_connection = data_source.signal_state_changed().connect(sigc::mem_fun(*this,
&Dialog_Import_CSV_Progress::on_data_source_state_changed));
break;
}
- case CsvParser::STATE_PARSED:
+ case CsvParser::State::PARSED:
begin_import();
break;
default:
@@ -129,11 +129,11 @@ void Dialog_Import_CSV_Progress::on_data_source_state_changed()
{
switch(m_data_source->get_parser_state())
{
- case CsvParser::STATE_ENCODING_ERROR:
+ case CsvParser::State::ENCODING_ERROR:
// Cancel on error
response(Gtk::RESPONSE_CANCEL);
break;
- case CsvParser::STATE_PARSED:
+ case CsvParser::State::PARSED:
// Begin importing when fully parsed
begin_import();
//m_progress_connection = Glib::signal_idle().connect(sigc::mem_fun(*this,
&Dialog_Import_CSV_Progress::on_idle_import));
diff --git a/glom/libglom/appstate.cc b/glom/libglom/appstate.cc
index c11bcca..bae52f8 100644
--- a/glom/libglom/appstate.cc
+++ b/glom/libglom/appstate.cc
@@ -26,7 +26,7 @@ namespace Glom
{
AppState::AppState()
-: m_userlevel(USERLEVEL_DEVELOPER)
+: m_userlevel(userlevels::DEVELOPER)
{
}
diff --git a/glom/libglom/appstate.h b/glom/libglom/appstate.h
index 7fec3b5..299ca10 100644
--- a/glom/libglom/appstate.h
+++ b/glom/libglom/appstate.h
@@ -36,10 +36,10 @@ public:
AppState();
virtual ~AppState();
- enum userlevels
+ enum class userlevels
{
- USERLEVEL_OPERATOR,
- USERLEVEL_DEVELOPER
+ OPERATOR,
+ DEVELOPER
};
/** Returns whether we are in developer mode.
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 085df51..e6bfc90 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -143,14 +143,14 @@ void ConnectionPool::setup_from_document(const Document* document)
{
switch(document->get_hosting_mode())
{
- case Document::HOSTING_MODE_POSTGRES_SELF:
+ case Document::HostingMode::POSTGRES_SELF:
{
ConnectionPoolBackends::PostgresSelfHosted* backend = new ConnectionPoolBackends::PostgresSelfHosted;
backend->set_database_directory_uri(document->get_connection_self_hosted_directory_uri());
set_backend(std::shared_ptr<ConnectionPool::Backend>(backend));
}
break;
- case Document::HOSTING_MODE_POSTGRES_CENTRAL:
+ case Document::HostingMode::POSTGRES_CENTRAL:
{
ConnectionPoolBackends::PostgresCentralHosted* backend = new
ConnectionPoolBackends::PostgresCentralHosted;
backend->set_host(document->get_connection_server());
@@ -159,21 +159,21 @@ void ConnectionPool::setup_from_document(const Document* document)
set_backend(std::shared_ptr<ConnectionPool::Backend>(backend));
}
break;
- case Document::HOSTING_MODE_SQLITE:
+ case Document::HostingMode::SQLITE:
{
ConnectionPoolBackends::Sqlite* backend = new ConnectionPoolBackends::Sqlite;
backend->set_database_directory_uri(document->get_connection_self_hosted_directory_uri());
set_backend(std::shared_ptr<ConnectionPool::Backend>(backend));
}
break;
- case Document::HOSTING_MODE_MYSQL_SELF:
+ case Document::HostingMode::MYSQL_SELF:
{
ConnectionPoolBackends::MySQLSelfHosted* backend = new ConnectionPoolBackends::MySQLSelfHosted;
backend->set_database_directory_uri(document->get_connection_self_hosted_directory_uri());
set_backend(std::shared_ptr<ConnectionPool::Backend>(backend));
}
break;
- case Document::HOSTING_MODE_MYSQL_CENTRAL:
+ case Document::HostingMode::MYSQL_CENTRAL:
{
ConnectionPoolBackends::MySQLCentralHosted* backend = new ConnectionPoolBackends::MySQLCentralHosted;
backend->set_host(document->get_connection_server());
@@ -185,7 +185,7 @@ void ConnectionPool::setup_from_document(const Document* document)
default:
//on_document_load() should have checked for this already, informing the user.
- std::cerr << G_STRFUNC << ": Unhandled hosting mode: " << document->get_hosting_mode() << std::endl;
+ std::cerr << G_STRFUNC << ": Unhandled hosting mode: " << static_cast<int>(document->get_hosting_mode())
<< std::endl;
g_assert_not_reached();
break;
}
@@ -248,7 +248,7 @@ std::shared_ptr<SharedConnection> ConnectionPool::get_and_connect()
if(!(connection_pool->m_backend.get()))
{
std::cerr << G_STRFUNC << ": m_backend is null." << std::endl;
- return result; //TODO: Return a FAILURE_NO_BACKEND error?, though that would be tedious.
+ return result; //TODO: Return a failure_type::NO_BACKEND error?, though that would be tedious.
}
result = connection_pool->connect();
@@ -631,10 +631,10 @@ static void on_linux_signal(int signum)
ConnectionPool::StartupErrors ConnectionPool::startup(const SlotProgress& slot_progress, bool network_shared)
{
if(!m_backend.get())
- return Backend::STARTUPERROR_FAILED_UNKNOWN_REASON;
+ return Backend::StartupErrors::FAILED_UNKNOWN_REASON;
const auto started = m_backend->startup(slot_progress, network_shared);
- if(started != Backend::STARTUPERROR_NONE)
+ if(started != Backend::StartupErrors::NONE)
return started;
#ifndef G_OS_WIN32
@@ -810,7 +810,7 @@ ConnectionPool::InitErrors ConnectionPool::initialize(const SlotProgress& slot_p
if(m_backend.get())
return m_backend->initialize(slot_progress, get_user(), get_password(), network_shared);
else
- return Backend::INITERROR_OTHER;
+ return Backend::InitErrors::OTHER;
}
Document* ConnectionPool::get_document()
diff --git a/glom/libglom/connectionpool_backends/backend.cc b/glom/libglom/connectionpool_backends/backend.cc
index 21cf37f..ebef9d4 100644
--- a/glom/libglom/connectionpool_backends/backend.cc
+++ b/glom/libglom/connectionpool_backends/backend.cc
@@ -47,12 +47,12 @@ namespace ConnectionPoolBackends
Backend::InitErrors Backend::initialize(const SlotProgress& /* slot_progress */, const Glib::ustring& /*
initial_username */, const Glib::ustring& /* password */, bool /* network_shared */)
{
- return INITERROR_NONE;
+ return InitErrors::NONE;
}
Backend::StartupErrors Backend::startup(const SlotProgress& /* slot_progress */, bool /* network_shared */)
{
- return STARTUPERROR_NONE;
+ return StartupErrors::NONE;
}
bool Backend::cleanup(const SlotProgress& /* slot_progress */)
diff --git a/glom/libglom/connectionpool_backends/backend.h b/glom/libglom/connectionpool_backends/backend.h
index da26337..356e9a6 100644
--- a/glom/libglom/connectionpool_backends/backend.h
+++ b/glom/libglom/connectionpool_backends/backend.h
@@ -37,11 +37,11 @@ class ConnectionPool;
class ExceptionConnection : public std::exception
{
public:
- enum failure_type
+ enum class failure_type
{
- FAILURE_NO_SERVER, //Either there was no attempt to connect to a specific database, or the connection
failed both with and without specifying the database.
- FAILURE_NO_DATABASE, //Connection without specifying the database was possible.
- FAILURE_NO_BACKEND //No backend instance available. Should never happen.
+ NO_SERVER, //Either there was no attempt to connect to a specific database, or the connection failed
both with and without specifying the database.
+ NO_DATABASE, //Connection without specifying the database was possible.
+ NO_BACKEND //No backend instance available. Should never happen.
};
ExceptionConnection(failure_type failure);
@@ -69,23 +69,23 @@ public:
virtual ~Backend() {}
typedef std::vector<std::shared_ptr<const Field> > type_vec_const_fields;
- enum InitErrors
+ enum class InitErrors
{
- INITERROR_NONE,
- INITERROR_DIRECTORY_ALREADY_EXISTS,
- INITERROR_COULD_NOT_CREATE_DIRECTORY,
- INITERROR_COULD_NOT_START_SERVER,
- INITERROR_OTHER
+ NONE,
+ DIRECTORY_ALREADY_EXISTS,
+ COULD_NOT_CREATE_DIRECTORY,
+ COULD_NOT_START_SERVER,
+ OTHER
};
- enum StartupErrors
+ enum class StartupErrors
{
- STARTUPERROR_NONE, /*< The database is ready for use. */
- STARTUPERROR_FAILED_NO_DATA, /*< There is no data for the database. */
- STARTUPERROR_FAILED_NO_DATA_HAS_BACKUP_DATA, /*< There is no data for the database, but there is a
backup file instead. */
- STARTUPERROR_FAILED_NO_MAIN_DIRECTORY, /*< The main directory (containing data and config directories)
could not be found. */
- STARTUPERROR_FAILED_NO_PORT_AVAILABLE, /*< There was no network port available in the normal range of
ports. */
- STARTUPERROR_FAILED_UNKNOWN_REASON /*< Something else failed. */
+ NONE, /*< The database is ready for use. */
+ FAILED_NO_DATA, /*< There is no data for the database. */
+ FAILED_NO_DATA_HAS_BACKUP_DATA, /*< There is no data for the database, but there is a backup file
instead. */
+ FAILED_NO_MAIN_DIRECTORY, /*< The main directory (containing data and config directories) could not be
found. */
+ FAILED_NO_PORT_AVAILABLE, /*< There was no network port available in the normal range of ports. */
+ FAILED_UNKNOWN_REASON /*< Something else failed. */
};
protected:
diff --git a/glom/libglom/connectionpool_backends/mysql.cc b/glom/libglom/connectionpool_backends/mysql.cc
index 2372355..6e8b1ac 100644
--- a/glom/libglom/connectionpool_backends/mysql.cc
+++ b/glom/libglom/connectionpool_backends/mysql.cc
@@ -147,7 +147,7 @@ Glib::RefPtr<Gnome::Gda::Connection> MySQL::attempt_connect(const Glib::ustring&
std::cerr << G_STRFUNC << ": (Could not connect even to the default database, database=" << database
<< std::endl;
#endif
- throw ExceptionConnection(temp_conn ? ExceptionConnection::FAILURE_NO_DATABASE :
ExceptionConnection::FAILURE_NO_SERVER);
+ throw ExceptionConnection(temp_conn ? ExceptionConnection::failure_type::NO_DATABASE :
ExceptionConnection::failure_type::NO_SERVER);
}
if(data_model && data_model->get_n_rows() && data_model->get_n_columns())
@@ -230,24 +230,24 @@ bool MySQL::change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connectio
switch(new_fields[i]->get_glom_type())
{
- case Field::TYPE_BOOLEAN:
+ case Field::glom_field_type::BOOLEAN:
{
- if(old_field_type == Field::TYPE_NUMERIC)
+ if(old_field_type == Field::glom_field_type::NUMERIC)
{
conversion_command = "(CASE WHEN " + field_name_old_quoted + " > 0 THEN true "
"WHEN " + field_name_old_quoted + " = 0 THEN false "
"WHEN " + field_name_old_quoted + " IS NULL THEN false
END)";
}
- else if(old_field_type == Field::TYPE_TEXT)
+ else if(old_field_type == Field::glom_field_type::TEXT)
conversion_command = '(' + field_name_old_quoted + " !~~* \'false\')"; // !~~*
means ! ILIKE
else // Dates and Times:
conversion_command = '(' + field_name_old_quoted + " IS NOT NULL)";
break;
}
- case Field::TYPE_NUMERIC: // CAST does not work if the destination type is numeric
+ case Field::glom_field_type::NUMERIC: // CAST does not work if the destination type
is numeric
{
- if(old_field_type == Field::TYPE_BOOLEAN)
+ if(old_field_type == Field::glom_field_type::BOOLEAN)
{
conversion_command = "(CASE WHEN " + field_name_old_quoted + " = true THEN 1 "
"WHEN " + field_name_old_quoted + " = false THEN 0 "
@@ -266,12 +266,12 @@ bool MySQL::change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connectio
break;
}
- case Field::TYPE_DATE: // CAST does not work if the destination type is date.
+ case Field::glom_field_type::DATE: // CAST does not work if the destination type is
date.
{
conversion_command = "to_date( " + field_name_old_quoted + ", 'YYYYMMDD' )"; //
TODO: Standardise date storage format.
break;
}
- case Field::TYPE_TIME: // CAST does not work if the destination type is timestamp.
+ case Field::glom_field_type::TIME: // CAST does not work if the destination type is
timestamp.
{
conversion_command = "to_timestamp( " + field_name_old_quoted + ", 'HHMMSS' )"; //
TODO: Standardise time storage format.
break;
@@ -282,7 +282,7 @@ bool MySQL::change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connectio
// To Text:
// bool to text:
- if(old_field_type == Field::TYPE_BOOLEAN)
+ if(old_field_type == Field::glom_field_type::BOOLEAN)
{
conversion_command = "(CASE WHEN " + field_name_old_quoted + " = true THEN
\'true\' "
"WHEN " + field_name_old_quoted + " = false THEN
\'false\' "
diff --git a/glom/libglom/connectionpool_backends/mysql_central.cc
b/glom/libglom/connectionpool_backends/mysql_central.cc
index 505c2ca..91da15b 100644
--- a/glom/libglom/connectionpool_backends/mysql_central.cc
+++ b/glom/libglom/connectionpool_backends/mysql_central.cc
@@ -104,7 +104,7 @@ Glib::RefPtr<Gnome::Gda::Connection> MySQLCentralHosted::connect(const Glib::ust
{
// Remember port if only the database was missing
connection_possible = false;
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_DATABASE)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_DATABASE)
{
connection_possible = true;
m_port = atoi(port.c_str());
@@ -130,7 +130,7 @@ Glib::RefPtr<Gnome::Gda::Connection> MySQLCentralHosted::connect(const Glib::ust
//show that a connection was possible with a previously-tried port: connection_possible = false;
// Remember port if only the database was missing
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_DATABASE)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_DATABASE)
{
connection_possible = true;
m_port = atoi(port.c_str());
@@ -151,9 +151,9 @@ Glib::RefPtr<Gnome::Gda::Connection> MySQLCentralHosted::connect(const Glib::ust
else
{
if(connection_possible)
- throw ExceptionConnection(ExceptionConnection::FAILURE_NO_DATABASE);
+ throw ExceptionConnection(ExceptionConnection::failure_type::NO_DATABASE);
else
- throw ExceptionConnection(ExceptionConnection::FAILURE_NO_SERVER);
+ throw ExceptionConnection(ExceptionConnection::failure_type::NO_SERVER);
}
return connection;
diff --git a/glom/libglom/connectionpool_backends/mysql_self.cc
b/glom/libglom/connectionpool_backends/mysql_self.cc
index 5741304..c9ca163 100644
--- a/glom/libglom/connectionpool_backends/mysql_self.cc
+++ b/glom/libglom/connectionpool_backends/mysql_self.cc
@@ -130,13 +130,13 @@ Backend::InitErrors MySQLSelfHosted::initialize(const SlotProgress& slot_progres
if(m_database_directory_uri.empty())
{
std::cerr << G_STRFUNC << ": initialize: m_self_hosting_data_uri is empty." << std::endl;
- return INITERROR_OTHER;
+ return InitErrors::OTHER;
}
if(initial_username.empty())
{
std::cerr << G_STRFUNC << ": MySQLSelfHosted::initialize(). Username was empty while attempting to
create self-hosting database" << std::endl;
- return INITERROR_OTHER;
+ return InitErrors::OTHER;
}
//Get the filepath of the directory that we should create:
@@ -144,7 +144,7 @@ Backend::InitErrors MySQLSelfHosted::initialize(const SlotProgress& slot_progres
//std::cout << "debug: dbdir_uri=" << dbdir_uri << std::endl;
if(file_exists_uri(dbdir_uri))
- return INITERROR_DIRECTORY_ALREADY_EXISTS;
+ return InitErrors::DIRECTORY_ALREADY_EXISTS;
const auto dbdir = Glib::filename_from_uri(dbdir_uri);
//std::cout << "debug: dbdir=" << dbdir << std::endl;
@@ -155,7 +155,7 @@ Backend::InitErrors MySQLSelfHosted::initialize(const SlotProgress& slot_progres
{
std::cerr << G_STRFUNC << ": Couldn't create directory: " << dbdir << std::endl;
- return INITERROR_COULD_NOT_CREATE_DIRECTORY;
+ return InitErrors::COULD_NOT_CREATE_DIRECTORY;
}
//Create these files: environment
@@ -167,7 +167,7 @@ Backend::InitErrors MySQLSelfHosted::initialize(const SlotProgress& slot_progres
{
std::cerr << G_STRFUNC << ": Couldn't create the data directory: " << dbdir << std::endl;
- return INITERROR_COULD_NOT_CREATE_DIRECTORY;
+ return InitErrors::COULD_NOT_CREATE_DIRECTORY;
}
// initdb creates a new mysql database cluster:
@@ -208,17 +208,17 @@ Backend::InitErrors MySQLSelfHosted::initialize(const SlotProgress& slot_progres
//TODO: This is inefficient, because the caller probably wants to start the server soon anyway,
//but that might be in a different instance of this backend,
//and we cannot take the risk of leaving the database with a default password.
- if(startup(slot_progress, false) != STARTUPERROR_NONE)
+ if(startup(slot_progress, false) != StartupErrors::NONE)
{
std::cerr << G_STRFUNC << ": Error while attempting to create self-hosting MySQL database, while
starting for the first time, to set the initial username and password." << std::endl;
- return INITERROR_OTHER;
+ return InitErrors::OTHER;
}
else
{
if(!cleanup(slot_progress))
{
std::cerr << G_STRFUNC << ": Error while attempting to create self-hosting MySQL database, while
shutting down, after setting the initial username and password." << std::endl;
- return INITERROR_OTHER;
+ return InitErrors::OTHER;
}
}
@@ -245,7 +245,7 @@ Backend::InitErrors MySQLSelfHosted::initialize(const SlotProgress& slot_progres
*/
}
- return result ? INITERROR_NONE : INITERROR_COULD_NOT_START_SERVER;
+ return result ? InitErrors::NONE : InitErrors::COULD_NOT_START_SERVER;
}
Glib::ustring MySQLSelfHosted::get_mysqlql_utils_version(const SlotProgress& /* slot_progress */)
@@ -297,7 +297,7 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
if(get_self_hosting_active())
{
std::cerr << G_STRFUNC << ": Already started." << std::endl;
- return STARTUPERROR_NONE; //Just do it once.
+ return StartupErrors::NONE; //Just do it once.
}
const auto dbdir_uri = m_database_directory_uri;
@@ -305,7 +305,7 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
if(!(file_exists_uri(dbdir_uri)))
{
std::cerr << G_STRFUNC << ": The data directory could not be found: " << dbdir_uri << std::endl;
- return STARTUPERROR_FAILED_NO_MAIN_DIRECTORY;
+ return StartupErrors::FAILED_NO_MAIN_DIRECTORY;
}
const auto dbdir = Glib::filename_from_uri(dbdir_uri);
@@ -321,12 +321,12 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
{
std::cerr << G_STRFUNC << ": There is no data, but there is backup data." << std::endl;
//Let the caller convert the backup to real data and then try again:
- return STARTUPERROR_FAILED_NO_DATA_HAS_BACKUP_DATA;
+ return StartupErrors::FAILED_NO_DATA_HAS_BACKUP_DATA;
}
else
{
std::cerr << G_STRFUNC << ": The data sub-directory could not be found." << dbdir_data_uri <<
std::endl;
- return STARTUPERROR_FAILED_NO_DATA;
+ return StartupErrors::FAILED_NO_DATA;
}
}
@@ -338,7 +338,7 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
if(available_port == 0)
{
std::cerr << G_STRFUNC << ": No port was available between " << PORT_MYSQL_SELF_HOSTED_START << " and "
<< PORT_MYSQL_SELF_HOSTED_END << std::endl;
- return STARTUPERROR_FAILED_NO_PORT_AVAILABLE;
+ return StartupErrors::FAILED_NO_PORT_AVAILABLE;
}
//TODO: Performance:
@@ -367,7 +367,7 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
m_port = 0;
std::cerr << G_STRFUNC << "Error while attempting to self-host a MySQL database." << std::endl;
- return STARTUPERROR_FAILED_UNKNOWN_REASON;
+ return StartupErrors::FAILED_UNKNOWN_REASON;
}
m_port = available_port; //Remember it for later.
@@ -378,7 +378,7 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
if(m_initial_password_to_set.empty()) {
//If this is empty then mysqladmin will ask for it on stdout, blocking us.
std::cerr << G_STRFUNC << "Error while attempting to self-host a MySQL database:
m_initial_password_to_set is empty." << std::endl;
- return STARTUPERROR_FAILED_UNKNOWN_REASON;
+ return StartupErrors::FAILED_UNKNOWN_REASON;
}
//Set the root password:
@@ -389,7 +389,7 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
if(!Glom::Spawn::execute_command_line_and_wait(command_initdb_set_initial_password, slot_progress))
{
std::cerr << G_STRFUNC << ": Error while attempting to start self-hosting MySQL database, when setting
the initial password." << std::endl;
- return STARTUPERROR_FAILED_UNKNOWN_REASON;
+ return StartupErrors::FAILED_UNKNOWN_REASON;
}
m_temporary_password_active = false;
@@ -402,7 +402,7 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
if(!gda_connection)
{
std::cerr << G_STRFUNC << "Error while attempting to start self-hosting MySQL database, when setting
the initial username: connection failed." << std::endl;
- return STARTUPERROR_FAILED_UNKNOWN_REASON;
+ return StartupErrors::FAILED_UNKNOWN_REASON;
}
m_saved_password = m_initial_password_to_set;
@@ -418,21 +418,21 @@ Backend::StartupErrors MySQLSelfHosted::startup(const SlotProgress& slot_progres
if(!test)
{
std::cerr << G_STRFUNC << "Error while attempting to start self-hosting MySQL database, when setting
the initial username: UPDATE failed." << std::endl;
- return STARTUPERROR_FAILED_UNKNOWN_REASON;
+ return StartupErrors::FAILED_UNKNOWN_REASON;
}
*/
}
catch(const Glib::Error& ex)
{
std::cerr << G_STRFUNC << "Error while attempting to start self-hosting MySQL database, when setting
the initial username: UPDATE failed: " << ex.what() << std::endl;
- return STARTUPERROR_FAILED_UNKNOWN_REASON;
+ return StartupErrors::FAILED_UNKNOWN_REASON;
}
}
m_saved_username = m_initial_username_to_set;
m_initial_username_to_set.clear();
- return STARTUPERROR_NONE;
+ return StartupErrors::NONE;
}
//TODO: Avoid copy/paste with PostgresSelfHosted:
@@ -589,7 +589,7 @@ Glib::RefPtr<Gnome::Gda::Connection> MySQLSelfHosted::connect(const Glib::ustrin
if(!get_self_hosting_active())
{
- throw ExceptionConnection(ExceptionConnection::FAILURE_NO_BACKEND); //TODO: But there is a backend. It's
just not ready.
+ throw ExceptionConnection(ExceptionConnection::failure_type::NO_BACKEND); //TODO: But there is a
backend. It's just not ready.
}
Glib::RefPtr<Gnome::Gda::Connection> result;
@@ -605,7 +605,7 @@ Glib::RefPtr<Gnome::Gda::Connection> MySQLSelfHosted::connect(const Glib::ustrin
}
catch(const ExceptionConnection& ex)
{
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_SERVER)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_SERVER)
{
//It must be using a default password, so any failure would not be due to a wrong password.
//However, pg_ctl sometimes reports success before it is really ready to let us connect,
diff --git a/glom/libglom/connectionpool_backends/postgres.cc
b/glom/libglom/connectionpool_backends/postgres.cc
index 463adbf..a77b0a8 100644
--- a/glom/libglom/connectionpool_backends/postgres.cc
+++ b/glom/libglom/connectionpool_backends/postgres.cc
@@ -134,7 +134,7 @@ Glib::RefPtr<Gnome::Gda::Connection> Postgres::attempt_connect(const Glib::ustri
std::cerr << G_STRFUNC << ": (Could not connect even to the default database, database=" << database
<< std::endl;
#endif
- throw ExceptionConnection(temp_conn ? ExceptionConnection::FAILURE_NO_DATABASE :
ExceptionConnection::FAILURE_NO_SERVER);
+ throw ExceptionConnection(temp_conn ? ExceptionConnection::failure_type::NO_DATABASE :
ExceptionConnection::failure_type::NO_SERVER);
}
if(data_model && data_model->get_n_rows() && data_model->get_n_columns())
@@ -217,24 +217,24 @@ bool Postgres::change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connec
switch(new_fields[i]->get_glom_type())
{
- case Field::TYPE_BOOLEAN:
+ case Field::glom_field_type::BOOLEAN:
{
- if(old_field_type == Field::TYPE_NUMERIC)
+ if(old_field_type == Field::glom_field_type::NUMERIC)
{
conversion_command = "(CASE WHEN " + field_name_old_quoted + " > 0 THEN true "
"WHEN " + field_name_old_quoted + " = 0 THEN false "
"WHEN " + field_name_old_quoted + " IS NULL THEN false
END)";
}
- else if(old_field_type == Field::TYPE_TEXT)
+ else if(old_field_type == Field::glom_field_type::TEXT)
conversion_command = '(' + field_name_old_quoted + " !~~* \'false\')"; // !~~*
means ! ILIKE
else // Dates and Times:
conversion_command = '(' + field_name_old_quoted + " IS NOT NULL)";
break;
}
- case Field::TYPE_NUMERIC: // CAST does not work if the destination type is numeric
+ case Field::glom_field_type::NUMERIC: // CAST does not work if the destination type
is numeric
{
- if(old_field_type == Field::TYPE_BOOLEAN)
+ if(old_field_type == Field::glom_field_type::BOOLEAN)
{
conversion_command = "(CASE WHEN " + field_name_old_quoted + " = true THEN 1 "
"WHEN " + field_name_old_quoted + " = false THEN 0 "
@@ -253,12 +253,12 @@ bool Postgres::change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connec
break;
}
- case Field::TYPE_DATE: // CAST does not work if the destination type is date.
+ case Field::glom_field_type::DATE: // CAST does not work if the destination type is
date.
{
conversion_command = "to_date( " + field_name_old_quoted + ", 'YYYYMMDD' )"; //
TODO: Standardise date storage format.
break;
}
- case Field::TYPE_TIME: // CAST does not work if the destination type is timestamp.
+ case Field::glom_field_type::TIME: // CAST does not work if the destination type is
timestamp.
{
conversion_command = "to_timestamp( " + field_name_old_quoted + ", 'HHMMSS' )"; //
TODO: Standardise time storage format.
break;
@@ -269,7 +269,7 @@ bool Postgres::change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connec
// To Text:
// bool to text:
- if(old_field_type == Field::TYPE_BOOLEAN)
+ if(old_field_type == Field::glom_field_type::BOOLEAN)
{
conversion_command = "(CASE WHEN " + field_name_old_quoted + " = true THEN
\'true\' "
"WHEN " + field_name_old_quoted + " = false THEN
\'false\' "
diff --git a/glom/libglom/connectionpool_backends/postgres_central.cc
b/glom/libglom/connectionpool_backends/postgres_central.cc
index 528ee01..54e0807 100644
--- a/glom/libglom/connectionpool_backends/postgres_central.cc
+++ b/glom/libglom/connectionpool_backends/postgres_central.cc
@@ -103,7 +103,7 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::
{
// Remember port if only the database was missing
connection_possible = false;
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_DATABASE)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_DATABASE)
{
connection_possible = true;
m_port = atoi(port.c_str());
@@ -129,7 +129,7 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::
//show that a connection was possible with a previously-tried port: connection_possible = false;
// Remember port if only the database was missing
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_DATABASE)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_DATABASE)
{
connection_possible = true;
m_port = atoi(port.c_str());
@@ -150,9 +150,9 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::
else
{
if(connection_possible)
- throw ExceptionConnection(ExceptionConnection::FAILURE_NO_DATABASE);
+ throw ExceptionConnection(ExceptionConnection::failure_type::NO_DATABASE);
else
- throw ExceptionConnection(ExceptionConnection::FAILURE_NO_SERVER);
+ throw ExceptionConnection(ExceptionConnection::failure_type::NO_SERVER);
}
return connection;
diff --git a/glom/libglom/connectionpool_backends/postgres_self.cc
b/glom/libglom/connectionpool_backends/postgres_self.cc
index 31b5aa2..9d13ba9 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.cc
+++ b/glom/libglom/connectionpool_backends/postgres_self.cc
@@ -150,13 +150,13 @@ Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_prog
if(m_database_directory_uri.empty())
{
std::cerr << G_STRFUNC << ": initialize: m_self_hosting_data_uri is empty." << std::endl;
- return INITERROR_OTHER;
+ return InitErrors::OTHER;
}
if(initial_username.empty())
{
std::cerr << G_STRFUNC << ": PostgresSelfHosted::initialize(). Username was empty while attempting to
create self-hosting database" << std::endl;
- return INITERROR_OTHER;
+ return InitErrors::OTHER;
}
//Get the filepath of the directory that we should create:
@@ -164,7 +164,7 @@ Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_prog
//std::cout << "debug: dbdir_uri=" << dbdir_uri << std::endl;
if(file_exists_uri(dbdir_uri))
- return INITERROR_DIRECTORY_ALREADY_EXISTS;
+ return InitErrors::DIRECTORY_ALREADY_EXISTS;
const auto dbdir = Glib::filename_from_uri(dbdir_uri);
//std::cout << "debug: dbdir=" << dbdir << std::endl;
@@ -175,7 +175,7 @@ Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_prog
{
std::cerr << G_STRFUNC << ": Couldn't create directory: " << dbdir << std::endl;
- return INITERROR_COULD_NOT_CREATE_DIRECTORY;
+ return InitErrors::COULD_NOT_CREATE_DIRECTORY;
}
//Create the config directory:
@@ -184,7 +184,7 @@ Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_prog
{
std::cerr << G_STRFUNC << ": Couldn't create the config directory: " << dbdir << std::endl;
- return INITERROR_COULD_NOT_CREATE_DIRECTORY;
+ return InitErrors::COULD_NOT_CREATE_DIRECTORY;
}
//Create these files: environment, pg_hba.conf, start.conf
@@ -196,7 +196,7 @@ Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_prog
{
std::cerr << G_STRFUNC << ": Couldn't create the data directory: " << dbdir << std::endl;
- return INITERROR_COULD_NOT_CREATE_DIRECTORY;
+ return InitErrors::COULD_NOT_CREATE_DIRECTORY;
}
// initdb creates a new postgres database cluster:
@@ -222,7 +222,7 @@ Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_prog
const auto temp_pwfile_removed = g_remove(temp_pwfile.c_str()); //Of course, we don't want this to stay
around. It would be a security risk.
g_assert(temp_pwfile_removed == 0);
- return result ? INITERROR_NONE : INITERROR_COULD_NOT_START_SERVER;
+ return result ? InitErrors::NONE : InitErrors::COULD_NOT_START_SERVER;
}
Glib::ustring PostgresSelfHosted::get_postgresql_utils_version(const SlotProgress& slot_progress)
@@ -338,7 +338,7 @@ Backend::StartupErrors PostgresSelfHosted::startup(const SlotProgress& slot_prog
if(get_self_hosting_active())
{
std::cerr << G_STRFUNC << ": Already started." << std::endl;
- return STARTUPERROR_NONE; //Just do it once.
+ return StartupErrors::NONE; //Just do it once.
}
const auto dbdir_uri = m_database_directory_uri;
@@ -346,7 +346,7 @@ Backend::StartupErrors PostgresSelfHosted::startup(const SlotProgress& slot_prog
if(!(file_exists_uri(dbdir_uri)))
{
std::cerr << G_STRFUNC << ": The data directory could not be found: " << dbdir_uri << std::endl;
- return STARTUPERROR_FAILED_NO_MAIN_DIRECTORY;
+ return StartupErrors::FAILED_NO_MAIN_DIRECTORY;
}
const auto dbdir = Glib::filename_from_uri(dbdir_uri);
@@ -362,12 +362,12 @@ Backend::StartupErrors PostgresSelfHosted::startup(const SlotProgress& slot_prog
{
std::cerr << G_STRFUNC << ": There is no data, but there is backup data." << std::endl;
//Let the caller convert the backup to real data and then try again:
- return STARTUPERROR_FAILED_NO_DATA_HAS_BACKUP_DATA;
+ return StartupErrors::FAILED_NO_DATA_HAS_BACKUP_DATA;
}
else
{
std::cerr << G_STRFUNC << ": ConnectionPool::create_self_hosting(): The data sub-directory could not
be found." << dbdir_data_uri << std::endl;
- return STARTUPERROR_FAILED_NO_DATA;
+ return StartupErrors::FAILED_NO_DATA;
}
}
@@ -379,7 +379,7 @@ Backend::StartupErrors PostgresSelfHosted::startup(const SlotProgress& slot_prog
if(available_port == 0)
{
std::cerr << G_STRFUNC << ": No port was available between " << PORT_POSTGRESQL_SELF_HOSTED_START << "
and " << PORT_POSTGRESQL_SELF_HOSTED_END << std::endl;
- return STARTUPERROR_FAILED_NO_PORT_AVAILABLE;
+ return StartupErrors::FAILED_NO_PORT_AVAILABLE;
}
//TODO: Performance:
@@ -420,12 +420,12 @@ Backend::StartupErrors PostgresSelfHosted::startup(const SlotProgress& slot_prog
if(!result)
{
std::cerr << G_STRFUNC << ": Error while attempting to self-host a database." << std::endl;
- return STARTUPERROR_FAILED_UNKNOWN_REASON;
+ return StartupErrors::FAILED_UNKNOWN_REASON;
}
m_port = available_port; //Remember it for later.
- return STARTUPERROR_NONE;
+ return StartupErrors::NONE;
}
void PostgresSelfHosted::show_active_connections()
@@ -566,7 +566,7 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresSelfHosted::connect(const Glib::ust
{
if(!get_self_hosting_active())
{
- throw ExceptionConnection(ExceptionConnection::FAILURE_NO_BACKEND); //TODO: But there is a backend. It's
just not ready.
+ throw ExceptionConnection(ExceptionConnection::failure_type::NO_BACKEND); //TODO: But there is a
backend. It's just not ready.
}
Glib::RefPtr<Gnome::Gda::Connection> result;
@@ -582,7 +582,7 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresSelfHosted::connect(const Glib::ust
}
catch(const ExceptionConnection& ex)
{
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_SERVER)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_SERVER)
{
//It must be using a default password, so any failure would not be due to a wrong password.
//However, pg_ctl sometimes reports success before it is really ready to let us connect,
diff --git a/glom/libglom/connectionpool_backends/sqlite.cc b/glom/libglom/connectionpool_backends/sqlite.cc
index 3f37ed5..10200ba 100644
--- a/glom/libglom/connectionpool_backends/sqlite.cc
+++ b/glom/libglom/connectionpool_backends/sqlite.cc
@@ -96,10 +96,10 @@ Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& databa
if(Glom::Utils::file_exists(db_dir) &&
(db_dir->query_file_type() == Gio::FILE_TYPE_DIRECTORY))
{
- throw ExceptionConnection(ExceptionConnection::FAILURE_NO_DATABASE);
+ throw ExceptionConnection(ExceptionConnection::failure_type::NO_DATABASE);
}
else
- throw ExceptionConnection(ExceptionConnection::FAILURE_NO_SERVER);
+ throw ExceptionConnection(ExceptionConnection::failure_type::NO_SERVER);
}
return connection;
@@ -228,7 +228,7 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
// Convert values to date or time, accordingly.
switch(changed_iter->second->get_glom_type())
{
- case Field::TYPE_TEXT:
+ case Field::glom_field_type::TEXT:
if(column->gtype == G_TYPE_BOOLEAN)
trans_fields += "(CASE WHEN "+ DbUtils::escape_sql_id(column->column_name) + " = 1 THEN 'true' "
"WHEN " + DbUtils::escape_sql_id(column->column_name) + " = 0
THEN 'false' "
@@ -240,7 +240,7 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
trans_fields += "(CASE WHEN "+ DbUtils::escape_sql_id(column->column_name) + " IS NULL THEN '' "
"WHEN " + DbUtils::escape_sql_id(column->column_name) + " IS
NOT NULL THEN " + DbUtils::escape_sql_id(column->column_name) + " END)";
break;
- case Field::TYPE_NUMERIC:
+ case Field::glom_field_type::NUMERIC:
if(column->gtype == G_TYPE_BOOLEAN)
trans_fields += "(CASE WHEN "+ DbUtils::escape_sql_id(column->column_name) + " = 0 THEN 0 "
"WHEN " + DbUtils::escape_sql_id(column->column_name) + " != 0
THEN 1 "
@@ -250,7 +250,7 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
else
trans_fields += Glib::ustring("CAST(")+ DbUtils::escape_sql_id(column->column_name) + " AS real)";
break;
- case Field::TYPE_BOOLEAN:
+ case Field::glom_field_type::BOOLEAN:
if(column->gtype == G_TYPE_STRING)
trans_fields += "(CASE WHEN "+ DbUtils::escape_sql_id(column->column_name) + " = 'true' THEN 1 "
"WHEN " + DbUtils::escape_sql_id(column->column_name) + " =
'false' THEN 0 "
@@ -264,19 +264,19 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
else
trans_fields += Glib::ustring(column->column_name) + " IS NOT NULL";
break;
- case Field::TYPE_DATE:
+ case Field::glom_field_type::DATE:
if(column->gtype == G_TYPE_BOOLEAN || column->gtype == GDA_TYPE_BLOB || column->gtype ==
G_TYPE_DOUBLE)
trans_fields += "NULL";
else
trans_fields += Glib::ustring("date(")+ DbUtils::escape_sql_id(column->column_name) + ')';
break;
- case Field::TYPE_TIME:
+ case Field::glom_field_type::TIME:
if(column->gtype == G_TYPE_BOOLEAN || column->gtype == GDA_TYPE_BLOB || column->gtype ==
G_TYPE_DOUBLE)
trans_fields += "NULL";
else
trans_fields += Glib::ustring("time(")+ DbUtils::escape_sql_id(column->column_name) + ')';
break;
- case Field::TYPE_IMAGE:
+ case Field::glom_field_type::IMAGE:
if(column->gtype == GDA_TYPE_BLOB)
trans_fields += column->column_name;
else
@@ -314,13 +314,13 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
{
switch(field->get_glom_type())
{
- case Field::TYPE_NUMERIC:
+ case Field::glom_field_type::NUMERIC:
trans_fields += '0';
break;
- case Field::TYPE_BOOLEAN:
+ case Field::glom_field_type::BOOLEAN:
trans_fields += '0';
break;
- case Field::TYPE_TEXT:
+ case Field::glom_field_type::TEXT:
trans_fields += "''";
break;
default:
diff --git a/glom/libglom/data_structure/choicevalue.cc b/glom/libglom/data_structure/choicevalue.cc
index 0bbce7f..b35fa73 100644
--- a/glom/libglom/data_structure/choicevalue.cc
+++ b/glom/libglom/data_structure/choicevalue.cc
@@ -28,7 +28,7 @@ namespace Glom
ChoiceValue::ChoiceValue()
{
- m_translatable_item_type = TRANSLATABLE_TYPE_CHOICEVALUE;
+ m_translatable_item_type = enumTranslatableItemType::CHOICEVALUE;
}
ChoiceValue::ChoiceValue(const ChoiceValue& src)
diff --git a/glom/libglom/data_structure/database_title.cc b/glom/libglom/data_structure/database_title.cc
index 9aec6ed..4d04a37 100644
--- a/glom/libglom/data_structure/database_title.cc
+++ b/glom/libglom/data_structure/database_title.cc
@@ -25,7 +25,7 @@ namespace Glom
DatabaseTitle::DatabaseTitle()
{
- m_translatable_item_type = TRANSLATABLE_TYPE_DATABASE_TITLE;
+ m_translatable_item_type = enumTranslatableItemType::DATABASE_TITLE;
}
DatabaseTitle::DatabaseTitle(const DatabaseTitle& src)
diff --git a/glom/libglom/data_structure/field.cc b/glom/libglom/data_structure/field.cc
index dd7ed88..0ea0082 100644
--- a/glom/libglom/data_structure/field.cc
+++ b/glom/libglom/data_structure/field.cc
@@ -40,13 +40,13 @@ bool Field::m_maps_inited = false;
Field::Field()
-: m_glom_type(TYPE_INVALID),
+: m_glom_type(glom_field_type::INVALID),
m_field_info(Gnome::Gda::Column::create()),
m_visible(true),
m_primary_key(false),
m_unique_key(false)
{
- m_translatable_item_type = TRANSLATABLE_TYPE_FIELD;
+ m_translatable_item_type = enumTranslatableItemType::FIELD;
}
Field::Field(const Field& src)
@@ -150,7 +150,7 @@ void Field::set_field_info(const Glib::RefPtr<Gnome::Gda::Column>& fieldinfo)
const auto glom_type = get_glom_type();
const auto new_type = fieldinfo->get_g_type();
- if( (glom_type == TYPE_INVALID) &&
+ if( (glom_type == glom_field_type::INVALID) &&
(new_type == GDA_TYPE_NULL)) //GDA_TYPE_NULL is the default for GdaColumn.
{
//Don't bother with any of the following checks.
@@ -160,7 +160,7 @@ void Field::set_field_info(const Glib::RefPtr<Gnome::Gda::Column>& fieldinfo)
// Also take fallback types into account as fieldinfo might originate from
// the database system directly.
GType cur_type = G_TYPE_NONE;
- if(glom_type != TYPE_INVALID)
+ if(glom_type != glom_field_type::INVALID)
{
cur_type = get_gda_type_for_glom_type(glom_type);
@@ -233,7 +233,7 @@ Glib::ustring Field::sql(const Gnome::Gda::Value& value, const Glib::RefPtr<Gnom
{
//std::cout << ": glom_type=" << get_glom_type() << std::endl;
- if(value.is_null() && (get_glom_type() == TYPE_TEXT))
+ if(value.is_null() && (get_glom_type() == glom_field_type::TEXT))
{
return "''"; //We want to ignore the concept of NULL strings, and deal only with empty strings.
}
@@ -271,8 +271,8 @@ Glib::ustring Field::to_file_format(const Gnome::Gda::Value& value) const
Glib::ustring Field::to_file_format(const Gnome::Gda::Value& value, glom_field_type glom_type)
{
- //Handle TYPE_IMAGE specially:
- if(glom_type == TYPE_IMAGE)
+ //Handle glom_field_type::IMAGE specially:
+ if(glom_type == glom_field_type::IMAGE)
{
if(!value.gobj())
return Glib::ustring();
@@ -366,7 +366,7 @@ Gnome::Gda::Value Field::from_file_format(const Glib::ustring& str, glom_field_t
//Unescape "" to ", because to_file_format() escaped ", as specified by the CSV RFC:
Glib::ustring string_unescaped;
- if(glom_type == TYPE_IMAGE)
+ if(glom_type == glom_field_type::IMAGE)
{
string_unescaped = str; //binary data does not have quote characters so we do not bother to escape or
unescape it.
}
@@ -377,7 +377,7 @@ Gnome::Gda::Value Field::from_file_format(const Glib::ustring& str, glom_field_t
}
- if(glom_type == TYPE_IMAGE)
+ if(glom_type == glom_field_type::IMAGE)
{
if(string_unescaped.empty())
return Gnome::Gda::Value();
@@ -420,7 +420,7 @@ Glib::ustring Field::sql_find(const Gnome::Gda::Value& value, const Glib::RefPtr
{
switch(get_glom_type())
{
- case(TYPE_TEXT):
+ case(glom_field_type::TEXT):
{
//% means 0 or more characters.
@@ -431,10 +431,10 @@ Glib::ustring Field::sql_find(const Gnome::Gda::Value& value, const Glib::RefPtr
break;
}
- case(TYPE_DATE):
- case(TYPE_TIME):
- case(TYPE_NUMERIC):
- case(TYPE_BOOLEAN):
+ case(glom_field_type::DATE):
+ case(glom_field_type::TIME):
+ case(glom_field_type::NUMERIC):
+ case(glom_field_type::BOOLEAN):
default:
{
return sql(value, connection);
@@ -447,7 +447,7 @@ Gnome::Gda::SqlOperatorType Field::sql_find_operator() const
{
switch(get_glom_type())
{
- case(TYPE_TEXT):
+ case(glom_field_type::TEXT):
{
auto connection_pool = ConnectionPool::get_instance();
if(connection_pool && connection_pool->get_backend())
@@ -456,10 +456,10 @@ Gnome::Gda::SqlOperatorType Field::sql_find_operator() const
return Gnome::Gda::SQL_OPERATOR_TYPE_LIKE; // Default
break;
}
- case(TYPE_DATE):
- case(TYPE_TIME):
- case(TYPE_NUMERIC):
- case(TYPE_BOOLEAN):
+ case(glom_field_type::DATE):
+ case(glom_field_type::TIME):
+ case(glom_field_type::NUMERIC):
+ case(glom_field_type::BOOLEAN):
default:
{
return Gnome::Gda::SQL_OPERATOR_TYPE_EQ;
@@ -557,7 +557,7 @@ Glib::ustring Field::get_sql_type() const
if(strType == "unknowntype")
{
- std::cerr << G_STRFUNC << ": returning unknowntype for field name=" << get_name() << ", glom_type=" <<
get_glom_type() << ", gda_type=" << (int)m_field_info->get_g_type() << std::endl;
+ std::cerr << G_STRFUNC << ": returning unknowntype for field name=" << get_name() << ", glom_type=" <<
static_cast<int>(get_glom_type()) << ", gda_type=" << (int)m_field_info->get_g_type() << std::endl;
}
return strType;
@@ -589,7 +589,7 @@ Field::glom_field_type Field::get_glom_type_for_gda_type(GType gda_type)
{
init_map();
- Field::glom_field_type result = TYPE_INVALID;
+ Field::glom_field_type result = glom_field_type::INVALID;
//Get the glom type used for this gda type:
{
@@ -617,7 +617,7 @@ GType Field::get_gda_type_for_glom_type(Field::glom_field_type glom_type)
if(ideal_gda_type == G_TYPE_NONE)
{
- std::cerr << G_STRFUNC << ": Returning G_TYPE_NONE for glom_type=" << glom_type << std::endl;
+ std::cerr << G_STRFUNC << ": Returning G_TYPE_NONE for glom_type=" << static_cast<int>(glom_type) <<
std::endl;
}
//std::cout << "debug: " << G_STRFUNC << ": returning: " << g_type_name(ideal_gda_type) << std::endl;
@@ -633,58 +633,58 @@ void Field::init_map()
//Fill maps.
//Ideals:
- m_map_gda_type_to_glom_type[GDA_TYPE_NUMERIC] = TYPE_NUMERIC;
- m_map_gda_type_to_glom_type[G_TYPE_INT] = TYPE_NUMERIC; //Only for "serial" (auto-increment) fields.
- m_map_gda_type_to_glom_type[G_TYPE_STRING] = TYPE_TEXT;
- m_map_gda_type_to_glom_type[GDA_TYPE_TIME] = TYPE_TIME;
- m_map_gda_type_to_glom_type[G_TYPE_DATE] = TYPE_DATE;
- m_map_gda_type_to_glom_type[G_TYPE_BOOLEAN] = TYPE_BOOLEAN;
- m_map_gda_type_to_glom_type[GDA_TYPE_BINARY] = TYPE_IMAGE;
+ m_map_gda_type_to_glom_type[GDA_TYPE_NUMERIC] = glom_field_type::NUMERIC;
+ m_map_gda_type_to_glom_type[G_TYPE_INT] = glom_field_type::NUMERIC; //Only for "serial" (auto-increment)
fields.
+ m_map_gda_type_to_glom_type[G_TYPE_STRING] = glom_field_type::TEXT;
+ m_map_gda_type_to_glom_type[GDA_TYPE_TIME] = glom_field_type::TIME;
+ m_map_gda_type_to_glom_type[G_TYPE_DATE] = glom_field_type::DATE;
+ m_map_gda_type_to_glom_type[G_TYPE_BOOLEAN] = glom_field_type::BOOLEAN;
+ m_map_gda_type_to_glom_type[GDA_TYPE_BINARY] = glom_field_type::IMAGE;
//SQLite can return a GdaBlob though it can take a GdaBinary:
- m_map_gda_type_to_glom_type[GDA_TYPE_BLOB] = TYPE_IMAGE;
+ m_map_gda_type_to_glom_type[GDA_TYPE_BLOB] = glom_field_type::IMAGE;
//Extra conversions for GTypes that can be returned by glom_pygda_value_from_pyobject():
- m_map_gda_type_to_glom_type[G_TYPE_DOUBLE] = TYPE_NUMERIC;
+ m_map_gda_type_to_glom_type[G_TYPE_DOUBLE] = glom_field_type::NUMERIC;
//TODO? m_map_gda_type_to_glom_type[GDA_TYPE_TIME] = ;
//TODO? m_map_gda_type_to_glom_type[GDA_TYPE_TIMESTAMP] = ;
- m_map_glom_type_to_gda_type[TYPE_NUMERIC] = GDA_TYPE_NUMERIC;
- m_map_glom_type_to_gda_type[TYPE_TEXT] = G_TYPE_STRING;
- m_map_glom_type_to_gda_type[TYPE_TIME] = GDA_TYPE_TIME;
- m_map_glom_type_to_gda_type[TYPE_DATE] = G_TYPE_DATE;
- m_map_glom_type_to_gda_type[TYPE_BOOLEAN] = G_TYPE_BOOLEAN;
- m_map_glom_type_to_gda_type[TYPE_IMAGE] = GDA_TYPE_BINARY;
+ m_map_glom_type_to_gda_type[glom_field_type::NUMERIC] = GDA_TYPE_NUMERIC;
+ m_map_glom_type_to_gda_type[glom_field_type::TEXT] = G_TYPE_STRING;
+ m_map_glom_type_to_gda_type[glom_field_type::TIME] = GDA_TYPE_TIME;
+ m_map_glom_type_to_gda_type[glom_field_type::DATE] = G_TYPE_DATE;
+ m_map_glom_type_to_gda_type[glom_field_type::BOOLEAN] = G_TYPE_BOOLEAN;
+ m_map_glom_type_to_gda_type[glom_field_type::IMAGE] = GDA_TYPE_BINARY;
// Translators: This means an unknown or unnacceptable value type in a database.
- m_map_type_names_ui[TYPE_INVALID] = _("Invalid");
+ m_map_type_names_ui[glom_field_type::INVALID] = _("Invalid");
// Translators: This means a numeric value type in a database.
- m_map_type_names_ui[TYPE_NUMERIC] = _("Number");
+ m_map_type_names_ui[glom_field_type::NUMERIC] = _("Number");
// Translators: This means a text/string value type in a database.
- m_map_type_names_ui[TYPE_TEXT] = _("Text");
+ m_map_type_names_ui[glom_field_type::TEXT] = _("Text");
// Translators: This means a time value type in a database.
- m_map_type_names_ui[TYPE_TIME] = _("Time");
+ m_map_type_names_ui[glom_field_type::TIME] = _("Time");
// Translators: This means a time value type in a database.
- m_map_type_names_ui[TYPE_DATE] = _("Date");
+ m_map_type_names_ui[glom_field_type::DATE] = _("Date");
// Translators: This means a true/false value type in a database.
- m_map_type_names_ui[TYPE_BOOLEAN] = _("Boolean");
+ m_map_type_names_ui[glom_field_type::BOOLEAN] = _("Boolean");
// Translators: This means a picture value type in a database.
- m_map_type_names_ui[TYPE_IMAGE] = _("Image");
+ m_map_type_names_ui[glom_field_type::IMAGE] = _("Image");
//Non-translated names used for the document:
- m_map_type_names[TYPE_INVALID] = "Invalid";
- m_map_type_names[TYPE_NUMERIC] = "Number";
- m_map_type_names[TYPE_TEXT] = "Text";
- m_map_type_names[TYPE_TIME] = "Time";
- m_map_type_names[TYPE_DATE] = "Date";
- m_map_type_names[TYPE_BOOLEAN] = "Boolean";
- m_map_type_names[TYPE_IMAGE] = "Image";
+ m_map_type_names[glom_field_type::INVALID] = "Invalid";
+ m_map_type_names[glom_field_type::NUMERIC] = "Number";
+ m_map_type_names[glom_field_type::TEXT] = "Text";
+ m_map_type_names[glom_field_type::TIME] = "Time";
+ m_map_type_names[glom_field_type::DATE] = "Date";
+ m_map_type_names[glom_field_type::BOOLEAN] = "Boolean";
+ m_map_type_names[glom_field_type::IMAGE] = "Image";
//Conversions:
@@ -692,41 +692,41 @@ void Field::init_map()
m_map_conversions.clear();
type_list_conversion_targets list_conversions( {
- Field::TYPE_BOOLEAN,
- Field::TYPE_TEXT} );
- //to_date(numeric) was supported in 8.2 but not in 8.3: list_conversions.push_back(Field::TYPE_DATE);
- //to_timestamp(numeric) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::TYPE_TIME);
- m_map_conversions[Field::TYPE_NUMERIC] = list_conversions;
+ Field::glom_field_type::BOOLEAN,
+ Field::glom_field_type::TEXT} );
+ //to_date(numeric) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::glom_field_type::DATE);
+ //to_timestamp(numeric) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::glom_field_type::TIME);
+ m_map_conversions[Field::glom_field_type::NUMERIC] = list_conversions;
//Text:
list_conversions = {
- Field::TYPE_BOOLEAN,
- Field::TYPE_NUMERIC,
- Field::TYPE_DATE,
- Field::TYPE_TIME};
- m_map_conversions[Field::TYPE_TEXT] = list_conversions;
+ Field::glom_field_type::BOOLEAN,
+ Field::glom_field_type::NUMERIC,
+ Field::glom_field_type::DATE,
+ Field::glom_field_type::TIME};
+ m_map_conversions[Field::glom_field_type::TEXT] = list_conversions;
//Boolean:
list_conversions = {
- Field::TYPE_TEXT,
- Field::TYPE_NUMERIC};
- //to_timestamp(numeric) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::TYPE_DATE);
- //to_timestamp(numeric) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::TYPE_TIME);
- m_map_conversions[Field::TYPE_BOOLEAN] = list_conversions;
+ Field::glom_field_type::TEXT,
+ Field::glom_field_type::NUMERIC};
+ //to_timestamp(numeric) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::glom_field_type::DATE);
+ //to_timestamp(numeric) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::glom_field_type::TIME);
+ m_map_conversions[Field::glom_field_type::BOOLEAN] = list_conversions;
//Date:
list_conversions = {
- Field::TYPE_TEXT};
- //to_number(textcat()) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::TYPE_NUMERIC);
- //to_number(textcat()) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::TYPE_BOOLEAN);
- m_map_conversions[Field::TYPE_DATE] = list_conversions;
+ Field::glom_field_type::TEXT};
+ //to_number(textcat()) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::glom_field_type::NUMERIC);
+ //to_number(textcat()) was supported in 8.2 but not in 8.3:
list_conversions.push_back(Field::glom_field_type::BOOLEAN);
+ m_map_conversions[Field::glom_field_type::DATE] = list_conversions;
//Time:
list_conversions = {
- Field::TYPE_TEXT,
- Field::TYPE_NUMERIC,
- Field::TYPE_BOOLEAN};
- m_map_conversions[Field::TYPE_TIME] = list_conversions;
+ Field::glom_field_type::TEXT,
+ Field::glom_field_type::NUMERIC,
+ Field::glom_field_type::BOOLEAN};
+ m_map_conversions[Field::glom_field_type::TIME] = list_conversions;
m_maps_inited = true;
@@ -770,7 +770,7 @@ Field::type_map_type_names Field::get_usable_type_names()
type_map_type_names result = m_map_type_names_ui;
//Remove INVALID, because it's not something that a user can use for a field type.
- auto iter = result.find(TYPE_INVALID);
+ auto iter = result.find(glom_field_type::INVALID);
if(iter != result.end())
result.erase(iter);
@@ -792,7 +792,7 @@ Glib::ustring Field::get_type_name_ui(glom_field_type glom_type)
//static:
Field::glom_field_type Field::get_type_for_ui_name(const Glib::ustring& glom_type)
{
- glom_field_type result = TYPE_INVALID;
+ glom_field_type result = glom_field_type::INVALID;
for(const auto& the_pair : m_map_type_names_ui)
{
diff --git a/glom/libglom/data_structure/field.h b/glom/libglom/data_structure/field.h
index c5ae566..7316898 100644
--- a/glom/libglom/data_structure/field.h
+++ b/glom/libglom/data_structure/field.h
@@ -55,21 +55,21 @@ public:
/* Possible formats when converting from/to SQL representation.
* TODO: Maybe we should move the code that does the conversion between gda
* type and SQL into the connectionpool backends. */
- enum sql_format
+ enum class sql_format
{
- SQL_FORMAT_POSTGRES,
- SQL_FORMAT_SQLITE
+ POSTGRES,
+ SQLITE
};
- enum glom_field_type
+ enum class glom_field_type
{
- TYPE_INVALID,
- TYPE_NUMERIC,
- TYPE_TEXT,
- TYPE_DATE,
- TYPE_TIME,
- TYPE_BOOLEAN,
- TYPE_IMAGE //Always stored as a standard format.
+ INVALID,
+ NUMERIC,
+ TEXT,
+ DATE,
+ TIME,
+ BOOLEAN,
+ IMAGE //Always stored as a standard format.
};
Field();
diff --git a/glom/libglom/data_structure/fieldtypes.cc b/glom/libglom/data_structure/fieldtypes.cc
index 6cca857..35fc951 100644
--- a/glom/libglom/data_structure/fieldtypes.cc
+++ b/glom/libglom/data_structure/fieldtypes.cc
@@ -30,12 +30,12 @@ FieldTypes::FieldTypes(const Glib::RefPtr<Gnome::Gda::Connection>& gda_connectio
{
// These are documented here:
// http://library.gnome.org/devel/libgda-4.0/3.99/connection.html#GdaConnectionMetaTypeHead
- enum GlomGdaDataModelTypesColumns
+ enum class GlomGdaDataModelTypesColumns
{
- DATAMODEL_FIELDS_COL_NAME = 0,
- DATAMODEL_FIELDS_COL_GTYPE = 1,
- DATAMODEL_FIELDS_COL_COMMENTS = 2,
- DATAMODEL_FIELDS_COL_SYNONYMS = 3
+ NAME = 0,
+ GTYPE = 1,
+ COMMENTS = 2,
+ SYNONYMS = 3
};
if(gda_connection && gda_connection->is_opened())
@@ -68,7 +68,7 @@ FieldTypes::FieldTypes(const Glib::RefPtr<Gnome::Gda::Connection>& gda_connectio
for(int i = 0; i < rows; ++i)
{
- const auto value_name = data_model_tables->get_value_at(DATAMODEL_FIELDS_COL_NAME, i);
+ const auto value_name =
data_model_tables->get_value_at(static_cast<int>(GlomGdaDataModelTypesColumns::NAME), i);
//Get the types's string representation:
Glib::ustring schema_type_string;
@@ -77,7 +77,7 @@ FieldTypes::FieldTypes(const Glib::RefPtr<Gnome::Gda::Connection>& gda_connectio
if(!schema_type_string.empty())
{
- const auto value_gdatype = data_model_tables->get_value_at(DATAMODEL_FIELDS_COL_GTYPE, i);
+ const auto value_gdatype =
data_model_tables->get_value_at(static_cast<int>(GlomGdaDataModelTypesColumns::GTYPE), i);
if(value_gdatype.get_value_type() == G_TYPE_STRING)
{
auto type_string = value_gdatype.get_string();
diff --git a/glom/libglom/data_structure/glomconversions.cc b/glom/libglom/data_structure/glomconversions.cc
index 797886c..2e1c5c5 100644
--- a/glom/libglom/data_structure/glomconversions.cc
+++ b/glom/libglom/data_structure/glomconversions.cc
@@ -408,7 +408,7 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
return Glib::ustring();
}
- if(glom_type == Field::TYPE_DATE)
+ if(glom_type == Field::glom_field_type::DATE)
{
tm the_c_time;
memset(&the_c_time, 0, sizeof(the_c_time));
@@ -450,7 +450,7 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
return date.format_string("%x"); //%x means "is replaced by the locale's appropriate date
representation".
*/
}
- else if(glom_type == Field::TYPE_TIME)
+ else if(glom_type == Field::glom_field_type::TIME)
{
tm the_c_time;
memset(&the_c_time, 0, sizeof(the_c_time));
@@ -481,7 +481,7 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
return format_time(the_c_time, locale, iso_format);
}
- else if(glom_type == Field::TYPE_NUMERIC)
+ else if(glom_type == Field::glom_field_type::NUMERIC)
{
const auto value_type = value.get_value_type();
if(value_type != GDA_TYPE_NUMERIC
@@ -558,11 +558,11 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
//std::cout << "debug: " << G_STRFUNC << ": number=" << number << ", text=" << text << std::endl;
return text; //Do something like Glib::locale_to_utf(), but with the specified locale instead of the
current locale.
}
- else if(glom_type == Field::TYPE_TEXT)
+ else if(glom_type == Field::glom_field_type::TEXT)
{
return value.get_string();
}
- else if(glom_type == Field::TYPE_BOOLEAN)
+ else if(glom_type == Field::glom_field_type::BOOLEAN)
{
//This is used only by Field::to_file_format(),
//and should never be shown in the UI.
@@ -571,18 +571,18 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
else
return "FALSE";
}
- else if(glom_type == Field::TYPE_IMAGE)
+ else if(glom_type == Field::glom_field_type::IMAGE)
{
//This function is only used for :
//- UI-visible strings, but images should never be shown as text in the UI.
//- Values in SQL queries, but we only do that for clauses (where/sort/order)
// which should never use image values.
- std::cerr << G_STRFUNC << ": Unexpected TYPE_IMAGE field type: " << glom_type << std::endl;
+ std::cerr << G_STRFUNC << ": Unexpected enumType::IMAGE field type: " << static_cast<int>(glom_type) <<
std::endl;
return Glib::ustring();
}
else
{
- std::cerr << G_STRFUNC << ": Unexpected glom field type: " << glom_type << std::endl;
+ std::cerr << G_STRFUNC << ": Unexpected glom field type: " << static_cast<int>(glom_type) << std::endl;
return value.to_string();
}
}
@@ -618,7 +618,7 @@ Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, con
//But we use "" for strings, because the distinction between NULL and "" would not be clear to users.
if(text.empty())
{
- if( (glom_type == Field::TYPE_DATE) || (glom_type == Field::TYPE_TIME) || (glom_type ==
Field::TYPE_NUMERIC) )
+ if( (glom_type == Field::glom_field_type::DATE) || (glom_type == Field::glom_field_type::TIME) ||
(glom_type == Field::glom_field_type::NUMERIC) )
{
Gnome::Gda::Value null_value;
success = true;
@@ -626,7 +626,7 @@ Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, con
}
}
- if(glom_type == Field::TYPE_DATE)
+ if(glom_type == Field::glom_field_type::DATE)
{
tm the_c_time = parse_date(text, the_locale, success);
@@ -635,7 +635,7 @@ Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, con
return Gnome::Gda::Value(gda_date);
}
- else if(glom_type == Field::TYPE_TIME)
+ else if(glom_type == Field::glom_field_type::TIME)
{
tm the_c_time = parse_time(text, the_locale, success);
@@ -652,7 +652,7 @@ Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, con
return Gnome::Gda::Value(gda_time);
}
- else if(glom_type == Field::TYPE_NUMERIC)
+ else if(glom_type == Field::glom_field_type::NUMERIC)
{
Glib::ustring text_to_parse = Utils::trim_whitespace(text);
@@ -686,16 +686,16 @@ Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, con
success = true; //Can this ever fail?
return Gnome::Gda::Value(numeric);
}
- else if(glom_type == Field::TYPE_BOOLEAN)
+ else if(glom_type == Field::glom_field_type::BOOLEAN)
{
success = true;
return Gnome::Gda::Value( (text.uppercase() == "TRUE" ? true : false) ); //TODO: Internationalize this,
but it should never be used anyway.
}
- else if(glom_type == Field::TYPE_IMAGE)
+ else if(glom_type == Field::glom_field_type::IMAGE)
{
//This function is only used for :
//- UI-visible strings, but images should never be entered as text in the UI.
- std::cerr << G_STRFUNC << ": Unexpected TYPE_IMAGE field type: " << glom_type << std::endl;
+ std::cerr << G_STRFUNC << ": Unexpected enumType::IMAGE field type: " << static_cast<int>(glom_type) <<
std::endl;
return Gnome::Gda::Value();
}
@@ -1023,7 +1023,7 @@ Gnome::Gda::Value Conversions::get_empty_value(Field::glom_field_type field_type
{
switch(field_type)
{
- case(Field::TYPE_TEXT):
+ case(Field::glom_field_type::TEXT):
return Gnome::Gda::Value( Glib::ustring() ); //Use an empty string instead of a null for text fields,
because the distinction is confusing for users, and gives no advantages.
default:
return Gnome::Gda::Value(); //A NULL instance, because there is no suitable empty value for numeric,
date, or time fields.
@@ -1034,21 +1034,21 @@ Gnome::Gda::Value Conversions::get_example_value(Field::glom_field_type field_ty
{
switch(field_type)
{
- case(Field::TYPE_BOOLEAN):
+ case(Field::glom_field_type::BOOLEAN):
return Gnome::Gda::Value(true);
- case(Field::TYPE_DATE):
+ case(Field::glom_field_type::DATE):
{
bool success = false;
return parse_value(field_type, "01/02/03", success, true /* iso_format */);
}
- case(Field::TYPE_NUMERIC):
+ case(Field::glom_field_type::NUMERIC):
{
bool success = false;
return parse_value(field_type, "1", success, true /* iso_format */);
}
- case(Field::TYPE_TEXT):
+ case(Field::glom_field_type::TEXT):
return Gnome::Gda::Value( Glib::ustring("example") ); //Use an empty string instead of a null for text
fields, because the distinction is confusing for users, and gives no advantages.
- case(Field::TYPE_TIME):
+ case(Field::glom_field_type::TIME):
{
bool success = false;
return parse_value(field_type, "01:02", success, true /* iso_format */);
@@ -1087,7 +1087,7 @@ Gnome::Gda::Value Conversions::convert_value(const Gnome::Gda::Value& value, Fie
{
//Try to return the canonical type,
//instead of just something of a similar GType:
- if((target_glom_type == Field::TYPE_NUMERIC) &&
+ if((target_glom_type == Field::glom_field_type::NUMERIC) &&
(vtype_is_numeric(gvalue_type_source)))
{
const auto number = get_double_for_gda_value_numeric(value);
diff --git a/glom/libglom/data_structure/layout/custom_title.cc
b/glom/libglom/data_structure/layout/custom_title.cc
index 904eeec..30a8ff8 100644
--- a/glom/libglom/data_structure/layout/custom_title.cc
+++ b/glom/libglom/data_structure/layout/custom_title.cc
@@ -27,7 +27,7 @@ namespace Glom
CustomTitle::CustomTitle()
: m_use_custom_title(false)
{
- m_translatable_item_type = TRANSLATABLE_TYPE_CUSTOM_TITLE;
+ m_translatable_item_type = enumTranslatableItemType::CUSTOM_TITLE;
}
CustomTitle::CustomTitle(const CustomTitle& src)
diff --git a/glom/libglom/data_structure/layout/formatting.cc
b/glom/libglom/data_structure/layout/formatting.cc
index f36a7ef..f485d10 100644
--- a/glom/libglom/data_structure/layout/formatting.cc
+++ b/glom/libglom/data_structure/layout/formatting.cc
@@ -35,7 +35,7 @@ Formatting::Formatting()
m_choices_related(false),
m_text_format_multiline(false),
m_text_multiline_height_lines(MULTILINE_TEXT_DEFAULT_HEIGHT_LINES),
- m_horizontal_alignment(HORIZONTAL_ALIGNMENT_AUTO),
+ m_horizontal_alignment(HorizontalAlignment::AUTO),
m_choices_related_show_all(true) //Because this a the simpler, more often useful, default.
{
}
diff --git a/glom/libglom/data_structure/layout/formatting.h b/glom/libglom/data_structure/layout/formatting.h
index 342ce41..1a368e7 100644
--- a/glom/libglom/data_structure/layout/formatting.h
+++ b/glom/libglom/data_structure/layout/formatting.h
@@ -164,11 +164,11 @@ public:
*/
Glib::ustring get_text_format_color_background() const;
- enum HorizontalAlignment
+ enum class HorizontalAlignment
{
- HORIZONTAL_ALIGNMENT_AUTO, //For instance, RIGHT for numeric fields.
- HORIZONTAL_ALIGNMENT_LEFT,
- HORIZONTAL_ALIGNMENT_RIGHT
+ AUTO, //For instance, RIGHT for numeric fields.
+ LEFT,
+ RIGHT
};
void set_horizontal_alignment(HorizontalAlignment alignment);
diff --git a/glom/libglom/data_structure/layout/layoutitem.cc
b/glom/libglom/data_structure/layout/layoutitem.cc
index 947aa12..a6ffa02 100644
--- a/glom/libglom/data_structure/layout/layoutitem.cc
+++ b/glom/libglom/data_structure/layout/layoutitem.cc
@@ -67,7 +67,7 @@ LayoutItem::LayoutItem()
m_display_width(0),
m_positions(0)
{
- m_translatable_item_type = TRANSLATABLE_TYPE_LAYOUT_ITEM;
+ m_translatable_item_type = enumTranslatableItemType::LAYOUT_ITEM;
}
LayoutItem::LayoutItem(const LayoutItem& src)
diff --git a/glom/libglom/data_structure/layout/layoutitem_button.cc
b/glom/libglom/data_structure/layout/layoutitem_button.cc
index 98ddc2a..4e81a10 100644
--- a/glom/libglom/data_structure/layout/layoutitem_button.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_button.cc
@@ -26,7 +26,7 @@ namespace Glom
LayoutItem_Button::LayoutItem_Button()
{
- m_translatable_item_type = TRANSLATABLE_TYPE_BUTTON;
+ m_translatable_item_type = enumTranslatableItemType::BUTTON;
}
LayoutItem_Button::LayoutItem_Button(const LayoutItem_Button& src)
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.cc
b/glom/libglom/data_structure/layout/layoutitem_field.cc
index 1ef2da8..17c5e0f 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_field.cc
@@ -258,17 +258,17 @@ Formatting::HorizontalAlignment LayoutItem_Field::get_formatting_used_horizontal
Formatting::HorizontalAlignment alignment =
format.get_horizontal_alignment();
- if(alignment == Formatting::HORIZONTAL_ALIGNMENT_AUTO)
+ if(alignment == Formatting::HorizontalAlignment::AUTO)
{
//By default, right-align numbers on list views, unless they are ID fields.
//And left-align them on details views, because that looks silly otherwise.
if(!for_details_view && (m_field && !m_field->get_primary_key())) //TODO: Also prevent this when it is a
foreign key.
{
//Align numbers to the right by default:
- alignment = (m_field->get_glom_type() == Field::TYPE_NUMERIC ? Formatting::HORIZONTAL_ALIGNMENT_RIGHT
: Formatting::HORIZONTAL_ALIGNMENT_LEFT);
+ alignment = (m_field->get_glom_type() == Field::glom_field_type::NUMERIC ?
Formatting::HorizontalAlignment::RIGHT : Formatting::HorizontalAlignment::LEFT);
}
else
- alignment = Formatting::HORIZONTAL_ALIGNMENT_LEFT;
+ alignment = Formatting::HorizontalAlignment::LEFT;
}
return alignment;
@@ -318,7 +318,7 @@ Field::glom_field_type LayoutItem_Field::get_glom_type() const
if(m_field && m_field_cache_valid)
return m_field->get_glom_type();
else
- return Field::TYPE_INVALID;
+ return Field::glom_field_type::INVALID;
}
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.h
b/glom/libglom/data_structure/layout/layoutitem_field.h
index b88065d..777c535 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.h
+++ b/glom/libglom/data_structure/layout/layoutitem_field.h
@@ -126,10 +126,10 @@ public:
virtual const Formatting& get_formatting_used() const;
/** Get the alignment for the formatting used (see get_formatting_used()),
- * choosing an appropriate alignment if it is set to HORIZONTAL_ALIGNMENT_AUTO.
- * Note that this never returns HORIZONTAL_ALIGNMENT_AUTO.
+ * choosing an appropriate alignment if it is set to HorizontalAlignment::AUTO.
+ * Note that this never returns HorizontalAlignment::AUTO.
*
- * @param for_details_view This can change the effect of HORIZONTAL_ALIGNMENT_AUTO.
+ * @param for_details_view This can change the effect of HorizontalAlignment::AUTO.
*/
virtual Formatting::HorizontalAlignment get_formatting_used_horizontal_alignment(bool for_details_view =
false) const;
diff --git a/glom/libglom/data_structure/layout/layoutitem_image.cc
b/glom/libglom/data_structure/layout/layoutitem_image.cc
index 74e4fa0..5b940a5 100644
--- a/glom/libglom/data_structure/layout/layoutitem_image.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_image.cc
@@ -28,7 +28,7 @@ namespace Glom
LayoutItem_Image::LayoutItem_Image()
{
- m_translatable_item_type = TRANSLATABLE_TYPE_IMAGEOBJECT;
+ m_translatable_item_type = enumTranslatableItemType::IMAGEOBJECT;
}
LayoutItem_Image::LayoutItem_Image(const LayoutItem_Image& src)
diff --git a/glom/libglom/data_structure/layout/layoutitem_line.cc
b/glom/libglom/data_structure/layout/layoutitem_line.cc
index 7c38ca7..d9e66a7 100644
--- a/glom/libglom/data_structure/layout/layoutitem_line.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_line.cc
@@ -33,7 +33,7 @@ LayoutItem_Line::LayoutItem_Line()
m_line_width(0.5f), //Arbitrary default
m_color("black") //Arbitrary default
{
- m_translatable_item_type = TRANSLATABLE_TYPE_INVALID; //There is no text in this to translate.
+ m_translatable_item_type = enumTranslatableItemType::INVALID; //There is no text in this to translate.
}
LayoutItem_Line::LayoutItem_Line(const LayoutItem_Line& src)
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.cc
b/glom/libglom/data_structure/layout/layoutitem_portal.cc
index d4208f3..39ed3ed 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.cc
@@ -30,7 +30,7 @@ LayoutItem_Portal::LayoutItem_Portal()
: m_print_layout_row_height(20), //arbitrary default.
m_print_layout_row_line_width(1), //Sensible default.
m_print_layout_column_line_width(1), //Sensible default.
- m_navigation_type(LayoutItem_Portal::NAVIGATION_AUTOMATIC),
+ m_navigation_type(LayoutItem_Portal::navigation_type::AUTOMATIC),
m_rows_count_min(6), //Sensible default.
m_rows_count_max(6) //Sensible default.
{
@@ -115,7 +115,7 @@ void LayoutItem_Portal::change_field_item_name(const Glib::ustring& table_name,
std::shared_ptr<UsesRelationship> LayoutItem_Portal::get_navigation_relationship_specific()
{
- if(get_navigation_type() == LayoutItem_Portal::NAVIGATION_SPECIFIC)
+ if(get_navigation_type() == LayoutItem_Portal::navigation_type::SPECIFIC)
return m_navigation_relationship_specific;
else
return std::shared_ptr<UsesRelationship>();
@@ -123,7 +123,7 @@ std::shared_ptr<UsesRelationship> LayoutItem_Portal::get_navigation_relationship
std::shared_ptr<const UsesRelationship> LayoutItem_Portal::get_navigation_relationship_specific() const
{
- if(get_navigation_type() == LayoutItem_Portal::NAVIGATION_SPECIFIC)
+ if(get_navigation_type() == LayoutItem_Portal::navigation_type::SPECIFIC)
return m_navigation_relationship_specific;
else
return std::shared_ptr<UsesRelationship>();
@@ -132,13 +132,13 @@ std::shared_ptr<const UsesRelationship> LayoutItem_Portal::get_navigation_relati
void LayoutItem_Portal::set_navigation_relationship_specific(const std::shared_ptr<UsesRelationship>&
relationship)
{
m_navigation_relationship_specific = relationship;
- m_navigation_type = LayoutItem_Portal::NAVIGATION_SPECIFIC;
+ m_navigation_type = LayoutItem_Portal::navigation_type::SPECIFIC;
}
void LayoutItem_Portal::reset_navigation_relationship()
{
m_navigation_relationship_specific = std::shared_ptr<UsesRelationship>();
- m_navigation_type = LayoutItem_Portal::NAVIGATION_AUTOMATIC;
+ m_navigation_type = LayoutItem_Portal::navigation_type::AUTOMATIC;
}
Glib::ustring LayoutItem_Portal::get_from_table() const
@@ -226,7 +226,7 @@ void LayoutItem_Portal::get_suitable_table_to_view_details(Glib::ustring& table_
std::shared_ptr<const UsesRelationship> navigation_relationship;
//Check whether a relationship was specified:
- if(get_navigation_type() == LayoutItem_Portal::NAVIGATION_AUTOMATIC)
+ if(get_navigation_type() == LayoutItem_Portal::navigation_type::AUTOMATIC)
{
//std::cout << "debug: decide automatically." << std::endl;
//Decide automatically:
@@ -253,7 +253,7 @@ void LayoutItem_Portal::get_suitable_table_to_view_details(Glib::ustring& table_
{
navigation_table_name = navigation_relationship->get_table_used(directly_related_table_name);
}
- else if(get_navigation_type() != LayoutItem_Portal::NAVIGATION_NONE)
+ else if(get_navigation_type() != LayoutItem_Portal::navigation_type::NONE)
{
//An empty result from get_portal_navigation_relationship_automatic() or
//get_navigation_relationship_specific() means we should use the directly related table:
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.h
b/glom/libglom/data_structure/layout/layoutitem_portal.h
index 1edf3e0..f7b481a 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.h
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.h
@@ -89,11 +89,11 @@ public:
/** The navigation (if any) that should be used when the user
* activates a related record row.
*/
- enum navigation_type
+ enum class navigation_type
{
- NAVIGATION_NONE, /**< No navigation will be offered. */
- NAVIGATION_AUTOMATIC, /**< The destination related table will be chosen automatically based on the
relationship and the visible fields. */
- NAVIGATION_SPECIFIC /**< The destination related table will be determined by a specified relationship. */
+ NONE, /**< No navigation will be offered. */
+ AUTOMATIC, /**< The destination related table will be chosen automatically based on the relationship and
the visible fields. */
+ SPECIFIC /**< The destination related table will be determined by a specified relationship. */
};
/** Discover what @a type (if any) navigation should be used when the user
diff --git a/glom/libglom/data_structure/layout/layoutitem_text.cc
b/glom/libglom/data_structure/layout/layoutitem_text.cc
index 448f9c9..738e988 100644
--- a/glom/libglom/data_structure/layout/layoutitem_text.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_text.cc
@@ -26,7 +26,7 @@ namespace Glom
LayoutItem_Text::LayoutItem_Text()
{
- m_translatable_item_type = TRANSLATABLE_TYPE_TEXTOBJECT;
+ m_translatable_item_type = enumTranslatableItemType::TEXTOBJECT;
m_text = std::make_shared<StaticText>(); //TODO: Why use a smartpointer?
}
diff --git a/glom/libglom/data_structure/layout/layoutitem_withformatting.cc
b/glom/libglom/data_structure/layout/layoutitem_withformatting.cc
index 9de0c49..58390c7 100644
--- a/glom/libglom/data_structure/layout/layoutitem_withformatting.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_withformatting.cc
@@ -67,8 +67,8 @@ Formatting::HorizontalAlignment LayoutItem_WithFormatting::get_formatting_used_h
Formatting::HorizontalAlignment alignment =
format.get_horizontal_alignment();
- if(alignment == Formatting::HORIZONTAL_ALIGNMENT_AUTO)
- alignment = Formatting::HORIZONTAL_ALIGNMENT_LEFT;
+ if(alignment == Formatting::HorizontalAlignment::AUTO)
+ alignment = Formatting::HorizontalAlignment::LEFT;
return alignment;
}
diff --git a/glom/libglom/data_structure/layout/layoutitem_withformatting.h
b/glom/libglom/data_structure/layout/layoutitem_withformatting.h
index 0d2d92e..b492713 100644
--- a/glom/libglom/data_structure/layout/layoutitem_withformatting.h
+++ b/glom/libglom/data_structure/layout/layoutitem_withformatting.h
@@ -52,8 +52,8 @@ public:
virtual const Formatting& get_formatting_used() const;
/** Get the alignment for the formatting used (see get_formatting_used()),
- * choosing an appropriate alignment if it is set to HORIZONTAL_ALIGNMENT_AUTO.
- * Note that this never returns HORIZONTAL_ALIGNMENT_AUTO.
+ * choosing an appropriate alignment if it is set to HorizontalAlignment::AUTO.
+ * Note that this never returns HorizontalAlignment::AUTO.
*/
virtual Formatting::HorizontalAlignment get_formatting_used_horizontal_alignment(bool for_details_view =
false) const;
};
diff --git a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.cc
b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.cc
index 229f056..f5e7ef4 100644
--- a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.cc
+++ b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.cc
@@ -25,7 +25,7 @@ namespace Glom
{
LayoutItem_FieldSummary::LayoutItem_FieldSummary()
-: m_summary_type(TYPE_INVALID)
+: m_summary_type(summaryType::INVALID)
{
}
@@ -96,13 +96,13 @@ void LayoutItem_FieldSummary::set_summary_type(summaryType summary_type)
Glib::ustring LayoutItem_FieldSummary::get_summary_type_sql() const
{
- if(m_summary_type == TYPE_INVALID)
+ if(m_summary_type == summaryType::INVALID)
return "INVALID";
- else if(m_summary_type == TYPE_SUM)
+ else if(m_summary_type == summaryType::SUM)
return "SUM";
- else if(m_summary_type == TYPE_AVERAGE)
+ else if(m_summary_type == summaryType::AVERAGE)
return "AVG";
- else if(m_summary_type == TYPE_COUNT)
+ else if(m_summary_type == summaryType::COUNT)
return "COUNT";
else
return "INVALID";
@@ -111,13 +111,13 @@ Glib::ustring LayoutItem_FieldSummary::get_summary_type_sql() const
void LayoutItem_FieldSummary::set_summary_type_from_sql(const Glib::ustring& summary_type)
{
if(summary_type == "SUM")
- m_summary_type = TYPE_SUM;
+ m_summary_type = summaryType::SUM;
else if(summary_type == "AVG")
- m_summary_type = TYPE_AVERAGE;
+ m_summary_type = summaryType::AVERAGE;
else if(summary_type == "COUNT")
- m_summary_type = TYPE_COUNT;
+ m_summary_type = summaryType::COUNT;
else
- m_summary_type = TYPE_INVALID;
+ m_summary_type = summaryType::INVALID;
}
void LayoutItem_FieldSummary::set_field(const std::shared_ptr<LayoutItem_Field>& field)
@@ -130,7 +130,7 @@ Glib::ustring LayoutItem_FieldSummary::get_layout_display_name() const
{
auto result = get_layout_display_name_field();
- if(m_summary_type == TYPE_INVALID)
+ if(m_summary_type == summaryType::INVALID)
result = _("No summary chosen");
else
result = get_summary_type_name(m_summary_type) + '(' + result + ')';
@@ -147,13 +147,13 @@ Glib::ustring LayoutItem_FieldSummary::get_layout_display_name_field() const
//static:
Glib::ustring LayoutItem_FieldSummary::get_summary_type_name(summaryType summary_type)
{
- if(summary_type == TYPE_INVALID)
+ if(summary_type == summaryType::INVALID)
return _("Invalid");
- else if(summary_type == TYPE_SUM)
+ else if(summary_type == summaryType::SUM)
return _("Sum");
- else if(summary_type == TYPE_AVERAGE)
+ else if(summary_type == summaryType::AVERAGE)
return _("Average");
- else if(summary_type == TYPE_COUNT)
+ else if(summary_type == summaryType::COUNT)
return _("Count");
else
return _("Invalid");
diff --git a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
index 4ca2822..4a263c8 100644
--- a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
+++ b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
@@ -44,12 +44,12 @@ public:
virtual Glib::ustring get_part_type_name() const;
virtual Glib::ustring get_report_part_id() const;
- enum summaryType
+ enum class summaryType
{
- TYPE_INVALID,
- TYPE_SUM,
- TYPE_AVERAGE,
- TYPE_COUNT
+ INVALID,
+ SUM,
+ AVERAGE,
+ COUNT
};
summaryType get_summary_type() const;
diff --git a/glom/libglom/data_structure/layout/static_text.cc
b/glom/libglom/data_structure/layout/static_text.cc
index d251750..330183a 100644
--- a/glom/libglom/data_structure/layout/static_text.cc
+++ b/glom/libglom/data_structure/layout/static_text.cc
@@ -26,7 +26,7 @@ namespace Glom
StaticText::StaticText()
{
- m_translatable_item_type = TRANSLATABLE_TYPE_STATIC_TEXT;
+ m_translatable_item_type = enumTranslatableItemType::STATIC_TEXT;
}
StaticText::StaticText(const StaticText& src)
diff --git a/glom/libglom/data_structure/print_layout.cc b/glom/libglom/data_structure/print_layout.cc
index e9caeb2..d876789 100644
--- a/glom/libglom/data_structure/print_layout.cc
+++ b/glom/libglom/data_structure/print_layout.cc
@@ -30,7 +30,7 @@ PrintLayout::PrintLayout()
m_show_outlines(true),
m_page_count(1) //A sensible default
{
- m_translatable_item_type = TRANSLATABLE_TYPE_PRINT_LAYOUT;
+ m_translatable_item_type = enumTranslatableItemType::PRINT_LAYOUT;
m_layout_group = std::make_shared<LayoutGroup>();
}
diff --git a/glom/libglom/data_structure/relationship.cc b/glom/libglom/data_structure/relationship.cc
index 8577307..c8d9270 100644
--- a/glom/libglom/data_structure/relationship.cc
+++ b/glom/libglom/data_structure/relationship.cc
@@ -26,7 +26,7 @@ namespace Glom
Relationship::Relationship()
: m_allow_edit(true), m_auto_create(false)
{
- m_translatable_item_type = TRANSLATABLE_TYPE_RELATIONSHIP;
+ m_translatable_item_type = enumTranslatableItemType::RELATIONSHIP;
}
Relationship::Relationship(const Relationship& src)
diff --git a/glom/libglom/data_structure/report.cc b/glom/libglom/data_structure/report.cc
index 7010358..16ad6cf 100644
--- a/glom/libglom/data_structure/report.cc
+++ b/glom/libglom/data_structure/report.cc
@@ -26,7 +26,7 @@ namespace Glom
Report::Report()
: m_show_table_title(true)
{
- m_translatable_item_type = TRANSLATABLE_TYPE_REPORT;
+ m_translatable_item_type = enumTranslatableItemType::REPORT;
m_layout_group = std::make_shared<LayoutGroup>();
}
diff --git a/glom/libglom/data_structure/system_prefs.h b/glom/libglom/data_structure/system_prefs.h
index b12b351..7423e82 100644
--- a/glom/libglom/data_structure/system_prefs.h
+++ b/glom/libglom/data_structure/system_prefs.h
@@ -45,7 +45,7 @@ public:
Glib::ustring m_name, m_org_name,
m_org_address_street, m_org_address_street2, m_org_address_town,
m_org_address_county, m_org_address_country, m_org_address_postcode;
- Gnome::Gda::Value m_org_logo; //TYPE_IMAGE.
+ Gnome::Gda::Value m_org_logo; //enumType::IMAGE.
};
} //namespace Glom
diff --git a/glom/libglom/data_structure/tableinfo.cc b/glom/libglom/data_structure/tableinfo.cc
index 83feb2c..5fd58ca 100644
--- a/glom/libglom/data_structure/tableinfo.cc
+++ b/glom/libglom/data_structure/tableinfo.cc
@@ -27,7 +27,7 @@ TableInfo::TableInfo() noexcept
: m_hidden(false),
m_default(false)
{
- m_translatable_item_type = TRANSLATABLE_TYPE_TABLE;
+ m_translatable_item_type = enumTranslatableItemType::TABLE;
}
TableInfo::TableInfo(const TableInfo& src) noexcept
diff --git a/glom/libglom/data_structure/translatable_item.cc
b/glom/libglom/data_structure/translatable_item.cc
index d2a92d7..7384a78 100644
--- a/glom/libglom/data_structure/translatable_item.cc
+++ b/glom/libglom/data_structure/translatable_item.cc
@@ -27,7 +27,7 @@ namespace Glom
{
TranslatableItem::TranslatableItem() noexcept
-: m_translatable_item_type(TRANSLATABLE_TYPE_INVALID)
+: m_translatable_item_type(enumTranslatableItemType::INVALID)
{
}
@@ -208,33 +208,33 @@ Glib::ustring TranslatableItem::get_translatable_type_name_nontranslated(enumTra
{
//TODO: Is there an easier way to do this, without duplicating code?
- if(item_type == TRANSLATABLE_TYPE_FIELD)
+ if(item_type == enumTranslatableItemType::FIELD)
return "Field";
- else if(item_type == TRANSLATABLE_TYPE_CUSTOM_TITLE)
+ else if(item_type == enumTranslatableItemType::CUSTOM_TITLE)
return "Custom Title";
- else if(item_type == TRANSLATABLE_TYPE_RELATIONSHIP)
+ else if(item_type == enumTranslatableItemType::RELATIONSHIP)
return "Relationship";
- else if(item_type == TRANSLATABLE_TYPE_RELATIONSHIP)
+ else if(item_type == enumTranslatableItemType::RELATIONSHIP)
return "Layout Item";
- else if(item_type == TRANSLATABLE_TYPE_PRINT_LAYOUT)
+ else if(item_type == enumTranslatableItemType::PRINT_LAYOUT)
return "Print Layout";
- else if(item_type == TRANSLATABLE_TYPE_REPORT)
+ else if(item_type == enumTranslatableItemType::REPORT)
return "Report";
- else if(item_type == TRANSLATABLE_TYPE_TABLE)
+ else if(item_type == enumTranslatableItemType::TABLE)
return "Table";
- else if(item_type == TRANSLATABLE_TYPE_LAYOUT_ITEM)
+ else if(item_type == enumTranslatableItemType::LAYOUT_ITEM)
return "Layout Group";
- else if(item_type == TRANSLATABLE_TYPE_BUTTON)
+ else if(item_type == enumTranslatableItemType::BUTTON)
return "Button";
- else if(item_type == TRANSLATABLE_TYPE_TEXTOBJECT)
+ else if(item_type == enumTranslatableItemType::TEXTOBJECT)
return "Text Item";
- else if(item_type == TRANSLATABLE_TYPE_IMAGEOBJECT)
+ else if(item_type == enumTranslatableItemType::IMAGEOBJECT)
return "Image";
- else if(item_type == TRANSLATABLE_TYPE_CHOICEVALUE)
+ else if(item_type == enumTranslatableItemType::CHOICEVALUE)
return "Field Choice";
- else if(item_type == TRANSLATABLE_TYPE_DATABASE_TITLE)
+ else if(item_type == enumTranslatableItemType::DATABASE_TITLE)
return "Database Title";
- else if(item_type == TRANSLATABLE_TYPE_STATIC_TEXT)
+ else if(item_type == enumTranslatableItemType::STATIC_TEXT)
return "Text";
else
return "Unknown";
@@ -242,33 +242,33 @@ Glib::ustring TranslatableItem::get_translatable_type_name_nontranslated(enumTra
Glib::ustring TranslatableItem::get_translatable_type_name(enumTranslatableItemType item_type) noexcept
{
- if(item_type == TRANSLATABLE_TYPE_FIELD)
+ if(item_type == enumTranslatableItemType::FIELD)
return _("Field");
- else if(item_type == TRANSLATABLE_TYPE_CUSTOM_TITLE)
+ else if(item_type == enumTranslatableItemType::CUSTOM_TITLE)
return _("Custom Title");
- else if(item_type == TRANSLATABLE_TYPE_RELATIONSHIP)
+ else if(item_type == enumTranslatableItemType::RELATIONSHIP)
return _("Relationship");
- else if(item_type == TRANSLATABLE_TYPE_RELATIONSHIP)
+ else if(item_type == enumTranslatableItemType::RELATIONSHIP)
return _("Layout Item");
- else if(item_type == TRANSLATABLE_TYPE_PRINT_LAYOUT)
+ else if(item_type == enumTranslatableItemType::PRINT_LAYOUT)
return _("Print Layout");
- else if(item_type == TRANSLATABLE_TYPE_REPORT)
+ else if(item_type == enumTranslatableItemType::REPORT)
return _("Report");
- else if(item_type == TRANSLATABLE_TYPE_TABLE)
+ else if(item_type == enumTranslatableItemType::TABLE)
return _("Table");
- else if(item_type == TRANSLATABLE_TYPE_LAYOUT_ITEM)
+ else if(item_type == enumTranslatableItemType::LAYOUT_ITEM)
return _("Layout Group");
- else if(item_type == TRANSLATABLE_TYPE_BUTTON)
+ else if(item_type == enumTranslatableItemType::BUTTON)
return _("Button");
- else if(item_type == TRANSLATABLE_TYPE_TEXTOBJECT)
+ else if(item_type == enumTranslatableItemType::TEXTOBJECT)
return _("Text Item");
- else if(item_type == TRANSLATABLE_TYPE_IMAGEOBJECT)
+ else if(item_type == enumTranslatableItemType::IMAGEOBJECT)
return _("Image");
- else if(item_type == TRANSLATABLE_TYPE_CHOICEVALUE)
+ else if(item_type == enumTranslatableItemType::CHOICEVALUE)
return _("Field Choice");
- else if(item_type == TRANSLATABLE_TYPE_DATABASE_TITLE)
+ else if(item_type == enumTranslatableItemType::DATABASE_TITLE)
return _("Database Title");
- else if(item_type == TRANSLATABLE_TYPE_STATIC_TEXT)
+ else if(item_type == enumTranslatableItemType::STATIC_TEXT)
return _("Text");
else
return _("Unknown");
diff --git a/glom/libglom/data_structure/translatable_item.h b/glom/libglom/data_structure/translatable_item.h
index ce9609c..2620831 100644
--- a/glom/libglom/data_structure/translatable_item.h
+++ b/glom/libglom/data_structure/translatable_item.h
@@ -98,22 +98,22 @@ public:
bool get_has_translations() const noexcept;
- enum enumTranslatableItemType
+ enum class enumTranslatableItemType
{
- TRANSLATABLE_TYPE_INVALID,
- TRANSLATABLE_TYPE_FIELD,
- TRANSLATABLE_TYPE_RELATIONSHIP,
- TRANSLATABLE_TYPE_LAYOUT_ITEM,
- TRANSLATABLE_TYPE_CUSTOM_TITLE,
- TRANSLATABLE_TYPE_PRINT_LAYOUT,
- TRANSLATABLE_TYPE_REPORT,
- TRANSLATABLE_TYPE_TABLE,
- TRANSLATABLE_TYPE_BUTTON,
- TRANSLATABLE_TYPE_TEXTOBJECT, //This has a TRANSLATABLE_TYPE_STATIC_TEXT child.
- TRANSLATABLE_TYPE_IMAGEOBJECT,
- TRANSLATABLE_TYPE_CHOICEVALUE,
- TRANSLATABLE_TYPE_DATABASE_TITLE,
- TRANSLATABLE_TYPE_STATIC_TEXT
+ INVALID,
+ FIELD,
+ RELATIONSHIP,
+ LAYOUT_ITEM,
+ CUSTOM_TITLE,
+ PRINT_LAYOUT,
+ REPORT,
+ TABLE,
+ BUTTON,
+ TEXTOBJECT, //This has a enumTranslatableItemType::STATIC_TEXT child.
+ IMAGEOBJECT,
+ CHOICEVALUE,
+ DATABASE_TITLE,
+ STATIC_TEXT
};
enumTranslatableItemType get_translatable_item_type() const noexcept;
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 0d37f5a..314df15 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -236,7 +236,7 @@ bool recreate_database_from_document(Document* document, const std::function<voi
}
catch(const ExceptionConnection& ex)
{
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_SERVER)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_SERVER)
{
std::cerr << G_STRFUNC << ": AppWindow::recreate_database(): Failed because connection to server
failed even without specifying a database." << std::endl;
return false;
@@ -349,7 +349,7 @@ bool recreate_database_from_document(Document* document, const std::function<voi
SystemPrefs get_database_preferences(const Document* document)
{
- //if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ //if(get_userlevel() == AppState::userlevels::DEVELOPER)
// add_standard_tables(document);
SystemPrefs result;
@@ -391,14 +391,14 @@ SystemPrefs get_database_preferences(const Document* document)
if(datamodel && (datamodel->get_n_rows() != 0))
{
const std::locale locale(std::locale::classic()); //Ignored for text types, but it's best to avoid
ever using the current arbitrary locale here.
- result.m_name = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(0, 0),
locale);
- result.m_org_name = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(1,
0), locale);
- result.m_org_address_street = Conversions::get_text_for_gda_value(Field::TYPE_TEXT,
datamodel->get_value_at(2, 0), locale);
- result.m_org_address_street2 = Conversions::get_text_for_gda_value(Field::TYPE_TEXT,
datamodel->get_value_at(3, 0), locale);
- result.m_org_address_town = Conversions::get_text_for_gda_value(Field::TYPE_TEXT,
datamodel->get_value_at(4, 0), locale);
- result.m_org_address_county = Conversions::get_text_for_gda_value(Field::TYPE_TEXT,
datamodel->get_value_at(5, 0), locale);
- result.m_org_address_country = Conversions::get_text_for_gda_value(Field::TYPE_TEXT,
datamodel->get_value_at(6, 0), locale);
- result.m_org_address_postcode = Conversions::get_text_for_gda_value(Field::TYPE_TEXT,
datamodel->get_value_at(7, 0), locale);
+ result.m_name = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(0, 0), locale);
+ result.m_org_name = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(1, 0), locale);
+ result.m_org_address_street = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(2, 0), locale);
+ result.m_org_address_street2 = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(3, 0), locale);
+ result.m_org_address_town = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(4, 0), locale);
+ result.m_org_address_county = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(5, 0), locale);
+ result.m_org_address_country = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(6, 0), locale);
+ result.m_org_address_postcode = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(7, 0), locale);
//We need to be more clever about these column indexes if we add more new fields:
if(optional_org_logo)
@@ -528,22 +528,22 @@ bool add_standard_tables(const Document* document)
auto primary_key = std::make_shared<Field>(); //It's not used, because there's only one record, but we
must have one.
primary_key->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_ID);
- primary_key->set_glom_type(Field::TYPE_NUMERIC);
+ primary_key->set_glom_type(Field::glom_field_type::NUMERIC);
fields.push_back(primary_key);
auto field_table_name = std::make_shared<Field>();
field_table_name->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME);
- field_table_name->set_glom_type(Field::TYPE_TEXT);
+ field_table_name->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_table_name);
auto field_field_name = std::make_shared<Field>();
field_field_name->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME);
- field_field_name->set_glom_type(Field::TYPE_TEXT);
+ field_field_name->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_field_name);
auto field_next_value = std::make_shared<Field>();
field_next_value->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE);
- field_next_value->set_glom_type(Field::TYPE_TEXT);
+ field_next_value->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_next_value);
const auto test = create_table(document->get_hosting_mode(), table_info, fields);
@@ -814,16 +814,16 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
// These are documented here:
// http://library.gnome.org/devel/libgda-4.0/3.99/connection.html#GdaConnectionMetaTypeHead
- enum GlomGdaDataModelFieldColumns
- {
- DATAMODEL_FIELDS_COL_NAME = 0,
- DATAMODEL_FIELDS_COL_TYPE = 1,
- DATAMODEL_FIELDS_COL_GTYPE = 2,
- DATAMODEL_FIELDS_COL_SIZE = 3,
- DATAMODEL_FIELDS_COL_SCALE = 4,
- DATAMODEL_FIELDS_COL_NOTNULL = 5,
- DATAMODEL_FIELDS_COL_DEFAULTVALUE = 6,
- DATAMODEL_FIELDS_COL_EXTRA = 6 // Could be auto-increment
+ enum class GlomGdaDataModelFieldColumns
+ {
+ NAME = 0,
+ TYPE = 1,
+ GTYPE = 2,
+ SIZE = 3,
+ SCALE = 4,
+ NOTNULL = 5,
+ DEFAULTVALUE = 6,
+ EXTRA = 6 // Could be auto-increment
};
//TODO: BusyCursor busy_cursor(get_appwindow());
@@ -907,7 +907,7 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
Glib::RefPtr<Gnome::Gda::Column> field_info = Gnome::Gda::Column::create();
//Get the field name:
- const auto value_name = data_model_fields->get_value_at(DATAMODEL_FIELDS_COL_NAME, row);
+ const auto value_name =
data_model_fields->get_value_at(static_cast<int>(GlomGdaDataModelFieldColumns::NAME), row);
if(value_name.get_value_type() == G_TYPE_STRING)
{
if(value_name.get_string().empty())
@@ -920,7 +920,7 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
}
//Get the field type:
- const auto value_fieldtype = data_model_fields->get_value_at(DATAMODEL_FIELDS_COL_GTYPE, row);
+ const auto value_fieldtype =
data_model_fields->get_value_at(static_cast<int>(GlomGdaDataModelFieldColumns::GTYPE), row);
if(value_fieldtype.get_value_type() == G_TYPE_STRING)
{
const auto type_string = value_fieldtype.get_string();
@@ -931,12 +931,12 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
//Get the default value:
const Gnome::Gda::Value value_defaultvalue =
- data_model_fields->get_value_at(DATAMODEL_FIELDS_COL_DEFAULTVALUE, row);
+ data_model_fields->get_value_at(static_cast<int>(GlomGdaDataModelFieldColumns::DEFAULTVALUE), row);
if(value_defaultvalue.get_value_type() == G_TYPE_STRING)
field_info->set_default_value(value_defaultvalue);
//Get whether it can be null:
- const auto value_notnull = data_model_fields->get_value_at(DATAMODEL_FIELDS_COL_NOTNULL, row);
+ const auto value_notnull =
data_model_fields->get_value_at(static_cast<int>(GlomGdaDataModelFieldColumns::NOTNULL), row);
if(value_notnull.get_value_type() == G_TYPE_BOOLEAN)
field_info->set_allow_null(value_notnull.get_boolean());
@@ -1173,7 +1173,7 @@ bool create_table_with_default_fields(Document* document, const Glib::ustring& t
field_info->set_allow_null(false);
field_primary_key->set_field_info(field_info);
- field_primary_key->set_glom_type(Field::TYPE_NUMERIC);
+ field_primary_key->set_glom_type(Field::glom_field_type::NUMERIC);
//std::cout << "debug: " << G_STRFUNC << ":" << field_primary_key->get_auto_increment() << std::endl;
type_vec_fields fields;
@@ -1183,14 +1183,14 @@ bool create_table_with_default_fields(Document* document, const Glib::ustring& t
auto field_description = std::make_shared<Field>();
field_description->set_name("description");
field_description->set_title_original(_("Description")); //Use a translation, because the original locale
will be marked as non-English if the current locale is non-English.
- field_description->set_glom_type(Field::TYPE_TEXT);
+ field_description->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_description);
//Comments:
auto field_comments = std::make_shared<Field>();
field_comments->set_name("comments");
field_comments->set_title_original(_("Comments"));
- field_comments->set_glom_type(Field::TYPE_TEXT);
+ field_comments->set_glom_type(Field::glom_field_type::TEXT);
field_comments->m_default_formatting.set_text_format_multiline();
fields.push_back(field_comments);
@@ -1229,7 +1229,7 @@ bool create_table(Document::HostingMode hosting_mode, const std::shared_ptr<cons
{
std::shared_ptr<Field> field = std::make_shared<Field>();
field->set_name(GLOM_STANDARD_FIELD_LOCK);
- field->set_glom_type(Field::TYPE_TEXT);
+ field->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field);
}
@@ -1247,8 +1247,8 @@ bool create_table(Document::HostingMode hosting_mode, const std::shared_ptr<cons
Glib::ustring field_type = field->get_sql_type();
- if( (hosting_mode == Document::HOSTING_MODE_MYSQL_CENTRAL) ||
- (hosting_mode == Document::HOSTING_MODE_MYSQL_SELF) )
+ if( (hosting_mode == Document::HostingMode::MYSQL_CENTRAL) ||
+ (hosting_mode == Document::HostingMode::MYSQL_SELF) )
{
if(field_type == "varchar")
field_type = "varchar(255)";
@@ -1469,7 +1469,7 @@ Gnome::Gda::Value auto_increment_insert_first_if_necessary(const Glib::ustring&
//GdaNumeric is a pain, so we take a short-cut:
bool success = false;
- value = Conversions::parse_value(Field::TYPE_NUMERIC, "0", success, true /* iso_format */);
+ value = Conversions::parse_value(Field::glom_field_type::NUMERIC, "0", success, true /* iso_format */);
}
else
{
@@ -1479,7 +1479,7 @@ Gnome::Gda::Value auto_increment_insert_first_if_necessary(const Glib::ustring&
//(our system_autoincrements table has it as text, for future flexibility):
const auto actual_value_text = actual_value.get_string();
bool success = false;
- value = Conversions::parse_value(Field::TYPE_NUMERIC, actual_value_text, success, true /* iso_format */);
+ value = Conversions::parse_value(Field::glom_field_type::NUMERIC, actual_value_text, success, true /*
iso_format */);
}
//std::cout << "auto_increment_insert_first_if_necessary: returning value of type=" <<
value.get_value_type() << std::endl;
@@ -1626,10 +1626,10 @@ bool insert_example_data(const Document* document, const Glib::ustring& table_na
break;
}
- if(field->get_glom_type() == Field::TYPE_IMAGE)
+ if(field->get_glom_type() == Field::glom_field_type::IMAGE)
{
- if((hosting_mode == Document::HOSTING_MODE_MYSQL_CENTRAL) ||
- (hosting_mode == Document::HOSTING_MODE_MYSQL_SELF))
+ if((hosting_mode == Document::HostingMode::MYSQL_CENTRAL) ||
+ (hosting_mode == Document::HostingMode::MYSQL_SELF))
{
//TODO: See https://bugzilla.gnome.org/show_bug.cgi?id=691099
std::cerr << G_STRFUNC << ": Skipping Image field because libgda does not support it for MySQL."
<< std::endl;
@@ -1946,7 +1946,7 @@ Glib::ustring get_unused_database_name(const Glib::ustring& base_name)
}
catch(const ExceptionConnection& ex)
{
- if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_SERVER)
+ if(ex.get_failure_type() == ExceptionConnection::failure_type::NO_SERVER)
{
//We couldn't even connect to the server,
//regardless of what database we try to connect to:
diff --git a/glom/libglom/document/bakery/document.cc b/glom/libglom/document/bakery/document.cc
index 996d240..ec66642 100644
--- a/glom/libglom/document/bakery/document.cc
+++ b/glom/libglom/document/bakery/document.cc
@@ -115,7 +115,7 @@ bool Document::get_modified() const
bool Document::load(int& failure_code)
{
//Initialize the output parameter:
- failure_code = LOAD_FAILURE_CODE_NONE;
+ failure_code = static_cast<int>(LoadFailureCodes::NONE);
auto bTest = read_from_disk(failure_code);
if(bTest)
@@ -204,7 +204,7 @@ bool Document::save_before()
bool Document::read_from_disk(int& failure_code)
{
- failure_code = LOAD_FAILURE_CODE_NONE;
+ failure_code = static_cast<int>(LoadFailureCodes::NONE);
m_strContents.erase();
@@ -227,7 +227,7 @@ bool Document::read_from_disk(int& failure_code)
if(ex.code() == Gio::Error::NOT_FOUND)
- failure_code = LOAD_FAILURE_CODE_NOT_FOUND;
+ failure_code = static_cast<int>(LoadFailureCodes::NOT_FOUND);
// std::cout << " File not found: " << m_file_uri << std::endl;
// If the operation was not successful, print the error and abort
diff --git a/glom/libglom/document/bakery/document.h b/glom/libglom/document/bakery/document.h
index 2f40a33..615d965 100644
--- a/glom/libglom/document/bakery/document.h
+++ b/glom/libglom/document/bakery/document.h
@@ -45,17 +45,17 @@ public:
*/
bool save();
- enum LoadFailureCodes
+ enum class LoadFailureCodes
{
- LOAD_FAILURE_CODE_NONE = 0,
- LOAD_FAILURE_CODE_NOT_FOUND = 1,
- LOAD_FAILURE_CODE_LAST = 20 //arbitrary large number. Anything after this is for the application's
custom codes.
+ NONE = 0,
+ NOT_FOUND = 1,
+ LAST = 20 //arbitrary large number. Anything after this is for the application's custom codes.
};
/* Loads data from disk, using the URI (set with set_file_uri()) then asks the View to update itself.
* bool indicates success.
* @param failure_code Used to return an error code that is understood by your application.
- * Custom error codes should be greater than LOAD_FAILURE_CODE_LAST.
+ * Custom error codes should be greater than LoadFailureCodes::CODE_LAST.
*/
bool load(int& failure_code);
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 900eaf3..9b5321a 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -267,7 +267,7 @@ auto find_if_layout(T_Container& container, const Glib::ustring& layout_name, co
}
Document::Document()
-: m_hosting_mode(HOSTING_MODE_DEFAULT),
+: m_hosting_mode(HostingMode::DEFAULT),
m_network_shared(false),
m_connection_port(0),
m_connection_try_other_ports(false),
@@ -336,12 +336,12 @@ bool Document::get_network_shared() const
//Enforce constraints:
const auto hosting_mode = get_hosting_mode();
- if( (hosting_mode == HOSTING_MODE_POSTGRES_CENTRAL) ||
- (hosting_mode == HOSTING_MODE_MYSQL_CENTRAL) )
+ if( (hosting_mode == HostingMode::POSTGRES_CENTRAL) ||
+ (hosting_mode == HostingMode::MYSQL_CENTRAL) )
{
shared = true; //Central hosting means that it must be shared on the network.
}
- else if(hosting_mode == HOSTING_MODE_SQLITE)
+ else if(hosting_mode == HostingMode::SQLITE)
shared = false; //sqlite does not allow network sharing.
return shared;
@@ -367,19 +367,19 @@ std::string Document::get_connection_self_hosted_directory_uri() const
{
switch(m_hosting_mode)
{
- case HOSTING_MODE_POSTGRES_SELF:
+ case HostingMode::POSTGRES_SELF:
datadir = parent->get_child("glom_postgres_data");
break;
- case HOSTING_MODE_POSTGRES_CENTRAL:
+ case HostingMode::POSTGRES_CENTRAL:
datadir = parent;
break;
- case HOSTING_MODE_SQLITE:
+ case HostingMode::SQLITE:
datadir = parent;
break;
- case HOSTING_MODE_MYSQL_SELF:
+ case HostingMode::MYSQL_SELF:
datadir = parent->get_child("glom_mysql_data");
break;
- case HOSTING_MODE_MYSQL_CENTRAL:
+ case HostingMode::MYSQL_CENTRAL:
datadir = parent;
break;
default:
@@ -533,61 +533,61 @@ std::shared_ptr<TableInfo> Document::create_table_system_preferences(type_vec_fi
auto primary_key = std::make_shared<Field>(); //It's not used, because there's only one record, but we
must have one.
primary_key->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ID);
- primary_key->set_glom_type(Field::TYPE_NUMERIC);
+ primary_key->set_glom_type(Field::glom_field_type::NUMERIC);
fields.push_back(primary_key);
auto field_name = std::make_shared<Field>();
field_name->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_NAME);
field_name->set_title_original(_("System Name"));
- field_name->set_glom_type(Field::TYPE_TEXT);
+ field_name->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_name);
auto field_org_name = std::make_shared<Field>();
field_org_name->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_NAME);
field_org_name->set_title_original(_("Organisation Name"));
- field_org_name->set_glom_type(Field::TYPE_TEXT);
+ field_org_name->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_org_name);
auto field_org_logo = std::make_shared<Field>();
field_org_logo->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO);
field_org_logo->set_title_original(_("Organisation Logo"));
- field_org_logo->set_glom_type(Field::TYPE_IMAGE);
+ field_org_logo->set_glom_type(Field::glom_field_type::IMAGE);
fields.push_back(field_org_logo);
auto field_org_address_street = std::make_shared<Field>();
field_org_address_street->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET);
field_org_address_street->set_title_original(_("Street"));
- field_org_address_street->set_glom_type(Field::TYPE_TEXT);
+ field_org_address_street->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_org_address_street);
auto field_org_address_street2 = std::make_shared<Field>();
field_org_address_street2->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET2);
field_org_address_street2->set_title_original(_("Street (line 2)"));
- field_org_address_street2->set_glom_type(Field::TYPE_TEXT);
+ field_org_address_street2->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_org_address_street2);
auto field_org_address_town = std::make_shared<Field>();
field_org_address_town->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_TOWN);
field_org_address_town->set_title_original(_("City"));
- field_org_address_town->set_glom_type(Field::TYPE_TEXT);
+ field_org_address_town->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_org_address_town);
auto field_org_address_county = std::make_shared<Field>();
field_org_address_county->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTY);
field_org_address_county->set_title_original(_("State"));
- field_org_address_county->set_glom_type(Field::TYPE_TEXT);
+ field_org_address_county->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_org_address_county);
auto field_org_address_country = std::make_shared<Field>();
field_org_address_country->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTRY);
field_org_address_country->set_title_original(_("Country"));
- field_org_address_country->set_glom_type(Field::TYPE_TEXT);
+ field_org_address_country->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_org_address_country);
auto field_org_address_postcode = std::make_shared<Field>();
field_org_address_postcode->set_name(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_POSTCODE);
field_org_address_postcode->set_title_original(_("Zip Code"));
- field_org_address_postcode->set_glom_type(Field::TYPE_TEXT);
+ field_org_address_postcode->set_glom_type(Field::glom_field_type::TEXT);
fields.push_back(field_org_address_postcode);
return prefs_table_info;
@@ -1705,21 +1705,21 @@ AppState::userlevels Document::get_userlevel() const
AppState::userlevels Document::get_userlevel(userLevelReason& reason) const
{
//Initialize output parameter:
- reason = USER_LEVEL_REASON_UNKNOWN;
+ reason = userLevelReason::UNKNOWN;
if(get_read_only())
{
- reason = USER_LEVEL_REASON_FILE_READ_ONLY;
- return AppState::USERLEVEL_OPERATOR; //A read-only document cannot be changed, so there's no point in
being in developer mode. This is one way to control the user level on purpose.
+ reason = userLevelReason::FILE_READ_ONLY;
+ return AppState::userlevels::OPERATOR; //A read-only document cannot be changed, so there's no point in
being in developer mode. This is one way to control the user level on purpose.
}
else if(get_opened_from_browse())
{
- reason = USER_LEVEL_REASON_OPENED_FROM_BROWSE;
- return AppState::USERLEVEL_OPERATOR; //Developer mode would require changes to the original document.
+ reason = userLevelReason::OPENED_FROM_BROWSE;
+ return AppState::userlevels::OPERATOR; //Developer mode would require changes to the original document.
}
else if(m_file_uri.empty()) //If it has never been saved then this is a new default document, so the user
created it, so the user can be a developer.
{
- return AppState::USERLEVEL_DEVELOPER;
+ return AppState::userlevels::DEVELOPER;
}
else
{
@@ -1740,18 +1740,18 @@ void Document::on_app_state_userlevel_changed(AppState::userlevels userlevel)
bool Document::set_userlevel(AppState::userlevels userlevel)
{
//Prevent incorrect user level:
- if((userlevel == AppState::USERLEVEL_DEVELOPER) && get_read_only())
+ if((userlevel == AppState::userlevels::DEVELOPER) && get_read_only())
{
std::cout << "debug: " << G_STRFUNC << ": Developer mode denied because get_read_only() returned true."
<< std::endl;
std::cout << " DEBUG: get_read_only()=" << get_read_only() << std::endl;
std::cout << " DEBUG: get_file_uri()=" << get_file_uri() << std::endl;
- m_app_state.set_userlevel(AppState::USERLEVEL_OPERATOR);
+ m_app_state.set_userlevel(AppState::userlevels::OPERATOR);
return false;
}
else if(get_opened_from_browse())
{
- m_app_state.set_userlevel(AppState::USERLEVEL_OPERATOR);
+ m_app_state.set_userlevel(AppState::userlevels::OPERATOR);
return false;
}
@@ -1833,7 +1833,7 @@ void Document::save_changes()
{
//Save changes automatically
//(when in developer mode - no changes should even be possible when not in developer mode)
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() == AppState::userlevels::DEVELOPER)
{
//This rebuilds the whole XML DOM and saves the whole document,
//so we need to be careful not to call set_modified() too often.
@@ -1851,7 +1851,7 @@ void Document::save_changes()
}
else
{
- //std::cout << "debug: " << G_STRFUNC << ": Not saving, because not AppState::USERLEVEL_DEVELOPER" <<
std::endl;
+ //std::cout << "debug: " << G_STRFUNC << ": Not saving, because not AppState::userlevels::DEVELOPER" <<
std::endl;
}
}
@@ -1865,7 +1865,7 @@ void Document::set_modified(bool value)
return;
}
- if(get_userlevel() != AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() != AppState::userlevels::DEVELOPER)
{
//Some things can be legitimately changed by the user,
//such as field information from the server,
@@ -1902,7 +1902,7 @@ void Document::load_after_layout_item_formatting(const xmlpp::Element* element,
auto field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
- Field::glom_field_type field_type = Field::TYPE_INVALID;
+ Field::glom_field_type field_type = Field::glom_field_type::INVALID;
if(field)
field_type = field->get_glom_type();
@@ -1916,7 +1916,7 @@ void Document::load_after_layout_item_formatting(const xmlpp::Element* element,
void Document::load_after_layout_item_formatting(const xmlpp::Element* element, Formatting& format,
Field::glom_field_type field_type, const Glib::ustring& table_name, const Glib::ustring& field_name)
{
//Numeric formatting:
- if(!field_name.empty() && (field_type == Field::TYPE_NUMERIC))
+ if(!field_name.empty() && (field_type == Field::glom_field_type::NUMERIC))
{
format.m_numeric_format.m_use_thousands_separator = XmlUtils::get_node_attribute_value_as_bool(element,
GLOM_ATTRIBUTE_FORMAT_THOUSANDS_SEPARATOR);
format.m_numeric_format.m_decimal_places_restricted =
XmlUtils::get_node_attribute_value_as_bool(element, GLOM_ATTRIBUTE_FORMAT_DECIMAL_PLACES_RESTRICTED);
@@ -1927,7 +1927,7 @@ void Document::load_after_layout_item_formatting(const xmlpp::Element* element,
}
//Text formatting:
- if(field_type == Field::TYPE_TEXT)
+ if(field_type == Field::glom_field_type::TEXT)
{
format.set_text_format_multiline( XmlUtils::get_node_attribute_value_as_bool(element,
GLOM_ATTRIBUTE_FORMAT_TEXT_MULTILINE) );
format.set_text_format_multiline_height_lines( XmlUtils::get_node_attribute_value_as_decimal(element,
@@ -1939,12 +1939,12 @@ void Document::load_after_layout_item_formatting(const xmlpp::Element* element,
format.set_text_format_color_background( XmlUtils::get_node_attribute_value (element,
GLOM_ATTRIBUTE_FORMAT_TEXT_COLOR_BACKGROUND) );
//Alignment. Not-specified means auto.
- Formatting::HorizontalAlignment alignment = Formatting::HORIZONTAL_ALIGNMENT_AUTO;
+ Formatting::HorizontalAlignment alignment = Formatting::HorizontalAlignment::AUTO;
const auto alignment_str = XmlUtils::get_node_attribute_value (element,
GLOM_ATTRIBUTE_FORMAT_HORIZONTAL_ALIGNMENT);
if(alignment_str == GLOM_ATTRIBUTE_FORMAT_HORIZONTAL_ALIGNMENT_LEFT)
- alignment = Formatting::HORIZONTAL_ALIGNMENT_LEFT;
+ alignment = Formatting::HorizontalAlignment::LEFT;
else if(alignment_str == GLOM_ATTRIBUTE_FORMAT_HORIZONTAL_ALIGNMENT_RIGHT)
- alignment = Formatting::HORIZONTAL_ALIGNMENT_RIGHT;
+ alignment = Formatting::HorizontalAlignment::RIGHT;
format.set_horizontal_alignment(alignment);
@@ -1968,7 +1968,7 @@ void Document::load_after_layout_item_formatting(const xmlpp::Element* element,
const auto element_custom_choices = dynamic_cast<const xmlpp::Element*>(node_choices);
if(element_custom_choices)
{
- if(field_type == Field::TYPE_INVALID)
+ if(field_type == Field::glom_field_type::INVALID)
{
//Discover the field type, so we can interpret the text as a value.
//Not all calling functions know this, so they don't all supply the correct value.
@@ -2221,13 +2221,13 @@ void Document::load_after_layout_group(const xmlpp::Element* node, const Glib::u
const auto nodeValue = XmlUtils::get_node_child_named(element, GLOM_NODE_VALUE);
if(nodeValue)
{
- value_image = XmlUtils::get_node_text_child_as_value(nodeValue, Field::TYPE_IMAGE);
+ value_image = XmlUtils::get_node_text_child_as_value(nodeValue, Field::glom_field_type::IMAGE);
}
if(value_image.is_null())
{
//Try the deprecated way:
- value_image = XmlUtils::get_node_attribute_value_as_value(element,
GLOM_ATTRIBUTE_DATA_LAYOUT_IMAGEOBJECT_IMAGE, Field::TYPE_IMAGE);
+ value_image = XmlUtils::get_node_attribute_value_as_value(element,
GLOM_ATTRIBUTE_DATA_LAYOUT_IMAGEOBJECT_IMAGE, Field::glom_field_type::IMAGE);
}
item->set_image(value_image);
@@ -2314,11 +2314,11 @@ void Document::load_after_layout_group(const xmlpp::Element* node, const Glib::u
if(navigation_type_as_string.empty() ||
navigation_type_as_string == GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE_AUTOMATIC)
{
- portal->set_navigation_type(LayoutItem_Portal::NAVIGATION_AUTOMATIC);
+ portal->set_navigation_type(LayoutItem_Portal::navigation_type::AUTOMATIC);
}
else if(navigation_type_as_string == GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE_NONE)
{
- portal->set_navigation_type(LayoutItem_Portal::NAVIGATION_NONE);
+ portal->set_navigation_type(LayoutItem_Portal::navigation_type::NONE);
}
else if(navigation_type_as_string == GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE_SPECIFIC)
{
@@ -2558,7 +2558,7 @@ bool Document::load_after(int& failure_code)
if(m_document_format_version > get_latest_known_document_format_version())
{
std::cerr << G_STRFUNC << ": Loading failed because format_version=" << m_document_format_version <<
", but latest known format version is " << get_latest_known_document_format_version() << std::endl;
- failure_code = LOAD_FAILURE_CODE_FILE_VERSION_TOO_NEW;
+ failure_code = static_cast<int>(load_failure_codes::FILE_VERSION_TOO_NEW);
return false;
}
@@ -2601,27 +2601,27 @@ bool Document::load_after(int& failure_code)
const auto attr_mode = XmlUtils::get_node_attribute_value(nodeConnection,
GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE);
- HostingMode mode = HOSTING_MODE_DEFAULT;
+ HostingMode mode = HostingMode::DEFAULT;
if(attr_mode.empty())
{
// If no hosting mode is set, then try the self_hosted flag which
// was used before sqlite support was implemented.
const auto self_hosted = XmlUtils::get_node_attribute_value_as_bool(nodeConnection,
GLOM_ATTRIBUTE_CONNECTION_SELF_HOSTED);
- mode = self_hosted ? HOSTING_MODE_POSTGRES_SELF : HOSTING_MODE_POSTGRES_CENTRAL;
+ mode = self_hosted ? HostingMode::POSTGRES_SELF : HostingMode::POSTGRES_CENTRAL;
}
else
{
if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_CENTRAL)
- mode = HOSTING_MODE_POSTGRES_CENTRAL;
+ mode = HostingMode::POSTGRES_CENTRAL;
else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_SELF)
- mode = HOSTING_MODE_POSTGRES_SELF;
+ mode = HostingMode::POSTGRES_SELF;
else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE)
- mode = HOSTING_MODE_SQLITE;
+ mode = HostingMode::SQLITE;
else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_MYSQL_CENTRAL)
- mode = HOSTING_MODE_MYSQL_CENTRAL;
+ mode = HostingMode::MYSQL_CENTRAL;
else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_MYSQL_SELF)
- mode = HOSTING_MODE_MYSQL_SELF;
+ mode = HostingMode::MYSQL_SELF;
else
{
std::cerr << G_STRFUNC << ": Hosting mode " << attr_mode << " is not supported" << std::endl;
@@ -2730,7 +2730,7 @@ bool Document::load_after(int& failure_code)
const auto field_type = XmlUtils::get_node_attribute_value(node_field, GLOM_ATTRIBUTE_TYPE);
//Get the type enum for this string representation of the type:
- Field::glom_field_type field_type_enum = Field::TYPE_INVALID;
+ Field::glom_field_type field_type_enum = Field::glom_field_type::INVALID;
for(const auto& type_pair : type_names)
{
if(type_pair.second == field_type)
@@ -3089,7 +3089,7 @@ void Document::save_before_layout_item_formatting(xmlpp::Element* nodeItem, cons
std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const
LayoutItem_Field>(layout_item);
- Field::glom_field_type field_type = Field::TYPE_INVALID;
+ Field::glom_field_type field_type = Field::glom_field_type::INVALID;
if(field)
field_type = field->get_glom_type();
@@ -3099,9 +3099,9 @@ void Document::save_before_layout_item_formatting(xmlpp::Element* nodeItem, cons
void Document::save_before_layout_item_formatting(xmlpp::Element* nodeItem, const Formatting& format,
Field::glom_field_type field_type)
{
//Numeric format:
- if(field_type != Field::TYPE_INVALID) //These options are only for fields:
+ if(field_type != Field::glom_field_type::INVALID) //These options are only for fields:
{
- if(field_type == Field::TYPE_NUMERIC)
+ if(field_type == Field::glom_field_type::NUMERIC)
{
XmlUtils::set_node_attribute_value_as_bool(nodeItem, GLOM_ATTRIBUTE_FORMAT_THOUSANDS_SEPARATOR,
format.m_numeric_format.m_use_thousands_separator);
XmlUtils::set_node_attribute_value_as_bool(nodeItem, GLOM_ATTRIBUTE_FORMAT_DECIMAL_PLACES_RESTRICTED,
format.m_numeric_format.m_decimal_places_restricted);
@@ -3119,7 +3119,7 @@ void Document::save_before_layout_item_formatting(xmlpp::Element* nodeItem, cons
}
//Text formatting:
- if(field_type == Field::TYPE_TEXT)
+ if(field_type == Field::glom_field_type::TEXT)
{
XmlUtils::set_node_attribute_value_as_bool(nodeItem, GLOM_ATTRIBUTE_FORMAT_TEXT_MULTILINE,
format.get_text_format_multiline());
XmlUtils::set_node_attribute_value_as_decimal(nodeItem,
GLOM_ATTRIBUTE_FORMAT_TEXT_MULTILINE_HEIGHT_LINES,
@@ -3132,15 +3132,15 @@ void Document::save_before_layout_item_formatting(xmlpp::Element* nodeItem, cons
//Alignment:
const auto alignment = format.get_horizontal_alignment();
- if(alignment != Formatting::HORIZONTAL_ALIGNMENT_AUTO) //Save file-size by not even writing this.
+ if(alignment != Formatting::HorizontalAlignment::AUTO) //Save file-size by not even writing this.
{
const Glib::ustring alignment_str =
- (alignment == Formatting::HORIZONTAL_ALIGNMENT_LEFT ? GLOM_ATTRIBUTE_FORMAT_HORIZONTAL_ALIGNMENT_LEFT
: GLOM_ATTRIBUTE_FORMAT_HORIZONTAL_ALIGNMENT_RIGHT);
+ (alignment == Formatting::HorizontalAlignment::LEFT ? GLOM_ATTRIBUTE_FORMAT_HORIZONTAL_ALIGNMENT_LEFT
: GLOM_ATTRIBUTE_FORMAT_HORIZONTAL_ALIGNMENT_RIGHT);
XmlUtils::set_node_attribute_value(nodeItem, GLOM_ATTRIBUTE_FORMAT_HORIZONTAL_ALIGNMENT, alignment_str);
}
//Choices:
- if(field_type != Field::TYPE_INVALID)
+ if(field_type != Field::glom_field_type::INVALID)
{
if(format.get_has_custom_choices())
{
@@ -3321,13 +3321,13 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
switch(portal->get_navigation_type())
{
- case LayoutItem_Portal::NAVIGATION_AUTOMATIC:
+ case LayoutItem_Portal::navigation_type::AUTOMATIC:
//We leave this blank to use the default.
break;
- case LayoutItem_Portal::NAVIGATION_NONE:
+ case LayoutItem_Portal::navigation_type::NONE:
navigation_type_string = GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE_NONE;
break;
- case LayoutItem_Portal::NAVIGATION_SPECIFIC:
+ case LayoutItem_Portal::navigation_type::SPECIFIC:
navigation_type_string = GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE_SPECIFIC;
break;
default:
@@ -3465,7 +3465,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
save_before_translations(nodeItem, imageobject);
xmlpp::Element* nodeValue = nodeItem->add_child(GLOM_NODE_VALUE);
- XmlUtils::set_node_text_child_as_value(nodeValue, imageobject->get_image(),
Field::TYPE_IMAGE);
+ XmlUtils::set_node_text_child_as_value(nodeValue, imageobject->get_image(),
Field::glom_field_type::IMAGE);
}
else
{
@@ -3624,23 +3624,23 @@ bool Document::save_before()
switch(m_hosting_mode)
{
- case HOSTING_MODE_POSTGRES_CENTRAL:
+ case HostingMode::POSTGRES_CENTRAL:
XmlUtils::set_node_attribute_value(nodeConnection,
GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_CENTRAL);
break;
- case HOSTING_MODE_POSTGRES_SELF:
+ case HostingMode::POSTGRES_SELF:
XmlUtils::set_node_attribute_value(nodeConnection,
GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_SELF);
break;
- case HOSTING_MODE_SQLITE:
+ case HostingMode::SQLITE:
XmlUtils::set_node_attribute_value(nodeConnection,
GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE);
break;
- case HOSTING_MODE_MYSQL_CENTRAL:
+ case HostingMode::MYSQL_CENTRAL:
XmlUtils::set_node_attribute_value(nodeConnection,
GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MYSQL_CENTRAL);
break;
- case HOSTING_MODE_MYSQL_SELF:
+ case HostingMode::MYSQL_SELF:
XmlUtils::set_node_attribute_value(nodeConnection,
GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MYSQL_SELF);
break;
@@ -4390,7 +4390,7 @@ Document::type_list_translatables Document::get_translatable_items()
add_to_translatable_list(result, field, hint);
//Custom Choices, if any:
- if(field->get_glom_type() == Field::TYPE_TEXT) //Choices for other field types could not be translated.
+ if(field->get_glom_type() == Field::glom_field_type::TEXT) //Choices for other field types could not
be translated.
{
const auto this_hint = hint + ", Parent Field: " + field->get_name();
type_list_translatables list_choice_items;
@@ -4513,7 +4513,7 @@ void Document::fill_translatable_layout_items(const std::shared_ptr<LayoutItem_F
//Custom Choices, if any:
//Only text fields can have translated choice values:
- if(layout_field->get_glom_type() == Field::TYPE_TEXT)
+ if(layout_field->get_glom_type() == Field::glom_field_type::TEXT)
{
const auto choice_hint = hint + ", Parent Field: " + layout_field->get_name();
fill_translatable_custom_choices(layout_field->m_formatting, the_list, hint);
@@ -4719,7 +4719,7 @@ void Document::set_opened_from_browse(bool val)
//This should stop developer mode from being possible,
//because we don't have access to the document:
if(!val)
- m_app_state.set_userlevel(AppState::USERLEVEL_OPERATOR);
+ m_app_state.set_userlevel(AppState::userlevels::OPERATOR);
}
bool Document::get_opened_from_browse() const
diff --git a/glom/libglom/document/document.h b/glom/libglom/document/document.h
index 2e9c2e1..05bd723 100644
--- a/glom/libglom/document/document.h
+++ b/glom/libglom/document/document.h
@@ -105,14 +105,14 @@ public:
static guint get_latest_known_document_format_version();
/// How the database is hosted.
- enum HostingMode
+ enum class HostingMode
{
- HOSTING_MODE_POSTGRES_CENTRAL, /*!< The database is hosted on an external PostgreSQL server. */
- HOSTING_MODE_POSTGRES_SELF, /*!< A new PostgreSQL database process is spawned that hosts the data. */
- HOSTING_MODE_SQLITE, /*!< A sqlite database file is used. */
- HOSTING_MODE_MYSQL_CENTRAL, /*!< The database is hosted on an external MySQL server. */
- HOSTING_MODE_MYSQL_SELF, /*!< A new MySQL database process is spawned that hosts the data. */
- HOSTING_MODE_DEFAULT = HOSTING_MODE_POSTGRES_SELF /*!- Arbitrary default. */
+ POSTGRES_CENTRAL, /*!< The database is hosted on an external PostgreSQL server. */
+ POSTGRES_SELF, /*!< A new PostgreSQL database process is spawned that hosts the data. */
+ SQLITE, /*!< A sqlite database file is used. */
+ MYSQL_CENTRAL, /*!< The database is hosted on an external MySQL server. */
+ MYSQL_SELF, /*!< A new MySQL database process is spawned that hosts the data. */
+ DEFAULT = HostingMode::POSTGRES_SELF /*!- Arbitrary default. */
};
/** Set the hosting mode of the database.
@@ -412,12 +412,12 @@ public:
*/
void set_table_overview_position( const Glib::ustring& utable_name, float x, float y );
- enum userLevelReason
+ enum class userLevelReason
{
- USER_LEVEL_REASON_UNKNOWN,
- USER_LEVEL_REASON_FILE_READ_ONLY,
- USER_LEVEL_REASON_DATABASE_ACCESS_LEVEL,
- USER_LEVEL_REASON_OPENED_FROM_BROWSE
+ UNKNOWN,
+ FILE_READ_ONLY,
+ DATABASE_ACCESS_LEVEL,
+ OPENED_FROM_BROWSE
};
/**
@@ -489,9 +489,9 @@ public:
#endif //SWIG
/// Failure codes that could be returned by load_after()
- enum load_failure_codes
+ enum class load_failure_codes
{
- LOAD_FAILURE_CODE_FILE_VERSION_TOO_NEW = LOAD_FAILURE_CODE_LAST + 1
+ FILE_VERSION_TOO_NEW = static_cast<int>(LoadFailureCodes::LAST) + 1
};
private:
@@ -502,7 +502,7 @@ private:
void save_before_sort_by(xmlpp::Element* node, const LayoutItem_GroupBy::type_list_sort_fields&
list_fields);
void save_before_layout_item_usesrelationship(xmlpp::Element* nodeItem, const std::shared_ptr<const
UsesRelationship>& item);
void save_before_layout_item_field(xmlpp::Element* nodeItem, const std::shared_ptr<const
LayoutItem_Field>& item);
- void save_before_layout_item_formatting(xmlpp::Element* nodeItem, const Formatting& format,
Field::glom_field_type field_type = Field::TYPE_INVALID);
+ void save_before_layout_item_formatting(xmlpp::Element* nodeItem, const Formatting& format,
Field::glom_field_type field_type = Field::glom_field_type::INVALID);
void save_before_layout_item_formatting(xmlpp::Element* nodeItem, const std::shared_ptr<const
LayoutItem_WithFormatting>& layout_item);
void save_before_translations(xmlpp::Element* nodeItem, const std::shared_ptr<const TranslatableItem>&
item);
@@ -516,7 +516,7 @@ private:
void load_after_sort_by(const xmlpp::Element* node, const Glib::ustring& table_name,
LayoutItem_GroupBy::type_list_sort_fields& list_fields);
void load_after_layout_item_usesrelationship(const xmlpp::Element* element, const Glib::ustring&
table_name, const std::shared_ptr<UsesRelationship>& item);
void load_after_layout_item_field(const xmlpp::Element* element, const Glib::ustring& table_name, const
std::shared_ptr<LayoutItem_Field>& item);
- void load_after_layout_item_formatting(const xmlpp::Element* element, Formatting& format,
Field::glom_field_type field_type = Field::TYPE_INVALID, const Glib::ustring& table_name = Glib::ustring(),
const Glib::ustring& field_name = Glib::ustring());
+ void load_after_layout_item_formatting(const xmlpp::Element* element, Formatting& format,
Field::glom_field_type field_type = Field::glom_field_type::INVALID, const Glib::ustring& table_name =
Glib::ustring(), const Glib::ustring& field_name = Glib::ustring());
void load_after_layout_item_formatting(const xmlpp::Element* element, const
std::shared_ptr<LayoutItem_WithFormatting>& layout_item, const Glib::ustring& table_name = Glib::ustring());
void load_after_translations(const xmlpp::Element* element, const std::shared_ptr<TranslatableItem>& item);
diff --git a/glom/libglom/privs.cc b/glom/libglom/privs.cc
index 1520cea..f394d2f 100644
--- a/glom/libglom/privs.cc
+++ b/glom/libglom/privs.cc
@@ -93,8 +93,8 @@ Glib::ustring Privs::get_default_developer_user_name(Glib::ustring& password, Do
{
password = "glom_default_developer_password";
- if((hosting_mode == Document::HOSTING_MODE_MYSQL_CENTRAL) ||
- (hosting_mode == Document::HOSTING_MODE_MYSQL_SELF))
+ if((hosting_mode == Document::HostingMode::MYSQL_CENTRAL) ||
+ (hosting_mode == Document::HostingMode::MYSQL_SELF))
{
return "glom_dev_user"; //MySQL restricts user names to 16 characters.
}
diff --git a/glom/libglom/privs.h b/glom/libglom/privs.h
index 8641732..39c5e60 100644
--- a/glom/libglom/privs.h
+++ b/glom/libglom/privs.h
@@ -37,10 +37,7 @@ public:
* with more characters (or bytes?) than this then
* a truncated version of it will be read back.
*/
- enum constant
- {
- MAX_ROLE_SIZE = 63
- };
+ static const guint MAX_ROLE_SIZE = 63;
/** Get the groups with access to the database.
*/
diff --git a/glom/libglom/report_builder.cc b/glom/libglom/report_builder.cc
index b5abd7a..624050f 100644
--- a/glom/libglom/report_builder.cc
+++ b/glom/libglom/report_builder.cc
@@ -348,7 +348,7 @@ bool ReportBuilder::report_build_records(const FoundSet& found_set, xmlpp::Eleme
//This adds a field heading (and therefore, column) for fields, or for a vertical group.
xmlpp::Element* nodeFieldHeading = parent_node.add_child("field_heading");
- if(layoutitem_field && layoutitem_field->get_glom_type() == Field::TYPE_NUMERIC)
+ if(layoutitem_field && layoutitem_field->get_glom_type() == Field::glom_field_type::NUMERIC)
nodeFieldHeading->set_attribute("field_type", "numeric"); //TODO: More sophisticated formatting.
nodeFieldHeading->set_attribute("name", layout_item->get_name()); //Not really necessary, but maybe
useful.
@@ -454,7 +454,7 @@ bool ReportBuilder::report_build_records_field(const FoundSet& found_set, xmlpp:
const auto field_type = field->get_glom_type();
xmlpp::Element* nodeField = nodeParent.add_child(field->get_report_part_id());
- if(field_type == Field::TYPE_NUMERIC)
+ if(field_type == Field::glom_field_type::NUMERIC)
nodeField->set_attribute("field_type", "numeric"); //TODO: More sophisticated formatting.
if(vertical)
@@ -489,14 +489,14 @@ bool ReportBuilder::report_build_records_field(const FoundSet& found_set, xmlpp:
nodeField->set_attribute("title", field->get_title_or_name(m_locale_id)); //Not always used, but useful.
//Handle the value:
- if(field_type == Field::TYPE_IMAGE)
+ if(field_type == Field::glom_field_type::IMAGE)
nodeField->set_attribute("image_uri", Utils::create_local_image_uri(value));
else
{
Glib::ustring text_value = Conversions::get_text_for_gda_value(field_type, value, m_locale,
field->get_formatting_used().m_numeric_format);
//The Postgres summary functions return NULL when summarising NULL records, but 0 is more sensible:
- if(text_value.empty() && std::dynamic_pointer_cast<const LayoutItem_FieldSummary>(field) && (field_type
== Field::TYPE_NUMERIC))
+ if(text_value.empty() && std::dynamic_pointer_cast<const LayoutItem_FieldSummary>(field) && (field_type
== Field::glom_field_type::NUMERIC))
{
//Use get_text_for_gda_value() instead of "0" so we get the correct numerical formatting:
const auto value_zero = Conversions::parse_value(0);
diff --git a/glom/libglom/test_avahi_publisher.cc b/glom/libglom/test_avahi_publisher.cc
index a5cc1d6..ed1cd42 100644
--- a/glom/libglom/test_avahi_publisher.cc
+++ b/glom/libglom/test_avahi_publisher.cc
@@ -28,7 +28,7 @@ private:
TestWindow::TestWindow()
-: m_box(Gtk::ORIENTATION_VERTICAL, Glom::UiUtils::DEFAULT_SPACING_SMALL),
+: m_box(Gtk::ORIENTATION_VERTICAL, static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL)),
m_button_start("Start"),
m_button_stop("Stop"),
m_avahi_publisher(nullptr)
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index 44f4d7a..7b74ede 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -1123,7 +1123,7 @@ Gnome::Gda::SqlExpr Utils::get_find_where_clause_quick(const Document* document,
Glib::ustring strClausePart;
bool use_this_field = true;
- if(field->get_glom_type() != Field::TYPE_TEXT)
+ if(field->get_glom_type() != Field::glom_field_type::TEXT)
{
use_this_field = false;
}
diff --git a/glom/libglom/xml_utils.cc b/glom/libglom/xml_utils.cc
index 1d7aa14..e6a845f 100644
--- a/glom/libglom/xml_utils.cc
+++ b/glom/libglom/xml_utils.cc
@@ -225,7 +225,7 @@ void set_node_text_child_as_value(xmlpp::Element* node, const Gnome::Gda::Value&
const auto value_as_text = Field::to_file_format(value, field_type);
node->set_child_text( Utils::string_clean_for_xml(value_as_text) );
- if(field_type == Field::TYPE_IMAGE)
+ if(field_type == Field::glom_field_type::IMAGE)
{
set_node_attribute_value(node, GLOM_ATTRIBUTE_IMAGE_DATA_FORMAT,
GLOM_ATTRIBUTE_IMAGE_DATA_FORMAT_BASE64);
}
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index bf98afa..76d487c 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -109,7 +109,7 @@ Gnome::Gda::SqlExpr Box_Data::get_find_where_clause() const
if(field)
{
bool use_this_field = true;
- if(field->get_glom_type() == Field::TYPE_BOOLEAN) //TODO: We need an intermediate state for boolean
fields, so that they can be ignored in searches.
+ if(field->get_glom_type() == Field::glom_field_type::BOOLEAN) //TODO: We need an intermediate state
for boolean fields, so that they can be ignored in searches.
{
if(!data.get_boolean())
use_this_field = false;
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index fb46ed8..1e25ad8 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -39,8 +39,8 @@ Box_Data_Calendar_Related::Box_Data_Calendar_Related()
set_size_request(400, -1); //An arbitrary default.
m_Frame.add(m_calendar);
- m_calendar.set_margin_start(UiUtils::DEFAULT_SPACING_LARGE);
- m_calendar.set_margin_top(UiUtils::DEFAULT_SPACING_SMALL);
+ m_calendar.set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
+ m_calendar.set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
m_calendar.show();
//m_calendar.set_show_details();
@@ -101,8 +101,8 @@ bool Box_Data_Calendar_Related::init_db_details(const Glib::ustring& parent_tabl
m_Label.set_markup(UiUtils::bold_message(title));
m_Label.show();
- m_calendar.set_margin_start(UiUtils::DEFAULT_SPACING_LARGE);
- m_calendar.set_margin_top(UiUtils::DEFAULT_SPACING_SMALL);
+ m_calendar.set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
+ m_calendar.set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
}
else
{
@@ -533,7 +533,7 @@ void Box_Data_Calendar_Related::setup_menu(Gtk::Widget* /* this */)
#ifndef GLOM_ENABLE_CLIENT_ONLY
if(pApp)
- m_refContextLayout->set_enabled(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER);
+ m_refContextLayout->set_enabled(pApp->get_userlevel() == AppState::userlevels::DEVELOPER);
#endif // !GLOM_ENABLE_CLIENT_ONLY
}
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index f86d2dd..a6ae6f2 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -40,7 +40,7 @@ namespace Glom
{
Box_Data_Details::Box_Data_Details(bool bWithNavButtons /* = true */)
-: m_hbox_content(Gtk::ORIENTATION_HORIZONTAL, UiUtils::DEFAULT_SPACING_SMALL),
+: m_hbox_content(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
m_show_toolbar(false),
m_hbox_buttons(Gtk::ORIENTATION_HORIZONTAL),
m_Button_New(_("_Add"), true),
@@ -58,19 +58,19 @@ Box_Data_Details::Box_Data_Details(bool bWithNavButtons /* = true */)
m_layout_name = "details";
m_hbox_buttons.set_layout(Gtk::BUTTONBOX_END);
- m_hbox_buttons.set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ m_hbox_buttons.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
add_view(&m_FlowTable); //Allow this to access the document too.
m_FlowTable.set_lines(1); //Sub-groups will have multiple columns (by default, there is one sub-group,
with 2 columns).
- m_FlowTable.set_horizontal_spacing(UiUtils::DEFAULT_SPACING_SMALL); //The default anyway.
- m_FlowTable.set_vertical_spacing(UiUtils::DEFAULT_SPACING_SMALL); //The default anyway.
+ m_FlowTable.set_horizontal_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL)); //The default
anyway.
+ m_FlowTable.set_vertical_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL)); //The default anyway.
//m_strHint = _("When you change the data in a field the database is updated immediately.\n Click [New] to
add a new record.\n Leave automatic ID fields empty - they will be filled for you.");
- //m_ScrolledWindow.set_border_width(UiUtils::DEFAULT_SPACING_SMALL);
+ //m_ScrolledWindow.set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
// Allow vertical scrolling, but never scroll horizontally:
m_ScrolledWindow.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
@@ -901,7 +901,7 @@ void Box_Data_Details::on_flowtable_field_choices_changed(const std::shared_ptr<
void Box_Data_Details::on_userlevel_changed(AppState::userlevels user_level)
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
- m_design_mode = ( user_level == AppState::USERLEVEL_DEVELOPER );
+ m_design_mode = ( user_level == AppState::userlevels::DEVELOPER );
m_FlowTable.set_design_mode(m_design_mode);
// Recreate the layout to correctly set the size of empty flowtables:
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 16b85e8..7268664 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -61,7 +61,7 @@ void Box_Data_List_Related::enable_buttons()
{
const bool view_details_possible =
get_has_suitable_record_to_view_details() &&
- (m_portal->get_navigation_type() != LayoutItem_Portal::NAVIGATION_NONE);
+ (m_portal->get_navigation_type() != LayoutItem_Portal::navigation_type::NONE);
// Don't allow the user to go to a record in a hidden table.
// Unless we are on Maemo - then we want to allow editing in a separate window only.
@@ -102,8 +102,8 @@ bool Box_Data_List_Related::init_db_details(const Glib::ustring& parent_table, b
if(!(m_Frame.get_label_widget()))
m_Frame.set_label_widget(m_Label);
- m_AddDel.set_margin_start(UiUtils::DEFAULT_SPACING_LARGE);
- m_AddDel.set_margin_top(UiUtils::DEFAULT_SPACING_SMALL);
+ m_AddDel.set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
+ m_AddDel.set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
}
else
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index def3e78..00575ef 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -43,8 +43,8 @@ Box_Data_Portal::Box_Data_Portal()
m_Label.show();
//The AddDel or Calendar is added to this:
- //They must use child.set_margin_start(UiUtils::DEFAULT_SPACING_LARGE) and
- //child.set_margin_top(UiUtils::DEFAULT_SPACING_SMALL);
+ //They must use child.set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE)) and
+ //child.set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
add(m_Frame);
m_layout_name = "list_portal"; //Replaced by derived classes.
diff --git a/glom/mode_data/buttonglom.cc b/glom/mode_data/buttonglom.cc
index e87d5fc..d76fc19 100644
--- a/glom/mode_data/buttonglom.cc
+++ b/glom/mode_data/buttonglom.cc
@@ -85,7 +85,7 @@ void ButtonGlom::on_menu_properties_activate()
bool ButtonGlom::on_button_press_event(GdkEventButton *button_event)
{
AppWindow* pApp = get_appwindow();
- if(pApp && pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp && pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0, 0,
&mods );
diff --git a/glom/mode_data/datawidget/cellcreation.cc b/glom/mode_data/datawidget/cellcreation.cc
index ff7dfe1..47d7cc3 100644
--- a/glom/mode_data/datawidget/cellcreation.cc
+++ b/glom/mode_data/datawidget/cellcreation.cc
@@ -47,7 +47,7 @@ static void apply_formatting(Gtk::CellRenderer* renderer, const std::shared_ptr<
//Horizontal alignment:
const Formatting::HorizontalAlignment alignment =
layout_item->get_formatting_used_horizontal_alignment();
- const float x_align = (alignment == Formatting::HORIZONTAL_ALIGNMENT_LEFT ? 0.0 : 1.0);
+ const float x_align = (alignment == Formatting::HorizontalAlignment::LEFT ? 0.0 : 1.0);
text_renderer->property_xalign() = x_align;
const auto formatting = layout_item->get_formatting_used();
@@ -84,13 +84,13 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
switch(item_field->get_glom_type())
{
- case(Field::TYPE_BOOLEAN):
+ case(Field::glom_field_type::BOOLEAN):
{
cell = Gtk::manage( new Gtk::CellRendererToggle() );
break;
}
- case(Field::TYPE_IMAGE):
+ case(Field::glom_field_type::IMAGE):
{
cell = Gtk::manage( new Gtk::CellRendererPixbuf() );
diff --git a/glom/mode_data/datawidget/cellrenderer_dblist.cc
b/glom/mode_data/datawidget/cellrenderer_dblist.cc
index 2501a29..947f7be 100644
--- a/glom/mode_data/datawidget/cellrenderer_dblist.cc
+++ b/glom/mode_data/datawidget/cellrenderer_dblist.cc
@@ -245,7 +245,7 @@ void CellRendererDbList::set_value(const Gnome::Gda::Value& value)
//Show a different color if the value is numeric, if that's specified:
/* TODO:
- if(layout_item->get_glom_type() == Field::TYPE_NUMERIC)
+ if(layout_item->get_glom_type() == Field::glom_field_type::NUMERIC)
{
std::vector<Gtk::CellRenderer*> cells = get_cells();
if(cells.empty())
diff --git a/glom/mode_data/datawidget/checkbutton.cc b/glom/mode_data/datawidget/checkbutton.cc
index c0f044d..7e5df2f 100644
--- a/glom/mode_data/datawidget/checkbutton.cc
+++ b/glom/mode_data/datawidget/checkbutton.cc
@@ -67,7 +67,7 @@ bool CheckButton::on_button_press_event(GdkEventButton *button_event)
//Only show this popup in developer mode, so operators still see the default GtkCheckButton context menu.
//TODO: It would be better to add it somehow to the standard context menu.
- if(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0,
0, &mods );
diff --git a/glom/mode_data/datawidget/combo.cc b/glom/mode_data/datawidget/combo.cc
index 603b836..945aecb 100644
--- a/glom/mode_data/datawidget/combo.cc
+++ b/glom/mode_data/datawidget/combo.cc
@@ -51,7 +51,7 @@ ComboGlom::ComboGlom(bool has_entry)
setup_menu(this);
#endif // !GLOM_ENABLE_CLIENT_ONLY
- //if(m_glom_type == Field::TYPE_NUMERIC)
+ //if(m_glom_type == Field::glom_field_type::NUMERIC)
// get_entry()->set_alignment(1.0); //Align numbers to the right.
//Let the combo be big enough:
@@ -141,7 +141,7 @@ void ComboGlom::set_choices_fixed(const Formatting::type_list_values& list_value
cell_area->pack_start(*cell, true /* expand */, true /* align */, true /* fixed */);
//Make the renderer render the column:
- if(restricted && field && (field->get_glom_type() == Field::TYPE_TEXT))
+ if(restricted && field && (field->get_glom_type() == Field::glom_field_type::TEXT))
{
//Use the translation instead:
add_attribute(*cell, "text", columns_count); //The extra text column.
@@ -272,7 +272,7 @@ void ComboGlom::set_value(const Gnome::Gda::Value& value)
m_ignore_changed = old_ignore;
//Show a different color if the value is numeric, if that's specified:
- if(layout_item->get_glom_type() == Field::TYPE_NUMERIC)
+ if(layout_item->get_glom_type() == Field::glom_field_type::NUMERIC)
{
std::vector<Gtk::CellRenderer*> cells = get_cells();
if(cells.empty())
@@ -329,7 +329,7 @@ g_warning("ComboGlom::on_button_press_event()");
//Only show this popup in developer mode, so operators still see the default GtkEntry context menu.
//TODO: It would be better to add it somehow to the standard context menu.
- if(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0,
0, &mods );
diff --git a/glom/mode_data/datawidget/combo_as_radio_buttons.cc
b/glom/mode_data/datawidget/combo_as_radio_buttons.cc
index cd38e6a..bef700a 100644
--- a/glom/mode_data/datawidget/combo_as_radio_buttons.cc
+++ b/glom/mode_data/datawidget/combo_as_radio_buttons.cc
@@ -48,7 +48,7 @@ ComboAsRadioButtons::ComboAsRadioButtons()
void ComboAsRadioButtons::init()
{
- //if(m_glom_type == Field::TYPE_NUMERIC)
+ //if(m_glom_type == Field::glom_field_type::NUMERIC)
// get_entry()->set_alignment(1.0); //Align numbers to the right.
}
@@ -210,7 +210,7 @@ void ComboAsRadioButtons::set_value(const Gnome::Gda::Value& value)
set_text(Conversions::get_text_for_gda_value(layout_item->get_glom_type(), value,
layout_item->get_formatting_used().m_numeric_format));
//Show a different color if the value is numeric, if that's specified:
- if(layout_item->get_glom_type() == Field::TYPE_NUMERIC)
+ if(layout_item->get_glom_type() == Field::glom_field_type::NUMERIC)
{
//TODO
}
@@ -276,7 +276,7 @@ void ComboAsRadioButtons::show_context_menu(GdkEventButton *button_event)
//Only show this popup in developer mode, so operators still see the default GtkEntry context menu.
//TODO: It would be better to add it somehow to the standard context menu.
- if(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0,
0, &mods );
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index 395fce7..973a44d 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -266,7 +266,7 @@ void ComboChoicesWithTreeModel::set_choices_related(const Document* document, co
Formatting::type_list_sort_fields choice_sort_fields;
bool choice_show_all = false;
format.get_choices_related(choice_relationship, layout_choice_first, layout_choice_extra,
choice_sort_fields, choice_show_all);
- if(layout_choice_first->get_glom_type() == Field::TYPE_INVALID)
+ if(layout_choice_first->get_glom_type() == Field::glom_field_type::INVALID)
std::cerr << G_STRFUNC << ": layout_choice_first has invalid type. field name: " <<
layout_choice_first->get_name() << std::endl;
//Set full field details, cloning the group to avoid the constness:
@@ -339,7 +339,7 @@ void ComboChoicesWithTreeModel::set_cell_for_field_value(Gtk::CellRenderer* cell
const auto type = field->get_glom_type();
switch(type)
{
- case(Field::TYPE_BOOLEAN):
+ case(Field::glom_field_type::BOOLEAN):
{
Gtk::CellRendererToggle* pDerived = dynamic_cast<Gtk::CellRendererToggle*>(cell);
if(pDerived)
@@ -347,7 +347,7 @@ void ComboChoicesWithTreeModel::set_cell_for_field_value(Gtk::CellRenderer* cell
break;
}
- case(Field::TYPE_IMAGE):
+ case(Field::glom_field_type::IMAGE):
{
Gtk::CellRendererPixbuf* pDerived = dynamic_cast<Gtk::CellRendererPixbuf*>(cell);
if(pDerived)
@@ -360,7 +360,7 @@ void ComboChoicesWithTreeModel::set_cell_for_field_value(Gtk::CellRenderer* cell
pDerived->property_pixbuf() = pixbuf;
}
else
- std::cerr << G_STRFUNC << ": Field::sql(): glom_type is TYPE_IMAGE but gda type is not
VALUE_TYPE_BINARY" << std::endl;
+ std::cerr << G_STRFUNC << ": Field::sql(): glom_type is enumType::IMAGE but gda type is not
VALUE_TYPE_BINARY" << std::endl;
break;
}
@@ -380,7 +380,7 @@ void ComboChoicesWithTreeModel::set_cell_for_field_value(Gtk::CellRenderer* cell
}
//Show a different color if the value is numeric, if that's specified:
- if(type == Field::TYPE_NUMERIC)
+ if(type == Field::glom_field_type::NUMERIC)
{
const Glib::ustring fg_color =
field->get_formatting_used().get_text_format_color_foreground_to_use(value);
diff --git a/glom/mode_data/datawidget/datawidget.cc b/glom/mode_data/datawidget/datawidget.cc
index abf7029..cda4cf5 100644
--- a/glom/mode_data/datawidget/datawidget.cc
+++ b/glom/mode_data/datawidget/datawidget.cc
@@ -74,7 +74,7 @@ DataWidget::DataWidget(const std::shared_ptr<LayoutItem_Field>& field, const Gli
m_child = 0;
LayoutWidgetField* pFieldWidget = nullptr;
- if(glom_type == Field::TYPE_BOOLEAN)
+ if(glom_type == Field::glom_field_type::BOOLEAN)
{
DataWidgetChildren::CheckButton* checkbutton = Gtk::manage( new DataWidgetChildren::CheckButton() );
checkbutton->show();
@@ -89,7 +89,7 @@ DataWidget::DataWidget(const std::shared_ptr<LayoutItem_Field>& field, const Gli
m_label.set_halign(Gtk::ALIGN_START);
m_label.show();
}
- else if(glom_type == Field::TYPE_IMAGE)
+ else if(glom_type == Field::glom_field_type::IMAGE)
{
ImageGlom* image = Gtk::manage( new ImageGlom() );
image->set_size_request(200, 200);
@@ -142,12 +142,12 @@ DataWidget::DataWidget(const std::shared_ptr<LayoutItem_Field>& field, const Gli
}
else
{
- if((glom_type == Field::TYPE_TEXT) && (field->get_formatting_used().get_text_format_multiline()))
+ if((glom_type == Field::glom_field_type::TEXT) &&
(field->get_formatting_used().get_text_format_multiline()))
{
DataWidgetChildren::TextView* textview = Gtk::manage(new DataWidgetChildren::TextView(glom_type));
pFieldWidget = textview;
}
- else //TYPE_DATE, TYPE_NUMBER, etc.
+ else //DATE, NUMBER, etc.
{
DataWidgetChildren::Entry* entry = Gtk::manage(new DataWidgetChildren::Entry(glom_type));
pFieldWidget = entry;
@@ -193,11 +193,11 @@ DataWidget::DataWidget(const std::shared_ptr<LayoutItem_Field>& field, const Gli
Gtk::Box* hbox_parent = nullptr; //Only used if there are extra widgets.
- const bool with_extra_widgets = field_used_in_relationship_to_one || add_open_button || (glom_type ==
Field::TYPE_DATE);
+ const bool with_extra_widgets = field_used_in_relationship_to_one || add_open_button || (glom_type ==
Field::glom_field_type::DATE);
if(with_extra_widgets)
{
hbox_parent = Gtk::manage( new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) ); //We put the child (and any
extra stuff) in this:
- hbox_parent->set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ hbox_parent->set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
hbox_parent->pack_start(*m_child);
hbox_parent->show();
@@ -206,7 +206,7 @@ DataWidget::DataWidget(const std::shared_ptr<LayoutItem_Field>& field, const Gli
child_added = true;
}
- if(glom_type == Field::TYPE_DATE)
+ if(glom_type == Field::glom_field_type::DATE)
{
//Let the user choose a date from a calendar dialog:
Gtk::Button* button_date = Gtk::manage(new Gtk::Button(_("..."))); //TODO: A better label/icon for
"Choose Date".
@@ -345,12 +345,12 @@ void DataWidget::set_child_size_by_field(const std::shared_ptr<const LayoutItem_
const auto glom_type = field->get_glom_type();
int width = get_suitable_width(field);
- if(glom_type == Field::TYPE_IMAGE) //GtkImage widgets default to no size (invisible) if they are empty.
+ if(glom_type == Field::glom_field_type::IMAGE) //GtkImage widgets default to no size (invisible) if they
are empty.
m_child->set_size_request(width, width);
else
{
int height = -1; //auto.
- if((glom_type == Field::TYPE_TEXT) && (field->get_formatting_used().get_text_format_multiline()))
+ if((glom_type == Field::glom_field_type::TEXT) &&
(field->get_formatting_used().get_text_format_multiline()))
{
int example_width = 0;
int example_height = 0;
@@ -439,7 +439,7 @@ bool DataWidget::on_button_press_event(GdkEventButton *button_event)
//Only show this popup in developer mode, so operators still see the default GtkEntry context menu.
//TODO: It would be better to add it somehow to the standard context menu.
- if(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0,
0, &mods );
diff --git a/glom/mode_data/datawidget/dialog_choose_id.cc b/glom/mode_data/datawidget/dialog_choose_id.cc
index e4ce6cb..b24b4be 100644
--- a/glom/mode_data/datawidget/dialog_choose_id.cc
+++ b/glom/mode_data/datawidget/dialog_choose_id.cc
@@ -40,7 +40,7 @@ Dialog_ChooseID::Dialog_ChooseID()
m_pButton_QuickFind(nullptr),
m_vbox_parent(nullptr),
m_document(nullptr),
- m_stage(STAGE_INVALID)
+ m_stage(enumStage::INVALID)
{
}
@@ -52,7 +52,7 @@ Dialog_ChooseID::Dialog_ChooseID(BaseObjectType* cobject, const Glib::RefPtr<Gtk
m_pButton_QuickFind(nullptr),
m_vbox_parent(nullptr),
m_document(nullptr),
- m_stage(STAGE_INVALID)
+ m_stage(enumStage::INVALID)
{
builder->get_widget("label_table_name", m_label_table_name);
builder->get_widget("vbox_parent", m_vbox_parent);
@@ -85,7 +85,7 @@ void Dialog_ChooseID::setup()
add_view(&m_box_select);
m_box_select.set_open_button_title(_("Select"));
- m_stage = STAGE_FIND;
+ m_stage = enumStage::FIND;
update_ui_for_stage();
}
@@ -134,7 +134,7 @@ void Dialog_ChooseID::on_box_find_criteria(const Gnome::Gda::SqlExpr& where_clau
}
else
{
- m_stage = STAGE_SELECT;
+ m_stage = enumStage::SELECT;
update_ui_for_stage();
}
}
@@ -150,14 +150,14 @@ void Dialog_ChooseID::update_ui_for_stage()
{
UiUtils::container_remove_all(*m_vbox_parent);
- if(m_stage == STAGE_FIND)
+ if(m_stage == enumStage::FIND)
{
m_pBox_QuickFind->show();
m_box_find.show();
m_vbox_parent->pack_start(m_box_find);
}
- else if(m_stage == STAGE_SELECT)
+ else if(m_stage == enumStage::SELECT)
{
m_pBox_QuickFind->hide();
@@ -174,7 +174,7 @@ bool Dialog_ChooseID::init_db_details(const Glib::ustring& table_name, const Gli
m_label_table_name->set_text( get_document()->get_table_title(m_table_name,
AppWindow::get_current_locale()) );
//Start by asking for find criteria:
- m_stage = STAGE_FIND;
+ m_stage = enumStage::FIND;
update_ui_for_stage();
bool result = m_box_find.init_db_details(table_name, layout_platform);
diff --git a/glom/mode_data/datawidget/dialog_choose_id.h b/glom/mode_data/datawidget/dialog_choose_id.h
index be6864f..03a6fdd 100644
--- a/glom/mode_data/datawidget/dialog_choose_id.h
+++ b/glom/mode_data/datawidget/dialog_choose_id.h
@@ -49,11 +49,11 @@ public:
bool get_id_chosen(Gnome::Gda::Value& chosen_id) const;
- enum enumStage
+ enum class enumStage
{
- STAGE_INVALID,
- STAGE_FIND,
- STAGE_SELECT
+ INVALID,
+ FIND,
+ SELECT
};
private:
diff --git a/glom/mode_data/datawidget/entry.cc b/glom/mode_data/datawidget/entry.cc
index 9dd3e0f..f85c426 100644
--- a/glom/mode_data/datawidget/entry.cc
+++ b/glom/mode_data/datawidget/entry.cc
@@ -41,7 +41,7 @@ namespace DataWidgetChildren
Entry::Entry(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& /* builder */)
:
Gtk::Entry(cobject),
- m_glom_type(Field::TYPE_TEXT)
+ m_glom_type(Field::glom_field_type::TEXT)
{
init();
}
@@ -72,13 +72,13 @@ void Entry::set_layout_item(const std::shared_ptr<LayoutItem>& layout_item, cons
//Horizontal Alignment:
Formatting::HorizontalAlignment alignment =
- Formatting::HORIZONTAL_ALIGNMENT_LEFT;
+ Formatting::HorizontalAlignment::LEFT;
std::shared_ptr<LayoutItem_Field> layout_field =
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
if(layout_field)
alignment = layout_field->get_formatting_used_horizontal_alignment(true /* for details view */);
- const float x_align = (alignment == Formatting::HORIZONTAL_ALIGNMENT_LEFT ? 0.0 : 1.0);
+ const float x_align = (alignment == Formatting::HorizontalAlignment::LEFT ? 0.0 : 1.0);
set_alignment(x_align);
}
@@ -156,7 +156,7 @@ void Entry::set_value(const Gnome::Gda::Value& value)
set_text(text);
//Show a different color if the value is numeric, if that's specified:
- if(layout_item->get_glom_type() == Field::TYPE_NUMERIC)
+ if(layout_item->get_glom_type() == Field::glom_field_type::NUMERIC)
{
const Glib::ustring fg_color =
layout_item->get_formatting_used().get_text_format_color_foreground_to_use(value);
@@ -204,7 +204,7 @@ bool Entry::on_button_press_event(GdkEventButton *button_event)
//Only show this popup in developer mode, so operators still see the default GtkEntry context menu.
//TODO: It would be better to add it somehow to the standard context menu.
- if(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0,
0, &mods );
diff --git a/glom/mode_data/datawidget/entry.h b/glom/mode_data/datawidget/entry.h
index e2bfeec..fab06a0 100644
--- a/glom/mode_data/datawidget/entry.h
+++ b/glom/mode_data/datawidget/entry.h
@@ -43,7 +43,7 @@ class Entry
{
public:
explicit Entry(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
- explicit Entry(Field::glom_field_type glom_type = Field::TYPE_TEXT);
+ explicit Entry(Field::glom_field_type glom_type = Field::glom_field_type::TEXT);
virtual ~Entry();
virtual void set_layout_item(const std::shared_ptr<LayoutItem>& layout_item, const Glib::ustring&
table_name) override;
diff --git a/glom/mode_data/datawidget/label.cc b/glom/mode_data/datawidget/label.cc
index 28b9474..e771107 100644
--- a/glom/mode_data/datawidget/label.cc
+++ b/glom/mode_data/datawidget/label.cc
@@ -105,7 +105,7 @@ void Label::on_menu_properties_activate()
bool Label::on_button_press_event(GdkEventButton *button_event)
{
AppWindow* pApp = get_appwindow();
- if(pApp && pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp && pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0, 0,
&mods );
diff --git a/glom/mode_data/datawidget/textview.cc b/glom/mode_data/datawidget/textview.cc
index c1cef38..1b0a42b 100644
--- a/glom/mode_data/datawidget/textview.cc
+++ b/glom/mode_data/datawidget/textview.cc
@@ -39,7 +39,7 @@ namespace DataWidgetChildren
TextView::TextView(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& /* builder */)
: Gtk::ScrolledWindow(cobject),
- m_glom_type(Field::TYPE_TEXT)
+ m_glom_type(Field::glom_field_type::TEXT)
{
init();
}
@@ -191,7 +191,7 @@ bool TextView::on_button_press_event(GdkEventButton *button_event)
//Only show this popup in developer mode, so operators still see the default GtkEntry context menu.
//TODO: It would be better to add it somehow to the standard context menu.
- if(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0,
0, &mods );
diff --git a/glom/mode_data/datawidget/textview.h b/glom/mode_data/datawidget/textview.h
index 580050c..aab6e75 100644
--- a/glom/mode_data/datawidget/textview.h
+++ b/glom/mode_data/datawidget/textview.h
@@ -43,7 +43,7 @@ class TextView
{
public:
explicit TextView(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
- explicit TextView(Field::glom_field_type glom_type = Field::TYPE_TEXT);
+ explicit TextView(Field::glom_field_type glom_type = Field::glom_field_type::TEXT);
virtual ~TextView();
void set_glom_type(Field::glom_field_type glom_type);
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index 54693ab..d1b3ddf 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -212,7 +212,7 @@ DbTreeModel::DbTreeModel(const FoundSet& found_set, const type_vec_const_layout_
std::shared_ptr<const LayoutItem_Field> item_field = std::dynamic_pointer_cast<const
LayoutItem_Field>(item);
if(item_field)
{
- if(item_field->get_glom_type() == Field::TYPE_INVALID)
+ if(item_field->get_glom_type() == Field::glom_field_type::INVALID)
std::cerr << G_STRFUNC << ": field has invalid type. field name: " << item_field->get_name() <<
std::endl;
m_column_fields.push_back(item_field);
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index bb93f30..466ac75 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -65,7 +65,7 @@ DbAddDel::DbAddDel()
set_prevent_user_signals();
set_ignore_treeview_signals(true);
- set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
//Start with a useful default TreeModel:
//set_columns_count(1);
@@ -279,7 +279,7 @@ void DbAddDel::setup_menu(Gtk::Widget* /* widget */)
#ifndef GLOM_ENABLE_CLIENT_ONLY
if(pApp)
- m_refContextLayout->set_enabled(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER);
+ m_refContextLayout->set_enabled(pApp->get_userlevel() == AppState::userlevels::DEVELOPER);
#endif // !GLOM_ENABLE_CLIENT_ONLY
}
@@ -1451,7 +1451,7 @@ void DbAddDel::on_treeview_cell_edited(const Glib::ustring& path_string, const G
return;
const auto field_type = item_field->get_glom_type();
- if(field_type != Field::TYPE_INVALID) //If a field type was specified for this column.
+ if(field_type != Field::glom_field_type::INVALID) //If a field type was specified for this column.
{
//Make sure that the entered data is suitable for this field type:
bool success = false;
@@ -1664,7 +1664,7 @@ bool DbAddDel::get_column_to_expand(guint& column_to_expand) const
//Only text columns should expand.
//Number fields are right-aligned, so expansion is annoying.
//Time and date fields don't vary their width much.
- if(layout_item_field->get_glom_type() == Field::TYPE_TEXT)
+ if(layout_item_field->get_glom_type() == Field::glom_field_type::TEXT)
{
//Check that no specific width has been specified:
const auto column_width = layout_item_field->get_display_width();
@@ -1920,7 +1920,7 @@ void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gt
const auto type = field->get_glom_type();
switch(type)
{
- case(Field::TYPE_BOOLEAN):
+ case(Field::glom_field_type::BOOLEAN):
{
Gtk::CellRendererToggle* pDerived = dynamic_cast<Gtk::CellRendererToggle*>(renderer);
if(pDerived)
@@ -1928,7 +1928,7 @@ void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gt
break;
}
- case(Field::TYPE_IMAGE):
+ case(Field::glom_field_type::IMAGE):
{
Gtk::CellRendererPixbuf* pDerived = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);
if(pDerived)
@@ -1942,7 +1942,7 @@ void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gt
pDerived->property_pixbuf() = pixbuf;
}
else
- std::cerr << G_STRFUNC << ": glom_type is TYPE_IMAGE but gda type is not VALUE_TYPE_BINARY" <<
std::endl;
+ std::cerr << G_STRFUNC << ": glom_type is enumType::IMAGE but gda type is not VALUE_TYPE_BINARY"
<< std::endl;
break;
}
@@ -1972,7 +1972,7 @@ void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gt
pDerived->property_text() = text;
//Show a different color if the value is numeric, if that's specified:
- if(type == Field::TYPE_NUMERIC)
+ if(type == Field::glom_field_type::NUMERIC)
{
const Glib::ustring fg_color =
field->get_formatting_used().get_text_format_color_foreground_to_use(value);
diff --git a/glom/mode_data/db_adddel/db_adddel_withbuttons.cc
b/glom/mode_data/db_adddel/db_adddel_withbuttons.cc
index 65721e0..5d1d93e 100644
--- a/glom/mode_data/db_adddel/db_adddel_withbuttons.cc
+++ b/glom/mode_data/db_adddel/db_adddel_withbuttons.cc
@@ -33,7 +33,7 @@ DbAddDel_WithButtons::DbAddDel_WithButtons()
m_Button_Add(_("_Add"), true)
{
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
- m_ButtonBox.set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ m_ButtonBox.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
setup_buttons();
pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 33ad3ba..842b9c4 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -203,11 +203,11 @@ void FlowTableWithFields::add_layout_group(const std::shared_ptr<LayoutGroup>& g
const int BASE_INDENT = 3;
//std::cout << "title= " << group_title << ", with_indent=" << with_indent << std::endl;
- event_box->set_margin_top(Glom::UiUtils::DEFAULT_SPACING_SMALL);
+ event_box->set_margin_top(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
if(with_indent)
{
- event_box->set_margin_start(Glom::UiUtils::DEFAULT_SPACING_SMALL + BASE_INDENT);
+ event_box->set_margin_start(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL) + BASE_INDENT);
}
else
{
@@ -373,7 +373,7 @@ void FlowTableWithFields::add_layout_notebook(const std::shared_ptr<LayoutItem_N
{
//Add a Related Records list for this portal:
Box_Data_List_Related* portal_box = create_related(portal, false /* no label, because it's in the
tab instead. */);
- //portal_box->set_border_width(Glom::UiUtils::DEFAULT_SPACING_SMALL); It has margins around the
frame's child widget instead.
+ //portal_box->set_border_width(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL)); It has
margins around the frame's child widget instead.
portal_box->show();
notebook_widget->append_page(*portal_box, *tab_label);
@@ -405,10 +405,10 @@ void FlowTableWithFields::add_layout_notebook(const std::shared_ptr<LayoutItem_N
//Put some space between the page child and the page edges.
//This doesn't work (probably because we haven't implemented it in our custom container),
//so we use GtkWidget margins instead. TODO: What's the difference.
- event_box->set_margin_start(Glom::UiUtils::DEFAULT_SPACING_SMALL);
- event_box->set_margin_end(Glom::UiUtils::DEFAULT_SPACING_SMALL);
- event_box->set_margin_top(Glom::UiUtils::DEFAULT_SPACING_SMALL);
- event_box->set_margin_bottom(Glom::UiUtils::DEFAULT_SPACING_SMALL);
+ event_box->set_margin_start(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
+ event_box->set_margin_end(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
+ event_box->set_margin_top(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
+ event_box->set_margin_bottom(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
notebook_widget->append_page(*event_box, *tab_label);
@@ -480,12 +480,12 @@ void FlowTableWithFields::add_field(const std::shared_ptr<LayoutItem_Field>& lay
//info.m_group = layoutitem_field.m_group;
//Expand multiline text fields to take up the maximum possible width:
- if( (layoutitem_field->get_glom_type() == Field::TYPE_TEXT) &&
layoutitem_field->get_formatting_used().get_text_format_multiline())
+ if( (layoutitem_field->get_glom_type() == Field::glom_field_type::TEXT) &&
layoutitem_field->get_formatting_used().get_text_format_multiline())
{
if(label)
label->set_valign(Gtk::ALIGN_START); //Center is neater next to entries, but center is silly next to
multi-line text boxes.
}
- else if(layoutitem_field->get_glom_type() == Field::TYPE_IMAGE)
+ else if(layoutitem_field->get_glom_type() == Field::glom_field_type::IMAGE)
{
if(label)
label->set_valign(Gtk::ALIGN_START); //Center is neater next to entries, but center is silly next to
large images.
@@ -538,14 +538,14 @@ void FlowTableWithFields::add_button(const std::shared_ptr<LayoutItem_Button>& l
layoutitem_button->get_formatting_used_horizontal_alignment();
Gtk::Widget* widget_to_add = button;
bool expand = false;
- if(alignment != Formatting::HORIZONTAL_ALIGNMENT_LEFT)
+ if(alignment != Formatting::HorizontalAlignment::LEFT)
{
//Put the button in a Gtk::Box so we can have non-default alignment in
//its space. Note that we will need a different technique if we ever
//support center alignment.
Gtk::Box* box_button = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
box_button->show();
- if(alignment == Formatting::HORIZONTAL_ALIGNMENT_RIGHT)
+ if(alignment == Formatting::HorizontalAlignment::RIGHT)
box_button->pack_end(*button, Gtk::PACK_SHRINK);
else
box_button->pack_start(*button, Gtk::PACK_SHRINK);
@@ -568,7 +568,7 @@ void FlowTableWithFields::add_textobject(const std::shared_ptr<LayoutItem_Text>&
const Formatting::HorizontalAlignment alignment =
layoutitem_text->get_formatting_used_horizontal_alignment();
- const Gtk::Align x_align = (alignment == Formatting::HORIZONTAL_ALIGNMENT_LEFT ? Gtk::ALIGN_START :
Gtk::ALIGN_END);
+ const Gtk::Align x_align = (alignment == Formatting::HorizontalAlignment::LEFT ? Gtk::ALIGN_START :
Gtk::ALIGN_END);
label->set_halign(x_align);
label->set_valign(Gtk::ALIGN_CENTER);
label->show();
@@ -1083,7 +1083,7 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
//Create/Choose the new layout item:
std::shared_ptr<LayoutItem> layout_item_new;
- if(item_type == LayoutWidgetBase::TYPE_FIELD)
+ if(item_type == LayoutWidgetBase::enumType::FIELD)
{
std::shared_ptr<LayoutItem_Field> layout_item_field = pDataWidget->offer_field_list(m_table_name);
if(layout_item_field)
@@ -1092,13 +1092,13 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
layout_item_new = layout_item_field;
}
}
- else if(item_type == LayoutWidgetBase::TYPE_GROUP)
+ else if(item_type == LayoutWidgetBase::enumType::GROUP)
{
std::shared_ptr<LayoutGroup> layout_item = std::make_shared<LayoutGroup>();
layout_item->set_title_original(_("New Group"));
layout_item_new = layout_item;
}
- else if(item_type == LayoutWidgetBase::TYPE_NOTEBOOK)
+ else if(item_type == LayoutWidgetBase::enumType::NOTEBOOK)
{
std::shared_ptr<LayoutItem_Notebook> layout_item = std::make_shared<LayoutItem_Notebook>();
layout_item->set_name(_("notebook"));
@@ -1116,18 +1116,18 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
layout_item_new = layout_item;
}
- else if(item_type == LayoutWidgetBase::TYPE_PORTAL)
+ else if(item_type == LayoutWidgetBase::enumType::PORTAL)
{
layout_item_new = get_portal_relationship();
}
- else if(item_type == LayoutWidgetBase::TYPE_BUTTON)
+ else if(item_type == LayoutWidgetBase::enumType::BUTTON)
{
std::shared_ptr<LayoutItem_Button> layout_item = std::make_shared<LayoutItem_Button>();
layout_item->set_name(_("button"));
layout_item->set_title_original(_("New Button"));
layout_item_new = layout_item;
}
- else if(item_type == LayoutWidgetBase::TYPE_TEXT)
+ else if(item_type == LayoutWidgetBase::enumType::TEXT)
{
std::shared_ptr<LayoutItem_Text> layout_item = std::make_shared<LayoutItem_Text>();
layout_item->set_name(_("text"));
@@ -1304,7 +1304,7 @@ void FlowTableWithFields::on_menu_delete_activate()
bool FlowTableWithFields::on_button_press_event(GdkEventButton *button_event)
{
AppWindow* pApp = AppWindow::get_appwindow();
- if(pApp && pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp && pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0, 0,
&mods );
diff --git a/glom/mode_data/notebook_data.cc b/glom/mode_data/notebook_data.cc
index 61aec05..5102699 100644
--- a/glom/mode_data/notebook_data.cc
+++ b/glom/mode_data/notebook_data.cc
@@ -162,8 +162,8 @@ bool Notebook_Data::init_db_details(const FoundSet& found_set, const Gnome::Gda:
if(details_record_specified)
{
- if(current_view != DATA_VIEW_Details)
- set_current_view(DATA_VIEW_Details);
+ if(current_view != dataview::DETAILS)
+ set_current_view(dataview::DETAILS);
}
else
{
@@ -177,10 +177,10 @@ bool Notebook_Data::init_db_details(const FoundSet& found_set, const Gnome::Gda:
}
//Set the layout:
- if( (current_layout.empty() || (current_layout == "list")) && (current_view != DATA_VIEW_List) )
- set_current_view(DATA_VIEW_List);
- else if( (current_layout == "details") && (current_view != DATA_VIEW_Details) )
- set_current_view(DATA_VIEW_Details);
+ if( (current_layout.empty() || (current_layout == "list")) && (current_view != dataview::LIST) )
+ set_current_view(dataview::LIST);
+ else if( (current_layout == "details") && (current_view != dataview::DETAILS) )
+ set_current_view(dataview::DETAILS);
}
//Re-enable this handler, so we can respond to notebook page changes:
@@ -204,8 +204,8 @@ void Notebook_Data::show_details(const Gnome::Gda::Value& primary_key_value)
//std::cout << "DEBUG: Notebook_Data::show_details() primary_key_value=" << primary_key_value.to_string()
<< std::endl;
m_Box_Details.refresh_data_from_database_with_primary_key(primary_key_value);
- if(get_current_view() != DATA_VIEW_Details)
- set_current_view(DATA_VIEW_Details);
+ if(get_current_view() != dataview::DETAILS)
+ set_current_view(dataview::DETAILS);
//Re-enable this handler, so we can respond to notebook page changes:
if(m_connection_switch_page)
@@ -231,7 +231,7 @@ void Notebook_Data::on_list_user_requested_details(const Gnome::Gda::Value& prim
FoundSet Notebook_Data::get_found_set_selected() const
{
- if(get_current_view() == DATA_VIEW_Details)
+ if(get_current_view() == dataview::DETAILS)
{
return m_Box_Details.get_found_set();
}
@@ -269,7 +269,7 @@ FoundSet Notebook_Data::get_found_set_selected() const
void Notebook_Data::set_current_view(dataview view)
{
- if(view == DATA_VIEW_List)
+ if(view == dataview::LIST)
set_visible_child(m_pagename_list);
else
set_visible_child(m_pagename_details);
@@ -318,19 +318,19 @@ void Notebook_Data::do_menu_file_print()
}
}
-enum dataview
+enum class dataview
{
- DATA_VIEW_Details,
- DATA_VIEW_List
+ Details,
+ List
};
Notebook_Data::dataview Notebook_Data::get_current_view() const
{
const auto current_page = get_visible_child_name();
- dataview result = DATA_VIEW_Details;
+ dataview result = dataview::DETAILS;
if(current_page == m_pagename_list)
- result = DATA_VIEW_List;
+ result = dataview::LIST;
return result;
}
diff --git a/glom/mode_data/notebook_data.h b/glom/mode_data/notebook_data.h
index 41a960d..4c80ff2 100644
--- a/glom/mode_data/notebook_data.h
+++ b/glom/mode_data/notebook_data.h
@@ -66,10 +66,10 @@ public:
void get_record_counts(gulong& total, gulong& found);
- enum dataview
+ enum class dataview
{
- DATA_VIEW_Details,
- DATA_VIEW_List
+ DETAILS,
+ LIST
};
dataview get_current_view() const;
diff --git a/glom/mode_design/box_db_table_relationships.cc b/glom/mode_design/box_db_table_relationships.cc
index 3b545f0..ba6c0aa 100644
--- a/glom/mode_design/box_db_table_relationships.cc
+++ b/glom/mode_design/box_db_table_relationships.cc
@@ -49,11 +49,11 @@ void Box_DB_Table_Relationships::init()
m_colTitle = m_AddDel.add_column(_("Title"));
//Translators: FROM as in SQL's FROM
- m_colFromField = m_AddDel.add_column(_("From Field"), AddDelColumnInfo::STYLE_Choices);
- m_colToTable = m_AddDel.add_column(_("Table"), AddDelColumnInfo::STYLE_Choices);
- m_colToField = m_AddDel.add_column(_("To Field"), AddDelColumnInfo::STYLE_Choices);
- m_colAllowEdit = m_AddDel.add_column(_("Allow Editing"), AddDelColumnInfo::STYLE_Boolean);
- m_colAutoCreate = m_AddDel.add_column(_("Automatic Creation"), AddDelColumnInfo::STYLE_Boolean);
+ m_colFromField = m_AddDel.add_column(_("From Field"), AddDelColumnInfo::enumStyles::Choices);
+ m_colToTable = m_AddDel.add_column(_("Table"), AddDelColumnInfo::enumStyles::Choices);
+ m_colToField = m_AddDel.add_column(_("To Field"), AddDelColumnInfo::enumStyles::Choices);
+ m_colAllowEdit = m_AddDel.add_column(_("Allow Editing"), AddDelColumnInfo::enumStyles::Boolean);
+ m_colAutoCreate = m_AddDel.add_column(_("Automatic Creation"), AddDelColumnInfo::enumStyles::Boolean);
m_colTitleSingular = m_AddDel.add_column(_("Title (Singular Form)"));
diff --git a/glom/mode_design/dialog_database_preferences.cc b/glom/mode_design/dialog_database_preferences.cc
index e4818cb..dbb266a 100644
--- a/glom/mode_design/dialog_database_preferences.cc
+++ b/glom/mode_design/dialog_database_preferences.cc
@@ -197,8 +197,8 @@ void Dialog_Database_Preferences::load_from_document()
{
auto iter = m_model_autoincrements->append();
Gtk::TreeModel::Row row = *iter;
- row[m_columns.m_col_table] = Conversions::get_text_for_gda_value(Field::TYPE_TEXT,
datamodel->get_value_at(0, i), numeric_format);
- row[m_columns.m_col_field] = Conversions::get_text_for_gda_value(Field::TYPE_TEXT,
datamodel->get_value_at(1, i), numeric_format);
+ row[m_columns.m_col_table] = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(0, i), numeric_format);
+ row[m_columns.m_col_field] = Conversions::get_text_for_gda_value(Field::glom_field_type::TEXT,
datamodel->get_value_at(1, i), numeric_format);
//TODO: Careful of locale:
row[m_columns.m_col_next_value] = atol(datamodel->get_value_at(2, i).to_string().c_str());
@@ -235,7 +235,7 @@ void Dialog_Database_Preferences::save_to_document()
return;
//Make sure that set_database_preferences() can work.
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() == AppState::userlevels::DEVELOPER)
DbUtils::add_standard_tables(document);
DbUtils::set_database_preferences(document, m_system_prefs);
diff --git a/glom/mode_design/fields/box_db_table_definition.cc
b/glom/mode_design/fields/box_db_table_definition.cc
index 14f52ce..d5a7285 100644
--- a/glom/mode_design/fields/box_db_table_definition.cc
+++ b/glom/mode_design/fields/box_db_table_definition.cc
@@ -64,7 +64,7 @@ void Box_DB_Table_Definition::init()
m_colTitle = m_AddDel.add_column(_("Title"));
- m_colType = m_AddDel.add_column(_("Type"), AddDelColumnInfo::STYLE_Choices);
+ m_colType = m_AddDel.add_column(_("Type"), AddDelColumnInfo::enumStyles::Choices);
m_AddDel.set_column_width(m_colType, 100); //TODO: Auto-size columns.
@@ -84,8 +84,8 @@ void Box_DB_Table_Definition::init()
m_AddDel.set_column_choices(m_colType, vecTypes);
- m_colUnique = m_AddDel.add_column("Unique", AddDelColumnInfo::STYLE_Boolean);
- m_colPrimaryKey = m_AddDel.add_column("Primary Key", AddDelColumnInfo::STYLE_Boolean);
+ m_colUnique = m_AddDel.add_column("Unique", AddDelColumnInfo::enumStyles::Boolean);
+ m_colPrimaryKey = m_AddDel.add_column("Primary Key", AddDelColumnInfo::enumStyles::Boolean);
//Connect signals:
m_AddDel.signal_user_added().connect(sigc::mem_fun(*this, &Box_DB_Table_Definition::on_adddel_add));
@@ -123,7 +123,7 @@ void Box_DB_Table_Definition::fill_field_row(const Gtk::TreeModel::iterator& ite
m_AddDel.set_value(iter, m_colTitle, title);
//Type:
- //Field::glom_field_type fieldType =
Field::get_glom_type_for_gda_type(field->get_field_info()->get_g_type()); //Could be TYPE_INVALID if the gda
type is not one of ours.
+ //Field::glom_field_type fieldType =
Field::get_glom_type_for_gda_type(field->get_field_info()->get_g_type()); //Could be INVALID if the gda type
is not one of ours.
// TODO: Why was this done by converting the field's gtype to a glom type
// instead of using the glom type directly? This breaks numerical types in
// sqlite which we store as double.
@@ -194,15 +194,15 @@ void Box_DB_Table_Definition::on_adddel_add(const Gtk::TreeModel::iterator& row)
auto field = std::make_shared<Field>();
field->set_name(name);
field->set_title( Utils::title_from_string(name) , AppWindow::get_current_locale()); //Start with a
title that might be useful.
- field->set_glom_type(Field::TYPE_NUMERIC);
+ field->set_glom_type(Field::glom_field_type::NUMERIC);
Glib::RefPtr<Gnome::Gda::Column> field_info = field->get_field_info();
- field_info->set_g_type( Field::get_gda_type_for_glom_type(Field::TYPE_NUMERIC) );
+ field_info->set_g_type( Field::get_gda_type_for_glom_type(Field::glom_field_type::NUMERIC) );
field->set_field_info(field_info);
//TODO: Warn about a delay before actually doing this when the backend
//needs to recreate the whole table.
- const auto bTest = DbUtils::add_column(m_table_name, field, get_app_window()); //TODO: Get schema type
for Field::TYPE_NUMERIC
+ const auto bTest = DbUtils::add_column(m_table_name, field, get_app_window()); //TODO: Get schema type
for Field::glom_field_type::NUMERIC
if(bTest)
{
//Store the generated title in the document:
@@ -215,7 +215,7 @@ void Box_DB_Table_Definition::on_adddel_add(const Gtk::TreeModel::iterator& row)
Document* pDoc = static_cast<Document*>(get_document());
if(pDoc)
{
- std::cout << field->get_glom_type() << std::endl;
+ std::cout << static_cast<int>(field->get_glom_type()) << std::endl;
Document::type_vec_fields vecFields = pDoc->get_table_fields(m_table_name);
vecFields.push_back(field);
pDoc->set_table_fields(m_table_name, vecFields);
@@ -296,7 +296,7 @@ bool Box_DB_Table_Definition::check_field_change(const std::shared_ptr<const Fie
//If we are changing a non-glom type:
//Refuse to edit field definitions that were not created by glom:
- if(field_old->get_glom_type() == Field::TYPE_INVALID)
+ if(field_old->get_glom_type() == Field::glom_field_type::INVALID)
{
UiUtils::show_ok_dialog(_("Invalid database structure"),
_("This database field was created or edited outside of Glom. It has a data type that is not supported
by Glom. Your system administrator may be able to correct this."), parent_window, Gtk::MESSAGE_ERROR);
diff --git a/glom/mode_design/fields/combo_fieldtype.cc b/glom/mode_design/fields/combo_fieldtype.cc
index 08a3d25..7574b38 100644
--- a/glom/mode_design/fields/combo_fieldtype.cc
+++ b/glom/mode_design/fields/combo_fieldtype.cc
@@ -85,7 +85,7 @@ void Combo_FieldType::set_field_type(Field::glom_field_type fieldType)
Field::glom_field_type Combo_FieldType::get_field_type() const
{
- Field::glom_field_type result = Field::TYPE_INVALID;
+ Field::glom_field_type result = Field::glom_field_type::INVALID;
//Get the active row:
auto active_row = get_active();
diff --git a/glom/mode_design/fields/dialog_fieldcalculation.cc
b/glom/mode_design/fields/dialog_fieldcalculation.cc
index 15df8d5..7a28239 100644
--- a/glom/mode_design/fields/dialog_fieldcalculation.cc
+++ b/glom/mode_design/fields/dialog_fieldcalculation.cc
@@ -133,7 +133,7 @@ void Dialog_FieldCalculation::on_button_test()
Glib::ustring error_message;
const auto value = glom_evaluate_python_function_implementation(
- Field::TYPE_TEXT,
+ Field::glom_field_type::TEXT,
calculation,
field_values, //TODO: Maybe use the field's type here.
document,
diff --git a/glom/mode_design/layout/dialog_choose_field.cc b/glom/mode_design/layout/dialog_choose_field.cc
index c58adf6..dded491 100644
--- a/glom/mode_design/layout/dialog_choose_field.cc
+++ b/glom/mode_design/layout/dialog_choose_field.cc
@@ -344,7 +344,7 @@ void Dialog_ChooseField::on_treeview_selection_changed()
/*
Gtk::TreeModel::Row row = *iter;
const Field& field = row[m_ColumnsFields.m_col_field];
- const auto is_numeric = (field.get_glom_type() == Field::TYPE_NUMERIC);
+ const auto is_numeric = (field.get_glom_type() == Field::glom_field_type::NUMERIC);
if(is_numeric)
m_vbox_numeric_format->show();
else
diff --git a/glom/mode_design/layout/dialog_layout_calendar_related.cc
b/glom/mode_design/layout/dialog_layout_calendar_related.cc
index b677132..94445ea 100644
--- a/glom/mode_design/layout/dialog_layout_calendar_related.cc
+++ b/glom/mode_design/layout/dialog_layout_calendar_related.cc
@@ -212,7 +212,7 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
//m_combo_navigation_specify->set_display_parent_table(""); //This would be superfluous, and a bit
confusing.
bool navigation_is_automatic = false;
- if(m_portal->get_navigation_type() == LayoutItem_Portal::NAVIGATION_SPECIFIC)
+ if(m_portal->get_navigation_type() == LayoutItem_Portal::navigation_type::SPECIFIC)
{
std::shared_ptr<UsesRelationship> navrel = m_portal->get_navigation_relationship_specific();
//std::cout << "debug navrel=" << navrel->get_relationship()->get_name() << std::endl;
@@ -255,7 +255,7 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
else
std::cout << "debug: " << G_STRFUNC << ": date field:" << debugfield->get_name() << std::endl;
- m_combobox_date_field->set_fields(document, related_table_name, Field::TYPE_DATE);
+ m_combobox_date_field->set_fields(document, related_table_name, Field::glom_field_type::DATE);
m_combobox_date_field->set_selected_field(m_portal->get_date_field());
m_modified = false;
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc
b/glom/mode_design/layout/dialog_layout_list_related.cc
index 8534ff6..df49b5d 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -267,7 +267,7 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
m_combo_navigation_specify->set_relationships(document, related_table_name, true /* show related
relationships */, false /* don't show parent table */); //TODO: Don't show the hidden tables, and don't show
relationships that are not used by any fields.
//m_combo_navigation_specify->set_display_parent_table(""); //This would be superfluous, and a bit
confusing.
- if(m_portal->get_navigation_type() == LayoutItem_Portal::NAVIGATION_SPECIFIC)
+ if(m_portal->get_navigation_type() == LayoutItem_Portal::navigation_type::SPECIFIC)
{
std::shared_ptr<UsesRelationship> navrel = m_portal->get_navigation_relationship_specific();
//std::cout << "debug navrel=" << navrel->get_relationship()->get_name() << std::endl;
@@ -283,15 +283,15 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
//std::cout << "debug: navrel_type=" << m_portal->get_navigation_relationship_type() << std::endl;
switch(m_portal->get_navigation_type())
{
- case LayoutItem_Portal::NAVIGATION_NONE:
+ case LayoutItem_Portal::navigation_type::NONE:
m_radio_navigation_none->set_active(true);
break;
- case LayoutItem_Portal::NAVIGATION_AUTOMATIC:
+ case LayoutItem_Portal::navigation_type::AUTOMATIC:
m_radio_navigation_automatic->set_active(true);
break;
- case LayoutItem_Portal::NAVIGATION_SPECIFIC:
+ case LayoutItem_Portal::navigation_type::SPECIFIC:
m_radio_navigation_specify->set_active(true);
break;
}
@@ -369,13 +369,13 @@ void Dialog_Layout_List_Related::save_to_document()
}
if(m_radio_navigation_automatic->get_active())
- m_portal->set_navigation_type(LayoutItem_Portal::NAVIGATION_AUTOMATIC);
+ m_portal->set_navigation_type(LayoutItem_Portal::navigation_type::AUTOMATIC);
if(m_radio_navigation_none->get_active())
{
std::shared_ptr<UsesRelationship> uses_rel = std::make_shared<UsesRelationship>();
uses_rel->set_related_relationship(std::shared_ptr<Relationship>());
- m_portal->set_navigation_type(LayoutItem_Portal::NAVIGATION_NONE);
+ m_portal->set_navigation_type(LayoutItem_Portal::navigation_type::NONE);
}
m_portal->set_rows_count(
diff --git a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
index b27934a..70c9f4c 100644
--- a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
@@ -110,15 +110,15 @@ Box_Formatting::Box_Formatting(BaseObjectType* cobject, const Glib::RefPtr<Gtk::
m_model_alignment = Gtk::ListStore::create(m_columns_alignment);
auto iter = m_model_alignment->append();
- (*iter)[m_columns_alignment.m_col_alignment] = Formatting::HORIZONTAL_ALIGNMENT_AUTO;
+ (*iter)[m_columns_alignment.m_col_alignment] = Formatting::HorizontalAlignment::AUTO;
//Translators: This is Automatic text alignment.
(*iter)[m_columns_alignment.m_col_title] = _("Automatic");
iter = m_model_alignment->append();
- (*iter)[m_columns_alignment.m_col_alignment] = Formatting::HORIZONTAL_ALIGNMENT_LEFT;
+ (*iter)[m_columns_alignment.m_col_alignment] = Formatting::HorizontalAlignment::LEFT;
//Translators: This is Left text alignment.
(*iter)[m_columns_alignment.m_col_title] = _("Left");
iter = m_model_alignment->append();
- (*iter)[m_columns_alignment.m_col_alignment] = Formatting::HORIZONTAL_ALIGNMENT_RIGHT;
+ (*iter)[m_columns_alignment.m_col_alignment] = Formatting::HorizontalAlignment::RIGHT;
//Translators: This is Right text alignment.
(*iter)[m_columns_alignment.m_col_title] = _("Right");
@@ -360,7 +360,7 @@ bool Box_Formatting::get_formatting(Formatting& format) const
//Text formatting:
auto iter = m_combo_format_text_horizontal_alignment->get_active();
- Formatting::HorizontalAlignment alignment = Formatting::HORIZONTAL_ALIGNMENT_LEFT;
+ Formatting::HorizontalAlignment alignment = Formatting::HorizontalAlignment::LEFT;
if(iter)
alignment = (*iter)[m_columns_alignment.m_col_alignment];
m_format.set_horizontal_alignment(alignment);
@@ -490,10 +490,10 @@ void Box_Formatting::enforce_constraints()
if(m_field)
{
m_show_numeric = false;
- if(m_field->get_glom_type() == Field::TYPE_NUMERIC)
+ if(m_field->get_glom_type() == Field::glom_field_type::NUMERIC)
m_show_numeric = true;
- if((m_field->get_glom_type() == Field::TYPE_BOOLEAN) || (m_field->get_glom_type() == Field::TYPE_IMAGE))
//TODO: Allow text options when showing booleans as Yes/No on print layouts.
+ if((m_field->get_glom_type() == Field::glom_field_type::BOOLEAN) || (m_field->get_glom_type() ==
Field::glom_field_type::IMAGE)) //TODO: Allow text options when showing booleans as Yes/No on print layouts.
{
show_text = false;
}
@@ -504,7 +504,7 @@ void Box_Formatting::enforce_constraints()
m_vbox_text_format->show();
//Hide multiline options for non-text fields:
- if(m_for_print_layout || !m_field || (m_field->get_glom_type() != Field::TYPE_TEXT))
+ if(m_for_print_layout || !m_field || (m_field->get_glom_type() != Field::glom_field_type::TEXT))
{
m_checkbox_format_text_multiline->hide();
m_label_format_text_multiline_height->hide();
diff --git a/glom/mode_design/layout/layout_item_dialogs/combo_summarytype.cc
b/glom/mode_design/layout/layout_item_dialogs/combo_summarytype.cc
index 951d757..dde1cc5 100644
--- a/glom/mode_design/layout/layout_item_dialogs/combo_summarytype.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/combo_summarytype.cc
@@ -34,14 +34,14 @@ Combo_SummaryType::Combo_SummaryType(BaseObjectType* cobject, const Glib::RefPtr
//Fill the model:
auto iter = m_model->append();
- (*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::TYPE_SUM;
- (*iter)[m_model_columns.m_name] =
LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::TYPE_SUM);
+ (*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::summaryType::SUM;
+ (*iter)[m_model_columns.m_name] =
LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::summaryType::SUM);
iter = m_model->append();
- (*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::TYPE_AVERAGE;
- (*iter)[m_model_columns.m_name] =
LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::TYPE_AVERAGE);
+ (*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::summaryType::AVERAGE;
+ (*iter)[m_model_columns.m_name] =
LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::summaryType::AVERAGE);
iter = m_model->append();
- (*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::TYPE_COUNT;
- (*iter)[m_model_columns.m_name] =
LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::TYPE_COUNT);
+ (*iter)[m_model_columns.m_summary_type] = LayoutItem_FieldSummary::summaryType::COUNT;
+ (*iter)[m_model_columns.m_name] =
LayoutItem_FieldSummary::get_summary_type_name(LayoutItem_FieldSummary::summaryType::COUNT);
set_model(m_model);
@@ -84,7 +84,7 @@ LayoutItem_FieldSummary::summaryType Combo_SummaryType::get_summary_type() const
return row[m_model_columns.m_summary_type];
}
- return LayoutItem_FieldSummary::TYPE_INVALID;
+ return LayoutItem_FieldSummary::summaryType::INVALID;
}
} //namespace Glom
diff --git a/glom/mode_design/print_layouts/box_print_layouts.cc
b/glom/mode_design/print_layouts/box_print_layouts.cc
index bc7d16f..03be099 100644
--- a/glom/mode_design/print_layouts/box_print_layouts.cc
+++ b/glom/mode_design/print_layouts/box_print_layouts.cc
@@ -77,7 +77,7 @@ bool Box_Print_Layouts::fill_from_database()
bool result = Base_DB::fill_from_database();
//Enable/Disable extra widgets:
- bool developer_mode = (get_userlevel() == AppState::USERLEVEL_DEVELOPER);
+ bool developer_mode = (get_userlevel() == AppState::userlevels::DEVELOPER);
//Developers see more columns, so make it bigger:
if(developer_mode)
@@ -92,11 +92,11 @@ bool Box_Print_Layouts::fill_from_database()
const bool editable = developer_mode;
const bool visible_extras = developer_mode;
- m_colName = m_AddDel.add_column(_("Name"), AddDelColumnInfo::STYLE_Text, editable, visible_extras);
+ m_colName = m_AddDel.add_column(_("Name"), AddDelColumnInfo::enumStyles::Text, editable, visible_extras);
m_AddDel.prevent_duplicates(m_colName); //Don't allow a relationship to be added twice.
m_AddDel.set_prevent_duplicates_warning(_("This item already exists. Please choose a different item
name"));
- m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::STYLE_Text, editable, true);
+ m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::enumStyles::Text, editable, true);
std::vector<Glib::ustring> listItems;
Document* document = get_document();
@@ -173,7 +173,7 @@ void Box_Print_Layouts::on_adddel_user_requested_edit(const Gtk::TreeModel::iter
void Box_Print_Layouts::save_to_document()
{
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() == AppState::userlevels::DEVELOPER)
{
//Add any that are not in the document:
std::vector<Glib::ustring> listItems = get_document()->get_print_layout_names(m_table_name);
@@ -202,7 +202,7 @@ void Box_Print_Layouts::save_to_document()
void Box_Print_Layouts::on_adddel_user_changed(const Gtk::TreeModel::iterator& row, guint column)
{
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() == AppState::userlevels::DEVELOPER)
{
const auto name = m_AddDel.get_value_key(row);
Document* document = get_document();
diff --git a/glom/mode_design/print_layouts/print_layout_toolbar.cc
b/glom/mode_design/print_layouts/print_layout_toolbar.cc
index 440aea9..5d6890f 100644
--- a/glom/mode_design/print_layouts/print_layout_toolbar.cc
+++ b/glom/mode_design/print_layouts/print_layout_toolbar.cc
@@ -29,17 +29,17 @@ PrintLayoutToolbar::PrintLayoutToolbar()
: m_group_items(_("Items")),
m_group_lines(_("Lines")),
m_group_records(_("Records")),
- m_drag_field("glom-field.png", PrintLayoutToolbarButton::ITEM_FIELD,
+ m_drag_field("glom-field.png", PrintLayoutToolbarButton::enumItems::FIELD,
_("Database Field"), _("Drag this to the layout to add a new database field.")),
- m_drag_text("glom-text.png", PrintLayoutToolbarButton::ITEM_TEXT,
+ m_drag_text("glom-text.png", PrintLayoutToolbarButton::enumItems::TEXT,
_("Text"), _("Drag this to the layout to add a new static text box.")),
- m_drag_image("glom-image.png", PrintLayoutToolbarButton::ITEM_IMAGE,
+ m_drag_image("glom-image.png", PrintLayoutToolbarButton::enumItems::IMAGE,
_("Image"), _("Drag this to the layout to add a new static image.")),
- m_drag_line_horizontal("glom-line-horizontal.png", PrintLayoutToolbarButton::ITEM_LINE_HORIZONTAL,
+ m_drag_line_horizontal("glom-line-horizontal.png", PrintLayoutToolbarButton::enumItems::LINE_HORIZONTAL,
_("Horizontal Line"), _("Drag this to the layout to add a new horizontal line.")),
- m_drag_line_vertical("glom-line-vertical.png", PrintLayoutToolbarButton::ITEM_LINE_VERTICAL,
+ m_drag_line_vertical("glom-line-vertical.png", PrintLayoutToolbarButton::enumItems::LINE_VERTICAL,
_("Vertical Line"), _("Drag this to the layout to add a new vertical line.")),
- m_drag_related_records("glom-related-records.png", PrintLayoutToolbarButton::ITEM_PORTAL,
+ m_drag_related_records("glom-related-records.png", PrintLayoutToolbarButton::enumItems::PORTAL,
_("Related Records"), _("Drag this to the layout to add a new related records portal."))
{
// Looks ugly otherwise:
diff --git a/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
b/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
index d701fc0..036517b 100644
--- a/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
+++ b/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
@@ -61,7 +61,7 @@ PrintLayoutToolbarButton::~PrintLayoutToolbarButton()
PrintLayoutToolbarButton::enumItems PrintLayoutToolbarButton::get_item_type_from_selection_data(const
Glib::RefPtr<Gdk::DragContext>& drag_context, const Gtk::SelectionData& selection_data)
{
- PrintLayoutToolbarButton::enumItems result = ITEM_INVALID;
+ PrintLayoutToolbarButton::enumItems result = enumItems::INVALID;
//Put this code in the toolbar class:
Gtk::Widget* palette_candidate = drag_get_source_widget(drag_context);
diff --git a/glom/mode_design/print_layouts/print_layout_toolbar_button.h
b/glom/mode_design/print_layouts/print_layout_toolbar_button.h
index c676cd0..97fbc9f 100644
--- a/glom/mode_design/print_layouts/print_layout_toolbar_button.h
+++ b/glom/mode_design/print_layouts/print_layout_toolbar_button.h
@@ -36,15 +36,15 @@ class PrintLayoutToolbarButton : public Gtk::ToolButton
public:
//TODO: Use LayoutWidgetBase::enumType m_type instead (and just use LayoutToolbarButton?)
- enum enumItems
+ enum class enumItems
{
- ITEM_INVALID,
- ITEM_FIELD,
- ITEM_TEXT,
- ITEM_IMAGE,
- ITEM_PORTAL,
- ITEM_LINE_HORIZONTAL,
- ITEM_LINE_VERTICAL
+ INVALID,
+ FIELD,
+ TEXT,
+ IMAGE,
+ PORTAL,
+ LINE_HORIZONTAL,
+ LINE_VERTICAL
};
PrintLayoutToolbarButton(const std::string& icon_name, enumItems type, const Glib::ustring& title, const
Glib::ustring& tooltip);
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.cc
b/glom/mode_design/print_layouts/window_print_layout_edit.cc
index 6020168..ae45ba6 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.cc
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.cc
@@ -367,7 +367,7 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
{
std::shared_ptr<LayoutItem> layout_item;
- if(item_type == PrintLayoutToolbarButton::ITEM_FIELD)
+ if(item_type == PrintLayoutToolbarButton::enumItems::FIELD)
{
std::shared_ptr<LayoutItem_Field> layout_item_derived = std::make_shared<LayoutItem_Field>();
layout_item = layout_item_derived;
@@ -377,7 +377,7 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
//Don't use the field's default formatting, because that is probably only for on-screen layouts:
layout_item_derived->set_formatting_use_default(false);
}
- else if(item_type == PrintLayoutToolbarButton::ITEM_TEXT)
+ else if(item_type == PrintLayoutToolbarButton::enumItems::TEXT)
{
std::shared_ptr<LayoutItem_Text> layout_item_derived = std::make_shared<LayoutItem_Text>();
@@ -387,26 +387,26 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
layout_item->set_print_layout_position(0, 0,
PrintLayoutUtils::ITEM_WIDTH_WIDE, PrintLayoutUtils::ITEM_HEIGHT);
}
- else if(item_type == PrintLayoutToolbarButton::ITEM_IMAGE)
+ else if(item_type == PrintLayoutToolbarButton::enumItems::IMAGE)
{
layout_item = std::make_shared<LayoutItem_Image>();
layout_item->set_print_layout_position(0, 0,
PrintLayoutUtils::ITEM_WIDTH_WIDE, PrintLayoutUtils::ITEM_WIDTH_WIDE);
}
- else if(item_type == PrintLayoutToolbarButton::ITEM_LINE_HORIZONTAL)
+ else if(item_type == PrintLayoutToolbarButton::enumItems::LINE_HORIZONTAL)
{
std::shared_ptr<LayoutItem_Line> layout_item_derived = std::make_shared<LayoutItem_Line>();
layout_item_derived->set_coordinates(0, 0,
PrintLayoutUtils::ITEM_WIDTH_WIDE * 2, 0);
layout_item = layout_item_derived;
}
- else if(item_type == PrintLayoutToolbarButton::ITEM_LINE_VERTICAL)
+ else if(item_type == PrintLayoutToolbarButton::enumItems::LINE_VERTICAL)
{
std::shared_ptr<LayoutItem_Line> layout_item_derived = std::make_shared<LayoutItem_Line>();
layout_item_derived->set_coordinates(0, 0, 0, PrintLayoutUtils::ITEM_WIDTH_WIDE * 2);
layout_item = layout_item_derived;
}
- else if(item_type == PrintLayoutToolbarButton::ITEM_PORTAL)
+ else if(item_type == PrintLayoutToolbarButton::enumItems::PORTAL)
{
std::shared_ptr<LayoutItem_Portal> portal = std::make_shared<LayoutItem_Portal>();
portal->set_print_layout_row_height(10); //Otherwise it will be 0, which is useless.
@@ -416,7 +416,7 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
}
else
{
- std::cerr << G_STRFUNC << ": Unhandled item type: " << item_type << std::endl;
+ std::cerr << G_STRFUNC << ": Unhandled item type: " << static_cast<int>(item_type) << std::endl;
}
//Set a default text style and size:
@@ -482,7 +482,7 @@ void Window_PrintLayout_Edit::on_canvas_drag_data_received(const Glib::RefPtr<Gd
//Discover what toolbar item was dropped:
const auto item_type = PrintLayoutToolbarButton::get_item_type_from_selection_data(drag_context,
selection_data);
- if(item_type == PrintLayoutToolbarButton::ITEM_INVALID)
+ if(item_type == PrintLayoutToolbarButton::enumItems::INVALID)
{
std::cerr << G_STRFUNC << ": item_type was invalid" << std::endl;
return;
@@ -771,7 +771,7 @@ void Window_PrintLayout_Edit::set_default_position(const std::shared_ptr<LayoutI
void Window_PrintLayout_Edit::on_menu_insert_field()
{
- std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::ITEM_FIELD);
+ std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::FIELD);
// Note to translators: This is the default contents of a text item on a print layout:
set_default_position(layout_item);
@@ -781,7 +781,7 @@ void Window_PrintLayout_Edit::on_menu_insert_field()
void Window_PrintLayout_Edit::on_menu_insert_text()
{
- std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::ITEM_TEXT);
+ std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::TEXT);
set_default_position(layout_item);
create_canvas_layout_item_and_add(layout_item);
@@ -789,7 +789,7 @@ void Window_PrintLayout_Edit::on_menu_insert_text()
void Window_PrintLayout_Edit::on_menu_insert_image()
{
- std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::ITEM_IMAGE);
+ std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::IMAGE);
// Note to translators: This is the default contents of a text item on a print layout:
//layout_item->set_text_original(_("text"));
set_default_position(layout_item);
@@ -799,7 +799,7 @@ void Window_PrintLayout_Edit::on_menu_insert_image()
void Window_PrintLayout_Edit::on_menu_insert_relatedrecords()
{
- std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::ITEM_PORTAL);
+ std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::PORTAL);
set_default_position(layout_item);
create_canvas_layout_item_and_add(layout_item);
@@ -807,7 +807,7 @@ void Window_PrintLayout_Edit::on_menu_insert_relatedrecords()
void Window_PrintLayout_Edit::on_menu_insert_line_horizontal()
{
- std::shared_ptr<LayoutItem> layout_item =
create_empty_item(PrintLayoutToolbarButton::ITEM_LINE_HORIZONTAL);
+ std::shared_ptr<LayoutItem> layout_item =
create_empty_item(PrintLayoutToolbarButton::enumItems::LINE_HORIZONTAL);
/*
double item_x = m_drop_x;
@@ -824,7 +824,7 @@ void Window_PrintLayout_Edit::on_menu_insert_line_horizontal()
void Window_PrintLayout_Edit::on_menu_insert_line_vertical()
{
- std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::ITEM_LINE_VERTICAL);
+ std::shared_ptr<LayoutItem> layout_item =
create_empty_item(PrintLayoutToolbarButton::enumItems::LINE_VERTICAL);
create_canvas_layout_item_and_add(layout_item);
}
diff --git a/glom/mode_design/users/dialog_groups_list.cc b/glom/mode_design/users/dialog_groups_list.cc
index a549957..2021805 100644
--- a/glom/mode_design/users/dialog_groups_list.cc
+++ b/glom/mode_design/users/dialog_groups_list.cc
@@ -463,13 +463,13 @@ bool Dialog_GroupsList::set_table_privilege(const Glib::ustring& table_name, con
//What to grant or revoke:
Glib::ustring strPrivilege;
- if(priv == PRIV_VIEW)
+ if(priv == enumPriv::VIEW)
strPrivilege = "SELECT";
- else if(priv == PRIV_EDIT)
+ else if(priv == enumPriv::EDIT)
strPrivilege = "UPDATE";
- else if(priv == PRIV_CREATE)
+ else if(priv == enumPriv::CREATE)
strPrivilege = "INSERT";
- else if(priv == PRIV_DELETE)
+ else if(priv == enumPriv::DELETE)
strPrivilege = "DELETE";
strQuery += " " + strPrivilege + " ON " + DbUtils::escape_sql_id(table_name) + " ";
@@ -506,19 +506,19 @@ void Dialog_GroupsList::on_treeview_tables_toggled_view(const Glib::ustring& pat
const auto group_name = get_selected_group();
const Glib::ustring table_name = row[m_model_columns_tables.m_col_name];
- if(set_table_privilege(table_name, group_name, bActive, PRIV_VIEW))
+ if(set_table_privilege(table_name, group_name, bActive, enumPriv::VIEW))
row[m_model_columns_tables.m_col_view] = bActive;
//If the group cannot view, then it should not do anything else either:
if(!bActive)
{
- if(set_table_privilege(table_name, group_name, bActive, PRIV_EDIT))
+ if(set_table_privilege(table_name, group_name, bActive, enumPriv::EDIT))
row[m_model_columns_tables.m_col_edit] = false;
- if(set_table_privilege(table_name, group_name, bActive, PRIV_CREATE))
+ if(set_table_privilege(table_name, group_name, bActive, enumPriv::CREATE))
row[m_model_columns_tables.m_col_create] = false;
- if(set_table_privilege(table_name, group_name, bActive, PRIV_DELETE))
+ if(set_table_privilege(table_name, group_name, bActive, enumPriv::DELETE))
row[m_model_columns_tables.m_col_delete] = false;
}
}
@@ -541,7 +541,7 @@ void Dialog_GroupsList::on_treeview_tables_toggled_edit(const Glib::ustring& pat
const auto group_name = get_selected_group();
const Glib::ustring table_name = row[m_model_columns_tables.m_col_name];
- bool test = set_table_privilege(table_name, group_name, bActive, PRIV_EDIT);
+ bool test = set_table_privilege(table_name, group_name, bActive, enumPriv::EDIT);
if(test)
row[m_model_columns_tables.m_col_edit] = bActive;
@@ -565,7 +565,7 @@ void Dialog_GroupsList::on_treeview_tables_toggled_create(const Glib::ustring& p
const auto group_name = get_selected_group();
const Glib::ustring table_name = row[m_model_columns_tables.m_col_name];
- const auto test = set_table_privilege(table_name, group_name, bActive, PRIV_CREATE);
+ const auto test = set_table_privilege(table_name, group_name, bActive, enumPriv::CREATE);
if(test)
row[m_model_columns_tables.m_col_create] = bActive;
@@ -589,7 +589,7 @@ void Dialog_GroupsList::on_treeview_tables_toggled_delete(const Glib::ustring& p
const auto group_name = get_selected_group();
const Glib::ustring table_name = row[m_model_columns_tables.m_col_name];
- const auto test = set_table_privilege(table_name, group_name, bActive, PRIV_DELETE);
+ const auto test = set_table_privilege(table_name, group_name, bActive, enumPriv::DELETE);
if(test)
row[m_model_columns_tables.m_col_delete] = bActive;
diff --git a/glom/mode_design/users/dialog_groups_list.h b/glom/mode_design/users/dialog_groups_list.h
index 09814a4..8fb048c 100644
--- a/glom/mode_design/users/dialog_groups_list.h
+++ b/glom/mode_design/users/dialog_groups_list.h
@@ -78,12 +78,12 @@ private:
virtual void on_treeview_tables_toggled_create(const Glib::ustring& path_string);
virtual void on_treeview_tables_toggled_delete(const Glib::ustring& path_string);
- enum enumPriv
+ enum class enumPriv
{
- PRIV_VIEW,
- PRIV_EDIT,
- PRIV_CREATE,
- PRIV_DELETE
+ VIEW,
+ EDIT,
+ CREATE,
+ DELETE
};
bool set_table_privilege(const Glib::ustring& table_name, const Glib::ustring& group_name, bool grant,
enumPriv priv);
diff --git a/glom/mode_find/box_data_list_find.cc b/glom/mode_find/box_data_list_find.cc
index 039d003..3169a13 100644
--- a/glom/mode_find/box_data_list_find.cc
+++ b/glom/mode_find/box_data_list_find.cc
@@ -26,7 +26,7 @@ namespace Glom
{
Box_Data_List_Find::Box_Data_List_Find()
-: m_HBox(Gtk::ORIENTATION_HORIZONTAL, Glom::UiUtils::DEFAULT_SPACING_SMALL)
+: m_HBox(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL))
{
//m_strHint = _("Enter the search criteria and click [Find]\n Glom will then change to Data mode to
display the results.");
diff --git a/glom/mode_find/notebook_find.cc b/glom/mode_find/notebook_find.cc
index 5924d5f..e7b12cd 100644
--- a/glom/mode_find/notebook_find.cc
+++ b/glom/mode_find/notebook_find.cc
@@ -72,7 +72,7 @@ bool Notebook_Find::init_db_details(const Glib::ustring& table_name, const Glib:
void Notebook_Find::set_current_view(Notebook_Data::dataview view)
{
- if(view == Notebook_Data::DATA_VIEW_List)
+ if(view == Notebook_Data::dataview::LIST)
set_visible_child(m_pagename_list);
else
set_visible_child(m_pagename_details);
diff --git a/glom/navigation/box_tables.cc b/glom/navigation/box_tables.cc
index 70e7910..9e6070b 100644
--- a/glom/navigation/box_tables.cc
+++ b/glom/navigation/box_tables.cc
@@ -80,7 +80,7 @@ void Box_Tables::fill_table_row(const Gtk::TreeModel::iterator& iter, const std:
if(iter)
{
- const auto developer_mode = (get_userlevel() == AppState::USERLEVEL_DEVELOPER);
+ const auto developer_mode = (get_userlevel() == AppState::userlevels::DEVELOPER);
m_AddDel.set_value_key(iter, table_info->get_name());
m_AddDel.set_value(iter, m_colTableName, table_info->get_name());
@@ -109,7 +109,7 @@ bool Box_Tables::fill_from_database()
bool result = Base_DB::fill_from_database();
//Enable/Disable extra widgets:
- const auto developer_mode = (get_userlevel() == AppState::USERLEVEL_DEVELOPER);
+ const auto developer_mode = (get_userlevel() == AppState::userlevels::DEVELOPER);
//Developers see more columns, so make it bigger:
if(developer_mode)
@@ -128,18 +128,18 @@ bool Box_Tables::fill_from_database()
const bool editable = developer_mode;
const bool visible_extras = developer_mode;
- m_colTableName = m_AddDel.add_column(_("Table"), AddDelColumnInfo::STYLE_Text, editable, visible_extras);
+ m_colTableName = m_AddDel.add_column(_("Table"), AddDelColumnInfo::enumStyles::Text, editable,
visible_extras);
m_AddDel.prevent_duplicates(m_colTableName); //Prevent two tables with the same name from being added.
m_AddDel.set_prevent_duplicates_warning(_("This table already exists. Please choose a different table
name"));
- m_colHidden = m_AddDel.add_column(_("Hidden"), AddDelColumnInfo::STYLE_Boolean, editable, visible_extras);
- m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::STYLE_Text, editable, true);
+ m_colHidden = m_AddDel.add_column(_("Hidden"), AddDelColumnInfo::enumStyles::Boolean, editable,
visible_extras);
+ m_colTitle = m_AddDel.add_column(_("Title"), AddDelColumnInfo::enumStyles::Text, editable, true);
//TODO: This should really be a radio, but the use of AddDel makes it awkward to change that CellRenderer
property.
- m_colDefault = m_AddDel.add_column(_("Default"), AddDelColumnInfo::STYLE_Boolean, editable,
visible_extras);
+ m_colDefault = m_AddDel.add_column(_("Default"), AddDelColumnInfo::enumStyles::Boolean, editable,
visible_extras);
if(developer_mode)
- m_colTitleSingular = m_AddDel.add_column(_("Title (Singular Form)"), AddDelColumnInfo::STYLE_Text,
editable, true);
+ m_colTitleSingular = m_AddDel.add_column(_("Title (Singular Form)"), AddDelColumnInfo::enumStyles::Text,
editable, true);
//Get the list of hidden tables:
@@ -355,7 +355,7 @@ void Box_Tables::on_adddel_Delete(const Gtk::TreeModel::iterator& rowStart, cons
void Box_Tables::on_adddel_changed(const Gtk::TreeModel::iterator& row, guint column)
{
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() == AppState::userlevels::DEVELOPER)
{
if(column == m_colHidden)
{
@@ -455,7 +455,7 @@ void Box_Tables::on_adddel_Edit(const Gtk::TreeModel::iterator& row)
#ifndef GLOM_ENABLE_CLIENT_ONLY
void Box_Tables::save_to_document()
{
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(get_userlevel() == AppState::userlevels::DEVELOPER)
{
//Save the hidden tables. TODO_usermode: Only if we are in developer mode.
Document::type_listTableInfo listTables;
diff --git a/glom/print_layout/canvas_layout_item.cc b/glom/print_layout/canvas_layout_item.cc
index 4243afc..f4f3e35 100644
--- a/glom/print_layout/canvas_layout_item.cc
+++ b/glom/print_layout/canvas_layout_item.cc
@@ -74,7 +74,7 @@ void CanvasLayoutItem::apply_formatting(const Glib::RefPtr<CanvasTextMovable>& c
//Horizontal alignment:
const Formatting::HorizontalAlignment alignment =
layout_item->get_formatting_used_horizontal_alignment();
- const Pango::Alignment x_align = (alignment == Formatting::HORIZONTAL_ALIGNMENT_LEFT ? Pango::ALIGN_LEFT :
Pango::ALIGN_RIGHT);
+ const Pango::Alignment x_align = (alignment == Formatting::HorizontalAlignment::LEFT ? Pango::ALIGN_LEFT :
Pango::ALIGN_RIGHT);
canvas_item->property_alignment() = x_align;
const auto formatting = layout_item->get_formatting_used();
@@ -244,7 +244,7 @@ Glib::RefPtr<CanvasItemMovable> CanvasLayoutItem::create_canvas_item_for_layout_
if(field)
{
//Create an appropriate canvas item for the field type:
- if(field->get_glom_type() == Field::TYPE_IMAGE)
+ if(field->get_glom_type() == Field::glom_field_type::IMAGE)
{
Glib::RefPtr<CanvasImageMovable> canvas_item = CanvasImageMovable::create();
canvas_item->set_image_empty();
@@ -454,11 +454,11 @@ void CanvasLayoutItem::set_db_data(const Gnome::Gda::Value& value)
const auto field_type = field->get_glom_type();
switch(field->get_glom_type())
{
- case(Field::TYPE_TEXT):
- case(Field::TYPE_NUMERIC):
- case(Field::TYPE_BOOLEAN):
- case(Field::TYPE_TIME):
- case(Field::TYPE_DATE):
+ case(Field::glom_field_type::TEXT):
+ case(Field::glom_field_type::NUMERIC):
+ case(Field::glom_field_type::BOOLEAN):
+ case(Field::glom_field_type::TIME):
+ case(Field::glom_field_type::DATE):
{
Glib::RefPtr<CanvasTextMovable> canvas_item = Glib::RefPtr<CanvasTextMovable>::cast_dynamic(child);
if(!canvas_item)
@@ -467,7 +467,7 @@ void CanvasLayoutItem::set_db_data(const Gnome::Gda::Value& value)
Glib::ustring text_value = Conversions::get_text_for_gda_value(field_type, value,
field->get_formatting_used().m_numeric_format);
//The Postgres summary functions return NULL when summarising NULL records, but 0 is more sensible:
- if(text_value.empty() && std::dynamic_pointer_cast<const LayoutItem_FieldSummary>(field) &&
(field_type == Field::TYPE_NUMERIC))
+ if(text_value.empty() && std::dynamic_pointer_cast<const LayoutItem_FieldSummary>(field) &&
(field_type == Field::glom_field_type::NUMERIC))
{
//Use get_text_for_gda_value() instead of "0" so we get the correct numerical formatting:
const auto value_zero = Conversions::parse_value(0);
@@ -477,7 +477,7 @@ void CanvasLayoutItem::set_db_data(const Gnome::Gda::Value& value)
canvas_item->set_text(text_value);
break;
}
- case(Field::TYPE_IMAGE):
+ case(Field::glom_field_type::IMAGE):
{
Glib::RefPtr<CanvasImageMovable> canvas_item = Glib::RefPtr<CanvasImageMovable>::cast_dynamic(child);
if(!canvas_item)
diff --git a/glom/print_layout/canvas_print_layout.cc b/glom/print_layout/canvas_print_layout.cc
index d99cf78..6da1a12 100644
--- a/glom/print_layout/canvas_print_layout.cc
+++ b/glom/print_layout/canvas_print_layout.cc
@@ -996,7 +996,7 @@ void Canvas_PrintLayout::set_canvas_item_field_value(const Glib::RefPtr<Goocanva
return;
//Expect the appropriate canvas item, depending on the field type:
- if(field->get_glom_type() == Field::TYPE_IMAGE)
+ if(field->get_glom_type() == Field::glom_field_type::IMAGE)
{
Glib::RefPtr<CanvasImageMovable> canvas_image =
Glib::RefPtr<CanvasImageMovable>::cast_dynamic(canvas_item);
if(!canvas_image)
diff --git a/glom/python_embed/glom_python.cc b/glom/python_embed/glom_python.cc
index b5a32d0..b1f5f42 100644
--- a/glom/python_embed/glom_python.cc
+++ b/glom/python_embed/glom_python.cc
@@ -182,7 +182,7 @@ static boost::python::object glom_python_call(Field::glom_field_type result_type
// std::cout << " field_value: name=" << iter->first << ", value=" << iter->second.to_string() <<
std::endl;
//}
- g_assert(result_type != Field::TYPE_INVALID);
+ g_assert(result_type != Field::glom_field_type::INVALID);
//g_warning("glom_evaluate_python_function_implementation: func=%s", func_impl.c_str());
@@ -406,7 +406,7 @@ void glom_execute_python_function_implementation(const Glib::ustring& func_impl,
//Pass an additional ui parameter for use by scripts:
boost::python::object objUI(new PyGlomUI(callbacks));
- glom_python_call(Field::TYPE_TEXT, pDocument, func_impl, error_message, objRecord, objUI);
+ glom_python_call(Field::glom_field_type::TEXT, pDocument, func_impl, error_message, objRecord, objUI);
}
Gnome::Gda::Value glom_evaluate_python_function_implementation(Field::glom_field_type result_type,
diff --git a/glom/utility_widgets/adddel/adddel.cc b/glom/utility_widgets/adddel/adddel.cc
index a19daa3..d3f4963 100644
--- a/glom/utility_widgets/adddel/adddel.cc
+++ b/glom/utility_widgets/adddel/adddel.cc
@@ -38,8 +38,8 @@ namespace Glom
{
AddDelColumnInfo::AddDelColumnInfo()
-: m_style(STYLE_Text),
- m_field_type(Field::TYPE_INVALID),
+: m_style(enumStyles::Text),
+ m_field_type(Field::glom_field_type::INVALID),
m_editable(true),
m_visible(true),
m_prevent_duplicates(false)
@@ -100,7 +100,7 @@ void AddDel::init()
set_prevent_user_signals();
set_ignore_treeview_signals();
- set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
m_bAllowUserActions = true;
@@ -348,7 +348,7 @@ Glib::ustring AddDel::get_value(const Gtk::TreeModel::iterator& iter, guint col)
{
const guint col_real = col;
//Get different types of data, depending on the column:
- if(m_ColumnTypes[col_real].m_style == AddDelColumnInfo::STYLE_Boolean)
+ if(m_ColumnTypes[col_real].m_style == AddDelColumnInfo::enumStyles::Boolean)
{
bool bValue = false;
treerow.get_value(col_real, bValue);
@@ -518,7 +518,7 @@ guint AddDel::get_columns_count() const
/*
void AddDel::set_columns_count(guint count)
{
- m_ColumnTypes.resize(count, STYLE_Text);
+ m_ColumnTypes.resize(count, enumStyles::Text);
m_vecColumnNames.resize(count);
}
*/
@@ -562,12 +562,12 @@ void AddDel::construct_specified_columns()
switch(column_info.m_style)
{
//Create an appropriate type of Model Column:
- case(AddDelColumnInfo::STYLE_Boolean):
+ case(AddDelColumnInfo::enumStyles::Boolean):
{
pModelColumn = new Gtk::TreeModelColumn<bool>();
break;
}
- case(AddDelColumnInfo::STYLE_Numerical):
+ case(AddDelColumnInfo::enumStyles::Numerical):
{
pModelColumn = new Gtk::TreeModelColumn<int>(); //TODO: Actually there are many different numeric
types.
break;
@@ -606,7 +606,7 @@ void AddDel::construct_specified_columns()
switch(m_ColumnTypes[model_column_index].m_style)
{
- case(AddDelColumnInfo::STYLE_Choices):
+ case(AddDelColumnInfo::enumStyles::Choices):
{
//Use a custom CellRenderer:
CellRendererList* pCellRendererList = Gtk::manage( new CellRendererList() );
@@ -624,7 +624,7 @@ void AddDel::construct_specified_columns()
break;
}
- case(AddDelColumnInfo::STYLE_Boolean):
+ case(AddDelColumnInfo::enumStyles::Boolean):
{
//Use whatever standard CellRenderer gtkmm thinks is appropriate:
@@ -704,13 +704,13 @@ void AddDel::construct_specified_columns()
{
//Cast it to the derived type, so we can delete it properly.
//This is necessary because TreeModelColumnBase's destructor is not virtual.
- case(AddDelColumnInfo::STYLE_Boolean):
+ case(AddDelColumnInfo::enumStyles::Boolean):
{
Gtk::TreeModelColumn<bool>* pModelColumnDerived = static_cast< Gtk::TreeModelColumn<bool>*
(pModelColumn);
delete pModelColumnDerived;
break;
}
- case(AddDelColumnInfo::STYLE_Numerical):
+ case(AddDelColumnInfo::enumStyles::Numerical):
{
Gtk::TreeModelColumn<int>* pModelColumnDerived = static_cast< Gtk::TreeModelColumn<int>*
(pModelColumn);
delete pModelColumnDerived;
@@ -743,7 +743,7 @@ void AddDel::set_value(const Gtk::TreeModel::iterator& iter, guint col, const Gn
//Different model columns have different types of data:
switch(m_ColumnTypes[col].m_style)
{
- case(AddDelColumnInfo::STYLE_Boolean):
+ case(AddDelColumnInfo::enumStyles::Boolean):
{
std::cerr << G_STRFUNC << ": boolean column being set as bool." << std::endl;
set_value(iter, col, value.get_bool());
@@ -772,7 +772,7 @@ void AddDel::set_value(const Gtk::TreeModel::iterator& iter, guint col, const Gl
//Different model columns have different types of data:
switch(m_ColumnTypes[col].m_style)
{
- case(AddDelColumnInfo::STYLE_Boolean):
+ case(AddDelColumnInfo::enumStyles::Boolean):
{
bool bValue = (strValue == "true");
treerow.set_value(col, bValue);
@@ -822,7 +822,7 @@ void AddDel::set_value(const Gtk::TreeModel::iterator& iter, guint col, bool bVa
//Different model columns have different types of data:
switch(m_ColumnTypes[col].m_style)
{
- case(AddDelColumnInfo::STYLE_Boolean):
+ case(AddDelColumnInfo::enumStyles::Boolean):
{
treerow.set_value(col, bVal);
break;
@@ -854,8 +854,8 @@ void AddDel::remove_all_columns()
//Add the hidden key.ID columns
//Make these visible (with true) if you want to debug problems.
- m_col_key = add_column("Glom Hidden Key", AddDelColumnInfo::STYLE_Text, false /* not editable */, false /*
not visible */);
- m_col_placeholder = add_column("Glom Hidden Placeholder", AddDelColumnInfo::STYLE_Boolean, true /* not
editable */, false /* not visible */);
+ m_col_key = add_column("Glom Hidden Key", AddDelColumnInfo::enumStyles::Text, false /* not editable */,
false /* not visible */);
+ m_col_placeholder = add_column("Glom Hidden Placeholder", AddDelColumnInfo::enumStyles::Boolean, true /*
not editable */, false /* not visible */);
}
guint AddDel::add_column(const AddDelColumnInfo& column_info)
@@ -1209,7 +1209,7 @@ void AddDel::on_treeview_cell_edited(const Glib::ustring& path_string, const Gli
bool do_signal = true;
const Field::glom_field_type field_type = m_ColumnTypes[model_column_index].m_field_type;
- if(field_type != Field::TYPE_INVALID) //If a field type was specified for this column.
+ if(field_type != Field::glom_field_type::INVALID) //If a field type was specified for this column.
{
//Make sure that the entered data is suitable for this field type:
bool success = false;
@@ -1578,11 +1578,11 @@ bool AddDel::row_has_duplicates(const Gtk::TreeModel::iterator& iter) const
bool value_bool = false;
int value_int = 0;
- if(m_ColumnTypes[col].m_style == AddDelColumnInfo::STYLE_Text)
+ if(m_ColumnTypes[col].m_style == AddDelColumnInfo::enumStyles::Text)
row.get_value(col, value_text);
- else if(m_ColumnTypes[col].m_style == AddDelColumnInfo::STYLE_Boolean)
+ else if(m_ColumnTypes[col].m_style == AddDelColumnInfo::enumStyles::Boolean)
row.get_value(col, value_bool);
- else if(m_ColumnTypes[col].m_style == AddDelColumnInfo::STYLE_Numerical)
+ else if(m_ColumnTypes[col].m_style == AddDelColumnInfo::enumStyles::Numerical)
row.get_value(col, value_int);
//std::cout << "value_text=" << value_text << std::endl;
@@ -1605,7 +1605,7 @@ bool AddDel::row_has_duplicates(const Gtk::TreeModel::iterator& iter) const
bool check_value_bool = false;
int check_value_int = 0;
- if(m_ColumnTypes[col].m_style == AddDelColumnInfo::STYLE_Text)
+ if(m_ColumnTypes[col].m_style == AddDelColumnInfo::enumStyles::Text)
{
check_row.get_value(col, check_value_text);
@@ -1614,13 +1614,13 @@ bool AddDel::row_has_duplicates(const Gtk::TreeModel::iterator& iter) const
if(check_value_text == value_text)
return true;
}
- else if(m_ColumnTypes[col].m_style == AddDelColumnInfo::STYLE_Boolean)
+ else if(m_ColumnTypes[col].m_style == AddDelColumnInfo::enumStyles::Boolean)
{
check_row.get_value(col, check_value_bool);
if(check_value_text == value_text)
return true;
}
- else if(m_ColumnTypes[col].m_style == AddDelColumnInfo::STYLE_Numerical)
+ else if(m_ColumnTypes[col].m_style == AddDelColumnInfo::enumStyles::Numerical)
{
check_row.get_value(col, check_value_int);
if(check_value_text == value_text)
diff --git a/glom/utility_widgets/adddel/adddel.h b/glom/utility_widgets/adddel/adddel.h
index afe963a..e749d85 100644
--- a/glom/utility_widgets/adddel/adddel.h
+++ b/glom/utility_widgets/adddel/adddel.h
@@ -46,12 +46,12 @@ public:
AddDelColumnInfo& operator=(AddDelColumnInfo&& src) = delete;
//If we need any more complicated style (e.g. number of decimal digits) then we will need a separate
AddDelStyle class.
- enum enumStyles
+ enum class enumStyles
{
- STYLE_Text,
- STYLE_Numerical, //TODO: Right-justify
- STYLE_Boolean,
- STYLE_Choices
+ Text,
+ Numerical, //TODO: Right-justify
+ Boolean,
+ Choices
};
enumStyles m_style;
@@ -140,8 +140,8 @@ public:
guint add_column(const AddDelColumnInfo& column_info);
- guint add_column(const Glib::ustring& strTitle, AddDelColumnInfo::enumStyles style =
AddDelColumnInfo::STYLE_Text, bool editable = true, bool visible = true);
- guint add_column(const Glib::ustring& strTitle, const Glib::ustring& column_id,
AddDelColumnInfo::enumStyles style = AddDelColumnInfo::STYLE_Text, bool editable = true, bool visible = true);
+ guint add_column(const Glib::ustring& strTitle, AddDelColumnInfo::enumStyles style =
AddDelColumnInfo::enumStyles::Text, bool editable = true, bool visible = true);
+ guint add_column(const Glib::ustring& strTitle, const Glib::ustring& column_id,
AddDelColumnInfo::enumStyles style = AddDelColumnInfo::enumStyles::Text, bool editable = true, bool visible =
true);
void prevent_duplicates(guint column_number);
diff --git a/glom/utility_widgets/adddel/adddel_withbuttons.cc
b/glom/utility_widgets/adddel/adddel_withbuttons.cc
index 56a2bff..d9b7eef 100644
--- a/glom/utility_widgets/adddel/adddel_withbuttons.cc
+++ b/glom/utility_widgets/adddel/adddel_withbuttons.cc
@@ -49,11 +49,11 @@ AddDel_WithButtons::AddDel_WithButtons(BaseObjectType* cobject, const Glib::RefP
void AddDel_WithButtons::init()
{
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
- m_ButtonBox.set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ m_ButtonBox.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
- //m_Button_Add.set_border_width(UiUtils::DEFAULT_SPACING_SMALL);
- //m_Button_Del.set_border_width(UiUtils::DEFAULT_SPACING_SMALL);
- //m_Button_Edit.set_border_width(UiUtils::DEFAULT_SPACING_SMALL);
+ //m_Button_Add.set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+ //m_Button_Del.set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+ //m_Button_Edit.set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
setup_buttons();
pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
diff --git a/glom/utility_widgets/canvas/canvas_group_movable.cc
b/glom/utility_widgets/canvas/canvas_group_movable.cc
index 8dbcf33..1a3b138 100644
--- a/glom/utility_widgets/canvas/canvas_group_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_movable.cc
@@ -168,19 +168,19 @@ void CanvasGroupMovable::snap_position_one_corner(Corners corner, double& x, dou
double corner_y_offset = 0;
switch(corner)
{
- case CORNER_TOP_LEFT:
+ case Corners::TOP_LEFT:
corner_x_offset = 0;
corner_y_offset = 0;
break;
- case CORNER_TOP_RIGHT:
+ case Corners::TOP_RIGHT:
corner_x_offset = width;
corner_y_offset = 0;
break;
- case CORNER_BOTTOM_LEFT:
+ case Corners::BOTTOM_LEFT:
corner_x_offset = 0;
corner_y_offset = height;
break;
- case CORNER_BOTTOM_RIGHT:
+ case Corners::BOTTOM_RIGHT:
corner_x_offset = width;
corner_y_offset = height;
break;
@@ -212,7 +212,7 @@ void CanvasGroupMovable::snap_position(double& x, double& y) const
double offset_y_min = 0;
//Try snapping each corner, to choose the one that snapped closest:
- for(int i = CORNER_TOP_LEFT; i < CORNER_COUNT; ++i)
+ for(int i = static_cast<int>(Corners::TOP_LEFT); i < static_cast<int>(Corners::COUNT); ++i)
{
const Corners corner = (Corners)i;
double temp_x = x;
diff --git a/glom/utility_widgets/canvas/canvas_group_movable.h
b/glom/utility_widgets/canvas/canvas_group_movable.h
index 940fc81..19538eb 100644
--- a/glom/utility_widgets/canvas/canvas_group_movable.h
+++ b/glom/utility_widgets/canvas/canvas_group_movable.h
@@ -47,13 +47,13 @@ public:
private:
virtual Goocanvas::Canvas* get_parent_canvas_widget();
- enum Corners
+ enum class Corners
{
- CORNER_TOP_LEFT,
- CORNER_TOP_RIGHT,
- CORNER_BOTTOM_LEFT,
- CORNER_BOTTOM_RIGHT,
- CORNER_COUNT
+ TOP_LEFT,
+ TOP_RIGHT,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT,
+ COUNT
};
void snap_position_one_corner(Corners corner, double& x, double& y) const;
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.cc
b/glom/utility_widgets/canvas/canvas_group_resizable.cc
index 59011e9..b2266d0 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.cc
@@ -114,13 +114,13 @@ void CanvasGroupResizable::create_rect_manipulators()
m_group_edge_manipulators->add_child(m_manipulator_edge_right);
m_manipulator_corner_top_left->set_grid(m_grid);
- m_manipulator_corner_top_left->set_snap_corner(CanvasRectMovable::CORNER_TOP_LEFT);
+ m_manipulator_corner_top_left->set_snap_corner(CanvasRectMovable::Corners::TOP_LEFT);
m_manipulator_corner_top_right->set_grid(m_grid);
- m_manipulator_corner_top_right->set_snap_corner(CanvasRectMovable::CORNER_TOP_RIGHT);
+ m_manipulator_corner_top_right->set_snap_corner(CanvasRectMovable::Corners::TOP_RIGHT);
m_manipulator_corner_bottom_left->set_grid(m_grid);
- m_manipulator_corner_bottom_left->set_snap_corner(CanvasRectMovable::CORNER_BOTTOM_LEFT);
+ m_manipulator_corner_bottom_left->set_snap_corner(CanvasRectMovable::Corners::BOTTOM_LEFT);
m_manipulator_corner_bottom_right->set_grid(m_grid);
- m_manipulator_corner_bottom_right->set_snap_corner(CanvasRectMovable::CORNER_BOTTOM_RIGHT);
+ m_manipulator_corner_bottom_right->set_snap_corner(CanvasRectMovable::Corners::BOTTOM_RIGHT);
m_manipulator_edge_top->set_grid(m_grid);
m_manipulator_edge_bottom->set_grid(m_grid);
m_manipulator_edge_left->set_grid(m_grid);
@@ -139,14 +139,14 @@ void CanvasGroupResizable::create_rect_manipulators()
m_group_edge_manipulators->raise();//m_group_outline);
m_group_corner_manipulators->raise();//m_group_outline);
- manipulator_connect_signals(m_manipulator_corner_top_left, MANIPULATOR_CORNER_TOP_LEFT);
- manipulator_connect_signals(m_manipulator_corner_top_right, MANIPULATOR_CORNER_TOP_RIGHT);
- manipulator_connect_signals(m_manipulator_corner_bottom_left, MANIPULATOR_CORNER_BOTTOM_LEFT);
- manipulator_connect_signals(m_manipulator_corner_bottom_right, MANIPULATOR_CORNER_BOTTOM_RIGHT);
- manipulator_connect_signals(m_manipulator_edge_top, MANIPULATOR_EDGE_TOP);
- manipulator_connect_signals(m_manipulator_edge_bottom, MANIPULATOR_EDGE_BOTTOM);
- manipulator_connect_signals(m_manipulator_edge_left, MANIPULATOR_EDGE_LEFT);
- manipulator_connect_signals(m_manipulator_edge_right, MANIPULATOR_EDGE_RIGHT);
+ manipulator_connect_signals(m_manipulator_corner_top_left, Manipulators::CORNER_TOP_LEFT);
+ manipulator_connect_signals(m_manipulator_corner_top_right, Manipulators::CORNER_TOP_RIGHT);
+ manipulator_connect_signals(m_manipulator_corner_bottom_left, Manipulators::CORNER_BOTTOM_LEFT);
+ manipulator_connect_signals(m_manipulator_corner_bottom_right, Manipulators::CORNER_BOTTOM_RIGHT);
+ manipulator_connect_signals(m_manipulator_edge_top, Manipulators::EDGE_TOP);
+ manipulator_connect_signals(m_manipulator_edge_bottom, Manipulators::EDGE_BOTTOM);
+ manipulator_connect_signals(m_manipulator_edge_left, Manipulators::EDGE_LEFT);
+ manipulator_connect_signals(m_manipulator_edge_right, Manipulators::EDGE_RIGHT);
}
void CanvasGroupResizable::create_line_manipulators()
@@ -160,15 +160,15 @@ void CanvasGroupResizable::create_line_manipulators()
m_group_edge_manipulators->add_child(m_manipulator_end);
m_manipulator_start->set_grid(m_grid);
- //m_manipulator_corner_top_left->set_snap_corner(CanvasRectMovable::CORNER_TOP_LEFT);
+ //m_manipulator_corner_top_left->set_snap_corner(CanvasRectMovable::Corners::TOP_LEFT);
m_manipulator_end->set_grid(m_grid);
- //m_manipulator_corner_top_right->set_snap_corner(CanvasRectMovable::CORNER_TOP_RIGHT);
+ //m_manipulator_corner_top_right->set_snap_corner(CanvasRectMovable::Corners::TOP_RIGHT);
m_manipulator_start->set_drag_cursor(Gdk::TCROSS); //A rather arbitrary cursor.
m_manipulator_end->set_drag_cursor(Gdk::TCROSS);
- manipulator_connect_signals(m_manipulator_start, MANIPULATOR_START);
- manipulator_connect_signals(m_manipulator_end, MANIPULATOR_END);
+ manipulator_connect_signals(m_manipulator_start, Manipulators::START);
+ manipulator_connect_signals(m_manipulator_end, Manipulators::END);
}
Glib::RefPtr<CanvasLineMovable> CanvasGroupResizable::create_outline_line(double x1, double y1, double x2,
double y2)
@@ -498,27 +498,27 @@ Glib::RefPtr<CanvasItemMovable> CanvasGroupResizable::get_manipulator(Manipulato
switch(manipulator_id)
{
//Rectangle manipulators:
- case(MANIPULATOR_CORNER_TOP_LEFT):
+ case(Manipulators::CORNER_TOP_LEFT):
return m_manipulator_corner_top_left;
- case(MANIPULATOR_CORNER_TOP_RIGHT):
+ case(Manipulators::CORNER_TOP_RIGHT):
return m_manipulator_corner_top_right;
- case(MANIPULATOR_CORNER_BOTTOM_LEFT):
+ case(Manipulators::CORNER_BOTTOM_LEFT):
return m_manipulator_corner_bottom_left;
- case(MANIPULATOR_CORNER_BOTTOM_RIGHT):
+ case(Manipulators::CORNER_BOTTOM_RIGHT):
return m_manipulator_corner_bottom_right;
- case(MANIPULATOR_EDGE_TOP):
+ case(Manipulators::EDGE_TOP):
return m_manipulator_edge_top;
- case(MANIPULATOR_EDGE_BOTTOM):
+ case(Manipulators::EDGE_BOTTOM):
return m_manipulator_edge_bottom;
- case(MANIPULATOR_EDGE_LEFT):
+ case(Manipulators::EDGE_LEFT):
return m_manipulator_edge_left;
- case(MANIPULATOR_EDGE_RIGHT):
+ case(Manipulators::EDGE_RIGHT):
return m_manipulator_edge_right;
//Line manipulators:
- case(MANIPULATOR_START):
+ case(Manipulators::START):
return m_manipulator_start;
- case(MANIPULATOR_END):
+ case(Manipulators::END):
return m_manipulator_end;
default:
return Glib::RefPtr<CanvasItemMovable>();
@@ -550,7 +550,7 @@ void CanvasGroupResizable::on_manipulator_corner_moved(const Glib::RefPtr<Canvas
switch(manipulator_id)
{
- case(MANIPULATOR_CORNER_TOP_LEFT):
+ case(Manipulators::CORNER_TOP_LEFT):
{
const double new_x = std::min(manipulator_x, child_x + child_width);
const double new_y = std::min(manipulator_y, child_y + child_height);
@@ -561,7 +561,7 @@ void CanvasGroupResizable::on_manipulator_corner_moved(const Glib::RefPtr<Canvas
break;
}
- case(MANIPULATOR_CORNER_TOP_RIGHT):
+ case(Manipulators::CORNER_TOP_RIGHT):
{
const double new_y = std::min(manipulator_y, child_y + child_height);
const double new_height = std::max(child_y + child_height - manipulator->property_y(), 0.0);
@@ -572,7 +572,7 @@ void CanvasGroupResizable::on_manipulator_corner_moved(const Glib::RefPtr<Canvas
break;
}
- case(MANIPULATOR_CORNER_BOTTOM_LEFT):
+ case(Manipulators::CORNER_BOTTOM_LEFT):
{
const double new_x = std::min(manipulator_x, child_x + child_width);
const double new_height = std::max(manipulator->property_y() + MANIPULATOR_CORNER_SIZE - child_y, 0.0);
@@ -582,7 +582,7 @@ void CanvasGroupResizable::on_manipulator_corner_moved(const Glib::RefPtr<Canvas
break;
}
- case(MANIPULATOR_CORNER_BOTTOM_RIGHT):
+ case(Manipulators::CORNER_BOTTOM_RIGHT):
{
const double new_height = std::max(manipulator->property_y() + MANIPULATOR_CORNER_SIZE - child_y, 0.0);
const double new_width = std::max(manipulator->property_x() + MANIPULATOR_CORNER_SIZE - child_x, 0.0);
@@ -626,7 +626,7 @@ void CanvasGroupResizable::on_manipulator_line_end_moved(const Glib::RefPtr<Canv
if(points.get_num_points() < 2)
return;
- const int point_index = (manipulator_id == MANIPULATOR_START) ? 0 : 1;
+ const int point_index = (manipulator_id == Manipulators::START) ? 0 : 1;
const double half_size = MANIPULATOR_CORNER_SIZE / 2;
points.set_coordinate(point_index, manipulator_x + half_size, manipulator_y + half_size);
line->property_points() = points; //TODO: Add a way to do this without getting and setting the points
property.
@@ -676,7 +676,7 @@ void CanvasGroupResizable::on_manipulator_edge_moved(const Glib::RefPtr<CanvasIt
switch(manipulator_id)
{
- case(MANIPULATOR_EDGE_TOP):
+ case(Manipulators::EDGE_TOP):
{
const double new_y = y1;
const double new_height = std::max(child_y + child_height - y1, 0.0);
@@ -687,7 +687,7 @@ void CanvasGroupResizable::on_manipulator_edge_moved(const Glib::RefPtr<CanvasIt
break;
}
- case(MANIPULATOR_EDGE_BOTTOM):
+ case(Manipulators::EDGE_BOTTOM):
{
const double new_height = std::max(y1 - child_y, 0.0);
@@ -695,7 +695,7 @@ void CanvasGroupResizable::on_manipulator_edge_moved(const Glib::RefPtr<CanvasIt
break;
}
- case(MANIPULATOR_EDGE_LEFT):
+ case(Manipulators::EDGE_LEFT):
{
const double new_x = x1;
const double new_width = std::max(child_x + child_width - x1, 0.0);
@@ -705,7 +705,7 @@ void CanvasGroupResizable::on_manipulator_edge_moved(const Glib::RefPtr<CanvasIt
break;
}
- case(MANIPULATOR_EDGE_RIGHT):
+ case(Manipulators::EDGE_RIGHT):
{
const double new_width = std::max(x1 - child_x, 0.0);
@@ -925,7 +925,7 @@ void CanvasGroupResizable::snap_position(double& x, double& y) const
double offset_y_min = 0;
//Try snapping each corner, to choose the one that snapped closest:
- for(int i = 0; i < CORNER_COUNT; ++i)
+ for(int i = 0; i < static_cast<int>(Corners::COUNT); ++i)
{
const Corners corner = (Corners)i;
double temp_x = x;
@@ -958,19 +958,19 @@ void CanvasGroupResizable::snap_position(Corners corner, double& x, double& y) c
double corner_y_offset = 0;
switch(corner)
{
- case CORNER_TOP_LEFT:
+ case Corners::TOP_LEFT:
corner_x_offset = 0;
corner_y_offset = 0;
break;
- case CORNER_TOP_RIGHT:
+ case Corners::TOP_RIGHT:
corner_x_offset = child_width;
corner_y_offset = 0;
break;
- case CORNER_BOTTOM_LEFT:
+ case Corners::BOTTOM_LEFT:
corner_x_offset = 0;
corner_y_offset = child_height;
break;
- case CORNER_BOTTOM_RIGHT:
+ case Corners::BOTTOM_RIGHT:
corner_x_offset = child_width;
corner_y_offset = child_height;
break;
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.h
b/glom/utility_widgets/canvas/canvas_group_resizable.h
index d7952fc..ee94ab3 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.h
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.h
@@ -80,13 +80,13 @@ private:
virtual void show_selected();
virtual Goocanvas::Canvas* get_parent_canvas_widget();
- enum Corners
+ enum class Corners
{
- CORNER_TOP_LEFT,
- CORNER_TOP_RIGHT,
- CORNER_BOTTOM_LEFT,
- CORNER_BOTTOM_RIGHT,
- CORNER_COUNT
+ TOP_LEFT,
+ TOP_RIGHT,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT,
+ COUNT
};
void snap_position(Corners corner, double& x, double& y) const;
@@ -103,23 +103,23 @@ private:
virtual bool on_child_button_release_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventButton*
event);
virtual bool on_child_motion_notify_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventMotion*
event);
- enum Manipulators
+ enum class Manipulators
{
- MANIPULATOR_NONE,
+ NONE,
//For rectangles:
- MANIPULATOR_CORNER_TOP_LEFT,
- MANIPULATOR_CORNER_TOP_RIGHT,
- MANIPULATOR_CORNER_BOTTOM_LEFT,
- MANIPULATOR_CORNER_BOTTOM_RIGHT,
- MANIPULATOR_EDGE_TOP,
- MANIPULATOR_EDGE_BOTTOM,
- MANIPULATOR_EDGE_LEFT,
- MANIPULATOR_EDGE_RIGHT,
+ CORNER_TOP_LEFT,
+ CORNER_TOP_RIGHT,
+ CORNER_BOTTOM_LEFT,
+ CORNER_BOTTOM_RIGHT,
+ EDGE_TOP,
+ EDGE_BOTTOM,
+ EDGE_LEFT,
+ EDGE_RIGHT,
//For straight lines:
- MANIPULATOR_START,
- MANIPULATOR_END
+ START,
+ END
};
Glib::RefPtr<CanvasItemMovable> get_manipulator(Manipulators manipulator_id);
diff --git a/glom/utility_widgets/canvas/canvas_image_movable.cc
b/glom/utility_widgets/canvas/canvas_image_movable.cc
index 2df1127..3a013b6 100644
--- a/glom/utility_widgets/canvas/canvas_image_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_image_movable.cc
@@ -31,7 +31,7 @@ namespace Glom
CanvasImageMovable::CanvasImageMovable(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double x, double y)
: Goocanvas::Image(pixbuf, x, y),
- m_snap_corner(CORNER_TOP_LEFT), //arbitrary default.
+ m_snap_corner(Corners::TOP_LEFT), //arbitrary default.
m_image_empty(false)
{
init();
@@ -40,7 +40,7 @@ CanvasImageMovable::CanvasImageMovable(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf,
CanvasImageMovable::CanvasImageMovable(double x, double y)
: Goocanvas::Image(x, y),
CanvasItemMovable(),
- m_snap_corner(CORNER_TOP_LEFT) //arbitrary default.
+ m_snap_corner(Corners::TOP_LEFT) //arbitrary default.
{
init();
}
@@ -107,19 +107,19 @@ void CanvasImageMovable::snap_position(double& x, double& y) const
double corner_y_offset = 0;
switch(m_snap_corner)
{
- case CORNER_TOP_LEFT:
+ case Corners::TOP_LEFT:
corner_x_offset = 0;
corner_y_offset = 0;
break;
- case CORNER_TOP_RIGHT:
+ case Corners::TOP_RIGHT:
corner_x_offset = property_width();
corner_y_offset = 0;
break;
- case CORNER_BOTTOM_LEFT:
+ case Corners::BOTTOM_LEFT:
corner_x_offset = 0;
corner_y_offset = height;
break;
- case CORNER_BOTTOM_RIGHT:
+ case Corners::BOTTOM_RIGHT:
corner_x_offset = width;
corner_y_offset = height;
break;
diff --git a/glom/utility_widgets/canvas/canvas_image_movable.h
b/glom/utility_widgets/canvas/canvas_image_movable.h
index b6ee660..879fbc2 100644
--- a/glom/utility_widgets/canvas/canvas_image_movable.h
+++ b/glom/utility_widgets/canvas/canvas_image_movable.h
@@ -60,12 +60,12 @@ public:
*/
void scale_to_size();
- enum Corners
+ enum class Corners
{
- CORNER_TOP_LEFT,
- CORNER_TOP_RIGHT,
- CORNER_BOTTOM_LEFT,
- CORNER_BOTTOM_RIGHT
+ TOP_LEFT,
+ TOP_RIGHT,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT
};
/** Specify the corner to be considered when snapping to a grid while moving.
diff --git a/glom/utility_widgets/canvas/canvas_rect_movable.cc
b/glom/utility_widgets/canvas/canvas_rect_movable.cc
index c7d30cc..a1d3760 100644
--- a/glom/utility_widgets/canvas/canvas_rect_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_rect_movable.cc
@@ -30,14 +30,14 @@ namespace Glom
CanvasRectMovable::CanvasRectMovable()
: Goocanvas::Rect(0.0, 0.0, 0.0, 0.0),
CanvasItemMovable(),
- m_snap_corner(CORNER_ALL)
+ m_snap_corner(Corners::ALL)
{
init();
}
CanvasRectMovable::CanvasRectMovable(double x, double y, double width, double height)
: Goocanvas::Rect(x, y, width, height),
- m_snap_corner(CORNER_ALL)
+ m_snap_corner(Corners::ALL)
{
init();
}
@@ -97,19 +97,19 @@ void CanvasRectMovable::snap_position_one_corner(Corners corner, double& x, doub
double corner_y_offset = 0;
switch(corner)
{
- case CORNER_TOP_LEFT:
+ case Corners::TOP_LEFT:
corner_x_offset = 0;
corner_y_offset = 0;
break;
- case CORNER_TOP_RIGHT:
+ case Corners::TOP_RIGHT:
corner_x_offset = property_width();
corner_y_offset = 0;
break;
- case CORNER_BOTTOM_LEFT:
+ case Corners::BOTTOM_LEFT:
corner_x_offset = 0;
corner_y_offset = property_height();
break;
- case CORNER_BOTTOM_RIGHT:
+ case Corners::BOTTOM_RIGHT:
corner_x_offset = property_width();
corner_y_offset = property_height();
break;
@@ -139,7 +139,7 @@ void CanvasRectMovable::snap_position_all_corners(double& x, double& y) const
double offset_y_min = 0;
//Try snapping each corner, to choose the one that snapped closest:
- for(int i = CORNER_TOP_LEFT; i < CORNER_COUNT; ++i)
+ for(int i = static_cast<int>(Corners::TOP_LEFT); i < static_cast<int>(Corners::COUNT); ++i)
{
const Corners corner = (Corners)i;
double temp_x = x;
@@ -163,7 +163,7 @@ void CanvasRectMovable::snap_position_all_corners(double& x, double& y) const
void CanvasRectMovable::snap_position(double& x, double& y) const
{
- if(m_snap_corner == CORNER_ALL)
+ if(m_snap_corner == Corners::ALL)
return snap_position_all_corners(x, y);
else
return snap_position_one_corner(m_snap_corner, x, y);
diff --git a/glom/utility_widgets/canvas/canvas_rect_movable.h
b/glom/utility_widgets/canvas/canvas_rect_movable.h
index c948f9c..5a7f332 100644
--- a/glom/utility_widgets/canvas/canvas_rect_movable.h
+++ b/glom/utility_widgets/canvas/canvas_rect_movable.h
@@ -42,14 +42,14 @@ public:
static Glib::RefPtr<CanvasRectMovable> create();
static Glib::RefPtr<CanvasRectMovable> create(double x, double y, double width, double height);
- enum Corners
+ enum class Corners
{
- CORNER_ALL, // Snap to all corners.
- CORNER_TOP_LEFT,
- CORNER_TOP_RIGHT,
- CORNER_BOTTOM_LEFT,
- CORNER_BOTTOM_RIGHT,
- CORNER_COUNT
+ ALL, // Snap to all corners.
+ TOP_LEFT,
+ TOP_RIGHT,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT,
+ COUNT
};
/** Specify the corner to be considered when snapping to a grid while moving.
diff --git a/glom/utility_widgets/canvas/canvas_table_movable.cc
b/glom/utility_widgets/canvas/canvas_table_movable.cc
index 17fe85d..a6833f6 100644
--- a/glom/utility_widgets/canvas/canvas_table_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_table_movable.cc
@@ -113,19 +113,19 @@ void CanvasTableMovable::snap_position_one_corner(Corners corner, double& x, dou
double corner_y_offset = 0;
switch(corner)
{
- case CORNER_TOP_LEFT:
+ case Corners::TOP_LEFT:
corner_x_offset = 0;
corner_y_offset = 0;
break;
- case CORNER_TOP_RIGHT:
+ case Corners::TOP_RIGHT:
corner_x_offset = width;
corner_y_offset = 0;
break;
- case CORNER_BOTTOM_LEFT:
+ case Corners::BOTTOM_LEFT:
corner_x_offset = 0;
corner_y_offset = height;
break;
- case CORNER_BOTTOM_RIGHT:
+ case Corners::BOTTOM_RIGHT:
corner_x_offset = width;
corner_y_offset = height;
break;
@@ -157,7 +157,7 @@ void CanvasTableMovable::snap_position(double& x, double& y) const
double offset_y_min = 0;
//Try snapping each corner, to choose the one that snapped closest:
- for(int i = CORNER_TOP_LEFT; i < CORNER_COUNT; ++i)
+ for(int i = static_cast<int>(Corners::TOP_LEFT); i < static_cast<int>(Corners::COUNT); ++i)
{
const Corners corner = (Corners)i;
double temp_x = x;
diff --git a/glom/utility_widgets/canvas/canvas_table_movable.h
b/glom/utility_widgets/canvas/canvas_table_movable.h
index 3746834..29f494d 100644
--- a/glom/utility_widgets/canvas/canvas_table_movable.h
+++ b/glom/utility_widgets/canvas/canvas_table_movable.h
@@ -54,13 +54,13 @@ public:
private:
virtual Goocanvas::Canvas* get_parent_canvas_widget();
- enum Corners
+ enum class Corners
{
- CORNER_TOP_LEFT,
- CORNER_TOP_RIGHT,
- CORNER_BOTTOM_LEFT,
- CORNER_BOTTOM_RIGHT,
- CORNER_COUNT
+ TOP_LEFT,
+ TOP_RIGHT,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT,
+ COUNT
};
void snap_position_one_corner(Corners corner, double& x, double& y) const;
diff --git a/glom/utility_widgets/canvas/canvas_text_movable.cc
b/glom/utility_widgets/canvas/canvas_text_movable.cc
index 7d865e4..c490277 100644
--- a/glom/utility_widgets/canvas/canvas_text_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_text_movable.cc
@@ -30,7 +30,7 @@ namespace Glom
CanvasTextMovable::CanvasTextMovable(const Glib::ustring& text, double x, double y, double width,
Goocanvas::AnchorType anchor)
: Goocanvas::Text(text, x, y, width, anchor),
- m_snap_corner(CORNER_TOP_LEFT) //arbitrary default.
+ m_snap_corner(Corners::TOP_LEFT) //arbitrary default.
{
init();
}
@@ -92,19 +92,19 @@ void CanvasTextMovable::snap_position(double& x, double& y) const
double corner_y_offset = 0;
switch(m_snap_corner)
{
- case CORNER_TOP_LEFT:
+ case Corners::TOP_LEFT:
corner_x_offset = 0;
corner_y_offset = 0;
break;
- case CORNER_TOP_RIGHT:
+ case Corners::TOP_RIGHT:
corner_x_offset = property_width();
corner_y_offset = 0;
break;
- case CORNER_BOTTOM_LEFT:
+ case Corners::BOTTOM_LEFT:
corner_x_offset = 0;
corner_y_offset = height;
break;
- case CORNER_BOTTOM_RIGHT:
+ case Corners::BOTTOM_RIGHT:
corner_x_offset = width;
corner_y_offset = height;
break;
diff --git a/glom/utility_widgets/canvas/canvas_text_movable.h
b/glom/utility_widgets/canvas/canvas_text_movable.h
index 5b8c006..f20ecc6 100644
--- a/glom/utility_widgets/canvas/canvas_text_movable.h
+++ b/glom/utility_widgets/canvas/canvas_text_movable.h
@@ -40,12 +40,12 @@ private:
public:
static Glib::RefPtr<CanvasTextMovable> create(const Glib::ustring& string = Glib::ustring(), double x =
0.0, double y = 0.0, double width = 0.0, Goocanvas::AnchorType anchor = Goocanvas::ANCHOR_NORTH_WEST);
- enum Corners
+ enum class Corners
{
- CORNER_TOP_LEFT,
- CORNER_TOP_RIGHT,
- CORNER_BOTTOM_LEFT,
- CORNER_BOTTOM_RIGHT
+ TOP_LEFT,
+ TOP_RIGHT,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT
};
/** Specify the corner to be considered when snapping to a grid while moving.
diff --git a/glom/utility_widgets/filechooserdialog_saveextras.cc
b/glom/utility_widgets/filechooserdialog_saveextras.cc
index a5f47e0..6106311 100644
--- a/glom/utility_widgets/filechooserdialog_saveextras.cc
+++ b/glom/utility_widgets/filechooserdialog_saveextras.cc
@@ -86,9 +86,9 @@ void FileChooserDialog_SaveExtras::create_child_widgets()
frame->set_shadow_type(Gtk::SHADOW_NONE);
frame->show();
- Gtk::Box* vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, UiUtils::DEFAULT_SPACING_SMALL));
- vbox->set_margin_start(UiUtils::DEFAULT_SPACING_LARGE);
- vbox->set_margin_top(UiUtils::DEFAULT_SPACING_SMALL);
+ Gtk::Box* vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL,
static_cast<int>(UiUtils::DefaultSpacings::SMALL)));
+ vbox->set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
+ vbox->set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
frame->add(*vbox);
vbox->show();
@@ -100,7 +100,7 @@ void FileChooserDialog_SaveExtras::create_child_widgets()
label_newdb->set_valign(Gtk::ALIGN_CENTER);
label_newdb->show();
- Gtk::Box* box_label = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL,
UiUtils::DEFAULT_SPACING_LARGE));
+ Gtk::Box* box_label = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL,
static_cast<int>(UiUtils::DefaultSpacings::LARGE)));
Gtk::Label* label_title = Gtk::manage(new Gtk::Label(_("_Title:"), true));
box_label->pack_start(*label_title, Gtk::PACK_SHRINK);
label_title->show();
@@ -177,25 +177,25 @@ void FileChooserDialog_SaveExtras::set_extra_newdb_hosting_mode(Document::Hostin
switch(mode)
{
#ifdef GLOM_ENABLE_POSTGRESQL
- case Document::HOSTING_MODE_POSTGRES_CENTRAL:
+ case Document::HostingMode::POSTGRES_CENTRAL:
m_radiobutton_server_postgres_central.set_active();
break;
- case Document::HOSTING_MODE_POSTGRES_SELF:
+ case Document::HostingMode::POSTGRES_SELF:
m_radiobutton_server_postgres_selfhosted.set_active();
break;
#endif //GLOM_ENABLE_POSTGRESQL
#ifdef GLOM_ENABLE_SQLITE
- case Document::HOSTING_MODE_SQLITE:
+ case Document::HostingMode::SQLITE:
m_radiobutton_server_sqlite.set_active();
break;
#endif //GLOM_ENABLE_SQLITE
#ifdef GLOM_ENABLE_MYSQL
- case Document::HOSTING_MODE_MYSQL_CENTRAL:
+ case Document::HostingMode::MYSQL_CENTRAL:
m_radiobutton_server_mysql_central.set_active();
break;
- case Document::HOSTING_MODE_MYSQL_SELF:
+ case Document::HostingMode::MYSQL_SELF:
m_radiobutton_server_mysql_selfhosted.set_active();
break;
#endif //GLOM_ENABLE_SQLITE
@@ -215,29 +215,29 @@ Document::HostingMode FileChooserDialog_SaveExtras::get_extra_newdb_hosting_mode
{
#ifdef GLOM_ENABLE_POSTGRESQL
if(m_radiobutton_server_postgres_central.get_active())
- return Document::HOSTING_MODE_POSTGRES_CENTRAL;
+ return Document::HostingMode::POSTGRES_CENTRAL;
else if(m_radiobutton_server_postgres_selfhosted.get_active())
- return Document::HOSTING_MODE_POSTGRES_SELF;
+ return Document::HostingMode::POSTGRES_SELF;
#endif //GLOM_ENABLE_POSTGRESQL
#ifdef GLOM_ENABLE_SQLITE
if(m_radiobutton_server_sqlite.get_active())
- return Document::HOSTING_MODE_SQLITE;
+ return Document::HostingMode::SQLITE;
#endif //GLOM_ENABLE_SQLITE
#ifdef GLOM_ENABLE_MYSQL
if(m_radiobutton_server_mysql_central.get_active())
- return Document::HOSTING_MODE_MYSQL_CENTRAL;
+ return Document::HostingMode::MYSQL_CENTRAL;
else if(m_radiobutton_server_mysql_selfhosted.get_active())
- return Document::HOSTING_MODE_MYSQL_SELF;
+ return Document::HostingMode::MYSQL_SELF;
#endif //GLOM_ENABLE_MYSQL
g_assert_not_reached();
#ifdef GLOM_ENABLE_SQLITE
- return Document::HOSTING_MODE_SQLITE; //Arbitrary
+ return Document::HostingMode::SQLITE; //Arbitrary
#else
- return Document::HOSTING_MODE_POSTGRES_SELF; //Arbitrary.
+ return Document::HostingMode::POSTGRES_SELF; //Arbitrary.
#endif //GLOM_ENABLE_SQLITE
}
diff --git a/glom/utility_widgets/imageglom.cc b/glom/utility_widgets/imageglom.cc
index 63f105e..80b784d 100644
--- a/glom/utility_widgets/imageglom.cc
+++ b/glom/utility_widgets/imageglom.cc
@@ -129,7 +129,7 @@ bool ImageGlom::on_button_press_event(GdkEventButton *button_event)
//Only show this popup in developer mode, so operators still see the default GtkEntry context menu.
//TODO: It would be better to add it somehow to the standard context menu.
#ifndef GLOM_ENABLE_CLIENT_ONLY
- if(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
if(mods & GDK_BUTTON3_MASK)
{
diff --git a/glom/utility_widgets/layouttoolbar.cc b/glom/utility_widgets/layouttoolbar.cc
index fb66e42..b9a019e 100644
--- a/glom/utility_widgets/layouttoolbar.cc
+++ b/glom/utility_widgets/layouttoolbar.cc
@@ -30,19 +30,19 @@ namespace Glom
LayoutToolbar::LayoutToolbar()
: m_group_items(_("Items")),
m_group_containers(_("Containers")),
- m_drag_group("glom-group.png", LayoutWidgetBase::TYPE_GROUP,
+ m_drag_group("glom-group.png", LayoutWidgetBase::enumType::GROUP,
_("Group"), _("Drag this to the layout to add a new group.")),
- m_drag_notebook("glom-notebook.png", LayoutWidgetBase::TYPE_NOTEBOOK,
+ m_drag_notebook("glom-notebook.png", LayoutWidgetBase::enumType::NOTEBOOK,
_("Notebook"), _("Drag this to the layout to add a new notebook.")),
- m_drag_item("glom-field.png", LayoutWidgetBase::TYPE_FIELD,
+ m_drag_item("glom-field.png", LayoutWidgetBase::enumType::FIELD,
_("Database Field"), _("Drag this to the layout to add a new database field.")),
- m_drag_portal("glom-related-records.png", LayoutWidgetBase::TYPE_PORTAL,
+ m_drag_portal("glom-related-records.png", LayoutWidgetBase::enumType::PORTAL,
_("Related Records"), _("Drag this to the layout to add a new Related Record.")),
- m_drag_button("glom-button.png", LayoutWidgetBase::TYPE_BUTTON,
+ m_drag_button("glom-button.png", LayoutWidgetBase::enumType::BUTTON,
_("Button"), _("Drag this to the layout to add a new button.")),
- m_drag_text("glom-text.png", LayoutWidgetBase::TYPE_TEXT,
+ m_drag_text("glom-text.png", LayoutWidgetBase::enumType::TEXT,
_("Group"), _("Drag this to the layout to add a new static text box.")),
- m_drag_image("glom-image.png", LayoutWidgetBase::TYPE_IMAGE,
+ m_drag_image("glom-image.png", LayoutWidgetBase::enumType::IMAGE,
_("Image"), _("Drag this to the layout to add a new static image."))
{
// Looks ugly otherwise:
diff --git a/glom/utility_widgets/layoutwidgetbase.cc b/glom/utility_widgets/layoutwidgetbase.cc
index a5ef17a..d6aa9fc 100644
--- a/glom/utility_widgets/layoutwidgetbase.cc
+++ b/glom/utility_widgets/layoutwidgetbase.cc
@@ -121,9 +121,9 @@ void LayoutWidgetBase::apply_formatting(Gtk::Widget& widget, const std::shared_p
const Formatting::HorizontalAlignment alignment =
layout_item->get_formatting_used_horizontal_alignment(true /* for details view */);
const Gtk::Justification justification =
- (alignment == Formatting::HORIZONTAL_ALIGNMENT_LEFT ? Gtk::JUSTIFY_LEFT : Gtk::JUSTIFY_RIGHT);
+ (alignment == Formatting::HorizontalAlignment::LEFT ? Gtk::JUSTIFY_LEFT : Gtk::JUSTIFY_RIGHT);
const Gtk::Align x_align =
- (alignment == Formatting::HORIZONTAL_ALIGNMENT_LEFT ? Gtk::ALIGN_START : Gtk::ALIGN_END);
+ (alignment == Formatting::HorizontalAlignment::LEFT ? Gtk::ALIGN_START : Gtk::ALIGN_END);
Gtk::Label* label = dynamic_cast<Gtk::Label*>(widget_to_change);
if(label)
diff --git a/glom/utility_widgets/layoutwidgetbase.h b/glom/utility_widgets/layoutwidgetbase.h
index a59e329..beae736 100644
--- a/glom/utility_widgets/layoutwidgetbase.h
+++ b/glom/utility_widgets/layoutwidgetbase.h
@@ -45,15 +45,15 @@ public:
std::shared_ptr<const LayoutItem> get_layout_item() const;
std::shared_ptr<LayoutItem> get_layout_item();
- enum enumType
+ enum class enumType
{
- TYPE_FIELD,
- TYPE_GROUP,
- TYPE_NOTEBOOK,
- TYPE_PORTAL,
- TYPE_BUTTON,
- TYPE_TEXT,
- TYPE_IMAGE
+ FIELD,
+ GROUP,
+ NOTEBOOK,
+ PORTAL,
+ BUTTON,
+ TEXT,
+ IMAGE
};
#ifndef GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/utility_widgets/layoutwidgetmenu.cc b/glom/utility_widgets/layoutwidgetmenu.cc
index 2da90bd..d2fc64c 100644
--- a/glom/utility_widgets/layoutwidgetmenu.cc
+++ b/glom/utility_widgets/layoutwidgetmenu.cc
@@ -79,22 +79,22 @@ void LayoutWidgetMenu::setup_menu(Gtk::Widget* widget)
sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_activate_layout_properties) );
add_action(m_refContextAddField,
- sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), TYPE_FIELD ) );
+ sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), enumType::FIELD ) );
add_action(m_refContextAddRelatedRecords,
- sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), TYPE_PORTAL ) );
+ sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), enumType::PORTAL ) );
add_action(m_refContextAddGroup,
- sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), TYPE_GROUP ) );
+ sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), enumType::GROUP ) );
add_action(m_refContextAddNotebook,
- sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), TYPE_NOTEBOOK ) );
+ sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), enumType::NOTEBOOK ) );
add_action(m_refContextAddButton,
- sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), TYPE_BUTTON ) );
+ sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), enumType::BUTTON ) );
add_action(m_refContextAddText,
- sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), TYPE_TEXT ) );
+ sigc::bind( sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_add_item), enumType::TEXT ) );
add_action(m_refContextDelete,
sigc::mem_fun(*this, &LayoutWidgetMenu::on_menupopup_activate_delete) );
@@ -130,7 +130,7 @@ void LayoutWidgetMenu::setup_menu(Gtk::Widget* widget)
m_pMenuPopup->attach_to_widget(*widget);
if(pApp)
- m_refContextLayout->set_enabled(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER);
+ m_refContextLayout->set_enabled(pApp->get_userlevel() == AppState::userlevels::DEVELOPER);
//Make our popup menu work:
widget->insert_action_group("context", m_refActionGroup);
diff --git a/glom/utility_widgets/notebook_noframe.cc b/glom/utility_widgets/notebook_noframe.cc
index 8fba0d6..74b000c 100644
--- a/glom/utility_widgets/notebook_noframe.cc
+++ b/glom/utility_widgets/notebook_noframe.cc
@@ -31,10 +31,10 @@ namespace Glom
NotebookNoFrame::NotebookNoFrame()
{
set_orientation(Gtk::ORIENTATION_VERTICAL);
- set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
m_box_top.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
- m_box_top.set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ m_box_top.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
m_box_top.pack_start(m_box_action_left, Gtk::PACK_SHRINK);
m_box_top.pack_start(m_box_tabs);
m_box_top.pack_end(m_box_action_right, Gtk::PACK_SHRINK);
@@ -48,7 +48,7 @@ NotebookNoFrame::NotebookNoFrame()
m_box_pages.property_visible_child().signal_changed().connect(
sigc::mem_fun(*this, &NotebookNoFrame::on_visible_child_changed));
- //m_box_tabs.set_spacing(UiUtils::DEFAULT_SPACING_SMALL);
+ //m_box_tabs.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
m_box_tabs.show();
diff --git a/glom/utility_widgets/notebooklabelglom.cc b/glom/utility_widgets/notebooklabelglom.cc
index 250a7ea..64bcc09 100644
--- a/glom/utility_widgets/notebooklabelglom.cc
+++ b/glom/utility_widgets/notebooklabelglom.cc
@@ -131,7 +131,7 @@ void NotebookLabel::setup_menu(Gtk::Widget* /* widget */)
bool NotebookLabel::on_button_press_event(GdkEventButton *button_event)
{
AppWindow* pApp = get_appwindow();
- if(pApp && pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ if(pApp && pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0, 0,
&mods );
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index d71364c..bde736c 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -349,13 +349,13 @@ int UiUtils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const std:
Glib::ustring example_text;
switch(field_type)
{
- case(Field::TYPE_DATE):
+ case(Field::glom_field_type::DATE):
{
const 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):
+ case(Field::glom_field_type::TIME):
{
Gnome::Gda::Time time = {0, 0, 0, 0, 0};
time.hour = 24;
@@ -364,7 +364,7 @@ int UiUtils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const std:
example_text = Conversions::get_text_for_gda_value(field_type, Gnome::Gda::Value(time));
break;
}
- case(Field::TYPE_NUMERIC):
+ case(Field::glom_field_type::NUMERIC):
{
if(for_treeview)
example_text = "EUR 999.99";
@@ -373,8 +373,8 @@ int UiUtils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const std:
break;
}
- case(Field::TYPE_TEXT):
- case(Field::TYPE_IMAGE): //Give images the same width as text fields, so they will often line up.
+ case(Field::glom_field_type::TEXT):
+ case(Field::glom_field_type::IMAGE): //Give images the same width as text fields, so they will often
line up.
{
if(for_treeview)
example_text = "AAAAAAAAAAAA";
@@ -444,15 +444,15 @@ Glib::RefPtr<Gdk::Pixbuf> UiUtils::image_scale_keeping_ratio(const Glib::RefPtr<
if(!pixbuf)
return pixbuf;
- enum enum_scale_mode
+ enum class enum_scale_mode
{
- SCALE_WIDTH,
- SCALE_HEIGHT,
- SCALE_BOTH,
- SCALE_NONE
+ WIDTH,
+ HEIGHT,
+ BOTH,
+ NONE
};
- enum_scale_mode scale_mode = SCALE_NONE; //Start with either the width or height, and scale the other
according to the ratio.
+ enum_scale_mode scale_mode = enum_scale_mode::NONE; //Start with either the width or height, and scale the
other according to the ratio.
const auto pixbuf_height = pixbuf->get_height();
const auto pixbuf_width = pixbuf->get_width();
@@ -461,33 +461,33 @@ Glib::RefPtr<Gdk::Pixbuf> UiUtils::image_scale_keeping_ratio(const Glib::RefPtr<
{
if(pixbuf_width > target_width)
{
- scale_mode = SCALE_BOTH;
+ scale_mode = enum_scale_mode::BOTH;
}
else
{
//Only the height is bigger:
- scale_mode = SCALE_HEIGHT;
+ scale_mode = enum_scale_mode::HEIGHT;
}
}
else if(pixbuf_width > target_width)
{
//Only the height is bigger:
- scale_mode = SCALE_WIDTH;
+ scale_mode = enum_scale_mode::WIDTH;
}
- if(scale_mode == SCALE_NONE)
+ if(scale_mode == enum_scale_mode::NONE)
return pixbuf;
- else if(scale_mode == SCALE_HEIGHT)
+ else if(scale_mode == enum_scale_mode::HEIGHT)
{
const float ratio = (float)target_height / (float)pixbuf_height;
target_width = (int)((float)pixbuf_width * ratio);
}
- else if(scale_mode == SCALE_WIDTH)
+ else if(scale_mode == enum_scale_mode::WIDTH)
{
const float ratio = (float)target_width / (float) pixbuf_width;
target_height = (int)((float)pixbuf_height * ratio);
}
- else if(scale_mode == SCALE_BOTH)
+ else if(scale_mode == enum_scale_mode::BOTH)
{
const auto ratio = std::min(
(float)target_width / (float) pixbuf_width,
diff --git a/glom/utils_ui.h b/glom/utils_ui.h
index 9dcfc9e..bc52d30 100644
--- a/glom/utils_ui.h
+++ b/glom/utils_ui.h
@@ -38,10 +38,10 @@ namespace Glom
namespace UiUtils
{
-enum DefaultSpacings
+enum class DefaultSpacings
{
- DEFAULT_SPACING_LARGE = 12,
- DEFAULT_SPACING_SMALL = 6
+ LARGE = 12,
+ SMALL = 6
};
/**
diff --git a/glom/window_boxholder.cc b/glom/window_boxholder.cc
index 3656e7b..da8e07e 100644
--- a/glom/window_boxholder.cc
+++ b/glom/window_boxholder.cc
@@ -36,7 +36,7 @@ Window_BoxHolder::Window_BoxHolder(Box_WithButtons* pBox, const Glib::ustring& t
pBox->signal_cancelled.connect(sigc::mem_fun(*this, &Window_BoxHolder::on_box_cancelled));
- set_border_width(UiUtils::DEFAULT_SPACING_LARGE);
+ set_border_width(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
add(*pBox);
pBox->show();
diff --git a/tests/import/utils.cc b/tests/import/utils.cc
index 41cc09d..ee06fcc 100644
--- a/tests/import/utils.cc
+++ b/tests/import/utils.cc
@@ -100,7 +100,7 @@ bool run_parser_from_buffer(const FuncConnectParserSignals& connect_parser_signa
const auto file_uri = create_file_from_buffer(input, input_size);
parser.set_file_and_start_parsing(file_uri);
- if(Glom::CsvParser::STATE_PARSING != parser.get_state())
+ if(Glom::CsvParser::State::PARSING != parser.get_state())
return false;
mainloop->run();
@@ -142,7 +142,7 @@ bool run_parser_on_file(const FuncConnectParserSignals& connect_parser_signals,
connect_parser_signals(parser);
parser.set_file_and_start_parsing(uri);
- if(Glom::CsvParser::STATE_PARSING != parser.get_state())
+ if(Glom::CsvParser::State::PARSING != parser.get_state())
return false;
mainloop->run();
diff --git a/tests/python/test_python_execute_func.cc b/tests/python/test_python_execute_func.cc
index 6219496..34b821b 100644
--- a/tests/python/test_python_execute_func.cc
+++ b/tests/python/test_python_execute_func.cc
@@ -18,7 +18,7 @@ int main()
try
{
value = Glom::glom_evaluate_python_function_implementation(
- Glom::Field::TYPE_NUMERIC, calculation, field_values,
+ Glom::Field::glom_field_type::NUMERIC, calculation, field_values,
0 /* document */, "" /* table name */,
std::shared_ptr<Glom::Field>(), Gnome::Gda::Value(), // primary key details. Not used in this test.
connection,
diff --git a/tests/python/test_python_execute_func_bad_syntax.cc
b/tests/python/test_python_execute_func_bad_syntax.cc
index 873b094..4f1ea3d 100644
--- a/tests/python/test_python_execute_func_bad_syntax.cc
+++ b/tests/python/test_python_execute_func_bad_syntax.cc
@@ -20,7 +20,7 @@ int main()
try
{
value = Glom::glom_evaluate_python_function_implementation(
- Glom::Field::TYPE_NUMERIC, calculation, field_values,
+ Glom::Field::glom_field_type::NUMERIC, calculation, field_values,
0 /* document */, "" /* table name */,
std::shared_ptr<Glom::Field>(), Gnome::Gda::Value(), // primary key details. Not used in this test.
connection,
diff --git a/tests/python/test_python_execute_func_change_result_type.cc
b/tests/python/test_python_execute_func_change_result_type.cc
index 119d558..fcdcad7 100644
--- a/tests/python/test_python_execute_func_change_result_type.cc
+++ b/tests/python/test_python_execute_func_change_result_type.cc
@@ -15,7 +15,7 @@ int main()
//Execute a python function:
Gnome::Gda::Value value;
Glib::ustring error_message;
- const Glom::Field::glom_field_type result_type = Glom::Field::TYPE_TEXT;
+ const Glom::Field::glom_field_type result_type = Glom::Field::glom_field_type::TEXT;
try
{
//We ask for a text result though the python function actually returns a number.
diff --git a/tests/python/test_python_execute_func_date.cc b/tests/python/test_python_execute_func_date.cc
index ac41579..4d1dd9b 100644
--- a/tests/python/test_python_execute_func_date.cc
+++ b/tests/python/test_python_execute_func_date.cc
@@ -17,7 +17,7 @@ void execute_func_with_date_return_value()
//Execute a python function:
Glib::ustring error_message;
const auto value = Glom::glom_evaluate_python_function_implementation(
- Glom::Field::TYPE_DATE, calculation, field_values,
+ Glom::Field::glom_field_type::DATE, calculation, field_values,
0 /* document */, "" /* table name */,
std::shared_ptr<Glom::Field>(), Gnome::Gda::Value(), // primary key details. Not used in this test.
connection,
@@ -52,7 +52,7 @@ void execute_func_with_date_input_value()
//Execute a python function:
Glib::ustring error_message;
const auto value = Glom::glom_evaluate_python_function_implementation(
- Glom::Field::TYPE_NUMERIC, calculation, field_values,
+ Glom::Field::glom_field_type::NUMERIC, calculation, field_values,
0 /* document */, "" /* table name */,
std::shared_ptr<Glom::Field>(), Gnome::Gda::Value(), // primary key details. Not used in this test.
connection,
@@ -89,7 +89,7 @@ void execute_func_with_date_input_value_relativedelta()
//Execute a python function:
const auto value = Glom::glom_evaluate_python_function_implementation(
- Glom::Field::TYPE_NUMERIC, calculation, field_values,
+ Glom::Field::glom_field_type::NUMERIC, calculation, field_values,
0, "",
std::shared_ptr<Glom::Field>(), Gnome::Gda::Value(), // primary key details. Not used in this test.
connection);
diff --git a/tests/python/test_python_execute_func_with_record.cc
b/tests/python/test_python_execute_func_with_record.cc
index 69c548d..5fd610c 100644
--- a/tests/python/test_python_execute_func_with_record.cc
+++ b/tests/python/test_python_execute_func_with_record.cc
@@ -73,11 +73,11 @@ int main()
//This is not really necessary for sqlite-based databases.
const Glom::ConnectionPool::StartupErrors started =
connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
- if(started != Glom::ConnectionPool::Backend::STARTUPERROR_NONE)
+ if(started != Glom::ConnectionPool::Backend::StartupErrors::NONE)
{
- std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << started << std::endl;
+ std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << static_cast<int>(started) <<
std::endl;
}
- g_assert(started == Glom::ConnectionPool::Backend::STARTUPERROR_NONE);
+ g_assert(started == Glom::ConnectionPool::Backend::StartupErrors::NONE);
std::shared_ptr<Glom::SharedConnection> connection = connection_pool->connect();
g_assert(connection);
@@ -99,7 +99,7 @@ int main()
try
{
value = Glom::glom_evaluate_python_function_implementation(
- Glom::Field::TYPE_BOOLEAN, calculation, field_values,
+ Glom::Field::glom_field_type::BOOLEAN, calculation, field_values,
0 /* document */, "" /* table name */,
std::shared_ptr<Glom::Field>(), Gnome::Gda::Value(), // primary key details. Not used in this test.
gda_connection,
diff --git a/tests/test_conversions.cc b/tests/test_conversions.cc
index 9c2bb70..0f6e529 100644
--- a/tests/test_conversions.cc
+++ b/tests/test_conversions.cc
@@ -25,7 +25,7 @@
static bool test_string_value(const Glib::ustring& str)
{
- const Glom::Field::glom_field_type field_type = Glom::Field::TYPE_TEXT;
+ const Glom::Field::glom_field_type field_type = Glom::Field::glom_field_type::TEXT;
bool success = false;
const Gnome::Gda::Value value =
@@ -75,11 +75,11 @@ int main()
/* TODO:
const Glib::Date date(11, Glib::Date::MAY, 1973);
- if(!test_value(Glom::Field::TYPE_DATE, Gnome::Gda::Value(date)))
+ if(!test_value(Glom::Field::glom_field_type::DATE, Gnome::Gda::Value(date)))
return EXIT_FAILURE;
Gnome::Gda::Time time = {10, 20, 30, 0, 0};
- if(!test_value(Glom::Field::TYPE_TIME, Gnome::Gda::Value(time)))
+ if(!test_value(Glom::Field::glom_field_type::TIME, Gnome::Gda::Value(time)))
return EXIT_FAILURE;
*/
diff --git a/tests/test_document_autosave.cc b/tests/test_document_autosave.cc
index 1452adf..3e7565d 100644
--- a/tests/test_document_autosave.cc
+++ b/tests/test_document_autosave.cc
@@ -71,7 +71,7 @@ int main()
Glom::Document document;
document.set_allow_autosave(false);
document.set_file_uri(file_uri);
- document.set_hosting_mode(Glom::Document::HOSTING_MODE_POSTGRES_CENTRAL);
+ document.set_hosting_mode(Glom::Document::HostingMode::POSTGRES_CENTRAL);
document.set_database_title_original(test_title);
const auto saved = document.save();
g_assert(saved);
@@ -92,7 +92,7 @@ int main()
{
Glom::Document document;
document.set_file_uri(file_uri);
- document.set_hosting_mode(Glom::Document::HOSTING_MODE_POSTGRES_CENTRAL);
+ document.set_hosting_mode(Glom::Document::HostingMode::POSTGRES_CENTRAL);
document.set_allow_autosave();
document.set_database_title_original(test_title);
g_assert( !document.get_modified() );
diff --git a/tests/test_document_load.cc b/tests/test_document_load.cc
index 73066c8..fd4287f 100644
--- a/tests/test_document_load.cc
+++ b/tests/test_document_load.cc
@@ -192,12 +192,12 @@ int main()
std::shared_ptr<const Glom::Field> field = document.get_field("contacts", "contact_id");
g_assert(field);
g_assert( field->get_title_original() == "Contact ID" );
- g_assert(field->get_glom_type() == Glom::Field::TYPE_NUMERIC);
+ g_assert(field->get_glom_type() == Glom::Field::glom_field_type::NUMERIC);
g_assert(field->get_auto_increment());
field = document.get_field("locations", "rent");
g_assert(field);
g_assert( field->get_title_original() == "Rent" );
- g_assert(field->get_glom_type() == Glom::Field::TYPE_NUMERIC);
+ g_assert(field->get_glom_type() == Glom::Field::glom_field_type::NUMERIC);
g_assert(!field->get_auto_increment());
g_assert(!field->get_unique_key());
@@ -235,9 +235,9 @@ int main()
//Check Field Formatting:
field = document.get_field("contacts", "name_title");
g_assert(field);
- g_assert(field->get_glom_type() == Glom::Field::TYPE_TEXT);
+ g_assert(field->get_glom_type() == Glom::Field::glom_field_type::TEXT);
const Glom::Formatting& formatting = field->m_default_formatting;
- g_assert(formatting.get_horizontal_alignment() == Glom::Formatting::HORIZONTAL_ALIGNMENT_AUTO);
+ g_assert(formatting.get_horizontal_alignment() == Glom::Formatting::HorizontalAlignment::AUTO);
g_assert(formatting.get_has_choices());
g_assert(formatting.get_has_custom_choices());
diff --git a/tests/test_field_file_format.cc b/tests/test_field_file_format.cc
index 4ddd726..f19e25a 100644
--- a/tests/test_field_file_format.cc
+++ b/tests/test_field_file_format.cc
@@ -74,18 +74,18 @@ int main()
Glom::libglom_init();
const Glib::ustring str = " Some value or other with a quote \" and leading space."; //Just to be awkward.
- if(!test_value(Glom::Field::TYPE_TEXT, Gnome::Gda::Value(str)))
+ if(!test_value(Glom::Field::glom_field_type::TEXT, Gnome::Gda::Value(str)))
return EXIT_FAILURE;
const Glib::Date date(11, Glib::Date::MAY, 1973);
- if(!test_value(Glom::Field::TYPE_DATE, Gnome::Gda::Value(date)))
+ if(!test_value(Glom::Field::glom_field_type::DATE, Gnome::Gda::Value(date)))
return EXIT_FAILURE;
Gnome::Gda::Time time = {10, 20, 30, 0, 0};
- if(!test_value(Glom::Field::TYPE_TIME, Gnome::Gda::Value(time)))
+ if(!test_value(Glom::Field::glom_field_type::TIME, Gnome::Gda::Value(time)))
return EXIT_FAILURE;
- if(!test_value(Glom::Field::TYPE_NUMERIC, Glom::Conversions::parse_value((double)3.91l)))
+ if(!test_value(Glom::Field::glom_field_type::NUMERIC, Glom::Conversions::parse_value((double)3.91l)))
return EXIT_FAILURE;
diff --git a/tests/test_parsing_time.cc b/tests/test_parsing_time.cc
index 1b52506..6a09ba3 100644
--- a/tests/test_parsing_time.cc
+++ b/tests/test_parsing_time.cc
@@ -23,7 +23,7 @@ int main()
success = false;
const Gnome::Gda::Value value =
- Glom::Conversions::parse_value(Glom::Field::TYPE_TIME, time_text_input, success);
+ Glom::Conversions::parse_value(Glom::Field::glom_field_type::TIME, time_text_input, success);
if(!success)
{
@@ -47,7 +47,7 @@ int main()
}
const Glib::ustring time_text_parsed =
- Glom::Conversions::get_text_for_gda_value(Glom::Field::TYPE_TIME, value);
+ Glom::Conversions::get_text_for_gda_value(Glom::Field::glom_field_type::TIME, value);
//std::cout << "time_text_parsed=" << time_text_parsed << std::endl;
diff --git a/tests/test_selfhosting_new_empty_then_users.cc b/tests/test_selfhosting_new_empty_then_users.cc
index 2d101dc..97199bf 100644
--- a/tests/test_selfhosting_new_empty_then_users.cc
+++ b/tests/test_selfhosting_new_empty_then_users.cc
@@ -117,7 +117,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
/* SQLite does not have user/group access levels,
* so the SQL queries would fail.
*/
- if(hosting_mode == Glom::Document::HOSTING_MODE_SQLITE)
+ if(hosting_mode == Glom::Document::HostingMode::SQLITE)
{
return true;
}
@@ -140,7 +140,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
"sometable with a ' quote character"} );
//MySQL has a 64-character limit on SQL identifiers:
- if(hosting_mode != Glom::Document::HOSTING_MODE_MYSQL_SELF)
+ if(hosting_mode != Glom::Document::HostingMode::MYSQL_SELF)
{
table_names.push_back("sometablewithaverylongnameyaddayaddayaddayaddayaddyaddayaddayaddayaddayaddayaddayaddayaddayaddayaddayaddayadda");
}
@@ -157,7 +157,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
//TODO_MySQL: Implement groups/users code.
- if(hosting_mode == Glom::Document::HOSTING_MODE_MYSQL_SELF)
+ if(hosting_mode == Glom::Document::HostingMode::MYSQL_SELF)
{
test_selfhosting_cleanup(false /* do not delete the file. */);
return true;
diff --git a/tests/test_selfhosting_new_from_example_operator.cc
b/tests/test_selfhosting_new_from_example_operator.cc
index 7fd4713..de800d9 100644
--- a/tests/test_selfhosting_new_from_example_operator.cc
+++ b/tests/test_selfhosting_new_from_example_operator.cc
@@ -41,7 +41,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
/* SQLite does not have user/group access levels,
* so the SQL queries woudl fail.
*/
- if(hosting_mode == Glom::Document::HOSTING_MODE_SQLITE)
+ if(hosting_mode == Glom::Document::HostingMode::SQLITE)
{
return true;
}
@@ -69,7 +69,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
}
//TODO_MySQL: Implement groups/users code.
- if(hosting_mode == Glom::Document::HOSTING_MODE_MYSQL_SELF)
+ if(hosting_mode == Glom::Document::HostingMode::MYSQL_SELF)
{
test_selfhosting_cleanup(false /* do not delete the file. */);
return true;
diff --git a/tests/test_selfhosting_new_from_example_strangepath.cc
b/tests/test_selfhosting_new_from_example_strangepath.cc
index df111f8..90f54a5 100644
--- a/tests/test_selfhosting_new_from_example_strangepath.cc
+++ b/tests/test_selfhosting_new_from_example_strangepath.cc
@@ -29,7 +29,7 @@
static bool test(Glom::Document::HostingMode hosting_mode)
{
//TODO: MySQL: See if we can get this to work.
- if(hosting_mode == Glom::Document::HOSTING_MODE_MYSQL_SELF)
+ if(hosting_mode == Glom::Document::HostingMode::MYSQL_SELF)
{
test_selfhosting_cleanup(false /* do not delete the file. */);
return true;
diff --git a/tests/test_selfhosting_new_then_backup_restore.cc
b/tests/test_selfhosting_new_then_backup_restore.cc
index 65597ad..f63e06d 100644
--- a/tests/test_selfhosting_new_then_backup_restore.cc
+++ b/tests/test_selfhosting_new_then_backup_restore.cc
@@ -105,7 +105,7 @@ int main()
{
Glom::libglom_init();
- if(!test(Glom::Document::HOSTING_MODE_POSTGRES_SELF))
+ if(!test(Glom::Document::HostingMode::POSTGRES_SELF))
{
std::cerr << G_STRFUNC << ": Failed with PostgreSQL" << std::endl;
test_selfhosting_cleanup();
@@ -113,7 +113,7 @@ int main()
}
/* TODO: Make this work with sqlite too:
- if(!test(Glom::Document::HOSTING_MODE_SQLITE))
+ if(!test(Glom::Document::HostingMode::SQLITE))
{
std::cerr << G_STRFUNC << ": Failed with SQLite" << std::endl;
test_selfhosting_cleanup();
diff --git a/tests/test_selfhosting_new_then_change_columns.cc
b/tests/test_selfhosting_new_then_change_columns.cc
index 4a61865..10153be 100644
--- a/tests/test_selfhosting_new_then_change_columns.cc
+++ b/tests/test_selfhosting_new_then_change_columns.cc
@@ -58,7 +58,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
std::cerr << G_STRFUNC << ": Failure: field_new is null." << std::endl;
return false;
}
- field_new->set_glom_type(Glom::Field::TYPE_TEXT);
+ field_new->set_glom_type(Glom::Field::glom_field_type::TEXT);
Glom::ConnectionPool* connection_pool = Glom::ConnectionPool::get_instance();
if(!connection_pool)
@@ -87,7 +87,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
//Try another change:
field_original = Glom::glom_sharedptr_clone(field_new);
- field_new->set_glom_type(Glom::Field::TYPE_NUMERIC);
+ field_new->set_glom_type(Glom::Field::glom_field_type::NUMERIC);
try
{
const auto test = connection_pool->change_column(table_name, field_original, field_new);
@@ -158,7 +158,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
//TODO: Avoid the need for this awkward use of set_g_type():
std::shared_ptr<Glom::Field> field_numeric = std::make_shared<Glom::Field>();
field_numeric->set_name("newfield");
- field_numeric->set_glom_type(Glom::Field::TYPE_NUMERIC);
+ field_numeric->set_glom_type(Glom::Field::glom_field_type::NUMERIC);
Glib::RefPtr<Gnome::Gda::Column> field_info = field_numeric->get_field_info();
field_info->set_g_type( Glom::Field::get_gda_type_for_glom_type(field_numeric->get_glom_type()) );
field_numeric->set_field_info(field_info);
diff --git a/tests/test_selfhosting_new_then_get_privs.cc b/tests/test_selfhosting_new_then_get_privs.cc
index ab320d8..176cc87 100644
--- a/tests/test_selfhosting_new_then_get_privs.cc
+++ b/tests/test_selfhosting_new_then_get_privs.cc
@@ -71,7 +71,7 @@ int main()
{
Glom::libglom_init();
- if(!test(Glom::Document::HOSTING_MODE_POSTGRES_SELF))
+ if(!test(Glom::Document::HostingMode::POSTGRES_SELF))
{
std::cerr << G_STRFUNC << ": Failed with PostgreSQL" << std::endl;
test_selfhosting_cleanup();
@@ -79,7 +79,7 @@ int main()
}
/* SQLite does not have this feature:
- if(!test(Glom::Document::HOSTING_MODE_SQLITE))
+ if(!test(Glom::Document::HostingMode::SQLITE))
{
std::cerr << G_STRFUNC << ": Failed with SQLite" << std::endl;
test_selfhosting_cleanup();
diff --git a/tests/test_selfhosting_new_then_report_summary.cc
b/tests/test_selfhosting_new_then_report_summary.cc
index 70a2950..2c8a68b 100644
--- a/tests/test_selfhosting_new_then_report_summary.cc
+++ b/tests/test_selfhosting_new_then_report_summary.cc
@@ -86,14 +86,14 @@ int main()
setlocale(LC_ALL, "en_US.UTF-8");
- if(!test(Glom::Document::HOSTING_MODE_POSTGRES_SELF))
+ if(!test(Glom::Document::HostingMode::POSTGRES_SELF))
{
std::cerr << G_STRFUNC << ": Failed with PostgreSQL" << std::endl;
test_selfhosting_cleanup();
return EXIT_FAILURE;
}
- if(!test(Glom::Document::HOSTING_MODE_SQLITE))
+ if(!test(Glom::Document::HostingMode::SQLITE))
{
std::cerr << G_STRFUNC << ": Failed with SQLite" << std::endl;
test_selfhosting_cleanup();
diff --git a/tests/test_selfhosting_sqlinjection.cc b/tests/test_selfhosting_sqlinjection.cc
index f1629b2..6ec3610 100644
--- a/tests/test_selfhosting_sqlinjection.cc
+++ b/tests/test_selfhosting_sqlinjection.cc
@@ -164,7 +164,7 @@ static bool check_avoid_quotes_and_drop_table_with_false_field_type()
//Specify a field with incorrect type information:
std::shared_ptr<Glom::Field> where_field =
document.get_field("albums", "name");
- where_field->set_glom_type(Glom::Field::TYPE_NUMERIC);
+ where_field->set_glom_type(Glom::Field::glom_field_type::NUMERIC);
//const GType gda_type = Glom::Field::get_gda_type_for_glom_type(Glom::TYPE_NUMERIC);
const Gnome::Gda::SqlExpr where_clause =
diff --git a/tests/test_selfhosting_utils.cc b/tests/test_selfhosting_utils.cc
index c316e0a..6ba5baf 100644
--- a/tests/test_selfhosting_utils.cc
+++ b/tests/test_selfhosting_utils.cc
@@ -160,24 +160,24 @@ bool test_selfhost(Glom::Document& document, const Glib::ustring& user, const Gl
connection_pool->set_password(password);
const auto started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
- if(started != Glom::ConnectionPool::Backend::STARTUPERROR_NONE)
+ if(started != Glom::ConnectionPool::Backend::StartupErrors::NONE)
{
- std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << started << std::endl;
+ std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << static_cast<int>(started) <<
std::endl;
test_selfhosting_cleanup();
return false;
}
- g_assert(started == Glom::ConnectionPool::Backend::STARTUPERROR_NONE);
+ g_assert(started == Glom::ConnectionPool::Backend::StartupErrors::NONE);
return true;
}
bool test_create_and_selfhost_new_empty(Glom::Document& document, Glom::Document::HostingMode hosting_mode,
const std::string& subdirectory_path)
{
- if( (hosting_mode != Glom::Document::HOSTING_MODE_POSTGRES_SELF) &&
- (hosting_mode != Glom::Document::HOSTING_MODE_MYSQL_SELF) &&
- (hosting_mode != Glom::Document::HOSTING_MODE_SQLITE) )
+ if( (hosting_mode != Glom::Document::HostingMode::POSTGRES_SELF) &&
+ (hosting_mode != Glom::Document::HostingMode::MYSQL_SELF) &&
+ (hosting_mode != Glom::Document::HostingMode::SQLITE) )
{
- std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " <<
hosting_mode << std::endl;
+ std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " <<
static_cast<int>(hosting_mode) << std::endl;
return false;
}
@@ -220,7 +220,7 @@ bool test_create_and_selfhost_new_empty(Glom::Document& document, Glom::Document
//Create the self-hosting files:
const Glom::ConnectionPool::InitErrors initialized_errors =
connection_pool->initialize( sigc::ptr_fun(&on_initialize_progress) );
- g_assert(initialized_errors == Glom::ConnectionPool::Backend::INITERROR_NONE);
+ g_assert(initialized_errors == Glom::ConnectionPool::Backend::InitErrors::NONE);
if(!check_directory_exists())
{
@@ -345,11 +345,11 @@ static bool after_load(Glom::Document& document, Glom::Document::HostingMode hos
bool test_create_and_selfhost_from_uri(const Glib::ustring& example_file_uri, Glom::Document& document,
Glom::Document::HostingMode hosting_mode, const std::string& subdirectory_path)
{
- if( (hosting_mode != Glom::Document::HOSTING_MODE_POSTGRES_SELF) &&
- (hosting_mode != Glom::Document::HOSTING_MODE_MYSQL_SELF) &&
- (hosting_mode != Glom::Document::HOSTING_MODE_SQLITE) )
+ if( (hosting_mode != Glom::Document::HostingMode::POSTGRES_SELF) &&
+ (hosting_mode != Glom::Document::HostingMode::MYSQL_SELF) &&
+ (hosting_mode != Glom::Document::HostingMode::SQLITE) )
{
- std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " <<
hosting_mode << std::endl;
+ std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " <<
static_cast<int>(hosting_mode) << std::endl;
return false;
}
@@ -371,11 +371,11 @@ bool test_create_and_selfhost_from_uri(const Glib::ustring& example_file_uri, Gl
bool test_create_and_selfhost_from_data(const Glib::ustring& example_file_contents, Glom::Document&
document, Glom::Document::HostingMode hosting_mode, const std::string& subdirectory_path)
{
- if( (hosting_mode != Glom::Document::HOSTING_MODE_POSTGRES_SELF) &&
- (hosting_mode != Glom::Document::HOSTING_MODE_MYSQL_SELF) &&
- (hosting_mode != Glom::Document::HOSTING_MODE_SQLITE) )
+ if( (hosting_mode != Glom::Document::HostingMode::POSTGRES_SELF) &&
+ (hosting_mode != Glom::Document::HostingMode::MYSQL_SELF) &&
+ (hosting_mode != Glom::Document::HostingMode::SQLITE) )
{
- std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " <<
hosting_mode << std::endl;
+ std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " <<
static_cast<int>(hosting_mode) << std::endl;
return false;
}
@@ -584,7 +584,7 @@ static bool test_hosting_mode(const SlotTest& slot, Glom::Document::HostingMode
int test_all_hosting_modes(const SlotTest& slot)
{
- if(!test_hosting_mode(slot, Glom::Document::HOSTING_MODE_SQLITE, "SQLite"))
+ if(!test_hosting_mode(slot, Glom::Document::HostingMode::SQLITE, "SQLite"))
return EXIT_FAILURE;
//Do not test MySQL unless it is enabled in the build,
@@ -594,11 +594,11 @@ int test_all_hosting_modes(const SlotTest& slot)
//Also, Ubuntu's AppArmor will not let use start a MySQL process by default anyway.
//See https://bugs.launchpad.net/ubuntu/+source/mysql-5.5/+bug/1095370
#ifdef GLOM_ENABLE_MYSQL
- if(!test_hosting_mode(slot, Glom::Document::HOSTING_MODE_MYSQL_SELF, "MySQL"))
+ if(!test_hosting_mode(slot, Glom::Document::HostingMode::MYSQL_SELF, "MySQL"))
return EXIT_FAILURE;
#endif //GLOM_ENABLE_MYSQL
- if(!test_hosting_mode(slot, Glom::Document::HOSTING_MODE_POSTGRES_SELF, "PostgreSQL"))
+ if(!test_hosting_mode(slot, Glom::Document::HostingMode::POSTGRES_SELF, "PostgreSQL"))
return EXIT_FAILURE;
return EXIT_SUCCESS;
@@ -608,12 +608,12 @@ bool test_check_numeric_value_type(Glom::Document::HostingMode hosting_mode, con
{
const auto gtype = value.get_value_type();
//std::cout << "debug: gtype=" << g_type_name(gtype) << std::endl;
- if(hosting_mode == Glom::Document::HOSTING_MODE_SQLITE)
+ if(hosting_mode == Glom::Document::HostingMode::SQLITE)
{
if(gtype == G_TYPE_DOUBLE)
return true;
- } else if( (hosting_mode == Glom::Document::HOSTING_MODE_MYSQL_CENTRAL) ||
- (hosting_mode == Glom::Document::HOSTING_MODE_MYSQL_SELF) )
+ } else if( (hosting_mode == Glom::Document::HostingMode::MYSQL_CENTRAL) ||
+ (hosting_mode == Glom::Document::HostingMode::MYSQL_SELF) )
{
if(gtype == G_TYPE_DOUBLE)
return true;
diff --git a/tests/test_selfhosting_utils.h b/tests/test_selfhosting_utils.h
index 9b6dcd9..221d1a2 100644
--- a/tests/test_selfhosting_utils.h
+++ b/tests/test_selfhosting_utils.h
@@ -28,7 +28,7 @@
/** Create a .glom file from an example, with database data, and start a PostgreSQL server if necessary.
*
* @param document A new empty document that will be filled with hosting details.
- * @param hosting_mode Either HOSTING_MODE_POSTGRES_SELF or HOSTING_MODE_SQLITE
+ * @param hosting_mode Either HostingMode::POSTGRES_SELF or HostingMode::SQLITE
* @param subdirectory_path: An additional directory path to use under the temporary directory that will be
used to save the file.
*/
bool test_create_and_selfhost_new_empty(Glom::Document& document, Glom::Document::HostingMode hosting_mode,
const std::string& subdirectory_path = std::string());
@@ -36,7 +36,7 @@ bool test_create_and_selfhost_new_empty(Glom::Document& document, Glom::Document
/** Create a .glom file from an example, with database data, and start a PostgreSQL server if necessary.
*
* @param document A new empty document that will be filled with hosting details.
- * @param hosting_mode Either HOSTING_MODE_POSTGRES_SELF or HOSTING_MODE_SQLITE
+ * @param hosting_mode Either HostingMode::POSTGRES_SELF or HostingMode::SQLITE
* @param database_name The name of the database to created.
* @param subdirectory_path: An additional directory path to use under the temporary directory that will be
used to save the file.
*/
@@ -45,7 +45,7 @@ bool test_create_and_selfhost_new_database(Glom::Document& document, Glom::Docum
/** Create a .glom file from an example, with database data, and start a PostgreSQL server if necessary.
*
* @param example_filename The filename (not the full path) of the example .glom file.
- * @param hosting_mode Either HOSTING_MODE_POSTGRES_SELF or HOSTING_MODE_SQLITE
+ * @param hosting_mode Either HostingMode::POSTGRES_SELF or HostingMode::SQLITE
* @param subdirectory_path: An additional directory path to use under the temporary directory that will be
used to save the file.
*/
bool test_create_and_selfhost_from_example(const std::string& example_filename, Glom::Document& document,
Glom::Document::HostingMode hosting_mode, const std::string& subdirectory_path = std::string());
@@ -53,7 +53,7 @@ bool test_create_and_selfhost_from_example(const std::string& example_filename,
/** Create a .glom file from a test example, with database data, and start a PostgreSQL server if necessary.
*
* @param example_filename The filename (not the full path) of the example .glom file.
- * @param hosting_mode Either HOSTING_MODE_POSTGRES_SELF or HOSTING_MODE_SQLITE
+ * @param hosting_mode Either HostingMode::POSTGRES_SELF or HostingMode::SQLITE
*/
bool test_create_and_selfhost_from_test_example(const std::string& example_filename, Glom::Document&
document, Glom::Document::HostingMode hosting_mode);
@@ -61,7 +61,7 @@ bool test_create_and_selfhost_from_test_example(const std::string& example_filen
/** Create a .glom file from an existing .glom example file with database data, and start a PostgreSQL
server if necessary.
*
* @param file_uri The full URI of the example .glom file.
- * @param hosting_mode Either HOSTING_MODE_POSTGRES_SELF or HOSTING_MODE_SQLITE
+ * @param hosting_mode Either HostingMode::POSTGRES_SELF or HostingMode::SQLITE
* @param subdirectory_path: An additional directory path to use under the temporary directory that will be
used to save the file.
*/
bool test_create_and_selfhost_from_uri(const Glib::ustring& example_file_uri, Glom::Document& document,
Glom::Document::HostingMode hosting_mode, const std::string& subdirectory_path = std::string());
@@ -69,7 +69,7 @@ bool test_create_and_selfhost_from_uri(const Glib::ustring& example_file_uri, Gl
/** Create a .glom file from an existing .glom example file with database data, and start a PostgreSQL
server if necessary.
*
* @param file_uri The full URI of the example .glom file.
- * @param hosting_mode Either HOSTING_MODE_POSTGRES_SELF or HOSTING_MODE_SQLITE
+ * @param hosting_mode Either HostingMode::POSTGRES_SELF or HostingMode::SQLITE
* @param subdirectory_path: An additional directory path to use under the temporary directory that will be
used to save the file.
*/
bool test_create_and_selfhost_from_data(const Glib::ustring& example_file_contents, Glom::Document&
document, Glom::Document::HostingMode hosting_mode, const std::string& subdirectory_path = std::string());
diff --git a/tests/test_xml_utils.cc b/tests/test_xml_utils.cc
index 8d745fb..956e3ac 100644
--- a/tests/test_xml_utils.cc
+++ b/tests/test_xml_utils.cc
@@ -56,18 +56,18 @@ int main()
Glom::libglom_init();
const Glib::ustring str = " Some value or other with a quote \" and leading space."; //Just to be awkward.
- if(!test_value(Glom::Field::TYPE_TEXT, Gnome::Gda::Value(str)))
+ if(!test_value(Glom::Field::glom_field_type::TEXT, Gnome::Gda::Value(str)))
return EXIT_FAILURE;
const Glib::Date date(11, Glib::Date::MAY, 1973);
- if(!test_value(Glom::Field::TYPE_DATE, Gnome::Gda::Value(date)))
+ if(!test_value(Glom::Field::glom_field_type::DATE, Gnome::Gda::Value(date)))
return EXIT_FAILURE;
Gnome::Gda::Time time = {10, 20, 30, 0, 0};
- if(!test_value(Glom::Field::TYPE_TIME, Gnome::Gda::Value(time)))
+ if(!test_value(Glom::Field::glom_field_type::TIME, Gnome::Gda::Value(time)))
return EXIT_FAILURE;
- if(!test_value(Glom::Field::TYPE_NUMERIC, Glom::Conversions::parse_value((double)3.50l)))
+ if(!test_value(Glom::Field::glom_field_type::NUMERIC, Glom::Conversions::parse_value((double)3.50l)))
return EXIT_FAILURE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]