Class: MyFRendererCombo
- Inherits:
-
Gtk::ComboBox
- Object
- Gtk::ComboBox
- MyFRendererCombo
- Includes:
- Conf, ManqodCommon
- Defined in:
- lib/ListHolder/ListPanel/ListFilter/FRenderer/Combo.rb
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Direct Known Subclasses
Constant Summary
Constants included from ManqodCommon
ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING
Constants included from Eprint
Instance Method Summary collapse
- #append_row(cdata, cdisplay) ⇒ Object
- #get_text_from_value(selected_combo_value) ⇒ Object
- #get_value_from_text(selected_combo_text) ⇒ Object
-
#initialize(caller, header) ⇒ MyFRendererCombo
constructor
A new instance of MyFRendererCombo.
- #select_value(selected_value = @defval) ⇒ Object
- #text ⇒ Object
- #update(new_value = @defval) ⇒ Object
Methods included from Conf
#get_conf, #load_conf, #save_conf, #set_conf
Methods included from ManqodCommon
#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
Constructor Details
#initialize(caller, header) ⇒ MyFRendererCombo
Returns a new instance of MyFRendererCombo.
8 9 10 11 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 |
# File 'lib/ListHolder/ListPanel/ListFilter/FRenderer/Combo.rb', line 8 def initialize(caller,header) @header=header @caller=caller @defval=get_conf(caller.list.get_id,header["id"],"filter") || "-1" @mycombomodel=Gtk::ListStore.new(String,String) @filter=Gtk::TreeModelFilter.new(@mycombomodel) @typed="" super() set_model(@filter) update() set_row_separator_func{|model, iter| iter[1]=='separator' or iter[0]=='---' } @filter.set_visible_func{|model, iter| if iter[0] and @typed ret=iter[0].upcase.index(@typed.upcase) # print iter[0],":",iter[0][0 .. @typed.length]," == ",@typed," = ",ret,"\n" ret end } # update signal_connect('changed'){|me| set_conf(caller.list.get_id,header['id'],"filter",self.active_iter[1]) @caller.list.refilter } signal_connect('key-press-event'){|me,key| case key.keyval when ?a .. ?z,?A .. ?Z, ?0 .. ?9 then @typed=@typed+key.keyval.chr when 65288 then @typed="" if @typed.length==1 @typed=@typed[0 .. @typed.length-2] if @typed.length>0 end # print "current filter: ",@typed,",",@typed.length,"\n" @filter.refilter } end |
Instance Method Details
#append_row(cdata, cdisplay) ⇒ Object
60 61 62 63 64 |
# File 'lib/ListHolder/ListPanel/ListFilter/FRenderer/Combo.rb', line 60 def append_row(cdata,cdisplay) iter=@mycombomodel.append iter[0]=cdisplay iter[1]=cdata end |
#get_text_from_value(selected_combo_value) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/ListHolder/ListPanel/ListFilter/FRenderer/Combo.rb', line 76 def get_text_from_value(selected_combo_value) selected_combo_text=nil @mycombomodel.each {|model, path, iter| if iter[0]==selected_combo_value selected_combo_text=iter[1] end } return selected_combo_text end |
#get_value_from_text(selected_combo_text) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/ListHolder/ListPanel/ListFilter/FRenderer/Combo.rb', line 66 def get_value_from_text(selected_combo_text) selected_combo_value=nil @mycombomodel.each {|model, path, iter| if iter[1]==selected_combo_text selected_combo_value=iter[0] end } return selected_combo_value end |
#select_value(selected_value = @defval) ⇒ Object
90 91 92 93 |
# File 'lib/ListHolder/ListPanel/ListFilter/FRenderer/Combo.rb', line 90 def select_value(selected_value=@defval) @defval=selected_value @mycombomodel.each {|model, path, iter| self.set_active(path.indices[0]) if iter[1]==@defval } end |
#text ⇒ Object
86 87 88 |
# File 'lib/ListHolder/ListPanel/ListFilter/FRenderer/Combo.rb', line 86 def text return self.active_iter[1] end |
#update(new_value = @defval) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ListHolder/ListPanel/ListFilter/FRenderer/Combo.rb', line 43 def update(new_value=@defval) set_model(nil) @defval=new_value @mycombomodel.clear if @header['wantnew'] append_row("-1","") append_row("---","---") end if @header['admin'] admin_rows(@header['querySQL'],@header['key'].include?(".")){|row| append_row(row[@header['key']],row[@header['display']])} else rows(@header['querySQL'],@header['key'].include?(".")){|row| append_row(row[@header['key']],row[@header['display']])} end unless @header['querySQL'].length == 0 set_model(@mycombomodel) select_value() end |