Remove set image in column
This commit is contained in:
parent
35d356a698
commit
5f1207836a
113
easymacro.py
113
easymacro.py
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
# ~ This file is part of ZAZ.
|
# ~ This file is part of ZAZ.
|
||||||
|
|
||||||
# ~ https://git.elmau.net/elmau/zaz
|
# ~ https://git.cuates.net/elmau/zaz
|
||||||
|
|
||||||
# ~ ZAZ is free software: you can redistribute it and/or modify
|
# ~ ZAZ is free software: you can redistribute it and/or modify
|
||||||
# ~ it under the terms of the GNU General Public License as published by
|
# ~ it under the terms of the GNU General Public License as published by
|
||||||
|
@ -4676,12 +4676,11 @@ class UnoGrid(UnoBaseObject):
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
super().__init__(obj)
|
super().__init__(obj)
|
||||||
self._gdm = self.model.GridDataModel
|
self._gdm = self.model.GridDataModel
|
||||||
self._columns = []
|
|
||||||
self._data = []
|
self._data = []
|
||||||
# ~ self._format_columns = ()
|
self._formats = ()
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
if name in ('_gdm', '_columns', '_data'):
|
if name in ('_gdm', '_data', '_formats'):
|
||||||
self.__dict__[name] = value
|
self.__dict__[name] = value
|
||||||
else:
|
else:
|
||||||
super().__setattr__(name, value)
|
super().__setattr__(name, value)
|
||||||
|
@ -4700,10 +4699,10 @@ class UnoGrid(UnoBaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def columns(self):
|
def columns(self):
|
||||||
return self._columns
|
return {}
|
||||||
@columns.setter
|
@columns.setter
|
||||||
def columns(self, values):
|
def columns(self, values):
|
||||||
self._columns = values
|
# ~ self._columns = values
|
||||||
#~ https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1grid_1_1XGridColumn.html
|
#~ https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1grid_1_1XGridColumn.html
|
||||||
model = create_instance('com.sun.star.awt.grid.DefaultGridColumnModel', True)
|
model = create_instance('com.sun.star.awt.grid.DefaultGridColumnModel', True)
|
||||||
for properties in values:
|
for properties in values:
|
||||||
|
@ -4742,35 +4741,46 @@ class UnoGrid(UnoBaseObject):
|
||||||
def row(self):
|
def row(self):
|
||||||
return self.obj.CurrentRow
|
return self.obj.CurrentRow
|
||||||
|
|
||||||
|
@property
|
||||||
|
def row_count(self):
|
||||||
|
return self._gdm.RowCount
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def column(self):
|
def column(self):
|
||||||
return self.obj.CurrentColumn
|
return self.obj.CurrentColumn
|
||||||
|
|
||||||
|
@property
|
||||||
|
def column(self):
|
||||||
|
return self.obj.CurrentColumn
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_valid(self):
|
||||||
|
return not (self.row == -1 or self.column == -1)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def formats(self):
|
||||||
|
return self._formats
|
||||||
|
@formats.setter
|
||||||
|
def formats(self, values):
|
||||||
|
self._formats = values
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self._gdm.removeAllRows()
|
self._gdm.removeAllRows()
|
||||||
return
|
return
|
||||||
|
|
||||||
# UP
|
def _format_columns(self, data):
|
||||||
def _format_cols(self):
|
row = data
|
||||||
rows = tuple(tuple(
|
if self.formats:
|
||||||
self._format_columns[i].format(r) for i, r in enumerate(row)) for row in self._data
|
for i, f in enumerate(formats):
|
||||||
)
|
if f:
|
||||||
return rows
|
row[i] = f.format(data[i])
|
||||||
|
return row
|
||||||
|
|
||||||
# ~ @property
|
def add_row(self, data):
|
||||||
# ~ def format_columns(self):
|
self._data.append(data)
|
||||||
# ~ return self._format_columns
|
row = self._format_columns(data)
|
||||||
# ~ @format_columns.setter
|
self._gdm.addRow(self.row_count + 1, row)
|
||||||
# ~ def format_columns(self, value):
|
return
|
||||||
# ~ self._format_columns = value
|
|
||||||
|
|
||||||
# ~ @property
|
|
||||||
# ~ def rows(self):
|
|
||||||
# ~ return self._gdm.RowCount
|
|
||||||
|
|
||||||
# ~ @property
|
|
||||||
# ~ def columns(self):
|
|
||||||
# ~ return self._gdm.ColumnCount
|
|
||||||
|
|
||||||
def set_cell_tooltip(self, col, row, value):
|
def set_cell_tooltip(self, col, row, value):
|
||||||
self._gdm.updateCellToolTip(col, row, value)
|
self._gdm.updateCellToolTip(col, row, value)
|
||||||
|
@ -4780,45 +4790,20 @@ class UnoGrid(UnoBaseObject):
|
||||||
value = self._gdm.getCellToolTip(col, row)
|
value = self._gdm.getCellToolTip(col, row)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def _validate_column(self, data):
|
|
||||||
row = []
|
|
||||||
for i, d in enumerate(data):
|
|
||||||
if i in self._columns:
|
|
||||||
if 'image' in self._columns[i]:
|
|
||||||
row.append(self._columns[i]['image'])
|
|
||||||
else:
|
|
||||||
row.append(d)
|
|
||||||
return tuple(row)
|
|
||||||
|
|
||||||
def add_row(self, data):
|
|
||||||
# ~ self._data.append(data)
|
|
||||||
data = self._validate_column(data)
|
|
||||||
self._gdm.addRow(self.rows + 1, data)
|
|
||||||
return
|
|
||||||
|
|
||||||
def remove_row(self, row):
|
|
||||||
self._gdm.removeRow(row)
|
|
||||||
# ~ del self._data[row]
|
|
||||||
self.update_row_heading()
|
|
||||||
return
|
|
||||||
|
|
||||||
def update_row_heading(self):
|
|
||||||
for i in range(self.rows):
|
|
||||||
self._gdm.updateRowHeading(i, i + 1)
|
|
||||||
return
|
|
||||||
|
|
||||||
def sort(self, column, asc=True):
|
def sort(self, column, asc=True):
|
||||||
self._gdm.sortByColumn(column, asc)
|
self._gdm.sortByColumn(column, asc)
|
||||||
self.update_row_heading()
|
self.update_row_heading()
|
||||||
return
|
return
|
||||||
|
|
||||||
def set_column_image(self, column, path):
|
def update_row_heading(self):
|
||||||
gp = create_instance('com.sun.star.graphic.GraphicProvider')
|
for i in range(self.row_count):
|
||||||
data = dict_to_property({'URL': _path_url(path)})
|
self._gdm.updateRowHeading(i, i + 1)
|
||||||
image = gp.queryGraphic(data)
|
return
|
||||||
if not column in self._columns:
|
|
||||||
self._columns[column] = {}
|
def remove_row(self, row):
|
||||||
self._columns[column]['image'] = image
|
self._gdm.removeRow(row)
|
||||||
|
del self._data[row]
|
||||||
|
self.update_row_heading()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -6212,6 +6197,14 @@ class Paths(object):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def image(cls, path):
|
||||||
|
gp = create_instance('com.sun.star.graphic.GraphicProvider')
|
||||||
|
image = gp.queryGraphic((
|
||||||
|
PropertyValue(Name='URL', Value=cls.to_url(path)),
|
||||||
|
))
|
||||||
|
return image
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def copy(cls, source, target='', name=''):
|
def copy(cls, source, target='', name=''):
|
||||||
p, f, n, e = _P(source).info
|
p, f, n, e = _P(source).info
|
||||||
|
|
Loading…
Reference in New Issue