Deleted the "new line selection while editing a view" system
This commit is contained in:
130
src/obiview.c
130
src/obiview.c
@ -740,7 +740,6 @@ int update_lines(Obiview_p view, index_t line_count)
|
||||
OBIDMS_column_p clone_column_in_view(Obiview_p view, const char* column_name)
|
||||
{
|
||||
int i;
|
||||
OBIDMS_column_p current_line_selection = NULL;
|
||||
OBIDMS_column_p column = NULL;
|
||||
OBIDMS_column_p column_buffer;
|
||||
bool found;
|
||||
@ -753,22 +752,17 @@ OBIDMS_column_p clone_column_in_view(Obiview_p view, const char* column_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (view->new_line_selection != NULL) // TODO Probably shouldn't happen, trigger error?
|
||||
current_line_selection = view->new_line_selection;
|
||||
else
|
||||
current_line_selection = view->line_selection;
|
||||
|
||||
found = false;
|
||||
for (i=0; i<((view->infos)->column_count); i++)
|
||||
{
|
||||
if ((current_line_selection != NULL) || (!strcmp((((view->infos)->column_references)[i]).alias, column_name)))
|
||||
if ((view->line_selection != NULL) || (!strcmp((((view->infos)->column_references)[i]).alias, column_name)))
|
||||
{ // Clone with the right line selection and replace (for all columns if there is a line selection)
|
||||
|
||||
// Save pointer to close column after cloning
|
||||
column_buffer = (view->columns)[i];
|
||||
|
||||
// Clone and replace the column in the view
|
||||
(view->columns)[i] = obi_clone_column(view->dms, current_line_selection, (((view->columns)[i])->header)->name, (((view->columns)[i])->header)->version, 1);
|
||||
(view->columns)[i] = obi_clone_column(view->dms, view->line_selection, (((view->columns)[i])->header)->name, (((view->columns)[i])->header)->version, 1);
|
||||
if ((view->columns)[i] == NULL)
|
||||
{
|
||||
obi_set_errno(OBIVIEW_ERROR);
|
||||
@ -786,7 +780,7 @@ OBIDMS_column_p clone_column_in_view(Obiview_p view, const char* column_name)
|
||||
}
|
||||
}
|
||||
|
||||
// Close old line selections
|
||||
// Close old line selection
|
||||
if (view->line_selection != NULL)
|
||||
{
|
||||
obi_close_column(view->line_selection);
|
||||
@ -795,11 +789,6 @@ OBIDMS_column_p clone_column_in_view(Obiview_p view, const char* column_name)
|
||||
(((view->infos)->line_selection).column_name)[0] = '\0';
|
||||
((view->infos)->line_selection).version = -1;
|
||||
}
|
||||
if (view->new_line_selection != NULL)
|
||||
{
|
||||
obi_close_column(view->new_line_selection);
|
||||
view->new_line_selection = NULL;
|
||||
}
|
||||
|
||||
// Update column refs and dict
|
||||
update_column_refs_and_dict(view);
|
||||
@ -1260,7 +1249,6 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
||||
// Fill informations
|
||||
strcpy((view->infos)->view_type, (view_to_clone->infos)->view_type);
|
||||
strcpy((view->infos)->created_from, (view_to_clone->infos)->name);
|
||||
view->new_line_selection = NULL;
|
||||
// Copy predicates
|
||||
view->nb_predicates = view_to_clone->nb_predicates;
|
||||
if (view->nb_predicates > 0)
|
||||
@ -1280,7 +1268,6 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
||||
(view->infos)->line_count = 0;
|
||||
(view->infos)->all_lines = true;
|
||||
view->line_selection = NULL;
|
||||
view->new_line_selection = NULL;
|
||||
((view->infos)->created_from)[0] = '\0';
|
||||
((view->infos)->view_type)[0] = '\0';
|
||||
view->nb_predicates = 0;
|
||||
@ -1625,7 +1612,6 @@ Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name)
|
||||
}
|
||||
|
||||
view->dms = dms;
|
||||
view->new_line_selection = NULL;
|
||||
view->read_only = true;
|
||||
view->nb_predicates = 0;
|
||||
view->predicate_functions = NULL;
|
||||
@ -1669,13 +1655,8 @@ int obi_view_add_column(Obiview_p view,
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If there is a line selection, clone the columns to delete it
|
||||
if (view->new_line_selection != NULL) // TODO Probably shouldn't happen, trigger error?
|
||||
current_line_selection = view->new_line_selection;
|
||||
else
|
||||
current_line_selection = view->line_selection;
|
||||
|
||||
if (create && (current_line_selection != NULL))
|
||||
// If there is a line selection and a new column is created, clone the columns to delete the line selection
|
||||
if (create && (view->line_selection != NULL))
|
||||
{
|
||||
for (i=0; i<((view->infos)->column_count); i++)
|
||||
{
|
||||
@ -1684,7 +1665,7 @@ int obi_view_add_column(Obiview_p view,
|
||||
column_buffer = (view->columns)[i];
|
||||
|
||||
// Clone and replace the column in the view
|
||||
(view->columns)[i] = obi_clone_column(view->dms, current_line_selection, (((view->columns)[i])->header)->name, (((view->columns)[i])->header)->version, 1);
|
||||
(view->columns)[i] = obi_clone_column(view->dms, view->line_selection, (((view->columns)[i])->header)->name, (((view->columns)[i])->header)->version, 1);
|
||||
if ((view->columns)[i] == NULL)
|
||||
{
|
||||
obi_set_errno(OBIVIEW_ERROR);
|
||||
@ -1697,7 +1678,7 @@ int obi_view_add_column(Obiview_p view,
|
||||
}
|
||||
}
|
||||
|
||||
// Close old line selections
|
||||
// Close old line selection
|
||||
if (view->line_selection != NULL)
|
||||
{
|
||||
obi_close_column(view->line_selection);
|
||||
@ -1706,11 +1687,6 @@ int obi_view_add_column(Obiview_p view,
|
||||
(((view->infos)->line_selection).column_name)[0] = '\0';
|
||||
((view->infos)->line_selection).version = -1;
|
||||
}
|
||||
if (view->new_line_selection != NULL)
|
||||
{
|
||||
obi_close_column(view->new_line_selection);
|
||||
view->new_line_selection = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the line count if needed
|
||||
@ -1887,78 +1863,6 @@ int obi_view_create_column_alias(Obiview_p view, const char* current_name, const
|
||||
}
|
||||
|
||||
|
||||
int obi_select_line(Obiview_p view, index_t line_nb)
|
||||
{
|
||||
// Check that the view is not read-only
|
||||
if (view->read_only)
|
||||
{
|
||||
obi_set_errno(OBIVIEW_ERROR);
|
||||
obidebug(1, "\nError trying to select a line in a read-only view");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If the column for line selection doesn't already exists, create it and store its informations
|
||||
if ((view->new_line_selection) == NULL)
|
||||
{
|
||||
view->new_line_selection = obi_create_column(view->dms, LINES_COLUMN_NAME, OBI_IDX, 0, 1, LINES_COLUMN_NAME, NULL, NULL, -1, NULL);
|
||||
if ((view->new_line_selection) == NULL)
|
||||
{
|
||||
obidebug(1, "\nError creating a column corresponding to a line selection");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// If there is already a line selection, get the pointed line number
|
||||
if (view->line_selection)
|
||||
line_nb = obi_column_get_index(view->line_selection, line_nb);
|
||||
|
||||
if (obi_column_set_index(view->new_line_selection, ((view->new_line_selection)->header)->lines_used, line_nb) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int obi_select_lines(Obiview_p view, index_t* line_nbs)
|
||||
{
|
||||
int i;
|
||||
index_t line_nb;
|
||||
|
||||
// Check that the view is not read-only
|
||||
if (view->read_only)
|
||||
{
|
||||
obi_set_errno(OBIVIEW_ERROR);
|
||||
obidebug(1, "\nError trying to select a line in a read-only view");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If column for line selection doesn't already exists, create it and store its informations
|
||||
if ((view->new_line_selection) == NULL)
|
||||
{
|
||||
view->new_line_selection = obi_create_column(view->dms, LINES_COLUMN_NAME, OBI_IDX, 0, 1, LINES_COLUMN_NAME, NULL, NULL, -1, NULL);
|
||||
if ((view->new_line_selection) == NULL)
|
||||
{
|
||||
obidebug(1, "\nError creating a column corresponding to a line selection");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; line_nbs[i] != -1; i++)
|
||||
{
|
||||
line_nb = line_nbs[i];
|
||||
|
||||
// If we are already working on a line selection, get the pointed line number
|
||||
if (view->line_selection)
|
||||
line_nb = obi_column_get_index(view->line_selection, line_nb);
|
||||
|
||||
if (obi_column_set_index(view->new_line_selection, ((view->new_line_selection)->header)->lines_used, line_nb) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int obi_save_view(Obiview_p view)
|
||||
{
|
||||
// Check that the view is not read-only
|
||||
@ -1970,14 +1874,7 @@ int obi_save_view(Obiview_p view)
|
||||
}
|
||||
|
||||
// Store reference for the line selection associated with that view if there is one
|
||||
if (view->new_line_selection != NULL)
|
||||
{
|
||||
(view->infos)->line_count = ((view->new_line_selection)->header)->lines_used;
|
||||
strcpy(((view->infos)->line_selection).column_name, ((view->new_line_selection)->header)->name);
|
||||
((view->infos)->line_selection).version = ((view->new_line_selection)->header)->version;
|
||||
(view->infos)->all_lines = false;
|
||||
}
|
||||
else if (view->line_selection != NULL) // Unnecessary in theory
|
||||
if (view->line_selection != NULL) // Unnecessary in theory, the line selection references are already saved
|
||||
{
|
||||
strcpy(((view->infos)->line_selection).column_name, ((view->line_selection)->header)->name);
|
||||
((view->infos)->line_selection).version = ((view->line_selection)->header)->version;
|
||||
@ -2012,7 +1909,7 @@ int obi_close_view(Obiview_p view)
|
||||
}
|
||||
}
|
||||
|
||||
// Close line selections if they exist
|
||||
// Close line selection if there is one
|
||||
if (view->line_selection != NULL)
|
||||
{
|
||||
if (obi_close_column(view->line_selection) < 0)
|
||||
@ -2022,15 +1919,6 @@ int obi_close_view(Obiview_p view)
|
||||
}
|
||||
}
|
||||
|
||||
if (view->new_line_selection != NULL)
|
||||
{
|
||||
if (obi_close_column(view->new_line_selection) < 0)
|
||||
{
|
||||
obidebug(1, "\nError closing a new line selection while closing a view");
|
||||
ret_value = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Free the column dictionary
|
||||
ht_free(view->column_dict);
|
||||
|
||||
|
Reference in New Issue
Block a user