Class: ZipDialog
- Inherits:
-
ZipDialogUI
- Object
- ZipDialogUI
- ZipDialog
- Defined in:
- lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb
Instance Method Summary collapse
- #add_files ⇒ Object
- #each(&proc) ⇒ Object
- #extract_files ⇒ Object
-
#initialize ⇒ ZipDialog
constructor
A new instance of ZipDialog.
- #load(zipfile) ⇒ Object
- #refresh ⇒ Object
- #zipfile(&proc) ⇒ Object
Constructor Details
#initialize ⇒ ZipDialog
Returns a new instance of ZipDialog.
19 20 21 22 23 24 25 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb', line 19 def initialize() super() connect(child('add_button'), SIGNAL('clicked()'), self, SLOT('add_files()')) connect(child('extract_button'), SIGNAL('clicked()'), self, SLOT('extract_files()')) end |
Instance Method Details
#add_files ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb', line 50 def add_files l = Qt::FileDialog.getOpenFileNames(nil, nil, self) zipfile { |zf| l.each { |path| zf.add(File.basename(path), path) } } refresh end |
#each(&proc) ⇒ Object
31 32 33 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb', line 31 def each(&proc) Zip::File.foreach(@zip_filename, &proc) end |
#extract_files ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb', line 62 def extract_files selected_items = [] unselected_items = [] lv_item = entry_list_view.first_child while (lv_item) if entry_list_view.is_selected(lv_item) selected_items << lv_item.text(0) else unselected_items << lv_item.text(0) end lv_item = lv_item.next_sibling end puts "selected_items.size = #{selected_items.size}" puts "unselected_items.size = #{unselected_items.size}" items = selected_items.size > 0 ? selected_items : unselected_items puts "items.size = #{items.size}" d = Qt::FileDialog.get_existing_directory(nil, self) if (!d) puts "No directory chosen" else zipfile { |zf| items.each { |e| zf.extract(e, File.join(d, e)) } } end end |
#load(zipfile) ⇒ Object
45 46 47 48 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb', line 45 def load(zipfile) @zip_filename = zipfile refresh end |
#refresh ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb', line 35 def refresh() lv = child("entry_list_view") lv.clear each { |e| lv.insert_item(Qt::ListViewItem.new(lv, e.name, e.size.to_s)) } end |