From b048e3fd581c4cfb56fd0146d00882717eff129b Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 30 Oct 2017 08:23:01 -0700 Subject: [PATCH] =?UTF-8?q?Move=20the=20timeline=20table=E2=80=99s=20data?= =?UTF-8?q?=20source=20a=20separate=20file/class.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Evergreen.xcodeproj/project.pbxproj | 4 +++ Evergreen/Base.lproj/MainWindow.storyboard | 1 - .../TimelineTableViewDataSource.swift | 32 +++++++++++++++++++ .../Timeline/TimelineViewController.swift | 4 +++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Evergreen/MainWindow/Timeline/TimelineTableViewDataSource.swift diff --git a/Evergreen.xcodeproj/project.pbxproj b/Evergreen.xcodeproj/project.pbxproj index 2cfd59d74..31df766d4 100644 --- a/Evergreen.xcodeproj/project.pbxproj +++ b/Evergreen.xcodeproj/project.pbxproj @@ -83,6 +83,7 @@ 84DAEE301F86CAFE0058304B /* OPMLImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */; }; 84DAEE321F870B390058304B /* DockBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DAEE311F870B390058304B /* DockBadge.swift */; }; 84E46C7D1F75EF7B005ECFB3 /* AppDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */; }; + 84FB3A6F1FA6612C00EFC320 /* TimelineTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84FB3A6E1FA6612C00EFC320 /* TimelineTableViewDataSource.swift */; }; 84FB9A2F1EDCD6C4003D53B9 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84FB9A2D1EDCD6B8003D53B9 /* Sparkle.framework */; }; 84FB9A301EDCD6C4003D53B9 /* Sparkle.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84FB9A2D1EDCD6B8003D53B9 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ @@ -444,6 +445,7 @@ 84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPMLImporter.swift; sourceTree = ""; }; 84DAEE311F870B390058304B /* DockBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = DockBadge.swift; path = Evergreen/DockBadge.swift; sourceTree = ""; }; 84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDefaults.swift; path = Evergreen/AppDefaults.swift; sourceTree = ""; }; + 84FB3A6E1FA6612C00EFC320 /* TimelineTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineTableViewDataSource.swift; sourceTree = ""; }; 84FB9A2D1EDCD6B8003D53B9 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = Frameworks/Vendor/Sparkle.framework; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ @@ -577,6 +579,7 @@ isa = PBXGroup; children = ( 849A976B1ED9EBC8007D329B /* TimelineViewController.swift */, + 84FB3A6E1FA6612C00EFC320 /* TimelineTableViewDataSource.swift */, 849A97691ED9EBC8007D329B /* TimelineTableRowView.swift */, 849A976A1ED9EBC8007D329B /* TimelineTableView.swift */, 849A976F1ED9EC04007D329B /* Cell */, @@ -1214,6 +1217,7 @@ 849A97851ED9ECCD007D329B /* PreferencesWindowController.swift in Sources */, 849A977A1ED9EC04007D329B /* TimelineTableCellView.swift in Sources */, 849A97761ED9EC04007D329B /* TimelineCellAppearance.swift in Sources */, + 84FB3A6F1FA6612C00EFC320 /* TimelineTableViewDataSource.swift in Sources */, 849A97A21ED9F180007D329B /* FeedTitleDownloader.swift in Sources */, 849A977F1ED9EC42007D329B /* ArticleRenderer.swift in Sources */, ); diff --git a/Evergreen/Base.lproj/MainWindow.storyboard b/Evergreen/Base.lproj/MainWindow.storyboard index ba89f8b62..b7ee3296b 100644 --- a/Evergreen/Base.lproj/MainWindow.storyboard +++ b/Evergreen/Base.lproj/MainWindow.storyboard @@ -504,7 +504,6 @@ - diff --git a/Evergreen/MainWindow/Timeline/TimelineTableViewDataSource.swift b/Evergreen/MainWindow/Timeline/TimelineTableViewDataSource.swift new file mode 100644 index 000000000..050f7d293 --- /dev/null +++ b/Evergreen/MainWindow/Timeline/TimelineTableViewDataSource.swift @@ -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 + } + +} diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index f37debf46..6b5cbf6d6 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -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()