From 182872c760d437556d606cc02c6b7c570667a715 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Fri, 12 Sep 2025 21:50:40 +0200 Subject: Add children --- QSThingsPlugin/Helpers/ObjectHelper.m | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 QSThingsPlugin/Helpers/ObjectHelper.m (limited to 'QSThingsPlugin/Helpers/ObjectHelper.m') diff --git a/QSThingsPlugin/Helpers/ObjectHelper.m b/QSThingsPlugin/Helpers/ObjectHelper.m new file mode 100644 index 0000000..cf26127 --- /dev/null +++ b/QSThingsPlugin/Helpers/ObjectHelper.m @@ -0,0 +1,58 @@ +#import "ObjectHelper.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation ObjectHelper + +#pragma mark - SQL Results to QSObjects + ++ (QSObject *) areaFromSQLResult:(NSDictionary *)result usingPath:(NSString *)path { + NSMutableDictionary *configuration = [result mutableCopy]; + [configuration setObject:path forKey:@"path"]; + QSObject *area = [QSObject + makeObjectWithIdentifier:[result objectForKey:@"uuid"]]; + [area setObject:configuration forType:kAreaType]; + [area setName:[result objectForKey:@"title"]]; + [area setPrimaryType:kAreaType]; + return area; +} + ++ (QSObject *) projectFromSQLResult:(NSDictionary *)result usingPath:(NSString *)path { + NSMutableDictionary *configuration = [result mutableCopy]; + [configuration setObject:path forKey:@"path"]; + QSObject *project = [QSObject + makeObjectWithIdentifier:[result objectForKey:@"uuid"]]; + [project setObject:configuration forType:kProjectType]; + [project setName:[result objectForKey:@"title"]]; + [project setDetails:[result objectForKey:@"notes"]]; + [project setPrimaryType:kProjectType]; + + return project; +} ++ (QSObject *) taskFromSQLResult:(NSDictionary *)result usingPath:(NSString *)path { + NSMutableDictionary *configuration = [result mutableCopy]; + [configuration setObject:path forKey:@"path"]; + QSObject *task = [QSObject + makeObjectWithIdentifier:[result objectForKey:@"uuid"]]; + [task setObject:configuration forType:kTaskType]; + [task setName:[result objectForKey:@"title"]]; + [task setDetails:[result objectForKey:@"notes"]]; + [task setPrimaryType:kTaskType]; + + return task; +} ++ (QSObject *) tagFromSQLResult:(NSDictionary *)result usingPath:(NSString *)path { + NSMutableDictionary *configuration = [result mutableCopy]; + [configuration setObject:path forKey:@"path"]; + QSObject *tag = [QSObject + makeObjectWithIdentifier:[result objectForKey:@"uuid"]]; + [tag setObject:configuration forType:kTagType]; + [tag setName:[result objectForKey:@"title"]]; + [tag setPrimaryType:kTagType]; + + return tag; +} + +@end + +NS_ASSUME_NONNULL_END -- cgit