Deleted the "new line selection while editing a view" system
This commit is contained in:
1 parent
43f3c69a40
commit
b083745f56
5 files changed
+10
-151
No files matched your search
@@ -65,8 +65,6 @@ cdef class OBIView:
|
||||
)
|
||||
cpdef change_column_alias(self, str current_alias, str new_alias)
|
||||
cpdef update_column_pointers(self)
|
||||
cpdef select_line(self, index_t line_nb)
|
||||
cpdef select_lines(self, list line_selection)
|
||||
cpdef save_and_close(self)
|
||||
cpdef str get_name(self)
|
||||
cpdef dict get_columns(self)
|
||||
|
||||
@@ -70,8 +70,6 @@ from .capi.obiview cimport Obiview_p, \
|
||||
obi_view_create_column_alias, \
|
||||
obi_view_get_column, \
|
||||
obi_view_get_pointer_on_column_in_view, \
|
||||
obi_select_line, \
|
||||
obi_select_lines, \
|
||||
obi_save_and_close_view, \
|
||||
VIEW_TYPE_NUC_SEQS, \
|
||||
NUC_SEQUENCE_COLUMN, \
|
||||
@@ -436,21 +434,6 @@ cdef class OBIView :
|
||||
elif type(item) == int :
|
||||
return OBIView_line(self, item)
|
||||
|
||||
|
||||
cpdef select_line(self, index_t line_nb) :
|
||||
if obi_select_line(self.pointer, line_nb) < 0 :
|
||||
raise Exception("Problem selecting a line")
|
||||
|
||||
|
||||
cpdef select_lines(self, list line_selection) :
|
||||
cdef index_t* line_selection_p
|
||||
line_selection_p = <index_t*> malloc((len(line_selection) + 1) * sizeof(index_t))
|
||||
for i in range(len(line_selection)) :
|
||||
line_selection_p[i] = line_selection[i]
|
||||
line_selection_p[len(line_selection)] = -1
|
||||
if obi_select_lines(self.pointer, line_selection_p) < 0 :
|
||||
raise Exception("Problem selecting a list of lines")
|
||||
|
||||
|
||||
def __contains__(self, str column_name):
|
||||
return (column_name in self.columns)
|
||||
|
||||
@@ -53,7 +53,6 @@ cdef extern from "obiview.h" nogil:
|
||||
OBIDMS_p dms
|
||||
bint read_only
|
||||
OBIDMS_column_p line_selection
|
||||
OBIDMS_column_p new_line_selection
|
||||
OBIDMS_column_p columns
|
||||
int nb_predicates
|
||||
# TODO declarations for column dictionary and predicate function array?
|
||||
@@ -90,11 +89,7 @@ cdef extern from "obiview.h" nogil:
|
||||
bint create)
|
||||
|
||||
int obi_view_delete_column(Obiview_p view, const_char_p column_name)
|
||||
|
||||
int obi_select_line(Obiview_p view, index_t line_nb)
|
||||
|
||||
int obi_select_lines(Obiview_p view, index_t* line_nbs)
|
||||
|
||||
|
||||
OBIDMS_column_p obi_view_get_column(Obiview_p view, const_char_p column_name)
|
||||
|
||||
OBIDMS_column_p* obi_view_get_pointer_on_column_in_view(Obiview_p view, const_char_p column_name)
|
||||
|
||||
+9
-121
@@ -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);
|
||||
|
||||
|
||||
@@ -113,11 +113,6 @@ typedef struct Obiview {
|
||||
* This line selection is read-only, and when a line from the view is read,
|
||||
* it is this line selection that is used.
|
||||
*/
|
||||
OBIDMS_column_p new_line_selection; /**< A pointer on the column containing the new line selection being built
|
||||
* to associate with the view, if there is one.
|
||||
* When a line is selected with obi_select_line() or obi_select_lines(),
|
||||
* it is recorded in this line selection.
|
||||
*/
|
||||
OBIDMS_column_p columns[MAX_NB_OPENED_COLUMNS]; /**< Array of pointers on all the columns of the view.
|
||||
*/
|
||||
hashtable_p column_dict; /**< Hash table storing the pairs of column names or aliases with the associated
|
||||
|
||||
Reference in new issue
Block a user