Skip to content
Browse files

added color row in upload table view

  • Loading branch information...
1 parent dc71582 commit 5acc411b0ac29529c424ec70ea57a0308c8a8bfe @aistomin aistomin committed Feb 24, 2012
Showing with 38 additions and 1 deletion.
  1. +6 −0 Fotki/AppDelegate.m
  2. +8 −1 Fotki/UploadWindowController.h
  3. +24 −0 Fotki/UploadWindowController.m
View
6 Fotki/AppDelegate.m
@@ -24,6 +24,7 @@
#import "UploadFilesDataSource.h"
#import "AboutWindowController.h"
#import "TextUtils.h"
+#import "UploadTableView.h"
#define APP_NAME @"Fotki"
@@ -278,6 +279,7 @@ - (void)uploadImagesAtPaths:(NSArray *)arrayPathsFiles toAlbum:(Album *)album {
LOG(@"Error occurred: %@", exception.description);
[self.controllerUploadWindow addError:exception.description forEvent:@"Upload images"];
self.dragStatusView.isEnable = YES;
+ [self.controllerUploadWindow.uploadFilesTable reloadData];
[self.controllerUploadWindow setStateUploadedWithException:exception];
}
@@ -300,6 +302,7 @@ - (void)doUploadImagesAtPaths:(NSArray *)arrayPathsFiles toAlbum:(Album *)album
NSString *crcFile = [CRCUtils crcFromDataAsString:[FileSystemHelper getFileData:pathFile]];
if ([self.serviceFacade checkCrc32:crcFile inAlbum:album]) {
LOG(@"File '%@' already exists on server, skipping it", pathFile);
+ [self.controllerUploadWindow addExistFileIndex:indexFilePath];
isFileUploaded = YES;
[statisticsCalculator setUploadSuccessForPath:pathFile];
} else {
@@ -341,11 +344,13 @@ - (void)doUploadImagesAtPaths:(NSArray *)arrayPathsFiles toAlbum:(Album *)album
}];
LOG(@"File '%@' was successfully uploaded", pathFile);
+ [self.controllerUploadWindow addSuccessFileIndex:indexFilePath];
[statisticsCalculator setUploadSuccessForPath:pathFile];
isFileUploaded = YES;
}
} @catch (ApiException *ex) {
LOG(@"Error uploading file '%@', reason: %@", pathFile, ex.description);
+ [self.controllerUploadWindow addErrorFileIndex:indexFilePath];
[self.controllerUploadWindow addError:ex.description forEvent:[NSString stringWithFormat:@"Uploading file: %@", pathFile]];
countAttempts++;
isFileUploaded = NO;
@@ -359,6 +364,7 @@ - (void)doUploadImagesAtPaths:(NSArray *)arrayPathsFiles toAlbum:(Album *)album
self.isUploadFinished = YES;
[NSThread doInMainThread:^() {
+ [self.controllerUploadWindow.uploadFilesTable reloadData];
[self.controllerUploadWindow setStateUploadedWithLinkToAlbum:linkToAlbum arrayPathsFilesFailed:[statisticsCalculator arrayPathsFilesFailed]];
} waitUntilDone:YES];
}
View
9 Fotki/UploadWindowController.h
@@ -11,13 +11,14 @@
@class UploadFilesDataSource;
@class ErrorsDataSource;
@class ClickableTextField;
+@class UploadTableView;
@interface UploadWindowController : NSWindowController<NSComboBoxDataSource, NSWindowDelegate, NSDraggingDestination>
@property(nonatomic, retain) NSArray *arrayAlbums;
@property(nonatomic, retain) IBOutlet NSTextField *welcomeLabel;
-@property(nonatomic, retain) IBOutlet NSTableView *uploadFilesTable;
+@property(nonatomic, retain) IBOutlet UploadTableView *uploadFilesTable;
@property(nonatomic, retain) UploadFilesDataSource *uploadFilesDataSource;
@property(nonatomic, retain) IBOutlet NSButton *uploadFilesAddButton;
@property(nonatomic, retain) IBOutlet NSButton *uploadFilesDeleteButton;
@@ -63,4 +64,10 @@
- (void)setStateUploadedWithLinkToAlbum:(NSString *)urlToAlbum arrayPathsFilesFailed:(NSMutableArray *)arrayPathsFilesFailed;
- (void)addError:(NSString *)errorDescription forEvent:(NSString *)event;
+
+- (void)addSuccessFileIndex:(NSInteger)index;
+
+- (void)addErrorFileIndex:(NSInteger)integer;
+
+- (void)addExistFileIndex:(NSInteger)integer;
@end
View
24 Fotki/UploadWindowController.m
@@ -11,6 +11,7 @@
#import "ErrorsDataSource.h"
#import "Lib/DataSources/UploadError.h"
#import "ClickableTextField.h"
+#import "UploadTableView.h"
typedef enum {
kStateUnknown, kStateInitialized, kStateUploading, kStateUploaded
@@ -95,6 +96,10 @@ - (id)init {
[self.window registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
[self.window setDelegate:self];
+
+ self.uploadFilesTable.redRows = [NSMutableArray array];
+ self.uploadFilesTable.greenRows = [NSMutableArray array];
+ self.uploadFilesTable.yellowRows = [NSMutableArray array];
}
return self;
@@ -294,6 +299,10 @@ - (void)setStateInitializedWithAccount:(Account *)account {
[self.welcomeLabel setTitleWithMnemonic:welcomeString];
[self.uploadFilesDataSource.arrayFilesToUpload removeAllObjects];
+ [self.uploadFilesTable.greenRows removeAllObjects];
+ [self.uploadFilesTable.yellowRows removeAllObjects];
+ [self.uploadFilesTable.redRows removeAllObjects];
+
[self.uploadFilesTable reloadData];
[self.uploadFilesTable setEnabled:YES];
@@ -409,4 +418,19 @@ - (void)addError:(NSString *)errorDescription forEvent:(NSString *)event {
[self.errorsDataSource.errors addObject:[[[UploadError alloc] initWithEvent:event andErrorDescription:errorDescription] autorelease]];
[self.errorsTable reloadData];
}
+
+- (void)addSuccessFileIndex:(NSInteger)index {
+ [self.uploadFilesTable.greenRows addObject:[NSNumber numberWithInteger:index]];
+
+}
+
+- (void)addErrorFileIndex:(NSInteger)index {
+ [self.uploadFilesTable.redRows addObject:[NSNumber numberWithInteger:index]];
+
+}
+
+- (void)addExistFileIndex:(NSInteger)index {
+ [self.uploadFilesTable.yellowRows addObject:[NSNumber numberWithInteger:index]];
+
+}
@end

0 comments on commit 5acc411

Please sign in to comment.
Something went wrong with that request. Please try again.