Class: MyEditableList
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Constant Summary
ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING
Constants included
from Eprint
Eprint::DOMAIN, Eprint::LEVEL
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Conf
#get_conf, #load_conf, #save_conf, #set_conf
#add_where, #admin, #admin_cache, #admin_qrow, #admin_rows, #backtrace_to_debug, #cache, #changed_ids_of_base, #client, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #qrow, #query, #reconnect_manqod_db, #rows, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick
Methods included from Eprint
#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception
Methods included from ListPrint
#gtkprint
#default_attribute, #gtk_attribute, #gtk_attribute_of_object, #gtkobjectid, #gtkobjecttype, #set_gtk_attribute
Constructor Details
Returns a new instance of MyEditableList.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/ListHolder/EditableList.rb', line 12
def initialize(caller)
@caller=caller
@list_id=nil
@parentM=nil
@info=caller.info
@title="list"
@tip=Gtk::Tooltips.new
super(nil)
@list_model=ListModel.new(self)
set_enable_grid_lines(case get_conf(0,0,"grid")
when "both" then Gtk::TreeView::GridLines::BOTH
when "vertical" then Gtk::TreeView::GridLines::VERTICAL
when "horizontal" then Gtk::TreeView::GridLines::HORIZONTAL
else Gtk::TreeView::GridLines::NONE
end
) if Gtk.check_version?(2,10,9)
set_enable_tree_lines(true)
set_fixed_height_mode(false)
set_reorderable(false) =false
set_rules_hint(true)
selection.set_mode(Gtk::SELECTION_MULTIPLE)
signal_connect('cursor-changed') { |me|
if !cursor[0].nil? and iter=model.get_iter(cursor[0])
id_at_cursor=iter[@list_model.column_of_id]
else
id_at_cursor=-1
end
if id_at_cursor != get_cursor_id
save_cursor_id(id_at_cursor)
einfo("#{self} selection changed to #{id_at_cursor}, notifying observers","list")
changed
begin
notify_observers(self)
rescue =>err
eerror("error notifying observers:#{err}","list")
end
end
}
signal_connect("button-press-event"){|me,ev|
holder.buttonholder.activate_default if ev.event_type == Gdk::Event::BUTTON2_PRESS
false
}
@tmp=Hash.new
@is_embedded=nil
@keep_expanded=false
signal_connect("row-collapsed"){|me, iter, path|
me.expand_all if @keep_expanded
}
end
|
Instance Attribute Details
#caller ⇒ Object
Returns the value of attribute caller.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def caller
@caller
end
|
Returns the value of attribute headers.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def
@headers
end
|
Returns the value of attribute headertypes.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def
@headertypes
end
|
#info ⇒ Object
Returns the value of attribute info.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def info
@info
end
|
#is_embedded ⇒ Object
Returns the value of attribute is_embedded.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def is_embedded
@is_embedded
end
|
#list_id ⇒ Object
Returns the value of attribute list_id.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def list_id
@list_id
end
|
#list_model ⇒ Object
Returns the value of attribute list_model.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def list_model
@list_model
end
|
#parentM ⇒ Object
Returns the value of attribute parentM.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def parentM
@parentM
end
|
#pop ⇒ Object
Returns the value of attribute pop.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def pop
@pop
end
|
#selected ⇒ Object
Returns the value of attribute selected.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def selected
@selected
end
|
#tip ⇒ Object
Returns the value of attribute tip.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def tip
@tip
end
|
#title ⇒ Object
Returns the value of attribute title.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def title
@title
end
|
#tmp ⇒ Object
Returns the value of attribute tmp.
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 64
def tmp
@tmp
end
|
Instance Method Details
#add_row(caller, added_id = nil) ⇒ Object
255
256
257
258
259
260
261
262
263
264
265
266
267
|
# File 'lib/ListHolder/EditableList.rb', line 255
def add_row(caller, added_id=nil)
if added_id.nil?
run_events(get_id,'list-OnInsert-BeforeSQL')
added_id=@list_model.add_iter
run_events(get_id,'list-OnInsert-AfterSQL')
else
row_modified(added_id)
end
set_conf(get_id,0,"cursor",added_id)
end
|
#child_by_id(mid) ⇒ Object
273
274
275
|
# File 'lib/ListHolder/EditableList.rb', line 273
def child_by_id(mid)
@caller.notebook.moditem_by_id(mid)
end
|
#column_by_id(column_id) ⇒ Object
292
293
294
295
296
297
298
299
300
301
|
# File 'lib/ListHolder/EditableList.rb', line 292
def column_by_id(column_id)
ret=nil
columns.each{|col|
if col.['id'].to_i == column_id.to_i
ret=col
break
end
}
ret
end
|
#columns_height ⇒ Object
303
304
305
306
307
308
309
|
# File 'lib/ListHolder/EditableList.rb', line 303
def columns_height
colh=0
columns.each{|col|
colh=col..allocation.height if col..allocation.height > colh
}
colh
end
|
#create_skeleton ⇒ Object
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/ListHolder/EditableList.rb', line 190
def create_skeleton
if get_id.nil?
edebug(" can't update","list","error")
return
end
@keep_expanded=(gtk_attribute("keep_expanded") || "false") == "true"
set_model(nil)
@list_model.create_skeleton
set_info("initializing")
@title=moditem["display"]
while c=get_column(0)
remove_column(c)
c.wipe
end
col_num=1;
@list_model..sort{|a,b| a[1]["oid"].to_f<=>b[1]["oid"].to_f}.each{|hk,|
['editable']="false" if ['writable']=="0"
column=nil
if column=MyColumn.new(self,)
append_column(column)
col_num+=1
end if ['visible']
}
einfo("#{self} skeleton created","list")
set_search_column(get_conf(get_id,0,"search").to_i)
set_info("loading")
@caller.list_panel.update(self)
@caller.advanced_filter.update
@caller.sum_button.update
@caller.buttonholder.update(self)
self
end
|
#duplicate_selected(caller) ⇒ Object
239
240
241
242
243
244
245
|
# File 'lib/ListHolder/EditableList.rb', line 239
def duplicate_selected(caller)
ret=nil
run_events(get_id,'list-OnDuplicate-BeforeSQL')
selection.selected_each { |model, path, iter| ret=@list_model.duplicate_iter(iter)}
run_events(get_id,'list-OnDuplicate-AfterSQL')
ret
end
|
#embedd? ⇒ Boolean
90
91
92
93
94
95
96
|
# File 'lib/ListHolder/EditableList.rb', line 90
def embedd?
if @moditem && @moditem['on_embed'].length >0
eeval(@moditem['on_embed'],self)
else
true
end
end
|
#get_cursor_id ⇒ Object
157
158
159
|
# File 'lib/ListHolder/EditableList.rb', line 157
def get_cursor_id
get_conf(get_id,0,"cursor").to_i
end
|
#get_id ⇒ Object
98
99
100
|
# File 'lib/ListHolder/EditableList.rb', line 98
def get_id
@list_id
end
|
#get_model ⇒ Object
70
71
72
|
# File 'lib/ListHolder/EditableList.rb', line 70
def get_model
@list_model
end
|
#holder ⇒ Object
66
67
68
|
# File 'lib/ListHolder/EditableList.rb', line 66
def holder
@caller
end
|
#inspect ⇒ Object
327
328
329
|
# File 'lib/ListHolder/EditableList.rb', line 327
def inspect
"List(#{title})"
end
|
#load_data(notifier, the_one = nil) ⇒ Object
124
125
126
|
# File 'lib/ListHolder/EditableList.rb', line 124
def load_data(notifier,the_one=nil)
@list_model.load_data(notifier,the_one=nil)
end
|
#moditem ⇒ Object
79
80
81
|
# File 'lib/ListHolder/EditableList.rb', line 79
def moditem
@list_model.moditem
end
|
#my ⇒ Object
118
119
120
|
# File 'lib/ListHolder/EditableList.rb', line 118
def my
@@my
end
|
#next_editable_column(column) ⇒ Object
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
# File 'lib/ListHolder/EditableList.rb', line 277
def next_editable_column(column)
next_col=nil
col_num=nil
i=0
columns.each{|col|
col_num=i if col == column
if !col_num.nil? and i > col_num and col.["editable"]=="true" and col.["type"]!='gtk_toggle'
next_col=col
break
end
i+=1
}
next_col
end
|
#parentselected ⇒ Object
76
77
78
|
# File 'lib/ListHolder/EditableList.rb', line 76
def parentselected
@list_model.parentselected
end
|
#progress ⇒ Object
82
83
84
|
# File 'lib/ListHolder/EditableList.rb', line 82
def progress
@caller.progress
end
|
#refilter ⇒ Object
128
129
130
|
# File 'lib/ListHolder/EditableList.rb', line 128
def refilter
@list_model.refilter
end
|
#remove_selected(caller, ids = nil) ⇒ Object
247
248
249
250
251
252
253
|
# File 'lib/ListHolder/EditableList.rb', line 247
def remove_selected(caller,ids=nil)
ids=[get_cursor_id] if ids.nil?
@removing=ids
run_events(get_id,'list-OnRemove-BeforeSQL')
@list_model.remove_iters(ids)
run_events(get_id,'list-OnRemove-AfterSQL')
end
|
#row_modified(modified_id = list.get_cursor_id) ⇒ Object
269
270
271
|
# File 'lib/ListHolder/EditableList.rb', line 269
def row_modified(modified_id=list.get_cursor_id)
@list_model.row_modified(modified_id)
end
|
#save_config ⇒ Object
73
74
75
|
# File 'lib/ListHolder/EditableList.rb', line 73
def save_config
set_conf(get_id,0,"search",search_column)
end
|
#save_cursor_id(id_to_set) ⇒ Object
153
154
155
156
|
# File 'lib/ListHolder/EditableList.rb', line 153
def save_cursor_id(id_to_set)
edebug("saving cursor to #{id_to_set.inspect}","list")
set_conf(get_id,0,"cursor",id_to_set)
end
|
161
162
163
164
165
166
167
|
# File 'lib/ListHolder/EditableList.rb', line 161
def scroll_to_cursor(id_to_scroll=get_cursor_id,scroll=true)
set_cursor_id(id_to_scroll,scroll)
changed
notify_observers(self)
expand_all if @keep_expanded
get_cursor_id
end
|
#selected_ids ⇒ Object
233
234
235
236
237
|
# File 'lib/ListHolder/EditableList.rb', line 233
def selected_ids
ids=Array.new
selection.selected_each { |model, path, iter| ids.push(iter[@list_model.column_of_id])}
ids
end
|
#set_cursor_id(id_to_set = get_cursor_id, scroll = true) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/ListHolder/EditableList.rb', line 132
def set_cursor_id(id_to_set=get_cursor_id,scroll=true)
current_id=cursor[0] ? @list_model.sorter.get_iter(cursor[0])[@list_model.column_of_id] : -1
if current_id != id_to_set.to_i
if iter=@list_model.iter_of_id(id_to_set)
edebug("setting cursor to #{id_to_set.inspect}","list")
expand_to_path(iter.path)
scroll_to_cell(iter.path,nil,false,0,0) if scroll
set_cursor(iter.path,nil,nil)
save_cursor_id(id_to_set)
else
unless cursor[0].nil?
edebug("setting cursor none #{id_to_set != -1?"insted of #{id_to_set.inspect}":""}","list")
set_cursor(Gtk::TreePath.new,nil,nil)
end
save_cursor_id(-1)
end
end
iter
end
|
#set_id(newid) ⇒ Object
103
104
105
106
107
108
109
110
111
|
# File 'lib/ListHolder/EditableList.rb', line 103
def set_id(newid)
if newid.to_i != @list_id.to_i
@list_id=newid.to_i
@caller.set_id(list_id)
create_skeleton
end
self
end
|
#set_info(new_info) ⇒ Object
169
170
171
|
# File 'lib/ListHolder/EditableList.rb', line 169
def set_info(new_info)
info.set_label(new_info)
end
|
#set_parentM(parentM) ⇒ Object
113
114
115
116
|
# File 'lib/ListHolder/EditableList.rb', line 113
def set_parentM(parentM)
@parentM=parentM
self
end
|
#to_s ⇒ Object
330
331
332
|
# File 'lib/ListHolder/EditableList.rb', line 330
def to_s
inspect
end
|
#update(notifier) ⇒ Object
226
227
228
229
230
231
|
# File 'lib/ListHolder/EditableList.rb', line 226
def update(notifier)
@list_model.update(notifier)
scroll_to_cursor
update_tip
self
end
|
#update_tip ⇒ Object
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/ListHolder/EditableList.rb', line 173
def update_tip
case get_conf(0,0,"list-tooltip")
when "filters" then
t="filters:"
@caller.list_panel.list_filter.columns.each_value{|frenderer|
fl=get_conf(get_id,frenderer.['id'],"filter")
case frenderer.['type']
when 'gtk_combo', 'gtk_const_combo' then fl = (fl=="-1" or fl=="") ? "" : "=#{fl}"
end
t+="\n#{frenderer.['header']}: #{fl}" if !fl.nil? and fl.length>0
}
t="#{t}\nnone" if t=="filters:"
@tip.set_tip(self,t,'extra hint')
@tip.enable
end
end
|
#wipe ⇒ Object
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
# File 'lib/ListHolder/EditableList.rb', line 311
def wipe
save_config
set_model(nil)
if @list_model.thread and @list_model.thread.alive?
progress.killed(object_id)
p Thread.kill(@list_model.thread)
while @list_model.thread.alive? do ecode("waiting for thread"); end
end
@list_model.wipe
while c=get_column(0)
remove_column(c)
c.wipe
end
destroy
end
|