Skip to content

Commit

Permalink
Fixes sorting of elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
escoz committed Feb 27, 2012
1 parent a5bff21 commit 7c10f10
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
8 changes: 8 additions & 0 deletions QuickDialog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
D8F180E813F0599A009B0CC2 /* QDynamicDataSection.h in Headers */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0CC1 /* QDynamicDataSection.h */; };
D8F180E813F0599A009B0CC4 /* QTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0CC3 /* QTableViewCell.m */; };
D8F180E813F0599A009B0CC6 /* QTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0CC5 /* QTableViewCell.h */; };
D8F180E813F0599A009B0CC8 /* NSMutableArray+MoveObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0CC7 /* NSMutableArray+MoveObject.m */; };
D8F180E813F0599A009B0CCA /* NSMutableArray+MoveObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0CC9 /* NSMutableArray+MoveObject.h */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -277,6 +279,8 @@
D8F180E813F0599A009B0CC1 /* QDynamicDataSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QDynamicDataSection.h; path = quickdialog/QDynamicDataSection.h; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0CC3 /* QTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = QTableViewCell.m; path = quickdialog/QTableViewCell.m; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0CC5 /* QTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QTableViewCell.h; path = quickdialog/QTableViewCell.h; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0CC7 /* NSMutableArray+MoveObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSMutableArray+MoveObject.m"; path = "quickdialog/NSMutableArray+MoveObject.m"; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0CC9 /* NSMutableArray+MoveObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSMutableArray+MoveObject.h"; path = "quickdialog/NSMutableArray+MoveObject.h"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -416,6 +420,8 @@
D860356713E0534000CB1785 /* quickdialog */ = {
isa = PBXGroup;
children = (
D8F180E813F0599A009B0CC9 /* NSMutableArray+MoveObject.h */,
D8F180E813F0599A009B0CC7 /* NSMutableArray+MoveObject.m */,
D87B4FC314F16197006DA833 /* DOAutocompleteTextField.h */,
D87B4FC414F16197006DA833 /* DOAutocompleteTextField.m */,
D87B4FC514F16197006DA833 /* QAutoEntryElement.h */,
Expand Down Expand Up @@ -530,6 +536,7 @@
buildActionMask = 2147483647;
files = (
2C54239F145ADF2B0026A152 /* QuickDialog.h in Headers */,
D8F180E813F0599A009B0CCA /* NSMutableArray+MoveObject.h in Headers */,
D81F2ED714BBAFCE0066C372 /* QRootBuilder.h in Headers */,
D81F2ED814BBAFCE0066C372 /* QBindingEvaluator.h in Headers */,
D81F2EE714BBAFCE0066C372 /* QLabelElement.h in Headers */,
Expand Down Expand Up @@ -718,6 +725,7 @@
194C3FC814EDF1350036C9E7 /* NSMutableArray+IMSExtensions.m in Sources */,
D87B4FCC14F16197006DA833 /* QAutoEntryElement.m in Sources */,
D87B4FCE14F16197006DA833 /* QAutoEntryTableViewCell.m in Sources */,
D8F180E813F0599A009B0CC8 /* NSMutableArray+MoveObject.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
7 changes: 7 additions & 0 deletions quickdialog/NSMutableArray+MoveObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import <Foundation/Foundation.h>

@interface NSMutableArray (MoveObject)

- (void)moveObjectFromIndex:(NSUInteger)from toIndex:(NSUInteger)to;

@end
19 changes: 19 additions & 0 deletions quickdialog/NSMutableArray+MoveObject.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#import "NSMutableArray+MoveObject.h"

@implementation NSMutableArray (MoveObject)

- (void)moveObjectFromIndex:(NSUInteger)from toIndex:(NSUInteger)to
{
if (to == from)
return;

id objectToMove = [self objectAtIndex:from];
[self removeObjectAtIndex:from];
if (to >= [self count]) {
[self addObject:objectToMove];
} else {
[self insertObject:objectToMove atIndex:to];
}
}
@end

2 changes: 1 addition & 1 deletion quickdialog/QSortingSection.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (void)fetchValueIntoObject:(id)obj {
}

- (void)moveElementFromRow:(NSUInteger)from toRow:(NSUInteger)to {
[self.elements exchangeObjectAtIndex:from withObjectAtIndex:to];
[self.elements moveObjectFromIndex:from toIndex:to];
}


Expand Down
1 change: 1 addition & 0 deletions quickdialog/QuickDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#import "QuickDialogController.h"
#import "QuickDialogController+Loading.h"
#import "NSMutableArray+MoveObject.h"
#import "QuickDialogTableView.h"
#import "QuickDialogTableDelegate.h"

Expand Down

0 comments on commit 7c10f10

Please sign in to comment.