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()
|
||||
else:
|
||||
self.append_text("%s " % self.prompt)
|
||||
end = buffer.get_end_iter()
|
||||
buffer.place_cursor(end)
|
||||
return True
|
||||
if echo:
|
||||
self.append_text(("%s " % self.prompt) + line)
|
||||
@ -807,6 +809,22 @@ class PythonGramplet(Gramplet):
|
||||
return True
|
||||
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):
|
||||
def init(self):
|
||||
# GUI setup:
|
||||
@ -990,22 +1008,6 @@ class AgeOnDateGramplet(Gramplet):
|
||||
'ageondate',
|
||||
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",
|
||||
name= "Top Surnames Gramplet",
|
||||
tname=_("Top Surnames Gramplet"),
|
||||
|
@ -284,9 +284,7 @@ class DBI:
|
||||
self.stab = SimpleTable(self.sdb)
|
||||
self.select = 0
|
||||
self.progress = Utils.ProgressMeter(_('Processing Query'))
|
||||
# display the title
|
||||
if self.command == "select":
|
||||
self.select_table()
|
||||
self.process_table()
|
||||
if self.select > 0:
|
||||
self.sdoc = SimpleDoc(self.document)
|
||||
self.sdoc.title(self.query)
|
||||
@ -306,8 +304,16 @@ class DBI:
|
||||
return ("grampsid", "type", "date",
|
||||
"description", "place",
|
||||
"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
|
||||
if col_name == "*":
|
||||
self.columns.remove('*')
|
||||
@ -385,10 +391,19 @@ class DBI:
|
||||
result = True
|
||||
if result:
|
||||
self.select += 1
|
||||
self.stab.row(*row)
|
||||
for (col, value) in sorts:
|
||||
self.stab.row_sort_val(col, value)
|
||||
|
||||
if self.command == "select":
|
||||
self.stab.row(*row)
|
||||
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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user