// delete a range, extend an adjacent (prior if available, otherwise next) // range to cover the same time period, then return the number of the new range // covering the date range of the deleted range int Zones::deleteRange(int rnum) { assert((ranges.size() > 1) && (rnum >= 0) && (rnum < ranges.size())); int return_rnum; // extend an adjacent range if (rnum == 0) { return_rnum = 0; setStartDate(rnum + 1, getStartDate(rnum)); } else { return_rnum = rnum - 1; setEndDate(return_rnum, getEndDate(rnum)); } // eliminate the allocation in the present range delete ranges[rnum]; // drop higher ranges down one slot for (int r = rnum; r < ranges.size() - 1; r ++) ranges[r] = ranges[r + 1]; // reduce the number of ranges by one ranges.removeLast(); return return_rnum; }
// 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 HrZones::insertRangeAtDate(QDate date, int lt) { assert(date.isValid()); int rnum; if (ranges.empty()) { addHrZoneRange(); 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, HrZoneRange(date, endDate)); } } if (lt > 0) { setLT(rnum, lt); setHrZonesFromLT(rnum); } return rnum; }
void YearlyRecurrence::setOnDayOfYear(const QDate &new_start_date, const QDate &new_end_date, int new_day, WeekendHandling new_weekendhandling, int new_frequency, int occurrences) { i_dayofyear = new_day; wh_weekendhandling = new_weekendhandling; i_frequency = new_frequency; setStartDate(new_start_date); if(occurrences <= 0) setEndDate(new_end_date); else setFixedOccurrenceCount(occurrences); }
void QFacebookGraphCommonWorkModel::populate(const QVariantMap &map) { setLocation(map["location"].toMap()); setPosition(map["position"].toMap()); setEmployer(map["employer"].toMap()); setStartDate(map["start_date"].toString()); setEndDate(map["end_date"].toString()); setDescription(map["description"].toString()); }
void MonthlyRecurrence::setOnDayOfWeek(const QDate &new_start_date, const QDate &new_end_date, int new_dayofweek, int new_week, int new_frequency, int occurrences) { i_week = new_week; i_frequency = new_frequency; i_dayofweek = new_dayofweek; wh_weekendhandling = WEEKEND_HANDLING_NONE; setStartDate(new_start_date); if(occurrences <= 0) setEndDate(new_end_date); else setFixedOccurrenceCount(occurrences); }
// delete a range, extend an adjacent (prior if available, otherwise next) // range to cover the same time period, then return the number of the new range // covering the date range of the deleted range or -1 if none left int PaceZones::deleteRange(int rnum) { // check bounds - silently fail, don't assert assert (rnum < ranges.count() && rnum >= 0); // extend the previous range to the end of this range // but only if we have a previous range if (rnum > 0) setEndDate(rnum-1, getEndDate(rnum)); // delete this range then ranges.removeAt(rnum); return rnum-1; }
void WeeklyRecurrence::set(const QDate &new_start_date, const QDate &new_end_date, bool d1, bool d2, bool d3, bool d4, bool d5, bool d6, bool d7, int new_frequency, int occurrences) { b_daysofweek[0] = d1; b_daysofweek[1] = d2; b_daysofweek[2] = d3; b_daysofweek[3] = d4; b_daysofweek[4] = d5; b_daysofweek[5] = d6; b_daysofweek[6] = d7; i_frequency = new_frequency; setStartDate(new_start_date); if(occurrences <= 0) setEndDate(new_end_date); else setFixedOccurrenceCount(occurrences); }
void TestRecurrentTransaction::testSetEndDateNoSignal() { auto endDate = QDate::currentDate().addYears(1); auto amount = .45; auto account = std::make_shared<PublicAccount>("Test account", .0, ""); auto category = std::make_shared<com::chancho::Category>("Sushi", com::chancho::Category::Type::EXPENSE); auto transactionPtr = std::make_shared<com::chancho::Transaction>(account, amount, category); auto recurrentPtr = std::make_shared<com::chancho::RecurrentTransaction>(transactionPtr, std::make_shared<com::chancho::RecurrentTransaction::Recurrence>( com::chancho::RecurrentTransaction::Recurrence::Defaults::DAILY, QDate::currentDate(), endDate)); auto qmlTransaction = std::make_shared<com::chancho::tests::PublicRecurrentTransaction>(recurrentPtr); QSignalSpy spy(qmlTransaction.get(), SIGNAL(endDateChanged(QDate))); qmlTransaction->setEndDate(endDate); QCOMPARE(spy.count(), 0); }
// 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(cp); fprintf( stderr, "Generating first range with CP = %d\n", cp ); rnum = 0; } else { rnum = whichRange(date); assert(rnum >= 0); QDate date1 = getStartDate(rnum); fprintf(stderr, "insertRangeAtDate(%s, %d):\n", date.toString().toAscii().constData(), cp); // 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); fprintf( stderr, "Inserting range\n" "old range %d: from %s to %s\n" "new range %d: from %s to %s\n" "added range %d: from %s to %s\n", rnum + 1, getStartDateString(rnum).toAscii().constData(), getEndDateString(rnum).toAscii().constData(), rnum + 1, getStartDateString(rnum).toAscii().constData(), (date.isNull() ? "END" : date.toString().toAscii().constData()), rnum + 2, (date.isNull() ? "BEGIN" : date.toString().toAscii().constData()), getEndDateString(rnum).toAscii().constData() ); ranges.insert(++ rnum, new ZoneRange(date, endDate)); } } if (cp > 0) { setCP(rnum, cp); setZonesFromCP(rnum); } return rnum; }
void Recurrence::setFixedOccurrenceCount(int new_count) { if(new_count <= 0) { i_count = -1; setEndDate(d_enddate); } else { i_count = new_count; d_enddate = QDate(); QDate new_enddate = d_startdate; for(int i = 1; i < i_count; i++) { new_enddate = nextOccurrence(new_enddate); if(new_enddate.isNull()) { i_count = i; break; } } d_enddate = new_enddate; if(d_enddate.isNull()) { d_enddate = d_startdate; } } }
void DailyRecurrence::set(const QDate &new_start_date, const QDate &new_end_date, int new_frequency, int occurrences) { i_frequency = new_frequency; setStartDate(new_start_date); if(occurrences <= 0) setEndDate(new_end_date); else setFixedOccurrenceCount(occurrences); }