aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTreeNode.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-05-11 02:04:06 +0200
committerMax <post@wickenrode.com>2015-05-11 02:04:06 +0200
commit11b8718ddfd44dc5786ac745f90fa390aaf57a06 (patch)
tree95689086e2ba13016034a0cab3382e5fc7e52084 /Source/SPTreeNode.m
parent0f11cb74639d17a2fe512ed81d67ccf33601b605 (diff)
downloadsequelpro-11b8718ddfd44dc5786ac745f90fa390aaf57a06.tar.gz
sequelpro-11b8718ddfd44dc5786ac745f90fa390aaf57a06.tar.bz2
sequelpro-11b8718ddfd44dc5786ac745f90fa390aaf57a06.zip
* Fully enable export of favorite groups
* Favorites can now be imported, sorted even if "Quick Connect" is selected * Favorite files containing groups will now be imported correctly * If a favorite and the group containing said favorite are exported, the favorite will no longer be included twice
Diffstat (limited to 'Source/SPTreeNode.m')
-rw-r--r--Source/SPTreeNode.m36
1 files changed, 33 insertions, 3 deletions
diff --git a/Source/SPTreeNode.m b/Source/SPTreeNode.m
index 13c86f27..22cfb1da 100644
--- a/Source/SPTreeNode.m
+++ b/Source/SPTreeNode.m
@@ -50,7 +50,7 @@ static NSString *SPTreeNodeIsGroupKey = @"SPTreeNodeIsGroup";
- (id)initWithRepresentedObject:(id)object
{
if ((self = [super initWithRepresentedObject:object])) {
- [self setIsGroup:NO];
+ [self setIsGroup:[object isKindOfClass:[SPGroupNode class]]];
}
return self;
@@ -197,11 +197,12 @@ static NSString *SPTreeNodeIsGroupKey = @"SPTreeNodeIsGroup";
/**
* Returns YES if self is contained anywhere inside the children or children of
- * sub-nodes of the nodes contained inside the supplied array.
+ * sub-nodes of the nodes contained inside the supplied array or is itself a
+ * member of the array.
*
* @param nodes The array of nodes to search
*
- * @return A BOOL indicating whether or not it's a descendent
+ * @return A BOOL indicating whether or not it's a descendent or array member
*/
- (BOOL)isDescendantOfOrOneOfNodes:(NSArray *)nodes
{
@@ -221,6 +222,34 @@ static NSString *SPTreeNodeIsGroupKey = @"SPTreeNodeIsGroup";
}
/**
+ * Returns YES if self is contained anywhere inside the children or children of
+ * sub-nodes of the nodes contained inside the supplied array, but NOT the given
+ * array itself.
+ * This means, if self is a member of nodes but not a child of any
+ * other node in nodes it will still return NO.
+ *
+ * @param nodes The array of nodes to search
+ *
+ * @return A BOOL indicating whether or not it's a descendent
+ */
+- (BOOL)isDescendantOfNodes:(NSArray *)nodes
+{
+ for (SPTreeNode *node in nodes)
+ {
+ if (node == self) continue;
+
+ // Check all the sub-nodes
+ if ([node isGroup]) {
+ if ([self isDescendantOfOrOneOfNodes:[node childNodes]]) {
+ return YES;
+ }
+ }
+ }
+
+ return NO;
+}
+
+/**
* Constructs a dictionary representation of the favorite.
*
* @return The dictionary representation.
@@ -265,6 +294,7 @@ static NSString *SPTreeNodeIsGroupKey = @"SPTreeNodeIsGroup";
- (id)initWithCoder:(NSCoder *)coder
{
+#warning This is not a valid initializer.
[self setIsGroup:[[coder decodeObjectForKey:SPTreeNodeIsGroupKey] boolValue]];
return self;