Commit 35676813 authored by Celine Mercier's avatar Celine Mercier

Now when a column is added to a view, if there is a line selection, all

columns in the view are cloned first
parent 757ef850
......@@ -471,7 +471,6 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
}
view->dms = dms;
view->column_count = view_to_clone->column_count;
// If the view to clone has an associated line selection and there is no new line selection, open the associated line selection
if ((view_to_clone->line_selection != NULL) && (line_selection == NULL))
......@@ -530,12 +529,14 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
(view->columns)[i] = obi_open_column(dms, (((view_to_clone->columns)[i])->header)->name, (((view_to_clone->columns)[i])->header)->version);
if ((view->columns)[i] == NULL)
{
obi_close_column(view->line_selection);
if (view->line_selection != NULL)
obi_close_column(view->line_selection);
free(view);
return NULL;
}
}
view->column_count = view_to_clone->column_count;
strcpy(view->view_type, view_to_clone->view_type);
strcpy(view->created_from, view_to_clone->name);
view->new_line_selection = NULL;
......@@ -599,6 +600,8 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
if (view_to_clone == NULL)
{
// TODO Add quality column?
// Adding sequence column
if (obi_view_add_column(view, NUC_SEQUENCE_COLUMN, -1, OBI_SEQ, 0, 1, NUC_SEQUENCE_COLUMN, NUC_SEQUENCE_INDEXER, "Nucleotide sequences", true) < 0)
{
......@@ -809,7 +812,10 @@ int obi_view_add_column(Obiview_p view,
const char* comments,
bool create) // all infos for creation or open
{
int i;
OBIDMS_column_p column;
OBIDMS_column_p column_buffer;
OBIDMS_column_p current_line_selection;
// Check that the view is not read-only
if (view->read_only)
......@@ -819,6 +825,48 @@ 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 (current_line_selection != NULL)
{
for (i=0; i<(view->column_count); i++)
{
{ // Clone with the right line selection and replace for all columns
// 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);
if ((view->columns)[i] == NULL)
{
obi_set_errno(OBIVIEW_ERROR);
obidebug(1, "\nError cloning a column to replace in a view");
return -1;
}
// Close old cloned column
obi_close_column(column_buffer);
}
}
}
// Close old line selections
if (view->line_selection != NULL)
{
obi_close_column(view->line_selection);
view->line_selection = NULL;
}
if (view->new_line_selection != NULL)
{
obi_close_column(view->new_line_selection);
view->new_line_selection = NULL;
}
// Update the line count
if (view->line_count > nb_lines)
nb_lines = view->line_count;
else if (nb_lines > view->line_count)
......@@ -905,7 +953,7 @@ OBIDMS_column_p obi_view_get_column(Obiview_p view, const char* column_name)
}
OBIDMS_column_p* obi_view_get_pointer_on_column_in_view(Obiview_p view, const char* column_name)
OBIDMS_column_p* obi_view_get_pointer_on_column_in_view(Obiview_p view, const char* column_name) // TODO delete?
{
int i;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment