Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b14c7c6
Add bytes transformation
bellini666 Feb 18, 2015
2c3f5c7
The database id is not necessarily an integer
bellini666 Feb 19, 2015
530e481
Allow datagrid to show hierarchical data
bellini666 Feb 20, 2015
1f9ac79
Return rows from load instead of storing them on data source
bellini666 Feb 23, 2015
5983723
Don't format id and parent columns when getting the row
bellini666 Feb 23, 2015
f236648
Avoid loading more results on an hierarchical data
bellini666 Feb 23, 2015
d1d0464
Add an optional callback for row activated on treeview
bellini666 Feb 23, 2015
02d883c
Format byte as B
bellini666 Feb 24, 2015
5cd7584
Keep track of expanded rows
bellini666 Feb 24, 2015
ffce8b2
Add "expand all"/"collapse all" buttons
bellini666 Feb 25, 2015
2d04394
Avoid conversion to str when getting single record
bellini666 Mar 3, 2015
71838b8
Implement lazy loading for hierarchical data
bellini666 Mar 4, 2015
8aca8f2
Fix operator order on existing where clauses
bellini666 Mar 4, 2015
dbc921c
Allow to add optional attribute filters
bellini666 Mar 5, 2015
b4dbc00
Use sqlalchemy to construct queries
bellini666 Mar 5, 2015
29cc349
Add flat view
bellini666 Mar 6, 2015
cae8fd0
Make the examples database work with the new code
bellini666 Mar 9, 2015
cac18d7
Access table name by self.table.name
bellini666 Mar 10, 2015
9351472
Fix wrong test
bellini666 Mar 10, 2015
0441b0a
We want flat for flat view only
bellini666 Mar 10, 2015
8a90885
Samples needs to be a list
bellini666 Mar 10, 2015
b1c0e54
Allow to set columns to expand
bellini666 Mar 10, 2015
d5c37f4
Move sqlite tests from vE and fix related code
bellini666 Mar 10, 2015
5ce556b
Change rowid to __id instead of __viaextract_id
bellini666 Mar 10, 2015
18a6131
Add a FIXME note on get_columns
bellini666 Mar 10, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions datagrid_gtk3/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,60 @@
"""


class Node(list):

"""A list that can hold data.

Just like a simple list, but one can set/get its data
from :obj:`.data`.

:param object data: the data that will be stored in this node
:param int children_len: the number of the children that will
be loaded lazely at some point
"""

def __init__(self, data=None, children_len=0):
super(Node, self).__init__()

self.data = data
self.children_len = children_len
self.path = None

def is_children_loaded(self, recursive=False):
"""Check if this node's children is loaded

:param bool recursive: wheather to ask each child if their
children is loaded (and their child too and so on) too.
:returns: `True` if children is loaded, otherwise `False`
:rtype: bool
"""
loaded = len(self) == self.children_len
if recursive:
loaded = (loaded and
all(c.is_children_loaded(recursive=True) for c in self))
return loaded


class DataSource(object):
"""Base class for data sources."""

ID_COLUMN = 'rowid'
PARENT_ID_COLUMN = None
FLAT_COLUMN = None

def __init__(self):
self.rows = []
self.columns = []
self.column_name_str = ''
self.total_recs = 0
self.display_all = True
self.id_column_idx = None
self.parent_column_idx = None
self.flat_column_idx = None

def get_selected_columns(self):
pass
return []

def load(self, params=None):
pass
return Node()

def update_selected_columns(self, columns):
pass
Expand Down
Loading