Skip to content

Commit

Permalink
progress on tree view for file consolidator
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 committed Dec 5, 2017
1 parent 4478b52 commit af5a42c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 72 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "jmc/Delegate:Main Window Controller/MainWindowController.swift"
timestampString = "534124211.01151"
timestampString = "534194284.233738"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "336"
Expand Down
33 changes: 26 additions & 7 deletions jmc/AlbumFileLocationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,16 @@ class AlbumFilePathNode: NSObject {
}
}

func getChildrenWithObject(object: NSObject) {
if self.totalFiles.contains(object) {
func getLowestChildWithObject(object: NSObject) -> AlbumFilePathNode? {
if self.totalFiles.contains(where: {($0 as! NSManagedObject).objectID == (object as! NSManagedObject).objectID}) {
for child in self.children {

if let childObject = child.getLowestChildWithObject(object: object) {
return childObject
}
}
return self
} else {
return nil
}
}

Expand Down Expand Up @@ -154,8 +159,12 @@ class AlbumFilePathTree: NSObject {
return AlbumFilePathTree(files: &filteredFiles)
}

func getNodesForObjects(objects: Set<NSObject>) {

func getNodesForObjects(objects: Set<NSObject>) -> Set<AlbumFilePathNode> {
var nodeSet = Set<AlbumFilePathNode>()
for object in objects {
nodeSet.insert(self.rootNode.getLowestChildWithObject(object: object)!)
}
return nodeSet
}
}

Expand Down Expand Up @@ -206,8 +215,18 @@ class AlbumFileLocationViewController: NSViewController, NSOutlineViewDataSource
}

func showItems(items: Set<NSObject>) {

self.outlineView.selectRowIndexes(<#T##indexes: IndexSet##IndexSet#>, byExtendingSelection: <#T##Bool#>)
if self.isSearching == true {
self.isSearching = false
self.outlineView.reloadData()
}
let nodes = self.masterTree.getNodesForObjects(objects: items)
var indexSet = IndexSet()
for node in nodes {
let row = self.outlineView.row(forItem: node)
indexSet.insert(row)
}
self.outlineView.selectRowIndexes(indexSet, byExtendingSelection: false)
self.outlineView.scrollRowToVisible(indexSet.last!)
}

func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,11 @@ class MainWindowController: NSWindowController, NSSearchFieldDelegate, NSWindowD
self.skipBackward()
}
@IBAction func tempBreak(_ sender: AnyObject) {
self.skip()
//self.skip()
print("dongels")
let fr = NSFetchRequest<Track>(entityName: "Track")
let result = try? managedContext.fetch(fr)
print(result?.count)
}
@IBAction func addPlaylistButton(_ sender: AnyObject) {
sourceListViewController!.createPlaylist(nil, smart_criteria: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ class ConsolidateLibrarySheetController: NSWindowController, ProgressBarControll
self.preConsolidationFileViewController.masterTree = AlbumFilePathTree(files: &currentTrackLocations)
self.targetView.addArrangedSubview(self.preConsolidationFileViewController.view)
self.preConsolidationFileViewController.setupForOldLocations()
self.preConsolidationFileViewController.parentController = self
self.postConsolidationFileViewController = AlbumFileLocationViewController(nibName: NSNib.Name(rawValue: "AlbumFileLocationViewController"), bundle: nil)
self.postConsolidationFileViewController.masterTree = AlbumFilePathTree(files: &self.things)
self.targetView.addArrangedSubview(postConsolidationFileViewController.view)
self.postConsolidationFileViewController.setupForNewLocations()
self.postConsolidationFileViewController.parentController = self
/*self.postConsolidationFileViewController!.view.topAnchor.constraint(equalTo: targetView.topAnchor).isActive = true
self.postConsolidationFileViewController!.view.rightAnchor.constraint(equalTo: targetView.rightAnchor).isActive = true
self.postConsolidationFileViewController!.view.bottomAnchor.constraint(equalTo: targetView.bottomAnchor).isActive = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ConsolidateLibrarySheetController" customModule="jmc" customModuleProvider="target">
<connections>
<outlet property="progressBar" destination="GtP-Hk-WyF" id="6Xi-3I-P4a"/>
<outlet property="progressTextLabel" destination="X1q-I0-Mdz" id="RKh-pM-elM"/>
<outlet property="targetView" destination="MFd-Wj-PLF" id="epV-eS-E0E"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
</connections>
Expand All @@ -25,18 +23,8 @@
<rect key="frame" x="0.0" y="0.0" width="837" height="430"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tTM-Jy-PPi">
<rect key="frame" x="654" y="13" width="169" height="32"/>
<buttonCell key="cell" type="push" title="Consolidate Selected" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="JlA-C3-G2A">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="consolidatePressed:" target="-2" id="GiF-hs-vHF"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="rpR-j6-0wn">
<rect key="frame" x="19" y="100" width="84" height="18"/>
<rect key="frame" x="19" y="41" width="84" height="18"/>
<buttonCell key="cell" type="radio" title="Move files" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="Khg-Id-0Ze">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -46,7 +34,7 @@
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="p3r-Lu-9Nn">
<rect key="frame" x="19" y="78" width="83" height="18"/>
<rect key="frame" x="19" y="19" width="83" height="18"/>
<buttonCell key="cell" type="radio" title="Copy files" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="x5h-co-iTE">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -55,27 +43,7 @@
<action selector="radioActio:" target="-2" id="CXE-Bd-Cc5"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iYL-2N-1q7">
<rect key="frame" x="540" y="13" width="114" height="32"/>
<buttonCell key="cell" type="push" title="Select None" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="gM1-gv-m0g">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="selectNonePressed:" target="-2" id="8iL-xo-gmU"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5ux-3v-gEs">
<rect key="frame" x="443" y="13" width="97" height="32"/>
<buttonCell key="cell" type="push" title="Select All" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="oPR-CW-bdp">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="selectAllPressed:" target="-2" id="ImL-tJ-oSY"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TJw-Cj-9eN">
<button verticalHuggingPriority="750" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="TJw-Cj-9eN">
<rect key="frame" x="361" y="13" width="82" height="32"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="RNm-WS-CkA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -88,40 +56,17 @@ Gw
<action selector="cancelPressed:" target="-2" id="MIf-4w-tOl"/>
</connections>
</button>
<progressIndicator hidden="YES" wantsLayer="YES" maxValue="100" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="GtP-Hk-WyF">
<rect key="frame" x="20" y="52" width="797" height="20"/>
</progressIndicator>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="X1q-I0-Mdz">
<rect key="frame" x="18" y="37" width="33" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="cNx-1d-wUz">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<splitView arrangesAllSubviews="NO" vertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MFd-Wj-PLF">
<rect key="frame" x="20" y="125" width="797" height="285"/>
<rect key="frame" x="20" y="66" width="797" height="344"/>
</splitView>
</subviews>
<constraints>
<constraint firstItem="5ux-3v-gEs" firstAttribute="leading" secondItem="TJw-Cj-9eN" secondAttribute="trailing" constant="12" id="1za-5k-uYn"/>
<constraint firstItem="GtP-Hk-WyF" firstAttribute="top" secondItem="p3r-Lu-9Nn" secondAttribute="bottom" constant="8" id="2wg-wd-8NZ"/>
<constraint firstAttribute="trailing" secondItem="GtP-Hk-WyF" secondAttribute="trailing" constant="20" id="3kH-xy-rIU"/>
<constraint firstItem="MFd-Wj-PLF" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="4LZ-Gb-pVM"/>
<constraint firstItem="GtP-Hk-WyF" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="7G6-cx-aEj"/>
<constraint firstItem="MFd-Wj-PLF" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" id="9jB-Ve-xDQ"/>
<constraint firstItem="tTM-Jy-PPi" firstAttribute="leading" secondItem="iYL-2N-1q7" secondAttribute="trailing" constant="12" id="BET-sE-VVR"/>
<constraint firstItem="rpR-j6-0wn" firstAttribute="top" secondItem="MFd-Wj-PLF" secondAttribute="bottom" constant="8" id="FCS-ou-NAF"/>
<constraint firstItem="iYL-2N-1q7" firstAttribute="leading" secondItem="5ux-3v-gEs" secondAttribute="trailing" constant="12" id="L2H-64-UYK"/>
<constraint firstAttribute="trailing" secondItem="tTM-Jy-PPi" secondAttribute="trailing" constant="20" id="NaS-i1-j6t"/>
<constraint firstAttribute="bottom" secondItem="X1q-I0-Mdz" secondAttribute="bottom" constant="37" id="TpX-Io-IJr"/>
<constraint firstAttribute="bottom" secondItem="p3r-Lu-9Nn" secondAttribute="bottom" constant="20" id="Oe7-VH-ssl"/>
<constraint firstItem="rpR-j6-0wn" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="WNe-l1-MzD"/>
<constraint firstAttribute="trailing" secondItem="MFd-Wj-PLF" secondAttribute="trailing" constant="20" id="YEo-Ro-OWA"/>
<constraint firstAttribute="bottom" secondItem="5ux-3v-gEs" secondAttribute="bottom" constant="20" id="cUM-uc-Avz"/>
<constraint firstItem="X1q-I0-Mdz" firstAttribute="top" secondItem="GtP-Hk-WyF" secondAttribute="bottom" constant="2" id="ctL-qb-dTT"/>
<constraint firstItem="X1q-I0-Mdz" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="dD3-z9-kuC"/>
<constraint firstAttribute="bottom" secondItem="iYL-2N-1q7" secondAttribute="bottom" constant="20" id="nGR-Xu-CEc"/>
<constraint firstAttribute="bottom" secondItem="tTM-Jy-PPi" secondAttribute="bottom" constant="20" id="rnm-iz-vFB"/>
<constraint firstItem="p3r-Lu-9Nn" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="ryL-s4-pds"/>
<constraint firstAttribute="bottom" secondItem="TJw-Cj-9eN" secondAttribute="bottom" constant="20" id="uZj-Q1-eCx"/>
<constraint firstItem="p3r-Lu-9Nn" firstAttribute="top" secondItem="rpR-j6-0wn" secondAttribute="bottom" constant="6" id="vy9-jQ-VNw"/>
Expand Down

0 comments on commit af5a42c

Please sign in to comment.