// insert a new range starting at the given date extending to the end of the zone currently // containing that date. If the start date of that zone is prior to the specified start // date, then that zone range is shorted. int Zones::insertRangeAtDate(QDate date, int cp) { assert(date.isValid()); int rnum; if (ranges.empty()) { addZoneRange(); rnum = 0; } else { rnum = whichRange(date); assert(rnum >= 0); QDate date1 = getStartDate(rnum); // if the old range has dates before the specified, then truncate // the old range and shift up the existing ranges if (date > date1) { QDate endDate = getEndDate(rnum); setEndDate(rnum, date); ranges.insert(++ rnum, ZoneRange(date, endDate)); } } if (cp > 0) { setCP(rnum, cp); setZonesFromCP(rnum); } return rnum; }
// insert a new zone range using the current scheme // return the range number int Zones::addZoneRange(QDate _start, int _cp) { int rnum; // where to add this range? for(rnum=0; rnum < ranges.count(); rnum++) if (ranges[rnum].begin > _start) break; // at the end ? if (rnum == ranges.count()) ranges.append(ZoneRange(_start, date_infinity, _cp)); else ranges.insert(rnum, ZoneRange(_start, ranges[rnum].begin, _cp)); // modify previous end date if (rnum) ranges[rnum-1].end = _start; // set zones from CP if (_cp > 0) { setCP(rnum, _cp); setZonesFromCP(rnum); } return rnum; }
void Zones::addZoneRange() { ranges.append(ZoneRange(date_zero, date_infinity)); }
void Zones::addZoneRange(QDate _start, QDate _end, int _cp) { ranges.append(ZoneRange(_start, _end, _cp)); }
void Zones::addZoneRange(QDate _start, QDate _end, int _cp, int _ftp, int _wprime, int _pmax) { ranges.append(ZoneRange(_start, _end, _cp, _ftp, _wprime, _pmax)); }