Clean print job names, modification dates for logs

This commit is contained in:
Matthias Neeracher 2015-03-16 16:02:09 +01:00 committed by Matthias Neeracher
parent d3894153fa
commit da0fb55ae0
2 changed files with 12 additions and 8 deletions

View File

@ -111,12 +111,6 @@ class ASLogNode : ASFileNode {
override func nodeName() -> String { override func nodeName() -> String {
return "📜 "+name return "📜 "+name
} }
override func modDate() -> NSDate? {
let url = NSURL(fileURLWithPath: path)
var date: AnyObject?
url?.getResourceValue(&date, forKey: NSURLContentModificationDateKey, error: nil)
return date as? NSDate
}
} }
class ASFileGroup : ASFileNode { class ASFileGroup : ASFileNode {

View File

@ -293,7 +293,17 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa
NSThread.detachNewThreadSelector(didPrintSelector, toTarget: del, withObject: contextInfo as? AnyObject) NSThread.detachNewThreadSelector(didPrintSelector, toTarget: del, withObject: contextInfo as? AnyObject)
} }
} }
if let logNode = mainEditor as? ASLogNode {
let url = fileURL!.URLByDeletingLastPathComponent?.URLByAppendingPathComponent(logNode.path)
var modified : AnyObject?
if url?.getResourceValue(&modified, forKey:NSURLAttributeModificationDateKey, error:nil) != nil {
printModDate = modified as? NSDate
} else {
printModDate = nil
}
} else {
printModDate = mainEditor?.modDate() printModDate = mainEditor?.modDate()
}
printRevision = mainEditor?.revision() printRevision = mainEditor?.revision()
printShowPanel = showPrintPanel printShowPanel = showPrintPanel
@ -330,7 +340,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa
} }
func startPrintOperation(printOp: NSPrintOperation) { func startPrintOperation(printOp: NSPrintOperation) {
printOp.jobTitle = mainEditor?.nodeName() ?? printOp.jobTitle = mainEditor?.name ??
fileURL?.lastPathComponent?.stringByDeletingPathExtension ?? fileURL?.lastPathComponent?.stringByDeletingPathExtension ??
"Untitled" "Untitled"
printOp.showsPrintPanel = printShowPanel printOp.showsPrintPanel = printShowPanel