TimerList is list of pointers now
This commit is contained in:
parent
2ee6aea0b3
commit
1895739c71
16
model.go
16
model.go
@ -98,9 +98,9 @@ func (a *AppState) getFilteredTimerList(args []string) *timertxt.TimerList {
|
||||
return true
|
||||
})
|
||||
}
|
||||
doFilters := func(t timertxt.Timer) bool {
|
||||
doFilters := func(t *timertxt.Timer) bool {
|
||||
for _, v := range allFilters {
|
||||
if !v(t) {
|
||||
if !v(*t) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@ -185,8 +185,8 @@ func (a *AppState) WriteDoneList() error {
|
||||
return a.DoneList.WriteToFilename(a.getDoneFile())
|
||||
}
|
||||
|
||||
func (a *AppState) getFilterPredicate(filter string) func(timertxt.Timer) bool {
|
||||
var predicates []func(timertxt.Timer) bool
|
||||
func (a *AppState) getFilterPredicate(filter string) func(*timertxt.Timer) bool {
|
||||
var predicates []func(*timertxt.Timer) bool
|
||||
// If none of the 'filter' is in upper-case, do a case-insensitive filter
|
||||
checkCase := true
|
||||
if strings.ToLower(filter) == filter {
|
||||
@ -195,7 +195,7 @@ func (a *AppState) getFilterPredicate(filter string) func(timertxt.Timer) bool {
|
||||
filterParts := strings.Split(filter, " ")
|
||||
for _, part := range filterParts {
|
||||
if strings.HasPrefix(part, "@") {
|
||||
predicates = append(predicates, func(t timertxt.Timer) bool {
|
||||
predicates = append(predicates, func(t *timertxt.Timer) bool {
|
||||
for _, v := range t.Contexts {
|
||||
if "@"+v == part {
|
||||
return true
|
||||
@ -204,7 +204,7 @@ func (a *AppState) getFilterPredicate(filter string) func(timertxt.Timer) bool {
|
||||
return false
|
||||
})
|
||||
} else if strings.HasPrefix(part, "+") {
|
||||
predicates = append(predicates, func(t timertxt.Timer) bool {
|
||||
predicates = append(predicates, func(t *timertxt.Timer) bool {
|
||||
for _, v := range t.Projects {
|
||||
if "+"+v == part {
|
||||
return true
|
||||
@ -213,7 +213,7 @@ func (a *AppState) getFilterPredicate(filter string) func(timertxt.Timer) bool {
|
||||
return false
|
||||
})
|
||||
} else {
|
||||
predicates = append(predicates, func(t timertxt.Timer) bool {
|
||||
predicates = append(predicates, func(t *timertxt.Timer) bool {
|
||||
val := t.Original
|
||||
if !checkCase {
|
||||
val = strings.ToLower(t.Original)
|
||||
@ -222,7 +222,7 @@ func (a *AppState) getFilterPredicate(filter string) func(timertxt.Timer) bool {
|
||||
})
|
||||
}
|
||||
}
|
||||
return func(t timertxt.Timer) bool {
|
||||
return func(t *timertxt.Timer) bool {
|
||||
for _, v := range predicates {
|
||||
if v(t) {
|
||||
return true
|
||||
|
@ -70,14 +70,14 @@ func (screen *MainScreen) reloadList(bundle Bundle) error {
|
||||
for _, av := range *screen.activeList {
|
||||
for _, fv := range *filteredList {
|
||||
if av.String() == fv.String() {
|
||||
screen.displayList.AddTimer(&av)
|
||||
screen.displayList.AddTimer(av)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, av := range *screen.activeList {
|
||||
screen.displayList.AddTimer(&av)
|
||||
screen.displayList.AddTimer(av)
|
||||
}
|
||||
}
|
||||
case MainBundleListArchive:
|
||||
@ -223,7 +223,7 @@ func (screen *MainScreen) drawScreen() {
|
||||
}
|
||||
lineY := k + 1 - displayOffset
|
||||
if lineY > 0 && lineY < screen.viewPort.numberOfRows {
|
||||
termboxUtil.DrawStringAtPoint(pad+app.getTimerString(v), 0, lineY, useFg, useBg)
|
||||
termboxUtil.DrawStringAtPoint(pad+app.getTimerString(*v), 0, lineY, useFg, useBg)
|
||||
}
|
||||
}
|
||||
screen.drawFooter()
|
||||
|
16
timer_ops.go
16
timer_ops.go
@ -24,7 +24,7 @@ func (a *AppState) opStatus(args []string) int {
|
||||
d := currDur.Round(GetRoundToDuration())
|
||||
fmt.Printf("%s ( %.2f hrs )\n", time.Now().Format(time.Stamp), DurationToDecimal(d))
|
||||
for _, v := range *a.TimerList.GetActiveTimers() {
|
||||
fmt.Println(timerToFriendlyString(&v))
|
||||
fmt.Println(timerToFriendlyString(v))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@ -127,9 +127,9 @@ func (a *AppState) opListTimers(args []string) int {
|
||||
return true
|
||||
})
|
||||
}
|
||||
doFilters := func(t timertxt.Timer) bool {
|
||||
doFilters := func(t *timertxt.Timer) bool {
|
||||
for _, v := range allFilters {
|
||||
if !v(t) {
|
||||
if !v(*t) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ func (a *AppState) opListTimers(args []string) int {
|
||||
fmt.Printf(fmtStr, DurationToDecimal(wrkDur))
|
||||
}
|
||||
|
||||
fmt.Println(" " + timerToFriendlyString(&v))
|
||||
fmt.Println(" " + timerToFriendlyString(v))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@ -302,7 +302,7 @@ func (a *AppState) opArchiveTimer(args []string) int {
|
||||
fmt.Printf("Error archiving timer %d\n", tmr.Id)
|
||||
continue
|
||||
}
|
||||
fmt.Println(a.getDoneTimerString(tmr))
|
||||
fmt.Println(a.getDoneTimerString(*tmr))
|
||||
} else {
|
||||
fmt.Println("Refusing to archive running timer:", tmr.Id)
|
||||
}
|
||||
@ -319,7 +319,7 @@ func (a *AppState) opArchiveTimer(args []string) int {
|
||||
fmt.Printf("Error archiving timer %d\n", tmr.Id)
|
||||
continue
|
||||
}
|
||||
fmt.Println(a.getDoneTimerString(tmr))
|
||||
fmt.Println(a.getDoneTimerString(*tmr))
|
||||
} else {
|
||||
fmt.Println("Refusing to archive running timer:", tmr.Id)
|
||||
}
|
||||
@ -352,7 +352,7 @@ func (a *AppState) opArchiveTimer(args []string) int {
|
||||
fmt.Printf("Error archiving task %d\n", v.Id)
|
||||
return 1
|
||||
}
|
||||
fmt.Println(a.getDoneTimerString(v))
|
||||
fmt.Println(a.getDoneTimerString(*v))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -393,7 +393,7 @@ func (a *AppState) opModifyTimer(args []string) int {
|
||||
if err != nil {
|
||||
// We didn't have a timer id, so try to modify the first active timer
|
||||
if len(*a.TimerList.GetActiveTimers()) > 0 {
|
||||
timer = &(*a.TimerList.GetActiveTimers())[0]
|
||||
timer = (*a.TimerList.GetActiveTimers())[0]
|
||||
} else {
|
||||
// And we don't have any active timers
|
||||
fmt.Println("No active timers, 'id' must be provided.")
|
||||
|
Loading…
Reference in New Issue
Block a user