From 17cd8e717d853946813deda9cb160832b445dfdd Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 18 May 2010 20:03:06 +0000 Subject: Change filesize units to base 2 rather than base 10. Fixes issue #690. Patch provided by Max Lohrmann, thanks Max!. --- Source/CMTextView.m | 4 ++-- Source/SPAppController.m | 4 ++-- Source/SPEditSheetTextView.m | 4 ++-- Source/SPStringAdditions.m | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 18059059..94e5a2bb 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -3094,8 +3094,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSAlert *alert = [[NSAlert alloc] init]; [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")]; [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")]; - [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Do you really want to proceed with %.1f MB of data?", @"message of panel asking for confirmation for inserting large text from dragging action"), - [filesize unsignedLongValue]/1048576.0]]; + [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Do you really want to proceed with %@ of data?", @"message of panel asking for confirmation for inserting large text from dragging action"), + [NSString stringForByteSize:[filesize longLongValue]]]]; [alert setHelpAnchor:filepath]; [alert setMessageText:NSLocalizedString(@"Warning",@"warning")]; [alert setAlertStyle:NSWarningAlertStyle]; diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 69fcca80..b80e0680 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -224,8 +224,8 @@ [alert addButtonWithTitle:NSLocalizedString(@"Import", @"import button")]; - [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Do you really want to load a SQL file with %.1f MB of data into the Query Editor?", @"message of panel asking for confirmation for loading large text into the query editor"), - [filesize unsignedLongValue]/1048576.0]]; + [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Do you really want to load a SQL file with %@ of data into the Query Editor?", @"message of panel asking for confirmation for loading large text into the query editor"), + [NSString stringForByteSize:[filesize longLongValue]]]]; [alert setHelpAnchor:filename]; [alert setMessageText:NSLocalizedString(@"Warning",@"warning")]; [alert setAlertStyle:NSWarningAlertStyle]; diff --git a/Source/SPEditSheetTextView.m b/Source/SPEditSheetTextView.m index 776d000e..3e22614d 100644 --- a/Source/SPEditSheetTextView.m +++ b/Source/SPEditSheetTextView.m @@ -173,8 +173,8 @@ NSAlert *alert = [[NSAlert alloc] init]; [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")]; [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")]; - [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Do you really want to proceed with %.1f MB of data?", @"message of panel asking for confirmation for inserting large text from dragging action"), - [filesize unsignedLongValue]/1048576.0]]; + [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Do you really want to proceed with %@ of data?", @"message of panel asking for confirmation for inserting large text from dragging action"), + [NSString stringForByteSize:[filesize longLongValue]]]]; [alert setHelpAnchor:filepath]; [alert setMessageText:NSLocalizedString(@"Warning", @"warning")]; [alert setAlertStyle:NSWarningAlertStyle]; diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index 09d80b9a..c36e55c1 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -54,7 +54,7 @@ size = (size / 1024); if (size < 1023) { - [numberFormatter setFormat:@"#,##0.0 KB"]; + [numberFormatter setFormat:@"#,##0.0 KiB"]; return [numberFormatter stringFromNumber:[NSNumber numberWithDouble:size]]; } @@ -62,7 +62,7 @@ size = (size / 1024); if (size < 1023) { - [numberFormatter setFormat:@"#,##0.0 MB"]; + [numberFormatter setFormat:@"#,##0.0 MiB"]; return [numberFormatter stringFromNumber:[NSNumber numberWithDouble:size]]; } @@ -70,14 +70,14 @@ size = (size / 1024); if (size < 1023) { - [numberFormatter setFormat:@"#,##0.0 GB"]; + [numberFormatter setFormat:@"#,##0.0 GiB"]; return [numberFormatter stringFromNumber:[NSNumber numberWithDouble:size]]; } size = (size / 1024); - [numberFormatter setFormat:@"#,##0.0 TB"]; + [numberFormatter setFormat:@"#,##0.0 TiB"]; return [numberFormatter stringFromNumber:[NSNumber numberWithDouble:size]]; } -- cgit v1.2.3