Example #1
0
// 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;
}
ConstraintModel& ScenarioCreate<ConstraintModel>::redo(
    const id_type<ConstraintModel>& id,
    const id_type<AbstractConstraintViewModel>& fullviewid,
    StateModel& sst,
    StateModel& est,
    double ypos,
    ScenarioModel& s)
{
    auto constraint = new ConstraintModel {
        id,
        fullviewid,
        ypos,
        &s};

    constraint->setStartState(sst.id());
    constraint->setEndState(est.id());

    s.addConstraint(constraint);

    sst.setNextConstraint(id);
    est.setPreviousConstraint(id);

    const auto& sev = s.event(sst.eventId());
    const auto& eev = s.event(est.eventId());

    ConstraintModel::Algorithms::changeAllDurations(*constraint,
            eev.date() - sev.date());
    constraint->setStartDate(sev.date());

    return *constraint;
}
Example #3
0
DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
	ui.setupUi(this);
	ui.dateEdit->setDisplayFormat(getDateFormat());
	ui.tableWidget->setTitle(tr("Dive planner points"));
	ui.tableWidget->setModel(DivePlannerPointsModel::instance());
	DivePlannerPointsModel::instance()->setRecalc(true);
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
	ui.cylinderTableWidget->setTitle(tr("Available gases"));
	ui.cylinderTableWidget->setModel(CylindersModel::instance());
	QTableView *view = ui.cylinderTableWidget->view();
	view->setColumnHidden(CylindersModel::START, true);
	view->setColumnHidden(CylindersModel::END, true);
	view->setColumnHidden(CylindersModel::DEPTH, false);
	view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this));
	connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addCylinder_clicked()));
	connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));

	connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
		GasSelectionModel::instance(), SLOT(repopulate()));
	connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)),
		GasSelectionModel::instance(), SLOT(repopulate()));
	connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)),
		GasSelectionModel::instance(), SLOT(repopulate()));
	connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
		plannerModel, SIGNAL(cylinderModelEdited()));
	connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)),
		plannerModel, SIGNAL(cylinderModelEdited()));
	connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)),
		plannerModel, SIGNAL(cylinderModelEdited()));

	ui.tableWidget->setBtnToolTip(tr("Add dive data point"));
	connect(ui.startTime, SIGNAL(timeChanged(QTime)), plannerModel, SLOT(setStartTime(QTime)));
	connect(ui.dateEdit, SIGNAL(dateChanged(QDate)), plannerModel, SLOT(setStartDate(QDate)));
	connect(ui.ATMPressure, SIGNAL(valueChanged(int)), this, SLOT(atmPressureChanged(int)));
	connect(ui.atmHeight, SIGNAL(valueChanged(int)), this, SLOT(heightChanged(int)));
	connect(ui.salinity, SIGNAL(valueChanged(double)), this, SLOT(salinityChanged(double)));
	connect(DivePlannerPointsModel::instance(), SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime)));

	// Creating (and canceling) the plan
	replanButton = ui.buttonBox->addButton(tr("Save new"), QDialogButtonBox::ActionRole);
	connect(replanButton, SIGNAL(clicked()), plannerModel, SLOT(saveDuplicatePlan()));
	connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(savePlan()));
	connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
	QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
	connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan()));

	// This makes shure the spinbox gets a setMinimum(0) on it so we can't have negative time or depth.
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, 1, this));
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, 1, this));
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, 1, this));
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0, 2, 0.1, this));

	/* set defaults. */
	ui.ATMPressure->setValue(1013);
	ui.atmHeight->setValue(0);

	setMinimumWidth(0);
	setMinimumHeight(0);
}
Example #4
0
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());
}
Example #6
0
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);
}
void RecurrenceWidget::setStartDateTime(QDateTime p)
{
  if (p.isValid())
  {
    _dates->setStartDate(p.date());
    _startTime->setTime(p.time());
  }
  else
    setStartDate(QDate::currentDate());
}
Example #8
0
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);
}
ConstraintModel& ScenarioCreate<ConstraintModel>::redo(
    const Id<ConstraintModel>& id,
    const Id<ConstraintViewModel>& fullviewid,
    StateModel& sst,
    StateModel& est,
    double ypos,
    ScenarioModel& s)
{
    auto constraint = new ConstraintModel {
        id,
        fullviewid,
        ypos,
        &s};

    constraint->setStartState(sst.id());
    constraint->setEndState(est.id());

    s.constraints.add(constraint);

    sst.setNextConstraint(id);
    est.setPreviousConstraint(id);

    const auto& sev = s.event(sst.eventId());
    const auto& eev = s.event(est.eventId());
    const auto& tn = s.timeNode(eev.timeNode());


    ConstraintDurations::Algorithms::changeAllDurations(*constraint,
            eev.date() - sev.date());
    constraint->setStartDate(sev.date());

    if(tn.trigger()->active())
    {
        constraint->duration.setRigid(false);
        const auto& dur = constraint->duration.defaultDuration();
        constraint->duration.setMinDuration( TimeValue::fromMsecs(0.8 * dur.msec()));
        constraint->duration.setMaxDuration( TimeValue::fromMsecs(1.2 * dur.msec()));
    }

    return *constraint;
}
Example #10
0
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);
}
Example #11
0
void ConstraintModel::translate(const TimeValue& deltaTime)
{
    setStartDate(m_startDate + deltaTime);
}