Beispiel #1
0
bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
	int i, shift;
	if (role == Qt::EditRole) {
		divedatapoint &p = divepoints[index.row()];
		switch (index.column()) {
		case DEPTH:
			if (value.toInt() >= 0) {
				p.depth = units_to_depth(value.toInt());
				if (updateMaxDepth())
					CylindersModel::instance()->updateBestMixes();
			}
			break;
		case RUNTIME:
			p.time = value.toInt() * 60;
			break;
		case DURATION:
			i = index.row();
			if (i)
				shift = divepoints[i].time - divepoints[i - 1].time - value.toInt() * 60;
			else
				shift = divepoints[i].time - value.toInt() * 60;
			while (i < divepoints.size())
				divepoints[i++].time -= shift;
			break;
		case CCSETPOINT: {
			int po2 = 0;
			QByteArray gasv = value.toByteArray();
			if (validate_po2(gasv.data(), &po2))
				p.setpoint = po2;
		} break;
		case GAS:
			if (value.toInt() >= 0 && value.toInt() < MAX_CYLINDERS)
				p.cylinderid = value.toInt();
			CylindersModel::instance()->updateTrashIcon();
			break;
		}
		editStop(index.row(), p);
	}
	return QAbstractItemModel::setData(index, value, role);
}
bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
	struct gasmix gas = { 0 };
	int i, shift;
	if (role == Qt::EditRole) {
		divedatapoint &p = divepoints[index.row()];
		switch (index.column()) {
		case DEPTH:
			if (value.toInt() >= 0)
				p.depth = units_to_depth(value.toInt());
			break;
		case RUNTIME:
			p.time = value.toInt() * 60;
			break;
		case DURATION:
			i = index.row();
			if (i)
				shift = divepoints[i].time - divepoints[i - 1].time - value.toInt() * 60;
			else
				shift = divepoints[i].time - value.toInt() * 60;
			while (i < divepoints.size())
				divepoints[i++].time -= shift;
			break;
		case CCSETPOINT: {
			int po2 = 0;
			QByteArray gasv = value.toByteArray();
			if (validate_po2(gasv.data(), &po2))
				p.setpoint = po2;
		} break;
		case GAS:
			QByteArray gasv = value.toByteArray();
			if (validate_gas(gasv.data(), &gas))
				p.gasmix = gas;
			break;
		}
		editStop(index.row(), p);
	}
	return QAbstractItemModel::setData(index, value, role);
}
Beispiel #3
0
bool MapHelperUniversal::keyPress(QKeyEvent *event)
{
    Q_UNUSED(event);
#if 0
    Q_D(MapHelperUniversal);
    switch (event->key()) {
    case Qt::Key_Q: {
        if (Qt::NoModifier == event->modifiers()) {
            move();
            qDebug() << "Move On";
        }
        else if (Qt::ShiftModifier == event->modifiers()) {
            moveStop();
            qDebug() << "Move Off";
        }
        break;
    }
    case Qt::Key_W: {
        if (Qt::NoModifier == event->modifiers()) {
            rotate();
            qDebug() << "Rotate On";
        }
        else if (Qt::ShiftModifier == event->modifiers()) {
            rotateStop();
            qDebug() << "Rotate Off";
        }
        break;
    }
    case Qt::Key_E: {
        if (Qt::NoModifier == event->modifiers()) {
            scale();
            qDebug() << "Scale On";
        }
        else if (Qt::ShiftModifier == event->modifiers()) {
            scaleStop();
            qDebug() << "Scalse Off";
        }
        break;
    }
    case Qt::Key_R: {
        if (Qt::NoModifier == event->modifiers()) {
            select();
            qDebug() << "Select On";
        }
        else if (Qt::ShiftModifier == event->modifiers()) {
            selectStop();
            qDebug() << "Select Off";
        }
        break;
    }
    case Qt::Key_T: {
        if (Qt::NoModifier == event->modifiers()) {
            edit();
            qDebug() << "Edit On";
        }
        else if (Qt::ShiftModifier == event->modifiers()) {
            editStop();
            qDebug() << "Edit Off";
        }
        break;
    }
    case Qt::Key_Y: {
        if (Qt::NoModifier == event->modifiers()) {
            create();
            qDebug() << "Create On";
        }
        else if (Qt::ShiftModifier == event->modifiers()) {
            createStop();
            qDebug() << "Create Off";
        }
        break;
    }
    case Qt::Key_A: {
        qDebug() << "Custom No On";
        d->customAction = 0;
        break;
    }
    case Qt::Key_S: {
        qDebug() << "Custom Move On";
        d->customAction = 1;
        break;
    }
    case Qt::Key_D: {
        qDebug() << "Custom Select On";
        d->customAction = 2;
        break;
    }
    case Qt::Key_F: {
        qDebug() << "Custom Edit On";
        d->customAction = 4;
        break;
    }
    case Qt::Key_G: {
        qDebug() << "Custom Create On";
        d->customAction = 3;
        break;
    }
    default:
        qDebug() << event;
        break;
    }

    QString types = "";
    foreach (MapSubHelper *sub, d->subhelpers)
        types += QString::number(sub->type()) + " ";
    qDebug() << types;
#endif

    return true;
}