Class: TaskWindow::TaskTable

Inherits:
Qt::TableWidget
  • Object
show all
Defined in:
lib/taskwin.rb

Overview


Instance Method Summary collapse

Constructor Details

#initializeTaskTable

Returns a new instance of TaskTable.



61
62
63
64
65
66
# File 'lib/taskwin.rb', line 61

def initialize
    super(0,4)

    # Hash table : key column_0_item  => TaskItem
    @taskItemTbl = {}
end

Instance Method Details

#deleteItem(i) ⇒ Object



101
102
103
104
# File 'lib/taskwin.rb', line 101

def deleteItem(i)
    removeRow(i.id.row)
    @taskItemTbl.delete(i.id)
end

#each(&block) ⇒ Object



92
93
94
95
96
97
98
99
# File 'lib/taskwin.rb', line 92

def each(&block)
    a = []
    rowCount.times do |r|
        i = taskItemAtRow(r)
        a << i if i
    end
    a.each do |i| block.call( i ) end
end

#insertTaskItem(taskItem) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/taskwin.rb', line 78

def insertTaskItem(taskItem)
    sortFlag = sortingEnabled
    self.sortingEnabled = false

    insertRow(0)
    setItem(0,SOURCE, taskItem.sourceUrlItem)
    setItem(0,FILE, taskItem.savePathItem)
    setItem(0,LAPSE, taskItem.timeItem)
    setItem(0,STATUS, taskItem.statusItem)
    @taskItemTbl[taskItem.id] = taskItem

    self.sortingEnabled = sortFlag
end

#taskItemAtRow(row) ⇒ Object



69
70
71
72
# File 'lib/taskwin.rb', line 69

def taskItemAtRow(row)
    i0 = item(row,0)     # column_0_item is key to taskItem ID
    i0 && taskItemFromId(i0)
end

#taskItemFromId(id) ⇒ Object



74
75
76
# File 'lib/taskwin.rb', line 74

def taskItemFromId(id)
    @taskItemTbl[id]
end