Move the timeline table’s data source a separate file/class.

This commit is contained in:
Brent Simmons
2017-10-30 08:23:01 -07:00
parent 82c75a56d3
commit b048e3fd58
4 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
//
// TimelineTableViewDataSource.swift
// Evergreen
//
// Created by Brent Simmons on 10/29/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Foundation
final class TimelineTableViewDataSource {
private weak var timelineViewController: TimelineViewController?
init(timelineViewController: TimelineViewController) {
self.timelineViewController = timelineViewController
}
// MARK: NSTableViewDataSource
func numberOfRows(in tableView: NSTableView) -> Int {
return timelineViewController?.articles.count ? 0
}
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
return timelineViewController?.articleAtRow(row) ? nil
}
}

View File

@@ -17,6 +17,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
@IBOutlet var tableView: TimelineTableView!
private var undoableCommands = [UndoableCommand]()
private var dataSource: TimelineTableViewDataSource!
var didRegisterForNotifications = false
var fontSize: FontSize = AppDefaults.shared.timelineFontSize {
didSet {
@@ -69,6 +70,9 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
override func viewDidLoad() {
dataSource = TimelineTableViewDataSource(timelineViewController: self)
tableView.dataSource = dataSource
cellAppearance = TimelineCellAppearance(theme: currentTheme, fontSize: fontSize)
tableView.rowHeight = calculateRowHeight()