| |
Changeset 120
- Timestamp:
- 02/11/08 10:17:18
(1 year ago)
- Author:
- mike
- Message:
[fix] QControlController adapted for smartfolder
[fix] QControlTableView adapted for smartfolder
[fix] QControlTableViewController adapted for smartfolder
[fix] QDocument adapted for smartfolder
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r119 |
r120 |
|
| 11 | 11 | <key>IBOpenObjects</key> |
|---|
| 12 | 12 | <array> |
|---|
| 13 | | <integer>216</integer> |
|---|
| | 13 | <integer>218</integer> |
|---|
| 14 | 14 | </array> |
|---|
| 15 | 15 | <key>IBSystem Version</key> |
|---|
| r119 |
r120 |
|
| 120 | 120 | |
|---|
| 121 | 121 | #pragma mark configurations |
|---|
| | 122 | NSInteger revCaseInsensitiveCompare(id string1, id string2, void *context) |
|---|
| | 123 | |
|---|
| | 124 | { |
|---|
| | 125 | return [[string2 lastPathComponent] caseInsensitiveCompare:[string1 lastPathComponent] ]; |
|---|
| | 126 | } |
|---|
| | 127 | |
|---|
| 122 | 128 | |
|---|
| 123 | 129 | |
|---|
| … | … | |
| 126 | 132 | Q_DEBUG(@"loadConfigurations"); |
|---|
| 127 | 133 | |
|---|
| | 134 | NSMutableDictionary *tempVM; |
|---|
| | 135 | NSMutableArray *knownVMs; |
|---|
| | 136 | |
|---|
| 128 | 137 | if (VMs) |
|---|
| 129 | 138 | [VMs release]; |
|---|
| 130 | | |
|---|
| 131 | | VMs = [[NSMutableArray alloc] init]; |
|---|
| 132 | | NSMutableDictionary *tempVM; |
|---|
| 133 | | |
|---|
| 134 | | // add knownVMs |
|---|
| | 139 | VMs =[[NSMutableArray alloc] init]; |
|---|
| | 140 | |
|---|
| | 141 | // check knownVMs |
|---|
| 135 | 142 | int i; |
|---|
| 136 | | NSMutableArray *knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; |
|---|
| | 143 | knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; |
|---|
| | 144 | [knownVMs sortUsingFunction:revCaseInsensitiveCompare context:nil]; |
|---|
| 137 | 145 | for (i = [knownVMs count] - 1; i > -1; i--) { |
|---|
| 138 | | // does it still exist? |
|---|
| 139 | | NSFileManager *fileManager = [NSFileManager defaultManager]; |
|---|
| 140 | | if ([fileManager fileExistsAtPath:[knownVMs objectAtIndex:i]]) { |
|---|
| 141 | | tempVM = [[QQvmManager sharedQvmManager] loadVMConfiguration:[knownVMs objectAtIndex:i]]; |
|---|
| 142 | | if (tempVM) { |
|---|
| 143 | | [VMs addObject:tempVM]; |
|---|
| 144 | | } else { |
|---|
| 145 | | [knownVMs removeObjectAtIndex:i]; |
|---|
| 146 | | } |
|---|
| | 146 | tempVM = [[QQvmManager sharedQvmManager] loadVMConfiguration:[knownVMs objectAtIndex:i]]; |
|---|
| | 147 | if (tempVM) { |
|---|
| | 148 | [VMs addObject:tempVM]; |
|---|
| 147 | 149 | } else { |
|---|
| 148 | 150 | [knownVMs removeObjectAtIndex:i]; |
|---|
| r119 |
r120 |
|
| 31 | 31 | #define ICON_WIDTH 9.0 |
|---|
| 32 | 32 | #define ICON_HEIGHT 9.0 |
|---|
| 33 | | #define ICON_X 45.0 |
|---|
| | 33 | #define ICON_X 3.0 |
|---|
| 34 | 34 | #define ICON_Y 31.0 |
|---|
| | 35 | #define ICON_SPACE 2.0 |
|---|
| 35 | 36 | |
|---|
| 36 | 37 | @implementation QControlTableView |
|---|
| … | … | |
| 65 | 66 | NSRect cellRect = [self frameOfCellAtColumn:1 row:row]; |
|---|
| 66 | 67 | |
|---|
| 67 | | for (i = 1; i < 5; i++) { |
|---|
| | 68 | for (i = 0; i < 4; i++) { |
|---|
| 68 | 69 | if (NSPointInRect(pointClicked, NSMakeRect( |
|---|
| 69 | | cellRect.origin.x + cellRect.size.width - i * (ICON_WIDTH + 4), |
|---|
| 70 | | cellRect.origin.y + cellRect.size.height - ICON_HEIGHT - 4, |
|---|
| | 70 | cellRect.origin.x + ICON_X + i * (ICON_WIDTH), |
|---|
| | 71 | cellRect.origin.y + ICON_Y, |
|---|
| 71 | 72 | ICON_WIDTH, |
|---|
| 72 | 73 | ICON_HEIGHT |
|---|
| … | … | |
| 74 | 75 | VM = [[qControl VMs] objectAtIndex:row]; |
|---|
| 75 | 76 | switch (i) { |
|---|
| 76 | | case 1: // delete |
|---|
| 77 | | if ([[[VM objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"shutdown"]) |
|---|
| 78 | | clicked = TRUE; |
|---|
| | 77 | case 0: // edit |
|---|
| | 78 | clicked = TRUE; |
|---|
| | 79 | break; |
|---|
| | 80 | case 1: // play/pause |
|---|
| | 81 | clicked = TRUE; |
|---|
| 79 | 82 | break; |
|---|
| 80 | 83 | case 2: // stop |
|---|
| … | … | |
| 82 | 85 | clicked = TRUE; |
|---|
| 83 | 86 | break; |
|---|
| 84 | | case 3: // play/pause |
|---|
| 85 | | clicked = TRUE; |
|---|
| 86 | | break; |
|---|
| 87 | | case 4: // edit |
|---|
| 88 | | clicked = TRUE; |
|---|
| | 87 | case 3: // delete |
|---|
| | 88 | if ([[[VM objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"shutdown"]) |
|---|
| | 89 | clicked = TRUE; |
|---|
| 89 | 90 | break; |
|---|
| 90 | 91 | } |
|---|
| … | … | |
| 118 | 119 | document = [[NSDocumentController sharedDocumentController] documentForURL:[[VM objectForKey:@"Temporary"] objectForKey:@"URL"]]; |
|---|
| 119 | 120 | |
|---|
| 120 | | for (i = 1; i < 5; i++) { |
|---|
| | 121 | for (i = 0; i < 4; i++) { |
|---|
| 121 | 122 | if (NSPointInRect(pointClicked, NSMakeRect( |
|---|
| 122 | | cellRect.origin.x + cellRect.size.width - i * (ICON_WIDTH + 4), |
|---|
| 123 | | cellRect.origin.y + cellRect.size.height - ICON_HEIGHT - 4, |
|---|
| | 123 | cellRect.origin.x + ICON_X + i * (ICON_WIDTH + ICON_SPACE), |
|---|
| | 124 | cellRect.origin.y + ICON_Y, |
|---|
| 124 | 125 | ICON_WIDTH, |
|---|
| 125 | 126 | ICON_HEIGHT |
|---|
| 126 | 127 | ))) { |
|---|
| 127 | 128 | switch (i) { |
|---|
| 128 | | case 1: // delete |
|---|
| 129 | | if (!document) // only allow if VM is not open |
|---|
| 130 | | [qControl deleteVM:VM]; |
|---|
| 131 | | break; |
|---|
| 132 | | case 2: // stop |
|---|
| 133 | | if (document) { |
|---|
| 134 | | if (([document VMState]==QDocumentRunning)||([document VMState]==QDocumentPaused)) { |
|---|
| 135 | | [document VMShutDown:self]; |
|---|
| 136 | | } |
|---|
| 137 | | } |
|---|
| 138 | | break; |
|---|
| 139 | | case 3: // play/pause |
|---|
| | 129 | case 0: // edit |
|---|
| | 130 | [qControl editVM:VM]; |
|---|
| | 131 | break; |
|---|
| | 132 | case 1: // play/pause |
|---|
| 140 | 133 | if (document) { |
|---|
| 141 | 134 | switch ([document VMState]) { |
|---|
| … | … | |
| 155 | 148 | } |
|---|
| 156 | 149 | break; |
|---|
| 157 | | case 4: // edit |
|---|
| 158 | | [qControl editVM:VM]; |
|---|
| 159 | | break; |
|---|
| | 150 | case 2: // stop |
|---|
| | 151 | if (document) { |
|---|
| | 152 | if (([document VMState]==QDocumentRunning)||([document VMState]==QDocumentPaused)) { |
|---|
| | 153 | [document VMShutDown:self]; |
|---|
| | 154 | } |
|---|
| | 155 | } |
|---|
| | 156 | break; |
|---|
| | 157 | case 3: // delete |
|---|
| | 158 | if (!document) // only allow if VM is not open |
|---|
| | 159 | [qControl deleteVM:VM]; |
|---|
| | 160 | break; |
|---|
| 160 | 161 | } |
|---|
| 161 | 162 | } |
|---|
| … | … | |
| 191 | 192 | |
|---|
| 192 | 193 | // edit icon |
|---|
| 193 | | point = NSMakePoint(cellRect.origin.x + ICON_X + (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); |
|---|
| | 194 | point = NSMakePoint(cellRect.origin.x + ICON_X, cellRect.origin.y + ICON_Y); |
|---|
| 194 | 195 | if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { |
|---|
| 195 | 196 | qFraction = 1.0; |
|---|
| … | … | |
| 215 | 216 | |
|---|
| 216 | 217 | // play/pause icon |
|---|
| 217 | | point = NSMakePoint(cellRect.origin.x + ICON_X + 2 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); |
|---|
| | 218 | point = NSMakePoint(cellRect.origin.x + ICON_X + (ICON_WIDTH + ICON_SPACE), cellRect.origin.y + ICON_Y); |
|---|
| 218 | 219 | if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { |
|---|
| 219 | 220 | qFraction = 1.0; |
|---|
| … | … | |
| 252 | 253 | |
|---|
| 253 | 254 | // stop icon |
|---|
| 254 | | point = NSMakePoint(cellRect.origin.x + ICON_X + 3 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); |
|---|
| | 255 | point = NSMakePoint(cellRect.origin.x + ICON_X + 2 * (ICON_WIDTH + ICON_SPACE), cellRect.origin.y + ICON_Y); |
|---|
| 255 | 256 | if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { |
|---|
| 256 | 257 | qFraction = 1.0; |
|---|
| … | … | |
| 276 | 277 | |
|---|
| 277 | 278 | // delete icon |
|---|
| 278 | | point = NSMakePoint(cellRect.origin.x + ICON_X + 4 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); |
|---|
| | 279 | point = NSMakePoint(cellRect.origin.x + ICON_X + 3 * (ICON_WIDTH + ICON_SPACE), cellRect.origin.y + ICON_Y); |
|---|
| 279 | 280 | if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) |
|---|
| 280 | 281 | qFraction = 1.0; |
|---|
| r119 |
r120 |
|
| 137 | 137 | paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease]; |
|---|
| 138 | 138 | |
|---|
| 139 | | color = [NSColor colorWithDeviceRed:0.5 green:0.5 blue:0.5 alpha:1.0]; |
|---|
| | 139 | color = [NSColor colorWithDeviceRed:0.75 green:0.75 blue:0.75 alpha:1.0]; |
|---|
| 140 | 140 | [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingHead]; |
|---|
| 141 | 141 | |
|---|
| 142 | 142 | attrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", name] attributes:[NSDictionary dictionaryWithObject: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]; |
|---|
| 143 | | [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", [path stringByDeletingLastPathComponent]] attributes:[NSDictionary dictionaryWithObjectsAndKeys: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, color, NSForegroundColorAttributeName, nil]] autorelease]]; |
|---|
| 144 | | [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:state attributes:[NSDictionary dictionaryWithObject:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]]; |
|---|
| | 143 | [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", state] attributes:[NSDictionary dictionaryWithObject:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]]; |
|---|
| | 144 | [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"\n%@", [path stringByDeletingLastPathComponent]] attributes:[NSDictionary dictionaryWithObjectsAndKeys: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, color, NSForegroundColorAttributeName, nil]] autorelease]]; |
|---|
| 145 | 145 | |
|---|
| 146 | 146 | return attrString; |
|---|
| r118 |
r120 |
|
| 270 | 270 | |
|---|
| 271 | 271 | // if outside default path, add to knownVNs |
|---|
| 272 | | if (![[[panel filename] stringByDeletingLastPathComponent] isEqual:[[qApplication userDefaults] objectForKey:@"dataPath"]]) { |
|---|
| 273 | | if (![[[qApplication userDefaults] objectForKey:@"knownVMs"] containsObject:[panel filename]]) { |
|---|
| 274 | | knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; |
|---|
| 275 | | [knownVMs addObject:[panel filename]]; |
|---|
| 276 | | [[qApplication userDefaults] setObject:knownVMs forKey:@"knownVMs"]; |
|---|
| 277 | | } |
|---|
| | 272 | if (![[[qApplication userDefaults] objectForKey:@"knownVMs"] containsObject:[panel filename]]) { |
|---|
| | 273 | knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; |
|---|
| | 274 | [knownVMs addObject:[panel filename]]; |
|---|
| | 275 | [[qApplication userDefaults] setObject:knownVMs forKey:@"knownVMs"]; |
|---|
| 278 | 276 | } |
|---|
| 279 | 277 | |
|---|
| … | … | |
| 293 | 291 | [savePanel setAllowedFileTypes:[NSArray arrayWithObject:@"qvm"]]; |
|---|
| 294 | 292 | [savePanel setCanSelectHiddenExtension:YES]; |
|---|
| 295 | | [savePanel beginSheetForDirectory:[[qApplication userDefaults] objectForKey:@"dataPath"] file:[self displayName] modalForWindow:[screenView window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:nil]; |
|---|
| | 293 | [savePanel beginSheetForDirectory:nil file:[self displayName] modalForWindow:[screenView window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:nil]; |
|---|
| 296 | 294 | } else { |
|---|
| 297 | 295 | [self defaultAlertMessage:@"VM is running" informativeText:@"Please shutdown the VM before saving the VM to a new Name"]; |
|---|
| r119 |
r120 |
|
| | 1 | 120 |
|---|
| | 2 | [fix] QControlController adapted for smartfolder |
|---|
| | 3 | [fix] QControlTableView adapted for smartfolder |
|---|
| | 4 | [fix] QControlTableViewController adapted for smartfolder |
|---|
| | 5 | [fix] QDocument adapted for smartfolder |
|---|
| | 6 | |
|---|
| 1 | 7 | 119 |
|---|
| 2 | | [new] smartfolder for Q Control (get rid of default folder) |
|---|
| | 8 | [new] smartfolder for Q Control (ie. show all qvm files using spotlight - get rid of default folder) |
|---|
| 3 | 9 | |
|---|
| 4 | 10 | 118 |
|---|
Download in other formats:
| |