 
     onRowChange: (from, to) ->
       @logger.debug "Switching from row #{from?.id} to row #{to?.id}"
+      if not do @isLogging
+        return
       time = new Date()
       if @currentRow and @currentRow.id != to?.id
         @onRowPeriod { start: @currentRow.time, stop: time, id: @currentRow.id, row: from }

      @logger = @api.logger
      @logger.info "Loading time tracking"
      @api.cursor.on 'rowChange', (@onRowChange.bind @)
      @onRowChange undefined, @api.cursor.row # Initial setup
      @api.view.on 'renderLine', (@onRenderLine.bind @)
      @api.view.data.on 'afterDescendantRemoved', (@onDescendantRemoved.bind @)
      @api.view.data.on 'afterDescendantAdded', (@onDescendantAdded.bind @)
      @rowChanges = []
      @currentRow = null
      @displayTime = true
      @api.view.on 'exit', () =>
        @onRowChange @currentRow, null

    getRowData: (id, keytype) ->
      key = "#{id}:#{keytype}"

      @api.setData key, value
    transformRowData: (id, keytype, transform) ->
      @setRowData id, keytype, (transform (@getRowData id, keytype))

    DEFAULT_LOGGING = true
    DEFAULT_DISPLAY = true
    isLogging: () ->
      (@api.getData "isLogging") ? DEFAULT_LOGGING
    shouldDisplayTime: () ->
      (@api.getData "display") ? DEFAULT_DISPLAY
    toggleLogging: () ->
      @logger.info "Turning logging #{if (do @isLogging) then "off" else "on"}"
      if do @isLogging
        @onRowChange @api.cursor.row, null # Final close
      else
        @onRowChange null, @api.cursor.row # Initial setup
      @api.setData "isLogging", not (do @isLogging)
      do @api.view.render
    toggleDisplay: () ->
      @logger.info "Turning display #{if (do @shouldDisplayTime) then "off" else "on"}"
      @api.setData "display", not (do @shouldDisplayTime)
      do @api.view.render

    _date: (timestamp) ->
      "#{timestamp.getFullYear()}-#{timestamp.getMonth()}-#{timestamp.getDate()}"
