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