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
67
# File 'lib/taskwin.rb', line 61

def initialize
    super(0,4)

    # Hash table : key column_0_item  => TaskItem
    @taskItemTbl = {}
    self.selectionMode = Qt::AbstractItemView::SingleSelection
end

Instance Method Details

#deleteItem(i) ⇒ Object



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

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

#each(&block) ⇒ Object



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

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



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

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



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

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

#taskItemFromId(id) ⇒ Object



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

def taskItemFromId(id)
    @taskItemTbl[id]
end