Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
#14 added missing resource to quicklook plugin target and added an in…
Browse files Browse the repository at this point in the history
…itializer of cell properties manager for the plugin
  • Loading branch information
Tae Won Ha committed May 6, 2013
1 parent ab5f429 commit 3e5a6d0
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 20 deletions.
2 changes: 2 additions & 0 deletions Qmind.xcodeproj/project.pbxproj
Expand Up @@ -158,6 +158,7 @@
4BE684B716922F6E00789892 /* QMIconGridView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE684B616922F6D00789892 /* QMIconGridView.m */; };
4BE684B816922F6E00789892 /* QMIconGridView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE684B616922F6D00789892 /* QMIconGridView.m */; };
4BE9D5C014F5A76A00FC8248 /* cell-layout-test.mm in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BFCD7AC14F3E32A0085092D /* cell-layout-test.mm */; };
4BF11362173836DF0029C032 /* dummy.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4BFCD7AC14F3E32A00850936 /* dummy.pdf */; };
4BFCD74F14F3D33600850924 /* QMAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BFCD74E14F3D33600850924 /* QMAppDelegate.m */; };
4BFCD75814F3D34700850924 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B8564C514E461DC00C6FF0A /* Cocoa.framework */; };
4BFCD76E14F3D53300850924 /* OCMockito.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B85653514E46D6800C6FF5D /* OCMockito.framework */; };
Expand Down Expand Up @@ -1104,6 +1105,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4BF11362173836DF0029C032 /* dummy.pdf in Resources */,
4BD8C1291736F43200DC4B6F /* IconsFreeMindToQmind.plist in Resources */,
4B992F001735176D00C5844E /* InfoPlist.strings in Resources */,
);
Expand Down
12 changes: 11 additions & 1 deletion Qmind/QMCellPropertiesManager.h
Expand Up @@ -8,12 +8,22 @@

#import <Cocoa/Cocoa.h>

@protocol QMMindmapViewDataSource;
@class QMCell;
@class QMMindmapView;

@interface QMCellPropertiesManager : NSObject

- (id)initWithDataSource:(QMMindmapView *)view;
/**
* Init for Quick Look plugin for which we don't need the view.
*/
- (id)initWithDataSource:(id <QMMindmapViewDataSource>)dataSource;

/**
* Designated initializer for Qmind App.
*/
- (id)initWithMindmapView:(QMMindmapView *)view;

- (QMCell *)cellWithParent:(QMCell *)parentCell itemOfParent:(id)itemOfParent;
- (void)fillCellPropertiesWithIdentifier:(id)givenItem cell:(QMCell *)cell;
- (void)fillIconsOfCell:(QMCell *)cell;
Expand Down
12 changes: 11 additions & 1 deletion Qmind/QMCellPropertiesManager.m
Expand Up @@ -22,7 +22,7 @@ @interface QMCellPropertiesManager ()
@implementation QMCellPropertiesManager

#pragma mark Public
- (id)initWithDataSource:(QMMindmapView *)view {
- (id)initWithMindmapView:(QMMindmapView *)view {
self = [super init];
if (self) {
_view = view;
Expand All @@ -32,6 +32,16 @@ - (id)initWithDataSource:(QMMindmapView *)view {
return self;
}

- (id)initWithDataSource:(id <QMMindmapViewDataSource>)dataSource {
self = [super init];
if (self) {
_view = nil;
_dataSource = dataSource;
}

return self;
}

- (QMCell *)cellWithParent:(QMCell *)parentCell itemOfParent:(id)itemOfParent {
QMCell *cell;

Expand Down
3 changes: 2 additions & 1 deletion Qmind/QMDocument.h
Expand Up @@ -10,7 +10,8 @@
#import "QMMindmapViewDataSource.h"

static NSString * const qMindmapVersion = @"0.9.0";
static NSString * const qMindmapDocumentType = @"Mindmap";
static NSString * const qMindmapUti = @"com.qvacua.mindmap";
static NSString * const qObjectiveCppUti = @"public.objective-c-plus-plus-source";

@class QMDocumentWindowController;
@class QMMindmapReader;
Expand Down
4 changes: 2 additions & 2 deletions Qmind/QMDocument.m
Expand Up @@ -501,7 +501,7 @@ - (void)initRootNodeProperties {
*/
- (id)initWithType:(NSString *)typeName error:(NSError **)outError {

if (![typeName isEqualToString:qMindmapDocumentType]) {
if (![typeName isEqualToString:qMindmapUti]) {
log4Warn(@"Trying to open an unsupported file: %@", typeName);
return nil;
}
Expand Down Expand Up @@ -546,7 +546,7 @@ - (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)type
}

- (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError {
if (![typeName isEqualToString:qMindmapDocumentType]) {
if (![typeName isEqualToString:qMindmapUti] && ![typeName isEqualToString:qObjectiveCppUti]) {
log4Warn(@"Trying to save an unsupported file: %@", typeName);
return nil;
}
Expand Down
2 changes: 1 addition & 1 deletion Qmind/QMMindmapView.m
Expand Up @@ -460,7 +460,7 @@ - (void)updateLeftCellFamilyForInsertionWithIdentifier:(id)identifier {

- (void)initMindmapViewWithDataSource:(id <QMMindmapViewDataSource>)aDataSource {
_dataSource = aDataSource;
_cellPropertiesManager = [[QMCellPropertiesManager alloc] initWithDataSource:self];
_cellPropertiesManager = [[QMCellPropertiesManager alloc] initWithMindmapView:self];

_rootCell = (QMRootCell *) [self.cellPropertiesManager cellWithParent:nil itemOfParent:nil];
[self registerForDraggedTypes:@[qNodeUti]];
Expand Down
26 changes: 13 additions & 13 deletions QmindTest/DocumentTest.m
Expand Up @@ -447,7 +447,7 @@ - (void)testAddNewPrevSiblingNode {
- (void)testNodeDao {
NSFont *font = [NSFont boldSystemFontOfSize:20];

doc = [[QMDocument alloc] initWithType:qMindmapDocumentType error:NULL];
doc = [[QMDocument alloc] initWithType:qMindmapUti error:NULL];
[doc setInstanceVarTo:reader];

rootNode.stringValue = @"root";
Expand All @@ -464,7 +464,7 @@ - (void)testNodeDao {

[given([reader rootNodeForFileUrl:instanceOf(NSURL.class)]) willReturn:rootNode];
[doc setFileURL:[self urlForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION]];
[doc readFromFileWrapper:[self fileWrapperForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION] ofType:qMindmapDocumentType error:NULL];
[doc readFromFileWrapper:[self fileWrapperForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION] ofType:qMindmapUti error:NULL];

assertThatInteger([doc numberOfChildrenOfNode:nil], equalToInt(NUMBER_OF_CHILD));
assertThatInteger([doc numberOfLeftChildrenOfNode:nil], equalToInt(NUMBER_OF_LEFT_CHILD));
Expand Down Expand Up @@ -626,13 +626,13 @@ - (void)testToggleFolding {
}

- (void)testNewDoc {
doc = [[QMDocument alloc] initWithType:qMindmapDocumentType error:NULL];
doc = [[QMDocument alloc] initWithType:qMindmapUti error:NULL];
assertThat(doc, notNilValue());
assertThat([doc instanceVarOfClass:[QMRootNode class]], isNot(nilValue()));
}

- (void)testMakeWindowControllers {
doc = [[QMDocument alloc] initWithType:qMindmapDocumentType error:NULL];
doc = [[QMDocument alloc] initWithType:qMindmapUti error:NULL];
[doc makeWindowControllers];

assertThat(doc.windowController, notNilValue());
Expand All @@ -645,30 +645,30 @@ - (void)testWrongType {
}

- (void)testOpenDoc {
doc = [[QMDocument alloc] initWithType:qMindmapDocumentType error:NULL];
doc = [[QMDocument alloc] initWithType:qMindmapUti error:NULL];
[doc setInstanceVarTo:reader];

[given([reader rootNodeForFileUrl:anything()]) willReturn:rootNode];

[doc readFromFileWrapper:[self fileWrapperForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION] ofType:qMindmapDocumentType error:NULL];
[doc readFromFileWrapper:[self fileWrapperForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION] ofType:qMindmapUti error:NULL];

assertThat(rootNode.undoManager, equalTo(doc.undoManager));
assertThat([NODE(1) undoManager], equalTo(doc.undoManager));
assertThat([LNODE(4, 1) undoManager], equalTo(doc.undoManager));
}

- (void)testOpenDocWithError {
doc = [[QMDocument alloc] initWithType:qMindmapDocumentType error:NULL];
doc = [[QMDocument alloc] initWithType:qMindmapUti error:NULL];
[doc setInstanceVarTo:reader];

[given([reader rootNodeForFileUrl:anything()]) willReturn:nil];
NSFileWrapper *const wrapper = [self fileWrapperForResource:@"document-test-fail-open" extension:MINDMAP_EXTENSION];

assertThatBool([doc readFromFileWrapper:wrapper ofType:qMindmapDocumentType error:NULL], isFalse);
assertThatBool([doc readFromFileWrapper:wrapper ofType:qMindmapUti error:NULL], isFalse);
}

- (void)testNewDocObserver {
doc = [[QMDocument alloc] initWithType:qMindmapDocumentType error:NULL];
doc = [[QMDocument alloc] initWithType:qMindmapUti error:NULL];
[doc setWindowController:controller];
[doc setUndoManager:undoManager];

Expand Down Expand Up @@ -696,7 +696,7 @@ - (void)testOpenDocObserver {
[doc setWindowController:controller];

[given([reader rootNodeForFileUrl:anything()]) willReturn:rootNode];
[doc readFromFileWrapper:[self fileWrapperForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION] ofType:qMindmapDocumentType error:NULL];
[doc readFromFileWrapper:[self fileWrapperForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION] ofType:qMindmapUti error:NULL];

QObserverInfo *strInfo = [[QObserverInfo alloc] initWithObserver:doc keyPath:qNodeStringValueKey];
QObserverInfo *fontInfo = [[QObserverInfo alloc] initWithObserver:doc keyPath:qNodeFontKey];
Expand All @@ -711,15 +711,15 @@ - (void)testOpenDocObserver {
}

- (void)testWriteDoc {
doc = [[QMDocument alloc] initWithType:qMindmapDocumentType error:NULL];
doc = [[QMDocument alloc] initWithType:qMindmapUti error:NULL];
[doc setInstanceVarTo:reader];
[doc setInstanceVarTo:writer];

[given([reader rootNodeForFileUrl:instanceOf(NSURL.class)]) willReturn:[[QMRootNode alloc] init]];
[doc setFileURL:[self urlForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION]];
[doc readFromFileWrapper:[self fileWrapperForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION] ofType:qMindmapDocumentType error:NULL];
[doc readFromFileWrapper:[self fileWrapperForResource:MINDMAP_FILE_NAME extension:MINDMAP_EXTENSION] ofType:qMindmapUti error:NULL];

[doc fileWrapperOfType:qMindmapDocumentType error:NULL];
[doc fileWrapperOfType:qMindmapUti error:NULL];
[verify(writer) dataForRootNode:instanceOf(QMNode.class)];
}

Expand Down
2 changes: 1 addition & 1 deletion QmindTest/QMCellPropertiesManagerTest.m
Expand Up @@ -40,7 +40,7 @@ - (void)setUp {
dataSource = [[QMMindmapViewDataSourceImpl alloc] initWithDoc:doc view:view];
[given([view dataSource]) willReturn:dataSource];

populator = [[QMCellPropertiesManager alloc] initWithDataSource:view];
populator = [[QMCellPropertiesManager alloc] initWithMindmapView:view];
rootCell = (QMRootCell *) [populator cellWithParent:nil itemOfParent:nil];
}

Expand Down

0 comments on commit 3e5a6d0

Please sign in to comment.