-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTableViewMethods.rb
35 lines (30 loc) · 932 Bytes
/
TableViewMethods.rb
1
2
3
4
5
6
7
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
#
# TableViewMethods.rb
# sqlite
#
# Created by Brad Wilson on 2/05/08.
# Copyright (c) 2008 Brad Wilson. All rights reserved.
#
module TableViewMethods
def numberOfRowsInTableView(aTableView)
@rows ? @rows.length : 0
end
###
# Returns the value to display for the given row and column
###
def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex)
colIndex = aTableColumn.identifier.to_i
return @rows[rowIndex][colIndex] if @rows and rowIndex < @rows.length and colIndex < @rows[rowIndex].length
end
###
# Update order for sql query, and force a reload
###
def tableView_sortDescriptorsDidChange(aTableView, oldDescriptors)
sort_descriptors = aTableView.sortDescriptors
puts sort_descriptors
puts oldDescriptors
@order = ""
@order = sort_descriptors.map { |sd| "lower(#{ sd.key }) #{ sd.ascending ? 'asc' : 'desc' }" }.join(', ') if sort_descriptors.any?
reload
end
end