From 5870e5cf03ceaff7080174b573618631a413110e Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Thu, 11 Sep 2025 17:13:17 +0200 Subject: Add tags and sections --- Info.plist | 56 +++++++++++++++++++++- QSThingsPlugin.xcodeproj/project.pbxproj | 2 + QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h | 4 ++ QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m | 52 ++++++++++++++++++++ QSThingsPlugin/Parsers/QSThingsTagsParser.h | 4 ++ QSThingsPlugin/Parsers/QSThingsTagsParser.m | 33 +++++++++++++ QSThingsPlugin/Types/Constants.h | 10 ++++ QSThingsPlugin/Types/Constants.m | 9 ++++ 8 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h create mode 100644 QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m create mode 100644 QSThingsPlugin/Parsers/QSThingsTagsParser.h create mode 100644 QSThingsPlugin/Parsers/QSThingsTagsParser.m diff --git a/Info.plist b/Info.plist index 3b2b7fd..400b7ea 100644 --- a/Info.plist +++ b/Info.plist @@ -224,7 +224,7 @@ QSThingsPluginSource things.project QSThingsPluginSource - things.section + things.app-section QSThingsPluginSource things.tag QSThingsPluginSource @@ -246,6 +246,60 @@ QSPresetThingsGroup children + + ID + QSPresetThingsAppSections + enabled + + name + Things 3 (App Sections) + icon + com.culturedcode.ThingsMac + requiresBundle + com.culturedcode.ThingsMac + requiresSettingsPath + + settings + + fileContents + Things 3 App Sections + parser + QSThingsAppSectionsParser + path + ~/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac/*/Things Database.thingsdatabase/main.sqlite + skipItem + 1 + + source + QSFileSystemObjectSource + + + ID + QSPresetThingsTags + enabled + + name + Things 3 (Tags) + icon + com.culturedcode.ThingsMac + requiresBundle + com.culturedcode.ThingsMac + requiresSettingsPath + + settings + + fileContents + Things 3 Tags + parser + QSThingsTagsParser + path + ~/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac/*/Things Database.thingsdatabase/main.sqlite + skipItem + 1 + + source + QSFileSystemObjectSource + ID QSPresetThingsAreas diff --git a/QSThingsPlugin.xcodeproj/project.pbxproj b/QSThingsPlugin.xcodeproj/project.pbxproj index 850ab01..973432e 100644 --- a/QSThingsPlugin.xcodeproj/project.pbxproj +++ b/QSThingsPlugin.xcodeproj/project.pbxproj @@ -49,8 +49,10 @@ Helpers/SQLHelper.m, Helpers/TextParsingHelper.m, Helpers/ThingsHelper.m, + Parsers/QSThingsAppSectionsParser.m, Parsers/QSThingsAreasParser.m, Parsers/QSThingsProjectsParser.m, + Parsers/QSThingsTagsParser.m, Parsers/QSThingsTasksParser.m, QSThingsPluginSource.m, Types/Constants.m, diff --git a/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h b/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h new file mode 100644 index 0000000..e81f8db --- /dev/null +++ b/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h @@ -0,0 +1,4 @@ +@interface QSThingsAppSectionsParser : QSParser +{ +} +@end diff --git a/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m b/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m new file mode 100644 index 0000000..70a37ae --- /dev/null +++ b/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m @@ -0,0 +1,52 @@ +#import "Constants.h" +#import "QSThingsAppSectionsParser.h" +#import "SQLHelper.h" + +@implementation QSThingsAppSectionsParser +- (BOOL)validParserForPath:(NSString *)path { + return [[path lastPathComponent] isEqualToString:@"main.sqlite"]; +} + +// This is not really a parser, but having the sqlite helps us +// confirm that this makes sense. +- (NSArray *)objectsFromPath:(NSString *)path withSettings:(NSDictionary *)settings { + NSMutableArray *objects = [NSMutableArray array]; + + // Inbox + QSObject *inbox = [QSObject + makeObjectWithIdentifier: ThingsAppSectionKeyInbox]; + [inbox setName:@"Inbox"]; + [inbox setPrimaryType:kAppSectionType]; + [objects addObject:inbox]; + + // Today + QSObject *today = [QSObject + makeObjectWithIdentifier: ThingsAppSectionKeyToday]; + [today setName:@"Today"]; + [today setPrimaryType:kAppSectionType]; + [objects addObject:today]; + + // Upcoming + QSObject *upcoming = [QSObject + makeObjectWithIdentifier: ThingsAppSectionKeyUpcoming]; + [upcoming setName:@"Upcoming"]; + [upcoming setPrimaryType:kAppSectionType]; + [objects addObject:upcoming]; + + // Anytime + QSObject *anytime = [QSObject + makeObjectWithIdentifier: ThingsAppSectionKeyAnytime]; + [anytime setName:@"Anytime"]; + [anytime setPrimaryType:kAppSectionType]; + [objects addObject:anytime]; + + // Anytime + QSObject *someday = [QSObject + makeObjectWithIdentifier: ThingsAppSectionKeySomeday]; + [someday setName:@"Someday"]; + [someday setPrimaryType:kAppSectionType]; + [objects addObject:someday]; + + return objects; +} +@end diff --git a/QSThingsPlugin/Parsers/QSThingsTagsParser.h b/QSThingsPlugin/Parsers/QSThingsTagsParser.h new file mode 100644 index 0000000..d57aac1 --- /dev/null +++ b/QSThingsPlugin/Parsers/QSThingsTagsParser.h @@ -0,0 +1,4 @@ +@interface QSThingsTagsParser : QSParser +{ +} +@end diff --git a/QSThingsPlugin/Parsers/QSThingsTagsParser.m b/QSThingsPlugin/Parsers/QSThingsTagsParser.m new file mode 100644 index 0000000..4a81de3 --- /dev/null +++ b/QSThingsPlugin/Parsers/QSThingsTagsParser.m @@ -0,0 +1,33 @@ +#import "Constants.h" +#import "QSThingsTagsParser.h" +#import "SQLHelper.h" + +@implementation QSThingsTagsParser +- (BOOL)validParserForPath:(NSString *)path { + return [[path lastPathComponent] isEqualToString:@"main.sqlite"]; +} + +- (NSArray *)objectsFromPath:(NSString *)path withSettings:(NSDictionary *)settings { + NSString *query = @"SELECT " + "uuid, " + "title " + "FROM TMTag " + "ORDER BY title;"; + + NSArray *results = [SQLHelper executeSql:query onFile:path]; + + NSMutableArray *objects = [NSMutableArray array]; + [results enumerateObjectsUsingBlock:^(NSDictionary *dictionary, NSUInteger i, BOOL *stop) { + + QSObject *newObject = [QSObject + makeObjectWithIdentifier:[dictionary objectForKey:@"uuid"]]; + [newObject setObject:dictionary forType:kTagType]; + [newObject setName:[dictionary objectForKey:@"title"]]; + [newObject setPrimaryType:kTagType]; + + [objects addObject:newObject]; + }]; + + return objects; +} +@end diff --git a/QSThingsPlugin/Types/Constants.h b/QSThingsPlugin/Types/Constants.h index 044dcde..b94fd7a 100644 --- a/QSThingsPlugin/Types/Constants.h +++ b/QSThingsPlugin/Types/Constants.h @@ -9,3 +9,13 @@ extern NSString *const kTaskType; #pragma mark - Keychain extern NSString *const kKeychainService; extern NSString *const kAuthenticationKeyKeychainKey; + +#pragma mark - App Section Keys +typedef NSString* ThingsAppSectionKey NS_STRING_ENUM; + +extern ThingsAppSectionKey const ThingsAppSectionKeyInbox; +extern ThingsAppSectionKey const ThingsAppSectionKeyToday; +extern ThingsAppSectionKey const ThingsAppSectionKeyUpcoming; +extern ThingsAppSectionKey const ThingsAppSectionKeyAnytime; +extern ThingsAppSectionKey const ThingsAppSectionKeySomeday; +extern ThingsAppSectionKey const ThingsURLRouteAdd; diff --git a/QSThingsPlugin/Types/Constants.m b/QSThingsPlugin/Types/Constants.m index e6158a2..d92d007 100644 --- a/QSThingsPlugin/Types/Constants.m +++ b/QSThingsPlugin/Types/Constants.m @@ -9,3 +9,12 @@ NSString *const kTaskType = @"things.task"; #pragma mark - Keychain NSString *const kKeychainService = @"QSThingsPlugin"; NSString *const kAuthenticationKeyKeychainKey = @"authenticationKey"; + +#pragma mark - App Section Keys +typedef NSString* ThingsAppSectionKey NS_STRING_ENUM; + +ThingsAppSectionKey const ThingsAppSectionKeyInbox = @"things-app-section-inbox"; +ThingsAppSectionKey const ThingsAppSectionKeyToday = @"things-app-section-today"; +ThingsAppSectionKey const ThingsAppSectionKeyUpcoming = @"things-app-section-upcoming"; +ThingsAppSectionKey const ThingsAppSectionKeyAnytime = @"things-app-section-anytime"; +ThingsAppSectionKey const ThingsAppSectionKeySomeday = @"things-app-section-someday"; -- cgit