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
64
65
66
|
# File 'lib/ListHolder/EditableList.rb', line 12
def initialize(caller)
@caller=caller
@back_button=false
@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
}
@popup=Gtk::Menu.new
end
|
Instance Attribute Details
#caller ⇒ Object
Returns the value of attribute caller.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def caller
@caller
end
|
Returns the value of attribute headers.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def
@headers
end
|
Returns the value of attribute headertypes.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def
@headertypes
end
|
#info ⇒ Object
Returns the value of attribute info.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def info
@info
end
|
#is_embedded ⇒ Object
Returns the value of attribute is_embedded.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def is_embedded
@is_embedded
end
|
#list_id ⇒ Object
Returns the value of attribute list_id.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def list_id
@list_id
end
|
#list_model ⇒ Object
Returns the value of attribute list_model.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def list_model
@list_model
end
|
#parentM ⇒ Object
Returns the value of attribute parentM.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def parentM
@parentM
end
|
#pop ⇒ Object
Returns the value of attribute pop.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def pop
@pop
end
|
#selected ⇒ Object
Returns the value of attribute selected.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def selected
@selected
end
|
#single_list_mode ⇒ Object
Returns the value of attribute single_list_mode.
68
69
70
|
# File 'lib/ListHolder/EditableList.rb', line 68
def single_list_mode
@single_list_mode
end
|
#tip ⇒ Object
Returns the value of attribute tip.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def tip
@tip
end
|
#title ⇒ Object
Returns the value of attribute title.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def title
@title
end
|
#tmp ⇒ Object
Returns the value of attribute tmp.
67
68
69
|
# File 'lib/ListHolder/EditableList.rb', line 67
def tmp
@tmp
end
|
Instance Method Details
#add_row(caller, added_id = nil) ⇒ Object
291
292
293
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/ListHolder/EditableList.rb', line 291
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
309
310
311
|
# File 'lib/ListHolder/EditableList.rb', line 309
def child_by_id(mid)
@caller.notebook.moditem_by_id(mid)
end
|
#column_by_id(column_id) ⇒ Object
328
329
330
331
332
333
334
335
336
337
|
# File 'lib/ListHolder/EditableList.rb', line 328
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
339
340
341
342
343
344
345
|
# File 'lib/ListHolder/EditableList.rb', line 339
def columns_height
colh=0
columns.each{|col|
colh=col..allocation.height if col..allocation.height > colh
}
colh
end
|
#create_skeleton ⇒ Object
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/ListHolder/EditableList.rb', line 199
def create_skeleton
if get_id.nil?
edebug(" can't update","list","error")
return
end
@keep_expanded=(gtk_attribute("keep_expanded") || "false") == "true"
@single_list_mode=(gtk_attribute('single_list_mode') || "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)
if single_list_mode
@list_model.drbmodel.childs.each{|ch|
@popup.append(item=Gtk::MenuItem.new(ch["display"]))
item.signal_connect("activate",ch["id"].to_i){|me,child_id|
einfo("#{me.label.inspect}(#{child_id}) activated on #{get_cursor_id}")
holder.pack_child(child_id)
}
}
end
if @back_button
@popup.append(item=Gtk::MenuItem.new("back"))
item.signal_connect("activate"){|me|
einfo("#{me.label} activated on #{get_cursor_id}")
parentM.holder.repack_self
}
end
@popup.show_all
signal_connect("button_release_event"){|me,ev|
if ev.kind_of? Gdk::EventButton and ev.button == 3
@popup.(nil,nil,ev.button,ev.time)
end
}
self
end
|
#duplicate_selected(caller) ⇒ Object
275
276
277
278
279
280
281
|
# File 'lib/ListHolder/EditableList.rb', line 275
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
94
95
96
97
98
99
100
|
# File 'lib/ListHolder/EditableList.rb', line 94
def embedd?
if @moditem && @moditem['on_embed'].length >0
eeval(@moditem['on_embed'],self)
else
true
end
end
|
#get_cursor_id ⇒ Object
166
167
168
|
# File 'lib/ListHolder/EditableList.rb', line 166
def get_cursor_id
get_conf(get_id,0,"cursor").to_i
end
|
#get_id ⇒ Object
102
103
104
|
# File 'lib/ListHolder/EditableList.rb', line 102
def get_id
@list_id
end
|
#get_model ⇒ Object
74
75
76
|
# File 'lib/ListHolder/EditableList.rb', line 74
def get_model
@list_model
end
|
#holder ⇒ Object
70
71
72
|
# File 'lib/ListHolder/EditableList.rb', line 70
def holder
@caller
end
|
#inspect ⇒ Object
363
364
365
|
# File 'lib/ListHolder/EditableList.rb', line 363
def inspect
"List(#{title})"
end
|
#load_data(notifier, the_one = nil) ⇒ Object
133
134
135
|
# File 'lib/ListHolder/EditableList.rb', line 133
def load_data(notifier,the_one=nil)
@list_model.load_data(notifier,the_one=nil)
end
|
#moditem ⇒ Object
83
84
85
|
# File 'lib/ListHolder/EditableList.rb', line 83
def moditem
@list_model.moditem
end
|
#my ⇒ Object
127
128
129
|
# File 'lib/ListHolder/EditableList.rb', line 127
def my
@@my
end
|
#next_editable_column(column) ⇒ Object
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
# File 'lib/ListHolder/EditableList.rb', line 313
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
80
81
82
|
# File 'lib/ListHolder/EditableList.rb', line 80
def parentselected
@list_model.parentselected
end
|
#progress ⇒ Object
86
87
88
|
# File 'lib/ListHolder/EditableList.rb', line 86
def progress
@caller.progress
end
|
#refilter ⇒ Object
137
138
139
|
# File 'lib/ListHolder/EditableList.rb', line 137
def refilter
@list_model.refilter
end
|
#remove_selected(caller, ids = nil) ⇒ Object
283
284
285
286
287
288
289
|
# File 'lib/ListHolder/EditableList.rb', line 283
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
305
306
307
|
# File 'lib/ListHolder/EditableList.rb', line 305
def row_modified(modified_id=list.get_cursor_id)
@list_model.row_modified(modified_id)
end
|
#save_config ⇒ Object
77
78
79
|
# File 'lib/ListHolder/EditableList.rb', line 77
def save_config
set_conf(get_id,0,"search",search_column)
end
|
#save_cursor_id(id_to_set) ⇒ Object
162
163
164
165
|
# File 'lib/ListHolder/EditableList.rb', line 162
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
|
170
171
172
173
174
175
176
|
# File 'lib/ListHolder/EditableList.rb', line 170
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
269
270
271
272
273
|
# File 'lib/ListHolder/EditableList.rb', line 269
def selected_ids
ids=Array.new
selection.selected_each { |model, path, iter| ids.push(iter[@list_model.column_of_id])}
ids
end
|
117
118
119
120
|
# File 'lib/ListHolder/EditableList.rb', line 117
def set_back_button(bb=true)
@back_button=bb
self
end
|
#set_cursor_id(id_to_set = get_cursor_id, scroll = true) ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/ListHolder/EditableList.rb', line 141
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
107
108
109
110
111
112
113
114
115
|
# File 'lib/ListHolder/EditableList.rb', line 107
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
178
179
180
|
# File 'lib/ListHolder/EditableList.rb', line 178
def set_info(new_info)
info.set_label(new_info)
end
|
#set_parentM(parentM) ⇒ Object
122
123
124
125
|
# File 'lib/ListHolder/EditableList.rb', line 122
def set_parentM(parentM)
@parentM=parentM
self
end
|
#to_s ⇒ Object
366
367
368
|
# File 'lib/ListHolder/EditableList.rb', line 366
def to_s
inspect
end
|
#update(notifier) ⇒ Object
262
263
264
265
266
267
|
# File 'lib/ListHolder/EditableList.rb', line 262
def update(notifier)
@list_model.update(notifier)
scroll_to_cursor
update_tip
self
end
|
#update_tip ⇒ Object
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/ListHolder/EditableList.rb', line 182
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
# File 'lib/ListHolder/EditableList.rb', line 347
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
|