void QgsRuleBasedRendererV2Widget::addRule() { QgsRuleBasedRendererV2::Rule newrule( QgsSymbolV2::defaultSymbol( mLayer->geometryType() ) ); QgsRendererRulePropsDialog dlg( newrule, mLayer, mStyle ); if ( dlg.exec() ) { // add rule dlg.updateRuleFromGui(); mRenderer->addRule( dlg.rule() ); treeRules->populateRules(); } }
int ruledata() /* **-------------------------------------------------------------- ** Parses a line from [RULES] section of input. ** Called by newline() in INPUT2.C module. ** Tok[] is global array of tokens parsed from input line. **-------------------------------------------------------------- */ { int key, /* Keyword code */ err; /* Exit if current rule has an error */ if (RuleState == r_ERROR) return(0); /* Find the key word that begins the rule statement */ err = 0; key = findmatch(Tok[0],Ruleword); switch (key) { case -1: err = 201; /* Unrecognized keyword */ break; case r_RULE: Nrules++; newrule(); RuleState = r_RULE; break; case r_IF: if (RuleState != r_RULE) { err = 221; /* Mis-placed IF clause */ break; } RuleState = r_IF; err = newpremise(r_AND); break; case r_AND: if (RuleState == r_IF) err = newpremise(r_AND); else if (RuleState == r_THEN || RuleState == r_ELSE) err = newaction(); else err = 221; break; case r_OR: if (RuleState == r_IF) err = newpremise(r_OR); else err = 221; break; case r_THEN: if (RuleState != r_IF) { err = 221; /* Mis-placed THEN clause */ break; } RuleState = r_THEN; err = newaction(); break; case r_ELSE: if (RuleState != r_THEN) { err = 221; /* Mis-placed ELSE clause */ break; } RuleState = r_ELSE; err = newaction(); break; case r_PRIORITY: if (RuleState != r_THEN && RuleState != r_ELSE) { err = 221; break; } RuleState = r_PRIORITY; err = newpriority(); break; default: err = 201; } /* Set RuleState to r_ERROR if errors found */ if (err) { RuleState = r_ERROR; ruleerrmsg(err); err = 200; } return(err); }
void CTzUserDataTest::CreateUserTzBasedOnLondonRuleL(RTz& aRTz, TTest aWhatToTest) { test.Next(_L("Test Creation user-defined time zone based on London rules")); //create a new rule which doesn't have DST saving. TTime start (TDateTime(2010, ESeptember, 0, 0, 0, 0, 0)); TInt year = start.DateTime().Year(); TMonth month = start.DateTime().Month(); TInt day = start.DateTime().Day(); TTzRule newrule(year, 9999, 0, 0, month, ETzFixedDate, day, 0, ETzWallTimeReference, 120); //Get the existing london rule _LIT8(KTimeNone, "Europe/London"); CTzId* londonId = CTzId::NewL(KTimeNone()); CleanupStack::PushL(londonId); CTzRules* userrule = aRTz.GetTimeZoneRulesL(*londonId, 0, 9999, ETzUtcTimeReference); CleanupStack::PopAndDestroy(londonId); //Use London rule to create a new user-defined rule TInt count = userrule->Count(); //Since the last two rules (TTzRule objects one for summer rule one for winter rule) in existing database covers the years in which a new rule starts. //The client has to amend the ending years of those two rules before adding a new rule. //We set the ending year for last two rules to 2009 since the new rule starts on 2010 TTzRule lastRule = (*userrule)[count-1]; TDateTime dateTimeLast = lastRule.iTo.iTime.DateTime(); dateTimeLast.SetYear(2009); lastRule.iTo.iTime = dateTimeLast; TTzRule lastSecondRule = (*userrule)[count-2]; TDateTime dateTimeLastSecond = lastSecondRule.iTo.iTime.DateTime(); dateTimeLastSecond.SetYear(2009); lastSecondRule.iTo.iTime = dateTimeLastSecond; CleanupStack::PushL(userrule); //Remove last two existing rules userrule->RemoveRule(count-1); userrule->RemoveRule(count-2); //Add two rules whoes ending years have been amended userrule->AddRuleL(lastRule); userrule->AddRuleL(lastSecondRule); //Add the new rule userrule->AddRuleL(newrule); //userrule->AddRuleL(newrule);//add the new rule which doesn't have DST CTzUserNames* newRuleNames = CreateUserDefinedTzNamesLC(); CTzId* id = iUserData->CreateL(*userrule, *newRuleNames); CleanupStack::PushL(id); iTzIds.AppendL(id); CleanupStack::Pop(id); CheckTimeZoneL(*id, *userrule, *newRuleNames); CleanupStack::PopAndDestroy(newRuleNames); RArray<TTime> timesOn; CleanupClosePushL(timesOn); RArray<TTime> timesOff; CleanupClosePushL(timesOff); // Check UTC offset and DST. TTime check = TDateTime(1998, ESeptember, 0, 0, 0, 0, 0); timesOn.AppendL(check); check = TDateTime(2005, ESeptember, 0, 0, 0, 0, 0); timesOn.AppendL(check); check = TDateTime(2009, ESeptember, 0, 0, 0, 0, 0); timesOn.AppendL(check); check = TDateTime(2010, ESeptember, 0, 3, 0, 0, 0); timesOff.AppendL(check); check = TDateTime(2015, ESeptember, 0, 3, 0, 0, 0); timesOff.AppendL(check); check = TDateTime(2020, ESeptember, 0, 3, 0, 0, 0); timesOff.AppendL(check); if(aWhatToTest==ETimeConversion) { TestUtcOffsetL(*id,*userrule, timesOn, 60, aRTz); TestUtcOffsetL(*id,*userrule, timesOff, 0, aRTz); } else if(aWhatToTest==EDayLightSave) { TestDaylightSavingStateL(*id, timesOn, ETrue, aRTz); TestDaylightSavingStateL(*id, timesOff, EFalse, aRTz); } CleanupStack::PopAndDestroy(3, userrule); }