blob: 035af2319fdca2157736edfdef630ff063008a88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
//
// This file is part of the LibreOffice project.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "MLOFileListViewController.h"
#import "MLOFileManagerViewController_Impl.h"
#import "MLOFileCacheManager.h"
#import "MLOCachedFile.h"
@interface MLOFileListViewController ()
@property MLOFileManagerViewController * fileManager;
@property UITableView * list;
@end
@implementation MLOFileListViewController
-(id)initWithFileManager:(MLOFileManagerViewController *)fileManager{
self = [self initWithStyle:UITableViewStylePlain];
if(self){
self.fileManager = fileManager;
self.list = [UITableView new];
self.view.backgroundColor = [UIColor clearColor];
[self reloadData];
}
return self;
}
-(void)onRotate{
self.list.frame = [self.fileManager currentFullscreenFrame];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(void)reloadData{
[self.list reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.fileManager.cache count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [self.fileManager.cache cellForTableView:tableView atIndexPath:indexPath];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
-(BOOL)hasFiles{
return [self.fileManager.cache count] > 0;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.fileManager.cache deleteIndexPath:indexPath];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
if(![self hasFiles]){
[self.fileManager reloadData];
}
}
}
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
[self.fileManager.cache sendFileAtIndexPath:indexPath];
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.fileManager.cache openFileAtIndex:indexPath.row];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
|