Conversion to swift 4

This commit is contained in:
2017-06-28 14:38:12 +02:00
parent 965db2c81a
commit 7fc78049d2
21 changed files with 91 additions and 60 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ extension CollectionViewMonth: NSCollectionViewDataSource {
}
func collectionView(_ itemForRepresentedObjectAtcollectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
let item = itemForRepresentedObjectAtcollectionView.makeItem(withIdentifier: "CollectionViewItemMonth", for: indexPath)
let item = itemForRepresentedObjectAtcollectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "CollectionViewItemMonth"), for: indexPath)
guard let item2 = item as? CollectionViewItemMonth else {
self.doc.progress.increment(by: 100/31)
if self.doc.progress.doubleValue > 98 {
+1 -1
View File
@@ -34,7 +34,7 @@ extension CollectionViewYear: NSCollectionViewDataSource {
}
func collectionView(_ itemForRepresentedObjectAtcollectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
let item = itemForRepresentedObjectAtcollectionView.makeItem(withIdentifier: "CollectionViewItemYear", for: indexPath)
let item = itemForRepresentedObjectAtcollectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "CollectionViewItemYear"), for: indexPath)
guard let item2 = item as? CollectionViewItemYear else { return item }
if item2.isSelected {
item2.view.layer?.borderColor = NSColor.gray.cgColor
+11 -11
View File
@@ -26,6 +26,10 @@ class Document: NSDocument {
@IBOutlet var progress: NSProgressIndicator!
@IBOutlet var exportProgress: NSProgressIndicator!
override class var autosavesInPlace: Bool {
return false;
}
override init() {
super.init()
for _ in 0..<12 {
@@ -37,12 +41,8 @@ class Document: NSDocument {
}
}
override class func autosavesInPlace() -> Bool {
return false
}
override var windowNibName: String? {
return "Document"
override var windowNibName: NSNib.Name? {
return NSNib.Name(rawValue: "Document")
}
override func read(from fileWrapper: FileWrapper, ofType typeName: String) throws {
@@ -63,13 +63,13 @@ class Document: NSDocument {
// Setup collection layout
let flowLayout = NSCollectionViewFlowLayout()
flowLayout.itemSize = NSSize(width: 228, height: 211)
flowLayout.sectionInset = EdgeInsets(top: 10, left: 0, bottom: 10, right: 0)
flowLayout.sectionInset = NSEdgeInsets(top: 10, left: 0, bottom: 10, right: 0)
flowLayout.minimumInteritemSpacing = 10
flowLayout.minimumLineSpacing = 10
collectionViewYear.collectionViewLayout = flowLayout
let flowLayout2 = NSCollectionViewFlowLayout()
flowLayout2.itemSize = NSSize(width: 135, height: 132)
flowLayout2.sectionInset = EdgeInsets(top: 2, left: 2, bottom: 2, right: 2)
flowLayout2.sectionInset = NSEdgeInsets(top: 2, left: 2, bottom: 2, right: 2)
flowLayout2.minimumInteritemSpacing = 2
flowLayout2.minimumLineSpacing = 2
collectionViewMonth.collectionViewLayout = flowLayout2
@@ -93,14 +93,14 @@ class Document: NSDocument {
let alert = NSAlert()
alert.messageText = "Warning"
alert.informativeText = "PDF export active. Please wait until completed."
alert.alertStyle = NSAlertStyle.warning
alert.alertStyle = NSAlert.Style.warning
alert.addButton(withTitle: "OK")
alert.runModal()
}
pthread_mutex_unlock(&(NSApp.delegate as! AppDelegate).lock)
}
override func printOperation(withSettings printSettings: [String : Any]) throws -> NSPrintOperation {
override func printOperation(withSettings printSettings: [NSPrintInfo.AttributeKey : Any]) throws -> NSPrintOperation {
let printOperation: NSPrintOperation = NSPrintOperation(view: collectionViewMonth)
printOperation.printInfo.orientation = .landscape
printOperation.printInfo.horizontalPagination = .fitPagination
@@ -119,7 +119,7 @@ class Document: NSDocument {
savePanel.nameFieldStringValue = name
savePanel.canCreateDirectories = true
savePanel.beginSheetModal(for: windowController.window!) { result in
if result == NSFileHandlingPanelOKButton {
if result.rawValue == NSFileHandlingPanelOKButton {
self.exportProgress.doubleValue = 0
self.exportProgress.isHidden = false
let operationQueue: OperationQueue = OperationQueue()
+1 -1
View File
@@ -57,7 +57,7 @@ class FrequencyGraph: NSView {
override func draw(_ dirtyRect: NSRect) {
NSColor.white.setFill()
NSRectFill(dirtyRect)
__NSRectFill(dirtyRect)
threshold.lineWidth = 0.5
+4 -4
View File
@@ -23,8 +23,8 @@ class GraphWindow: NSWindowController {
let loadingQueue3: OperationQueue = OperationQueue()
let loadingQueue4: OperationQueue = OperationQueue()
override var windowNibName: String! {
return "GraphWindow"
override var windowNibName: NSNib.Name? {
return NSNib.Name(rawValue: "GraphWindow")
}
required init?(coder: NSCoder) {
@@ -103,7 +103,7 @@ class GraphWindow: NSWindowController {
}
extension GraphWindow: NSWindowDelegate {
func windowShouldClose(_ sender: Any) -> Bool {
func windowShouldClose(_ sender: NSWindow) -> Bool {
for op in loadingQueue1.operations {
if !op.isFinished {
return false
@@ -124,7 +124,7 @@ extension GraphWindow: NSWindowDelegate {
return false
}
}
collectionViewItem.collectionView.deselectAll(self)
collectionViewItem.collectionView?.deselectAll(self)
return true
}
}
+1 -1
View File
@@ -44,7 +44,7 @@
<key>CFBundleShortVersionString</key>
<string>2.1</string>
<key>CFBundleVersion</key>
<string>481</string>
<string>491</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
+4 -4
View File
@@ -39,10 +39,10 @@ class LossDistributionPie: NSView {
arc.move(to: center)
arc.addArc(center: center, radius: 18, startAngle: startAngle - CGFloat(i)*increment, endAngle: startAngle - CGFloat(i+1)*increment, clockwise: true)
arc.closeSubpath()
NSGraphicsContext.current()!.cgContext.addPath(arc)
NSGraphicsContext.current()!.cgContext.setFillColor(CGColor(red: 1, green: 0, blue: 0, alpha: CGFloat(distribution[i]) / 60))
NSGraphicsContext.current()!.cgContext.setStrokeColor(NSColor.controlShadowColor.cgColor)
NSGraphicsContext.current()!.cgContext.drawPath(using: CGPathDrawingMode.fillStroke)
NSGraphicsContext.current!.cgContext.addPath(arc)
NSGraphicsContext.current!.cgContext.setFillColor(CGColor(red: 1, green: 0, blue: 0, alpha: CGFloat(distribution[i]) / 60))
NSGraphicsContext.current!.cgContext.setStrokeColor(NSColor.controlShadowColor.cgColor)
NSGraphicsContext.current!.cgContext.drawPath(using: CGPathDrawingMode.fillStroke)
}
}
}
+3 -2
View File
@@ -46,8 +46,9 @@ class PDFDraw: NSWindowController {
var month: Int = 0
var days: [FileWrapper?] = [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
override var windowNibName: String! {
return "PDFDraw"
//override var windowNibName: NSNib.Name! {
override var windowNibName: NSNib.Name? {
return NSNib.Name(rawValue: "PDFDraw")
}
required init?(coder: NSCoder)
@@ -25,14 +25,14 @@ class PDFItemViewController: NSViewController {
}
init(dayFW: FileWrapper?, day: Int, monthName: String) {
super.init(nibName: "PDFItemViewController", bundle: Bundle.main)!
super.init(nibName: NSNib.Name(rawValue: "PDFItemViewController"), bundle: Bundle.main)
self.dayFW = dayFW
self.dayI = day
self.monthName = monthName
}
init(dayFW: FileWrapper?, day: Int) {
super.init(nibName: "PDFItemViewController", bundle: Bundle.main)!
super.init(nibName: NSNib.Name(rawValue: "PDFItemViewController"), bundle: Bundle.main)
self.dayFW = dayFW
self.dayI = day
}
+2 -2
View File
@@ -30,8 +30,8 @@ class PDFTitle: NSWindowController {
appName.stringValue = "Graphic Analysis 2 Version \(version())"
}
override var windowNibName: String! {
return "PDFTitle"
override var windowNibName: NSNib.Name? {
return NSNib.Name(rawValue: "PDFTitle")
}
required init?(coder: NSCoder)
+1 -1
View File
@@ -1,2 +1,2 @@
version 2.1
build 481
build 491