Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#14 fixed newly introduced bug: no selection ring displayed

  • Loading branch information...
commit ab5f42909ce685b4cb124a4ea94ca7d164ccd2cc 1 parent 2c5818d
Tae Won Ha authored
View
4 Qmind/QMCellPropertiesManager.h
@@ -8,12 +8,12 @@
#import <Cocoa/Cocoa.h>
-@protocol QMMindmapViewDataSource;
@class QMCell;
+@class QMMindmapView;
@interface QMCellPropertiesManager : NSObject
-- (id)initWithDataSource:(id <QMMindmapViewDataSource>)dataSource;
+- (id)initWithDataSource:(QMMindmapView *)view;
- (QMCell *)cellWithParent:(QMCell *)parentCell itemOfParent:(id)itemOfParent;
- (void)fillCellPropertiesWithIdentifier:(id)givenItem cell:(QMCell *)cell;
- (void)fillIconsOfCell:(QMCell *)cell;
View
31 Qmind/QMCellPropertiesManager.m
@@ -10,20 +10,23 @@
#import "QMCell.h"
#import "QMMindmapViewDataSource.h"
#import "QMRootCell.h"
+#import "QMMindmapView.h"
@interface QMCellPropertiesManager ()
@property id <QMMindmapViewDataSource> dataSource;
+@property QMMindmapView *view;
@end
@implementation QMCellPropertiesManager
#pragma mark Public
-- (id)initWithDataSource:(id <QMMindmapViewDataSource>)dataSource {
+- (id)initWithDataSource:(QMMindmapView *)view {
self = [super init];
if (self) {
- _dataSource = dataSource;
+ _view = view;
+ _dataSource = _view.dataSource;
}
return self;
@@ -33,13 +36,13 @@ - (QMCell *)cellWithParent:(QMCell *)parentCell itemOfParent:(id)itemOfParent {
QMCell *cell;
if (itemOfParent == nil) {
- QMRootCell *rootCell = [[QMRootCell alloc] initWithView:nil];
+ QMRootCell *rootCell = [[QMRootCell alloc] initWithView:self.view];
cell = rootCell;
} else {
- cell = [[QMCell alloc] initWithView:nil];
+ cell = [[QMCell alloc] initWithView:self.view];
if (parentCell.isRoot) {
- BOOL isItemLeft = [_dataSource mindmapView:nil isItemLeft:itemOfParent];
+ BOOL isItemLeft = [_dataSource mindmapView:self.view isItemLeft:itemOfParent];
if (isItemLeft) {
[(QMRootCell *) parentCell addObjectInLeftChildren:cell];
} else {
@@ -57,25 +60,25 @@ - (QMCell *)cellWithParent:(QMCell *)parentCell itemOfParent:(id)itemOfParent {
}
- (void)fillCellPropertiesWithIdentifier:(id)givenItem cell:(QMCell *)cell {
- cell.identifier = [_dataSource mindmapView:nil identifierForItem:givenItem];
- cell.stringValue = [_dataSource mindmapView:nil stringValueOfItem:givenItem];
- cell.font = [_dataSource mindmapView:nil fontOfItem:givenItem];
- cell.folded = [_dataSource mindmapView:nil isItemFolded:givenItem];
+ cell.identifier = [_dataSource mindmapView:self.view identifierForItem:givenItem];
+ cell.stringValue = [_dataSource mindmapView:self.view stringValueOfItem:givenItem];
+ cell.font = [_dataSource mindmapView:self.view fontOfItem:givenItem];
+ cell.folded = [_dataSource mindmapView:self.view isItemFolded:givenItem];
[self fillIconsOfCell:cell];
}
- (void)fillIconsOfCell:(QMCell *)cell {
- NSArray *iconsOfItem = [_dataSource mindmapView:nil iconsOfItem:cell.identifier];
+ NSArray *iconsOfItem = [_dataSource mindmapView:self.view iconsOfItem:cell.identifier];
for (id icon in iconsOfItem) {
[cell insertObject:icon inIconsAtIndex:cell.icons.count];
}
}
- (void)fillAllChildrenWithIdentifier:(id)givenItem cell:(QMCell *)cell {
- NSInteger childrenCount = [_dataSource mindmapView:nil numberOfChildrenOfItem:givenItem];
+ NSInteger childrenCount = [_dataSource mindmapView:self.view numberOfChildrenOfItem:givenItem];
for (NSUInteger i = 0; i < childrenCount; i++) {
- id childItem = [_dataSource mindmapView:nil child:i ofItem:givenItem];
+ id childItem = [_dataSource mindmapView:self.view child:i ofItem:givenItem];
[self cellWithParent:cell itemOfParent:childItem];
}
@@ -83,9 +86,9 @@ - (void)fillAllChildrenWithIdentifier:(id)givenItem cell:(QMCell *)cell {
return;
}
- NSInteger leftChildrenCount = [_dataSource mindmapView:nil numberOfLeftChildrenOfItem:givenItem];
+ NSInteger leftChildrenCount = [_dataSource mindmapView:self.view numberOfLeftChildrenOfItem:givenItem];
for (NSUInteger i = 0; i < leftChildrenCount; i++) {
- id childItem = [_dataSource mindmapView:nil leftChild:i ofItem:givenItem];
+ id childItem = [_dataSource mindmapView:self.view leftChild:i ofItem:givenItem];
[self cellWithParent:cell itemOfParent:childItem];
}
}
View
2  Qmind/QMMindmapView.m
@@ -460,7 +460,7 @@ - (void)updateLeftCellFamilyForInsertionWithIdentifier:(id)identifier {
- (void)initMindmapViewWithDataSource:(id <QMMindmapViewDataSource>)aDataSource {
_dataSource = aDataSource;
- _cellPropertiesManager = [[QMCellPropertiesManager alloc] initWithDataSource:aDataSource];
+ _cellPropertiesManager = [[QMCellPropertiesManager alloc] initWithDataSource:self];
_rootCell = (QMRootCell *) [self.cellPropertiesManager cellWithParent:nil itemOfParent:nil];
[self registerForDraggedTypes:@[qNodeUti]];
View
16 QmindTest/QMCellPropertiesManagerTest.m
@@ -1,4 +1,5 @@
-/**
+#import "QMRootCell.h"
+#import "QMMindmapView.h"/**
* Tae Won Ha
* http://qvacua.com
* https://github.com/qvacua
@@ -23,6 +24,7 @@ @implementation QMCellPropertiesManagerTest {
QMDocument *doc;
id <QMMindmapViewDataSource> dataSource;
QMCellPropertiesManager *populator;
+ QMMindmapView *view;
QMRootCell *rootCell;
}
@@ -34,16 +36,23 @@ - (void)setUp {
wireRootNodeOfDoc(doc, rootNode);
[doc setUndoManager:mock([NSUndoManager class])];
- dataSource = [[QMMindmapViewDataSourceImpl alloc] initWithDoc:doc view:nil];
+ view = mock(QMMindmapView.class);
+ dataSource = [[QMMindmapViewDataSourceImpl alloc] initWithDoc:doc view:view];
+ [given([view dataSource]) willReturn:dataSource];
- populator = [[QMCellPropertiesManager alloc] initWithDataSource:dataSource];
+ populator = [[QMCellPropertiesManager alloc] initWithDataSource:view];
rootCell = (QMRootCell *) [populator cellWithParent:nil itemOfParent:nil];
}
/**
* The following test tests all public methods of QMCellPropertiesManager
+*
+* @bug
+* cell.view was nil
*/
- (void)testPopulateCells {
+ assertThat(rootCell.view, is(view));
+
BOOL (^checkCellAndNode)(QMCell *, QMNode *) = ^(QMCell *cell, QMNode *node) {
assertThat(cell.identifier, is(node));
assertThat(@(cell.isFolded), is(@(node.isFolded)));
@@ -51,6 +60,7 @@ - (void)testPopulateCells {
assertThat(cell.stringValue, equalTo(node.stringValue));
assertThat(cell.children, hasSize(node.children.count));
assertThat(cell.icons, hasSize(node.icons.count));
+ assertThat(cell.view, is(view));
if (cell.font != nil) {
assertThat(node.font, notNilValue());
}
Please sign in to comment.
Something went wrong with that request. Please try again.