XDCC-Fetch 1.386
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +23 -0
- data/XDCC-Fetch.rbw +54 -0
- data/doc/ark.png +0 -0
- data/doc/connect_established.png +0 -0
- data/doc/index.html +300 -0
- data/doc/mega_ark.png +0 -0
- data/doc/package.png +0 -0
- data/doc/package_unknown.png +0 -0
- data/doc/shot1.png +0 -0
- data/doc/shot1_mini.png +0 -0
- data/doc/shot2.png +0 -0
- data/doc/shot2_mini.png +0 -0
- data/doc/xdccfetch.css +155 -0
- data/icons/ark.png +0 -0
- data/icons/ark_big.png +0 -0
- data/icons/camera_test.png +0 -0
- data/icons/cancel.png +0 -0
- data/icons/connect_creating.png +0 -0
- data/icons/connect_established.png +0 -0
- data/icons/connect_failed.png +0 -0
- data/icons/connect_no.png +0 -0
- data/icons/edit_add.png +0 -0
- data/icons/edit_remove.png +0 -0
- data/icons/exit.png +0 -0
- data/icons/fileclose.png +0 -0
- data/icons/folder_inbox.png +0 -0
- data/icons/idea.png +0 -0
- data/icons/mega_ark.png +0 -0
- data/icons/messagebox_critical.png +0 -0
- data/icons/messagebox_info.png +0 -0
- data/icons/messagebox_warning.png +0 -0
- data/icons/messagebox_warning_small.png +0 -0
- data/icons/package.png +0 -0
- data/icons/package_favourite.png +0 -0
- data/icons/package_unknown.png +0 -0
- data/src/Console/Console_Parser.rb +71 -0
- data/src/Console/XDCC_Pack_Match_Template.rb +29 -0
- data/src/Console/xdcc-fetch.rb +123 -0
- data/src/GUI/About_Dialog.rb +50 -0
- data/src/GUI/Application_Builder.rb +280 -0
- data/src/GUI/Context_Menu.rb +81 -0
- data/src/GUI/Custom_Tabs.rb +60 -0
- data/src/GUI/Dialog_Box.rb +116 -0
- data/src/GUI/Download_Finished_Box.rb +41 -0
- data/src/GUI/Empty_Text_Field_Handler.rb +86 -0
- data/src/GUI/Gui_Logic.rb +629 -0
- data/src/GUI/Icon_Loader.rb +58 -0
- data/src/GUI/Main_Window.rb +227 -0
- data/src/GUI/Packet_Item.rb +171 -0
- data/src/GUI/Packet_List.rb +145 -0
- data/src/GUI/Speed_Widget.rb +101 -0
- data/src/GUI/Talk_Back.rb +118 -0
- data/src/GUI/Toggle_Button.rb +56 -0
- data/src/Network/CTCP_Handler.rb +61 -0
- data/src/Network/DCC_File.rb +323 -0
- data/src/Network/DCC_Parser.rb +71 -0
- data/src/Network/IPAddr_Ext.rb +76 -0
- data/src/Network/IRC_Message.rb +161 -0
- data/src/Network/IRC_Server.rb +273 -0
- data/src/Network/IRC_Server_Respond_Map.rb +223 -0
- data/src/Network/IRC_User.rb +58 -0
- data/src/Network/TCP_Connection.rb +168 -0
- data/src/Network/XDCC_Announcement.rb +120 -0
- data/src/Network/XDCC_Announcement_Storage.rb +167 -0
- data/src/Network/XDCC_Download_Handler.rb +412 -0
- data/src/Network/XDCC_Pack.rb +58 -0
- data/src/Network/XDCC_Parser.rb +253 -0
- data/src/Translations/README +61 -0
- data/src/Translations/check_translations +83 -0
- data/src/Translations/de.rb +140 -0
- data/src/Translations/en.rb +145 -0
- data/src/Utilities/Configuration.rb +91 -0
- data/src/Utilities/Events.rb +87 -0
- data/src/Utilities/Globals.rb +138 -0
- data/src/Utilities/PrettyException.rb +1091 -0
- data/src/Utilities/Recursive_Open_Struct.rb +159 -0
- data/src/Utilities/Timer.rb +71 -0
- metadata +135 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
# Copyright (c) 2004, 2005 Martin Ankerl
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
# are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice, this list
|
8
|
+
# of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright notice, this list
|
10
|
+
# of conditions and the following disclaimer in the documentation and/or other materials
|
11
|
+
# provided with the distribution.
|
12
|
+
# * Neither the name of Martin Ankerl nor the names of its contributors may be used to
|
13
|
+
# endorse or promote products derived from this software without specific prior written
|
14
|
+
# permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
17
|
+
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
18
|
+
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
21
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
22
|
+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
23
|
+
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
|
25
|
+
|
26
|
+
# Converts a Recursive_Open_Struct that contains filenames of PNG-icons into real icons.
|
27
|
+
class Icon_Loader
|
28
|
+
# Create a new Icon_Loader. You need to specify the Fox-application.
|
29
|
+
def initialize(app)
|
30
|
+
@app = app
|
31
|
+
end
|
32
|
+
|
33
|
+
# Takes each attribute of the given Recursive_Open_Struct,
|
34
|
+
# converts it into a real icon, and sets it.
|
35
|
+
def cfg_to_icons(cfg)
|
36
|
+
cfg.attrs.each do |attr|
|
37
|
+
value = cfg.send(attr.to_sym)
|
38
|
+
if (value.class == Recursive_Open_Struct)
|
39
|
+
cfg_to_icons(value)
|
40
|
+
else
|
41
|
+
# value is a filename
|
42
|
+
icon = make_icon(value)
|
43
|
+
cfg.send((attr + "=").to_sym, icon)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Constructs an icon from the given filename (from the icons directory).
|
49
|
+
def make_icon(filename)
|
50
|
+
filename = File.join("icons", filename)
|
51
|
+
icon = nil
|
52
|
+
File.open(filename, "rb") do |f|
|
53
|
+
icon = FXPNGIcon.new(@app, f.read, 0)
|
54
|
+
end
|
55
|
+
icon.create
|
56
|
+
icon
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# Copyright (c) 2004, 2005 Martin Ankerl
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
# are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice, this list
|
8
|
+
# of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright notice, this list
|
10
|
+
# of conditions and the following disclaimer in the documentation and/or other materials
|
11
|
+
# provided with the distribution.
|
12
|
+
# * Neither the name of Martin Ankerl nor the names of its contributors may be used to
|
13
|
+
# endorse or promote products derived from this software without specific prior written
|
14
|
+
# permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
17
|
+
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
18
|
+
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
21
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
22
|
+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
23
|
+
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
|
25
|
+
# Load FXRuby: try gem, then Fox 1.2, then Fox 1.0
|
26
|
+
begin
|
27
|
+
# try fxruby gem
|
28
|
+
require 'rubygems'
|
29
|
+
require_gem 'fxruby', '>= 1.1.0'
|
30
|
+
require 'fox12'
|
31
|
+
require 'fox12/colors'
|
32
|
+
FOXVERSION="1.2"
|
33
|
+
include Fox
|
34
|
+
rescue LoadError
|
35
|
+
# no gem? try fox12 direct.
|
36
|
+
begin
|
37
|
+
require "fox12"
|
38
|
+
require "fox12/colors"
|
39
|
+
FOXVERSION="1.2"
|
40
|
+
include Fox
|
41
|
+
rescue LoadError
|
42
|
+
# no gem, no fox12? try fox 1.0
|
43
|
+
require "fox"
|
44
|
+
require "fox/colors"
|
45
|
+
# grep for FOXVERSION to find all code that depends on this
|
46
|
+
FOXVERSION="1.0"
|
47
|
+
include Fox
|
48
|
+
FXMenuBar = FXMenubar
|
49
|
+
FXToolTip = FXTooltip
|
50
|
+
FXStatusBar = FXStatusbar
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
require 'thread'
|
55
|
+
|
56
|
+
require 'src/Utilities/Globals'
|
57
|
+
require 'src/Utilities/Configuration'
|
58
|
+
require 'src/GUI/Gui_Logic'
|
59
|
+
require 'src/GUI/Icon_Loader'
|
60
|
+
require 'src/GUI/Empty_Text_Field_Handler'
|
61
|
+
require 'src/GUI/Packet_List'
|
62
|
+
require 'src/GUI/Custom_Tabs'
|
63
|
+
require 'src/GUI/Context_Menu'
|
64
|
+
require 'src/GUI/Dialog_Box'
|
65
|
+
require 'src/GUI/Speed_Widget'
|
66
|
+
require 'src/GUI/Toggle_Button'
|
67
|
+
require 'src/GUI/About_Dialog'
|
68
|
+
require 'src/GUI/Download_Finished_Box'
|
69
|
+
require 'src/GUI/Application_Builder'
|
70
|
+
require 'src/GUI/Gui_Logic'
|
71
|
+
|
72
|
+
require 'src/Network/IRC_Server'
|
73
|
+
require 'src/Network/XDCC_Announcement_Storage'
|
74
|
+
require 'src/Network/XDCC_Download_Handler'
|
75
|
+
require 'src/Network/XDCC_Parser'
|
76
|
+
|
77
|
+
class FXTreeList
|
78
|
+
|
79
|
+
attr_reader :clickedItem
|
80
|
+
|
81
|
+
def init_clickedItem
|
82
|
+
self.connect(SEL_LEFTBUTTONPRESS) do |sender, sel, data|
|
83
|
+
@clickedItem = self.item_from_pos(data.click_x, data.click_y)
|
84
|
+
if @clickedItem
|
85
|
+
self.selectItem(@clickedItem, false)
|
86
|
+
else
|
87
|
+
self.killSelection(false)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
self.connect(SEL_RIGHTBUTTONPRESS) do |sender, sel, data|
|
92
|
+
@clickedItem = self.item_from_pos(data.click_x, data.click_y)
|
93
|
+
if @clickedItem
|
94
|
+
self.selectItem(@clickedItem, false)
|
95
|
+
else
|
96
|
+
self.killSelection(false)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def hit_rec(x, y, item)
|
102
|
+
return item if self.hitItem(item, x, y) != 0
|
103
|
+
i = nil
|
104
|
+
item.each do |child|
|
105
|
+
break if i = self.hit_rec(x, y, child)
|
106
|
+
end
|
107
|
+
i
|
108
|
+
end
|
109
|
+
|
110
|
+
def item_from_pos(x, y)
|
111
|
+
i = nil
|
112
|
+
self.each do |item|
|
113
|
+
break if i = self.hit_rec(x, y, item)
|
114
|
+
end
|
115
|
+
i
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# Responsible for application initialization
|
120
|
+
class Main_Window < FXMainWindow
|
121
|
+
|
122
|
+
# Initializes the XDCC-application.
|
123
|
+
def initialize(app)
|
124
|
+
#app.disableThreads
|
125
|
+
@data = Recursive_Open_Struct.new
|
126
|
+
@gui = Recursive_Open_Struct.new
|
127
|
+
@logic = Gui_Logic.new(@gui, @data)
|
128
|
+
|
129
|
+
# load configuration
|
130
|
+
@data.config = Configuration.new($cfg)
|
131
|
+
@data.config.load
|
132
|
+
init_variables
|
133
|
+
@data.close
|
134
|
+
|
135
|
+
# setup main window
|
136
|
+
$main_window = self
|
137
|
+
super(app, $cfg.app.name, nil, nil, DECOR_ALL, 0, 0, $cfg.app.width, $cfg.app.height)
|
138
|
+
set_default_font
|
139
|
+
FXToolTip.new(FXApp::instance, TOOLTIP_NORMAL)
|
140
|
+
|
141
|
+
# load icons
|
142
|
+
icon_loader = Icon_Loader.new(FXApp::instance)
|
143
|
+
icon_loader.cfg_to_icons($cfg.icons)
|
144
|
+
self.icon = $cfg.icons.app_big
|
145
|
+
self.miniIcon = $cfg.icons.app
|
146
|
+
|
147
|
+
# build base layout, and connections to logic.
|
148
|
+
@gui.main_window = self
|
149
|
+
Application_Builder.new(self, @gui, @data, @logic)
|
150
|
+
|
151
|
+
# TODO start
|
152
|
+
#sleep 1
|
153
|
+
#just_testing
|
154
|
+
@logic.connect_to_saved_servers
|
155
|
+
end
|
156
|
+
|
157
|
+
# Automatically called when the Fox application is created
|
158
|
+
def create
|
159
|
+
super
|
160
|
+
@logic.update_search_status_text
|
161
|
+
show(PLACEMENT_SCREEN)
|
162
|
+
end
|
163
|
+
|
164
|
+
# Set the default font to the first font of $cfg.app.font.name that is available on this system.
|
165
|
+
def set_default_font
|
166
|
+
# load default font
|
167
|
+
font = nil
|
168
|
+
$cfg.app.font.name.detect do |name|
|
169
|
+
next if FXFont.listFonts(name).empty?
|
170
|
+
font = FXFont.new(FXApp::instance, name, $cfg.app.font.size)
|
171
|
+
end
|
172
|
+
FXApp::instance.normalFont = font if font
|
173
|
+
end
|
174
|
+
|
175
|
+
# TODO remove
|
176
|
+
# Set up all variables.
|
177
|
+
def init_variables
|
178
|
+
@data.match_data = ""
|
179
|
+
@data.server_item_to_warning = Hash.new
|
180
|
+
@data.packet_icon_to_toggle_btn = Hash.new
|
181
|
+
@data.detached_items = Array.new
|
182
|
+
@data.allpack_to_item = Hash.new
|
183
|
+
@data.gui_mutex = Mutex.new
|
184
|
+
@data.irc_server_to_item = Hash.new
|
185
|
+
@data.downloadpack_to_item = Hash.new
|
186
|
+
@data.server_to_channels = Hash.new
|
187
|
+
@data.server_item_to_status = Hash.new
|
188
|
+
@data.ann_parser = XDCC_Parser.iroffer_parser
|
189
|
+
@data.ann_storage = XDCC_Announcement_Storage.new(@data.ann_parser)
|
190
|
+
@data.ann_storage.connect_to_events(XDCC_Announcement_Storage::ON_ANNOUNCEMENT_NEW, @logic)
|
191
|
+
@data.ann_storage.connect_to_events(XDCC_Announcement_Storage::ON_ANNOUNCEMENT_LOST, @logic)
|
192
|
+
@data.download_handlers = Hash.new
|
193
|
+
end
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
# debugging stuff
|
198
|
+
def just_testing
|
199
|
+
icons = [$cfg.icons.packet, $cfg.icons.free_slots, $cfg.icons.slots_unknown]
|
200
|
+
50000.times do |i|
|
201
|
+
# set slot representing icon
|
202
|
+
icon = icons[rand(3)]
|
203
|
+
# create an unconnected item
|
204
|
+
item = Packet_Item.new(nil, icon, "bot-#{rand(1e3)}", "#{rand(1e10).to_s(36)}", rand(100).to_s + ["M","K","G"][rand(3)])
|
205
|
+
@data.allpack_to_item[i] = item
|
206
|
+
# item needs to be added to a list, before calling match()
|
207
|
+
item.parent = @gui.packet_list
|
208
|
+
#if !@logic.match?(item, @gui.search_field.text.downcase.split)
|
209
|
+
# remove if it does not match
|
210
|
+
# item.parent = nil
|
211
|
+
#else
|
212
|
+
# is_added = true
|
213
|
+
#end
|
214
|
+
#@logic.update_search_status_text
|
215
|
+
end
|
216
|
+
@logic.update_search_status_text
|
217
|
+
#@gui.packet_list.on_cmd_header(2)
|
218
|
+
#@gui.packet_list.sortItems
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
Thread.abort_on_exception= true
|
223
|
+
|
224
|
+
$app = FXApp.new($cfg.app.name, $cfg.app.name)
|
225
|
+
$main_window = Main_Window.new($app)
|
226
|
+
$app.create
|
227
|
+
$app.run
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# Copyright (c) 2004, 2005 Christoph Heindl and Martin Ankerl
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
# are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice, this list
|
8
|
+
# of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright notice, this list
|
10
|
+
# of conditions and the following disclaimer in the documentation and/or other materials
|
11
|
+
# provided with the distribution.
|
12
|
+
# * Neither the name of Christoph Heindl and Martin Ankerl nor the names of its contributors
|
13
|
+
# may be used to endorse or promote products derived from this software without specific
|
14
|
+
# prior written permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
17
|
+
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
18
|
+
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
19
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
21
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
22
|
+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
23
|
+
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
|
25
|
+
|
26
|
+
# An item for Packet_List. This is a convenient wrapper for the FXIconItem.
|
27
|
+
class Packet_Item
|
28
|
+
|
29
|
+
# Fox_Item is a very thin wrapper that calles Packet_Item functionality.
|
30
|
+
class Fox_Item < FXIconItem
|
31
|
+
# optimization: directly sort by sort_key and reversed
|
32
|
+
attr_accessor :sort_key
|
33
|
+
attr_accessor :reversed
|
34
|
+
|
35
|
+
# Create a new item with packet_item as the parent. *args is passed to the FXIconItem.
|
36
|
+
def initialize(packet_item, *args)
|
37
|
+
@packet_item = packet_item
|
38
|
+
@sort_key = nil
|
39
|
+
@reversed = 1
|
40
|
+
super(*args)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Called from sortItems, uses packet_item's comparison.
|
44
|
+
def <=>(other)
|
45
|
+
(@sort_key <=> other.sort_key) * @reversed
|
46
|
+
end
|
47
|
+
|
48
|
+
# Get the packet item
|
49
|
+
def packet_item
|
50
|
+
@packet_item
|
51
|
+
end
|
52
|
+
|
53
|
+
# Pass-through method
|
54
|
+
def data
|
55
|
+
@packet_item.data
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Creates a Packet_Item with newParent as the parent list, which is allowed to be nil.
|
60
|
+
# You can also use Packet_List#add_item instead.
|
61
|
+
def initialize(newParent, icon, *content)
|
62
|
+
@content = content
|
63
|
+
@sortable = Array.new(@content.size)
|
64
|
+
@icon = icon
|
65
|
+
@data = nil
|
66
|
+
@parent = nil
|
67
|
+
@sort_key = nil
|
68
|
+
# call parent=, don't forget the self!!
|
69
|
+
self.parent = newParent
|
70
|
+
show if newParent
|
71
|
+
# update sortable
|
72
|
+
@content.each_index do |pos|
|
73
|
+
update_sortable(pos, @content[pos]) if parent
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Get the content of the given column number.
|
78
|
+
def [](column_nr)
|
79
|
+
@content[column_nr]
|
80
|
+
end
|
81
|
+
|
82
|
+
# Set new text for the given column number.
|
83
|
+
def []=(column_nr, newVal)
|
84
|
+
@content[column_nr] = newVal
|
85
|
+
return unless @parent
|
86
|
+
@item.text = @content.join("\t")
|
87
|
+
update_sortable(column_nr, newVal)
|
88
|
+
@parent.recalc
|
89
|
+
end
|
90
|
+
|
91
|
+
# Get the sortable representation of this column's content.
|
92
|
+
def sortable(pos)
|
93
|
+
@sortable[pos]
|
94
|
+
end
|
95
|
+
|
96
|
+
# update FXIconItem's sort key and reversed status
|
97
|
+
def update_sort_key
|
98
|
+
@item.sort_key = @sortable[@parent.sort_index]
|
99
|
+
@item.reversed = @parent.reversed? ? -1 : 1
|
100
|
+
end
|
101
|
+
|
102
|
+
# Get the parent list for this item.
|
103
|
+
def parent
|
104
|
+
@parent
|
105
|
+
end
|
106
|
+
|
107
|
+
# Set a new parent. This removes this item from the current list and adds itself to
|
108
|
+
# the new one.
|
109
|
+
def parent=(newParent)
|
110
|
+
return if newParent == @parent
|
111
|
+
remove_item if @parent
|
112
|
+
@parent = newParent
|
113
|
+
@content.each_index do |pos|
|
114
|
+
update_sortable(pos, @content[pos]) if @parent
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Shows item on parent without updating the search index. This can be used
|
119
|
+
# if an item is removed and added to the same list.
|
120
|
+
def show
|
121
|
+
create_item
|
122
|
+
@parent.add_item(self)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Get the wrapper item.
|
126
|
+
def fox_item
|
127
|
+
@item
|
128
|
+
end
|
129
|
+
|
130
|
+
# Allows to set user data.
|
131
|
+
def data=(data)
|
132
|
+
@data = data
|
133
|
+
end
|
134
|
+
|
135
|
+
# Get user data.
|
136
|
+
def data
|
137
|
+
@data
|
138
|
+
end
|
139
|
+
|
140
|
+
# Removes the item from its parent.
|
141
|
+
def clear
|
142
|
+
@parent = nil
|
143
|
+
end
|
144
|
+
|
145
|
+
# The icon of this item.
|
146
|
+
def icon
|
147
|
+
@icon
|
148
|
+
end
|
149
|
+
|
150
|
+
private
|
151
|
+
|
152
|
+
# Calles the sort function to update the sortable representation of column pos.
|
153
|
+
def update_sortable(pos, newVal)
|
154
|
+
sort_function = @parent.sort_function(pos)
|
155
|
+
if sort_function
|
156
|
+
@sortable[pos] = sort_function.call(newVal)
|
157
|
+
else
|
158
|
+
@sortable[pos] = newVal
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Remove item from parent
|
163
|
+
def remove_item
|
164
|
+
@parent.remove_item(self)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Creates wrapper item, and sets it's data
|
168
|
+
def create_item
|
169
|
+
@item = Fox_Item.new(self, @content.join("\t"), @icon, @icon)
|
170
|
+
end
|
171
|
+
end
|