Added dragging from the logBox onto the project list to change the project of the dragged time entries.
1.1 --- a/English.lproj/MainMenu.xib Mon Sep 28 21:54:21 2009 -0400
1.2 +++ b/English.lproj/MainMenu.xib Tue Sep 29 00:05:07 2009 -0400
1.3 @@ -8,6 +8,7 @@
1.4 <string key="IBDocument.HIToolboxVersion">353.00</string>
1.5 <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
1.6 <bool key="EncodedWithXMLCoder">YES</bool>
1.7 + <integer value="424"/>
1.8 </object>
1.9 <object class="NSArray" key="IBDocument.PluginDependencies">
1.10 <bool key="EncodedWithXMLCoder">YES</bool>
1.11 @@ -740,7 +741,7 @@
1.12 <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
1.13 <string key="NSWindowContentMinSize">{422, 216}</string>
1.14 <object class="NSView" key="NSWindowView" id="885368816">
1.15 - <nil key="NSNextResponder"/>
1.16 + <reference key="NSNextResponder"/>
1.17 <int key="NSvFlags">256</int>
1.18 <object class="NSMutableArray" key="NSSubviews">
1.19 <bool key="EncodedWithXMLCoder">YES</bool>
1.20 @@ -1296,7 +1297,7 @@
1.21 <reference key="NSBackgroundColor" ref="265497563"/>
1.22 <reference key="NSGridColor" ref="303660738"/>
1.23 <double key="NSRowHeight">1.700000e+01</double>
1.24 - <int key="NSTvFlags">1377828864</int>
1.25 + <int key="NSTvFlags">1512046592</int>
1.26 <string key="NSAutosaveName">TMLogBox</string>
1.27 <int key="NSColumnAutoresizingStyle">4</int>
1.28 <int key="NSDraggingSourceMaskForLocal">15</int>
1.29 @@ -1409,6 +1410,7 @@
1.30 </object>
1.31 </object>
1.32 <string key="NSFrameSize">{662, 275}</string>
1.33 + <reference key="NSSuperview"/>
1.34 </object>
1.35 <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
1.36 <string key="NSMinSize">{422, 238}</string>
1.37 @@ -1418,6 +1420,9 @@
1.38 <object class="NSCustomObject" id="656714836">
1.39 <string key="NSClassName">SUUpdater</string>
1.40 </object>
1.41 + <object class="NSCustomObject" id="338660838">
1.42 + <string key="NSClassName">TMTimesDragController</string>
1.43 + </object>
1.44 <object class="NSCustomObject" id="339013080">
1.45 <string key="NSClassName">TMProjectDragController</string>
1.46 </object>
1.47 @@ -2336,6 +2341,22 @@
1.48 </object>
1.49 <int key="connectionID">1713</int>
1.50 </object>
1.51 + <object class="IBConnectionRecord">
1.52 + <object class="IBOutletConnection" key="connection">
1.53 + <string key="label">dataSource</string>
1.54 + <reference key="source" ref="882866638"/>
1.55 + <reference key="destination" ref="338660838"/>
1.56 + </object>
1.57 + <int key="connectionID">1723</int>
1.58 + </object>
1.59 + <object class="IBConnectionRecord">
1.60 + <object class="IBOutletConnection" key="connection">
1.61 + <string key="label">timeEntryArray</string>
1.62 + <reference key="source" ref="338660838"/>
1.63 + <reference key="destination" ref="946697528"/>
1.64 + </object>
1.65 + <int key="connectionID">1724</int>
1.66 + </object>
1.67 </object>
1.68 <object class="IBMutableOrderedSet" key="objectRecords">
1.69 <object class="NSArray" key="orderedObjects">
1.70 @@ -2938,7 +2959,7 @@
1.71 <int key="objectID">624</int>
1.72 <reference key="object" ref="339013080"/>
1.73 <reference key="parent" ref="0"/>
1.74 - <string key="objectName">DragController</string>
1.75 + <string key="objectName">ProjectDragController</string>
1.76 </object>
1.77 <object class="IBObjectRecord">
1.78 <int key="objectID">1003</int>
1.79 @@ -3224,6 +3245,12 @@
1.80 <reference key="object" ref="477543123"/>
1.81 <reference key="parent" ref="283033676"/>
1.82 </object>
1.83 + <object class="IBObjectRecord">
1.84 + <int key="objectID">1721</int>
1.85 + <reference key="object" ref="338660838"/>
1.86 + <reference key="parent" ref="0"/>
1.87 + <string key="objectName">TimesDragController</string>
1.88 + </object>
1.89 </object>
1.90 </object>
1.91 <object class="NSMutableDictionary" key="flattenedProperties">
1.92 @@ -3374,6 +3401,7 @@
1.93 <string>1696.IBPluginDependency</string>
1.94 <string>1697.IBPluginDependency</string>
1.95 <string>1698.IBPluginDependency</string>
1.96 + <string>1721.IBPluginDependency</string>
1.97 <string>196.IBPluginDependency</string>
1.98 <string>196.ImportedFromIB2</string>
1.99 <string>257.IBPluginDependency</string>
1.100 @@ -3624,6 +3652,7 @@
1.101 <string>com.brandonwalkin.BWToolkit</string>
1.102 <string>com.brandonwalkin.BWToolkit</string>
1.103 <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
1.104 + <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
1.105 <reference ref="9"/>
1.106 <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
1.107 <reference ref="9"/>
1.108 @@ -3747,7 +3776,7 @@
1.109 </object>
1.110 </object>
1.111 <nil key="sourceID"/>
1.112 - <int key="maxID">1720</int>
1.113 + <int key="maxID">1724</int>
1.114 </object>
1.115 <object class="IBClassDescriber" key="IBDocument.Classes">
1.116 <object class="NSMutableArray" key="referencedPartialClassDescriptions">
1.117 @@ -3846,6 +3875,14 @@
1.118 </object>
1.119 </object>
1.120 <object class="IBClassDescriptionSource" key="sourceIdentifier">
1.121 + <string key="majorKey">IBProjectSource</string>
1.122 + <string key="minorKey">TMProjectDragController.h</string>
1.123 + </object>
1.124 + </object>
1.125 + <object class="IBPartialClassDescription">
1.126 + <string key="className">TMProjectDragController</string>
1.127 + <string key="superclassName">NSObject</string>
1.128 + <object class="IBClassDescriptionSource" key="sourceIdentifier">
1.129 <string key="majorKey">IBUserSource</string>
1.130 <string key="minorKey"/>
1.131 </object>
1.132 @@ -3867,6 +3904,18 @@
1.133 </object>
1.134 </object>
1.135 <object class="IBPartialClassDescription">
1.136 + <string key="className">TMTimesDragController</string>
1.137 + <string key="superclassName">NSObject</string>
1.138 + <object class="NSMutableDictionary" key="outlets">
1.139 + <string key="NS.key.0">timeEntryArray</string>
1.140 + <string key="NS.object.0">NSArrayController</string>
1.141 + </object>
1.142 + <object class="IBClassDescriptionSource" key="sourceIdentifier">
1.143 + <string key="majorKey">IBProjectSource</string>
1.144 + <string key="minorKey">TMTimesDragController.h</string>
1.145 + </object>
1.146 + </object>
1.147 + <object class="IBPartialClassDescription">
1.148 <string key="className">TimeMon</string>
1.149 <string key="superclassName">NSObject</string>
1.150 <object class="NSMutableDictionary" key="actions">
2.1 --- a/TMProjectDragController.h Mon Sep 28 21:54:21 2009 -0400
2.2 +++ b/TMProjectDragController.h Tue Sep 29 00:05:07 2009 -0400
2.3 @@ -14,7 +14,6 @@
2.4 IBOutlet NSTreeController *groupTreeControl;
2.5 IBOutlet NSOutlineView *treeTable;
2.6
2.7 - NSArray *dragType;
2.8 NSTreeNode *draggedNode;
2.9 }
2.10
3.1 --- a/TMProjectDragController.m Mon Sep 28 21:54:21 2009 -0400
3.2 +++ b/TMProjectDragController.m Tue Sep 29 00:05:07 2009 -0400
3.3 @@ -17,11 +17,7 @@
3.4
3.5 @implementation TMProjectDragController
3.6 - (void)awakeFromNib {
3.7 - dragType = [NSArray arrayWithObjects:@"factorialDragType", nil];
3.8 - [dragType retain];
3.9 -
3.10 - [groupTreeControl setSelectsInsertedObjects:YES];
3.11 - [treeTable registerForDraggedTypes:dragType];
3.12 + [treeTable registerForDraggedTypes:[NSArray arrayWithObjects:@"projectDragType", @"timesDragType", nil]];
3.13
3.14 NSSortDescriptor *sortDesc = [[NSSortDescriptor alloc] initWithKey:@"position" ascending:YES];
3.15 [groupTreeControl setSortDescriptors:[NSArray arrayWithObject: sortDesc]];
3.16 @@ -80,7 +76,7 @@
3.17 #pragma mark NSOutlineView datasource methods -- see NSOutlineViewDataSource
3.18 //---------------------------------------------------------------------------
3.19 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard{
3.20 - [pboard declareTypes:dragType owner:self];
3.21 + [pboard declareTypes:[NSArray arrayWithObject:@"projectDragType"] owner:self];
3.22 // items is an array of NSTreeControllerTreeNodes
3.23 draggedNode = [items objectAtIndex:0];
3.24
3.25 @@ -89,18 +85,31 @@
3.26
3.27 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index{
3.28 NSTreeNode *parentNode = item;
3.29 - NSTreeNode *siblingNode;
3.30 - NSTreeNode *proxy = groupTreeControl.arrangedObjects;
3.31 - NSManagedObject *draggedGroup = [draggedNode representedObject];
3.32 -
3.33 - BOOL draggingDown = NO;
3.34 - BOOL isRootLevelDrag = NO;
3.35 +
3.36 + //We can accept a project or a time
3.37 + NSPasteboard *pboard = info.draggingPasteboard;
3.38 + if ([pboard.types containsObject:@"timesDragType"]){
3.39 + if (!parentNode)
3.40 + return NO;
3.41 +
3.42 + NSArray *URIs = [NSKeyedUnarchiver unarchiveObjectWithData:[pboard dataForType:@"timesDragType"]];
3.43 + NSManagedObjectContext *moc = [[parentNode representedObject] managedObjectContext];
3.44 +
3.45 + for (NSURL *url in URIs){
3.46 + NSManagedObject *obj = [moc objectWithID:[[moc persistentStoreCoordinator] managedObjectIDForURIRepresentation:url]];
3.47 + [obj setValue:[parentNode representedObject] forKey:@"project"];
3.48 + }
3.49 +
3.50 + return YES;
3.51 + }
3.52
3.53 // -------------------------
3.54 // Setup comparison paths
3.55 // -------------------------
3.56 NSIndexPath *draggedPath = draggedNode.indexPath;
3.57 NSIndexPath *siblingPath = [NSIndexPath indexPathWithIndex:index];
3.58 + BOOL isRootLevelDrag = NO;
3.59 +
3.60 if (!parentNode)
3.61 isRootLevelDrag = YES;
3.62 else
3.63 @@ -110,6 +119,7 @@
3.64 // -----------------------------------------------------------------------------
3.65 // Compare paths - modify sibling path for down drags, exit for redundant drags
3.66 // -----------------------------------------------------------------------------
3.67 + BOOL draggingDown = NO;
3.68 switch ([draggedPath compare:siblingPath]){
3.69 case NSOrderedAscending: // reset path for down dragging
3.70 if (isRootLevelDrag)
3.71 @@ -125,7 +135,8 @@
3.72 break;
3.73 }
3.74
3.75 - siblingNode = [proxy descendantNodeAtIndexPath:siblingPath];
3.76 + NSTreeNode *proxy = groupTreeControl.arrangedObjects;
3.77 + NSTreeNode *siblingNode = [proxy descendantNodeAtIndexPath:siblingPath];
3.78
3.79 // ------------------------------------------------------------
3.80 // SPECIAL CASE: Dragging to the bottom
3.81 @@ -146,13 +157,13 @@
3.82 // ------------------------------------------------------------
3.83 NSManagedObject *sibling = [siblingNode representedObject];
3.84 NSNumber *bystanderPosition = [sibling valueForKey:@"position"];
3.85 + NSManagedObject *draggedGroup = [draggedNode representedObject];
3.86 int newPos = (draggingDown ? [bystanderPosition intValue] + 1 : [bystanderPosition intValue] - 1);
3.87 [draggedGroup setValue:[NSNumber numberWithInt:newPos] forKey:@"position"];
3.88
3.89 // ----------------------------------------------------------------------------------------------
3.90 // Set the new parent for the dragged item, resort the position attributes and refresh the tree
3.91 // ----------------------------------------------------------------------------------------------
3.92 -
3.93 [draggedGroup setValue:[parentNode representedObject] forKey:@"parent"];
3.94
3.95 [self resortGroups:[draggedGroup managedObjectContext] forParent:[parentNode representedObject]];
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/TMTimesDragController.h Tue Sep 29 00:05:07 2009 -0400
4.3 @@ -0,0 +1,20 @@
4.4 +/* TimeMon
4.5 + Copyright (C) 2009 Ceresalto
4.6 +
4.7 + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
4.8 + as published by the Free Software Foundation; version 2 of the License.
4.9 +
4.10 + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
4.11 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
4.12 +
4.13 + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
4.14 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
4.15 +
4.16 +#import <Cocoa/Cocoa.h>
4.17 +
4.18 +
4.19 +@interface TMTimesDragController : NSObject {
4.20 + IBOutlet NSArrayController *timeEntryArray;
4.21 +}
4.22 +
4.23 +@end
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/TMTimesDragController.m Tue Sep 29 00:05:07 2009 -0400
5.3 @@ -0,0 +1,33 @@
5.4 +/* TimeMon
5.5 + Copyright (C) 2009 Ceresalto
5.6 +
5.7 + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
5.8 + as published by the Free Software Foundation; version 2 of the License.
5.9 +
5.10 + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
5.11 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5.12 +
5.13 + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
5.14 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
5.15 +
5.16 +#import "TMTimesDragController.h"
5.17 +
5.18 +
5.19 +@implementation TMTimesDragController
5.20 +
5.21 +- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
5.22 +{
5.23 + //Put the URIs on the pasteboard so that they can be referenced properly
5.24 + [pboard declareTypes:[NSArray arrayWithObject:@"timesDragType"] owner:nil];
5.25 +
5.26 + NSMutableArray *rows = [NSMutableArray array];
5.27 + for (NSManagedObject *obj in [[timeEntryArray arrangedObjects] objectsAtIndexes:rowIndexes])
5.28 + [rows addObject:obj.objectID.URIRepresentation];
5.29 +
5.30 + NSData *encodedIDs = [NSKeyedArchiver archivedDataWithRootObject:rows];
5.31 + [pboard setData:encodedIDs forType:@"timesDragType"];
5.32 +
5.33 + return YES;
5.34 +}
5.35 +
5.36 +@end
6.1 --- a/TimeMon.xcodeproj/project.pbxproj Mon Sep 28 21:54:21 2009 -0400
6.2 +++ b/TimeMon.xcodeproj/project.pbxproj Tue Sep 29 00:05:07 2009 -0400
6.3 @@ -40,6 +40,7 @@
6.4 5A823DA41002F2B400245AB8 /* NSDate_Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A823DA31002F2B400245AB8 /* NSDate_Extensions.m */; };
6.5 5AA754BE0F088E8B00F9A4A5 /* BWToolkitFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AA754BD0F088E8B00F9A4A5 /* BWToolkitFramework.framework */; };
6.6 5AA754E10F088F0200F9A4A5 /* BWToolkitFramework.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5AA754BD0F088E8B00F9A4A5 /* BWToolkitFramework.framework */; };
6.7 + 5AB1F11F1071A0B800C30F61 /* TMTimesDragController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1F11E1071A0B800C30F61 /* TMTimesDragController.m */; };
6.8 5ABBE3370DE2718D00549EB3 /* 0.8-0.9.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = 5ABBE3360DE2718D00549EB3 /* 0.8-0.9.xcmappingmodel */; };
6.9 5ABBE39F0DE2771900549EB3 /* 0.7.1-0.8.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = 5ABBE39E0DE2771900549EB3 /* 0.7.1-0.8.xcmappingmodel */; };
6.10 5AD959230CDF9BF700B696D1 /* CalendarStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AD959150CDF9BF700B696D1 /* CalendarStore.framework */; };
6.11 @@ -162,6 +163,8 @@
6.12 5A823DA21002F2B400245AB8 /* NSDate_Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDate_Extensions.h; sourceTree = "<group>"; };
6.13 5A823DA31002F2B400245AB8 /* NSDate_Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDate_Extensions.m; sourceTree = "<group>"; };
6.14 5AA754BD0F088E8B00F9A4A5 /* BWToolkitFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = BWToolkitFramework.framework; sourceTree = "<group>"; };
6.15 + 5AB1F11D1071A0B800C30F61 /* TMTimesDragController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMTimesDragController.h; sourceTree = "<group>"; };
6.16 + 5AB1F11E1071A0B800C30F61 /* TMTimesDragController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMTimesDragController.m; sourceTree = "<group>"; };
6.17 5AB5C7720CFFA29B00BB23B5 /* entryData.xcdatamodel */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = wrapper.xcdatamodel; path = entryData.xcdatamodel; sourceTree = "<group>"; };
6.18 5ABBE3340DE2714E00549EB3 /* entryData 3.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "entryData 3.xcdatamodel"; sourceTree = "<group>"; };
6.19 5ABBE3360DE2718D00549EB3 /* 0.8-0.9.xcmappingmodel */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = wrapper.xcmappingmodel; path = "0.8-0.9.xcmappingmodel"; sourceTree = "<group>"; };
6.20 @@ -397,6 +400,8 @@
6.21 5A71DE530D08FB3C003F6DF9 /* TMTableView.m */,
6.22 0181E08E0A375E02002B95CC /* TMProjectDragController.h */,
6.23 0181E08F0A375E02002B95CC /* TMProjectDragController.m */,
6.24 + 5AB1F11D1071A0B800C30F61 /* TMTimesDragController.h */,
6.25 + 5AB1F11E1071A0B800C30F61 /* TMTimesDragController.m */,
6.26 5AF60F760DD68514005B58DA /* ImageAndTextCell.h */,
6.27 5AF60F770DD68514005B58DA /* ImageAndTextCell.m */,
6.28 );
6.29 @@ -499,6 +504,7 @@
6.30 5A823B6E1002E25100245AB8 /* TMDurationMigration.m in Sources */,
6.31 5A823DA41002F2B400245AB8 /* NSDate_Extensions.m in Sources */,
6.32 5AFB7A4A10042E4B00747FAB /* TMDurationTransformer.m in Sources */,
6.33 + 5AB1F11F1071A0B800C30F61 /* TMTimesDragController.m in Sources */,
6.34 );
6.35 runOnlyForDeploymentPostprocessing = 0;
6.36 };