Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
94
iphone/Maps/Core/Settings/MWMRoutingOptions.mm
Normal file
94
iphone/Maps/Core/Settings/MWMRoutingOptions.mm
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#import "MWMRoutingOptions.h"
|
||||
|
||||
#include "routing/routing_options.hpp"
|
||||
|
||||
@interface MWMRoutingOptions() {
|
||||
routing::RoutingOptions _options;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMRoutingOptions
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_options = routing::RoutingOptions::LoadCarOptionsFromSettings();
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)avoidToll {
|
||||
return _options.Has(routing::RoutingOptions::Road::Toll);
|
||||
}
|
||||
|
||||
- (void)setAvoidToll:(BOOL)avoid {
|
||||
[self setOption:(routing::RoutingOptions::Road::Toll) enabled:avoid];
|
||||
}
|
||||
|
||||
- (BOOL)avoidDirty {
|
||||
return _options.Has(routing::RoutingOptions::Road::Dirty);
|
||||
}
|
||||
|
||||
- (void)setAvoidDirty:(BOOL)avoid {
|
||||
[self setOption:(routing::RoutingOptions::Road::Dirty) enabled:avoid];
|
||||
}
|
||||
|
||||
- (BOOL)avoidPaved {
|
||||
return _options.Has(routing::RoutingOptions::Road::Paved);
|
||||
}
|
||||
|
||||
- (void)setAvoidPaved:(BOOL)avoid {
|
||||
[self setOption:(routing::RoutingOptions::Road::Paved) enabled:avoid];
|
||||
}
|
||||
|
||||
- (BOOL)avoidFerry {
|
||||
return _options.Has(routing::RoutingOptions::Road::Ferry);
|
||||
}
|
||||
|
||||
- (void)setAvoidFerry:(BOOL)avoid {
|
||||
[self setOption:(routing::RoutingOptions::Road::Ferry) enabled:avoid];
|
||||
}
|
||||
|
||||
- (BOOL)avoidMotorway {
|
||||
return _options.Has(routing::RoutingOptions::Road::Motorway);
|
||||
}
|
||||
|
||||
- (void)setAvoidMotorway:(BOOL)avoid {
|
||||
[self setOption:(routing::RoutingOptions::Road::Motorway) enabled:avoid];
|
||||
}
|
||||
|
||||
- (BOOL)avoidSteps {
|
||||
return _options.Has(routing::RoutingOptions::Road::Steps);
|
||||
}
|
||||
|
||||
- (void)setAvoidSteps:(BOOL)avoid {
|
||||
[self setOption:(routing::RoutingOptions::Road::Steps) enabled:avoid];
|
||||
}
|
||||
|
||||
- (BOOL)hasOptions {
|
||||
return self.avoidToll || self.avoidDirty || self.avoidPaved|| self.avoidFerry || self.avoidMotorway || self.avoidSteps;
|
||||
}
|
||||
|
||||
- (void)save {
|
||||
routing::RoutingOptions::SaveCarOptionsToSettings(_options);
|
||||
}
|
||||
|
||||
- (void)setOption:(routing::RoutingOptions::Road)option enabled:(BOOL)enabled {
|
||||
if (enabled) {
|
||||
_options.Add(option);
|
||||
} else {
|
||||
_options.Remove(option);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)object {
|
||||
if (![object isMemberOfClass:self.class]) {
|
||||
return NO;
|
||||
}
|
||||
MWMRoutingOptions *another = (MWMRoutingOptions *)object;
|
||||
return another.avoidToll == self.avoidToll && another.avoidDirty == self.avoidDirty && another.avoidPaved == self.avoidPaved && another.avoidFerry == self.avoidFerry && another.avoidMotorway == self.avoidMotorway && another.avoidSteps == self.avoidSteps;
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Add table
Add a link
Reference in a new issue