rows can now be deleted from a table, just people currently
svn: r10581
This commit is contained in:
parent
0709ed5606
commit
a2734ca3e7
@ -792,6 +792,8 @@ class PythonGramplet(Gramplet):
|
|||||||
line = line[1:].strip()
|
line = line[1:].strip()
|
||||||
else:
|
else:
|
||||||
self.append_text("%s " % self.prompt)
|
self.append_text("%s " % self.prompt)
|
||||||
|
end = buffer.get_end_iter()
|
||||||
|
buffer.place_cursor(end)
|
||||||
return True
|
return True
|
||||||
if echo:
|
if echo:
|
||||||
self.append_text(("%s " % self.prompt) + line)
|
self.append_text(("%s " % self.prompt) + line)
|
||||||
@ -807,6 +809,22 @@ class PythonGramplet(Gramplet):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
class QueryGramplet(PythonGramplet):
|
||||||
|
def init(self):
|
||||||
|
self.prompt = "$"
|
||||||
|
self.tooltip = _("Enter SQL query")
|
||||||
|
# GUI setup:
|
||||||
|
self.gui.textview.set_editable(True)
|
||||||
|
self.set_text("Structured Query Language\n%s " % self.prompt)
|
||||||
|
self.gui.textview.connect('key-press-event', self.on_key_press)
|
||||||
|
|
||||||
|
def process_command(self, command):
|
||||||
|
retval = run_quick_report_by_name(self.gui.dbstate,
|
||||||
|
self.gui.uistate,
|
||||||
|
'query',
|
||||||
|
command)
|
||||||
|
return retval
|
||||||
|
|
||||||
class TODOGramplet(Gramplet):
|
class TODOGramplet(Gramplet):
|
||||||
def init(self):
|
def init(self):
|
||||||
# GUI setup:
|
# GUI setup:
|
||||||
@ -990,22 +1008,6 @@ class AgeOnDateGramplet(Gramplet):
|
|||||||
'ageondate',
|
'ageondate',
|
||||||
date)
|
date)
|
||||||
|
|
||||||
class QueryGramplet(PythonGramplet):
|
|
||||||
def init(self):
|
|
||||||
self.prompt = "$"
|
|
||||||
self.tooltip = _("Enter SQL query")
|
|
||||||
# GUI setup:
|
|
||||||
self.gui.textview.set_editable(True)
|
|
||||||
self.set_text("Structured Query Language\n%s " % self.prompt)
|
|
||||||
self.gui.textview.connect('key-press-event', self.on_key_press)
|
|
||||||
|
|
||||||
def process_command(self, command):
|
|
||||||
retval = run_quick_report_by_name(self.gui.dbstate,
|
|
||||||
self.gui.uistate,
|
|
||||||
'query',
|
|
||||||
command)
|
|
||||||
return retval
|
|
||||||
|
|
||||||
register(type="gramplet",
|
register(type="gramplet",
|
||||||
name= "Top Surnames Gramplet",
|
name= "Top Surnames Gramplet",
|
||||||
tname=_("Top Surnames Gramplet"),
|
tname=_("Top Surnames Gramplet"),
|
||||||
|
@ -284,9 +284,7 @@ class DBI:
|
|||||||
self.stab = SimpleTable(self.sdb)
|
self.stab = SimpleTable(self.sdb)
|
||||||
self.select = 0
|
self.select = 0
|
||||||
self.progress = Utils.ProgressMeter(_('Processing Query'))
|
self.progress = Utils.ProgressMeter(_('Processing Query'))
|
||||||
# display the title
|
self.process_table()
|
||||||
if self.command == "select":
|
|
||||||
self.select_table()
|
|
||||||
if self.select > 0:
|
if self.select > 0:
|
||||||
self.sdoc = SimpleDoc(self.document)
|
self.sdoc = SimpleDoc(self.document)
|
||||||
self.sdoc.title(self.query)
|
self.sdoc.title(self.query)
|
||||||
@ -306,8 +304,16 @@ class DBI:
|
|||||||
return ("grampsid", "type", "date",
|
return ("grampsid", "type", "date",
|
||||||
"description", "place",
|
"description", "place",
|
||||||
"change", "marker", "private")
|
"change", "marker", "private")
|
||||||
|
# families = grampsid, father, mother, relationship, date
|
||||||
|
# sources =
|
||||||
|
# places =
|
||||||
|
# media =
|
||||||
|
# repos =
|
||||||
|
# notes =
|
||||||
|
else:
|
||||||
|
raise AttributeError("unknown table: '%s'" % table)
|
||||||
|
|
||||||
def select_table(self):
|
def process_table(self):
|
||||||
for col_name in self.columns[:]: # copy
|
for col_name in self.columns[:]: # copy
|
||||||
if col_name == "*":
|
if col_name == "*":
|
||||||
self.columns.remove('*')
|
self.columns.remove('*')
|
||||||
@ -385,10 +391,19 @@ class DBI:
|
|||||||
result = True
|
result = True
|
||||||
if result:
|
if result:
|
||||||
self.select += 1
|
self.select += 1
|
||||||
self.stab.row(*row)
|
if self.command == "select":
|
||||||
for (col, value) in sorts:
|
self.stab.row(*row)
|
||||||
self.stab.row_sort_val(col, value)
|
for (col, value) in sorts:
|
||||||
|
self.stab.row_sort_val(col, value)
|
||||||
|
elif self.command == "delete":
|
||||||
|
self.database.active = person
|
||||||
|
trans = self.database.transaction_begin()
|
||||||
|
active_name = _("Delete Person (%s)") % self.sdb.name(person)
|
||||||
|
gen.utils.delete_person_from_database(self.database, person, trans)
|
||||||
|
# FIXME: delete familes, events, notes, resources, etc, if possible
|
||||||
|
self.database.transaction_commit(trans, active_name)
|
||||||
|
else:
|
||||||
|
raise AttributeError("unknown command: '%s'", self.command)
|
||||||
|
|
||||||
def run(database, document, query):
|
def run(database, document, query):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user