예제 #1
0
void RenderWindow::sEdit()
{
    if(_table->currentSelection() == -1)
        return;

    bool do_update = false;

    int r = _table->currentRow();
    Q3CheckTableItem * ctItem = (Q3CheckTableItem*)_table->item(r, 0);
    if(ctItem == 0)
        return;
    bool active = ctItem->isChecked();
    QString name = _table->text(r, 1);
    QVariant var = _params[name];

    BoolEdit * be = 0;
    IntEdit * ie = 0;
    DoubleEdit * de = 0;
    StringEdit * se = 0;
    ListEdit * le = 0;

    switch(var.type()) {
    case QVariant::Bool:
        be = new BoolEdit(this);
        be->_name->setText(name);
        be->_active->setChecked(active);
        be->setValue(var.toBool());
        if(be->exec() == QDialog::Accepted) {
            var = QVariant(be->value(), 0);
            active = be->_active->isChecked();
            do_update = TRUE;
        }
        delete be;
        be = 0;
        break;
    case QVariant::Int:
        ie = new IntEdit(this);
        ie->_name->setText(name);
        ie->_active->setChecked(active);
        ie->_value->setText(QString::number(var.toInt()));
        if(ie->exec() == QDialog::Accepted) {
            var = QVariant(ie->_value->text().toInt());
            active = ie->_active->isChecked();
            do_update = TRUE;
        }
        delete ie;
        ie = 0;
        break;
    case QVariant::Double:
        de = new DoubleEdit(this);
        de->_name->setText(name);
        de->_active->setChecked(active);
        de->_value->setText(QString::number(var.toDouble()));
        if(de->exec() == QDialog::Accepted) {
            var = QVariant(de->_value->text().toDouble());
            active = de->_active->isChecked();
            do_update = TRUE;
        }
        delete de;
        de = 0;
        break;
    case QVariant::String:
        se = new StringEdit(this);
        se->_name->setText(name);
        se->_active->setChecked(active);
        se->_value->setText(var.toString());
        if(se->exec() == QDialog::Accepted) {
            var = QVariant(se->_value->text());
            active = se->_active->isChecked();
            do_update = TRUE;
        }
        delete se;
        se = 0;
        break;
    case QVariant::List:
        le = new ListEdit(this);
        le->_name->setText(name);
        le->_active->setChecked(active);
        le->setList(var.toList());
        if(le->exec() == QDialog::Accepted) {
            var = QVariant(le->list());
            active = le->_active->isChecked();
            do_update = TRUE;
        }
        delete le;
        le = 0;
        break;
    default:
        QMessageBox::warning(this, tr("Warning"), QString(tr("I do not know how to edit QVariant type %1.")).arg(var.typeName()));
    };

    if(do_update) {
        _params[name] = var;
        ctItem->setChecked(active);
        _table->setText(r, 1, name);
        _table->setText(r, 2, var.typeName());
        _table->setText(r, 3, var.toString());
    }
}
예제 #2
0
void RenderWindow::sAdd()
{
    bool ok = false;
    bool active = false;

    QString name;
    QString varType;
    QVariant var;

    NewVariant newVar(this);

    while(!ok)
    {
        if(newVar.exec() != QDialog::Accepted)
            return;

        name = newVar._name->text();
        varType = newVar._type->currentText();

        ok = !_params.contains(name);
        if(!ok)
            QMessageBox::warning(this, tr("Name already exists"), tr("The name for the parameter you specified already exists in the list."));
    }


    BoolEdit * be = 0;
    IntEdit * ie = 0;
    DoubleEdit * de = 0;
    StringEdit * se = 0;
    ListEdit * le = 0;

    if(varType == NewVariant::tr("String")) {
        se = new StringEdit(this);
        se->_name->setText(name);
        ok = (se->exec() == QDialog::Accepted);
        var = QVariant(se->_value->text());
        active = se->_active->isChecked();
        delete se;
        se = 0;
    } else if(varType == NewVariant::tr("Int")) {
        ie = new IntEdit(this);
        ie->_name->setText(name);
        ok = (ie->exec() == QDialog::Accepted);
        var = QVariant(ie->_value->text().toInt());
        active = ie->_active->isChecked();
        delete ie;
        ie = 0;
    } else if(varType == NewVariant::tr("Double")) {
        de = new DoubleEdit(this);
        de->_name->setText(name);
        ok = (de->exec() == QDialog::Accepted);
        var = QVariant(de->_value->text().toDouble());
        active = de->_active->isChecked();
        delete de;
        de = 0;
    } else if(varType == NewVariant::tr("Bool")) {
        be = new BoolEdit(this);
        be->_name->setText(name);
        ok = (be->exec() == QDialog::Accepted);
        var = QVariant(be->value(), 0);
        active = be->_active->isChecked();
        delete be;
        be = 0;
    } else if(varType == NewVariant::tr("List")) {
        le = new ListEdit(this);
        le->_name->setText(name);
        ok = (le->exec() == QDialog::Accepted);
        var = QVariant(le->list());
        active = le->_active->isChecked();
        delete le;
        le = 0;
    } else {
        QMessageBox::warning(this, tr("Unknown Type"), QString(tr("I do not understand the type %1.")).arg(varType));
        return;
    }

    if(!ok)
        return;

    _params[name] = var;

    int r = _table->numRows();
    _table->setNumRows(r+1);
    Q3CheckTableItem * ctItem = new Q3CheckTableItem(_table, QString::null);
    ctItem->setChecked(active);
    _table->setItem(r, 0, ctItem);
    _table->setText(r, 1, name);
    _table->setText(r, 2, var.typeName());
    _table->setText(r, 3, var.toString());
    sSelectionChanged();
}
예제 #3
0
void ListEdit::newItem()
{
    NewVariant newVar(this);
    newVar._lblName->hide();
    newVar._name->hide();
    if(newVar.exec() == QDialog::Accepted) {
	QString varType = newVar._type->currentText();
	BoolEdit * be = 0;
	IntEdit * ie = 0;
	DoubleEdit * de = 0;
	StringEdit * se = 0;
	ListEdit * le = 0;
	if(varType == tr("String")) {
	    se = new StringEdit(this);
	    se->_lblName->hide();
	    se->_name->hide();
	    se->_active->hide();
	    if(se->exec() == QDialog::Accepted) {
		new QListBoxVariant(_list, QVariant(se->_value->text()));
	    }
	    delete se;
	    se = 0;
	} else if(varType == tr("Int")) {
	    ie = new IntEdit(this);
	    ie->_lblName->hide();
	    ie->_name->hide();
	    ie->_active->hide();
	    if(ie->exec() == QDialog::Accepted) {
		new QListBoxVariant(_list, QVariant(ie->_value->text().toInt()));
	    }
	    delete ie;
	    ie = 0;
	} else if(varType == tr("Double")) {
	    de = new DoubleEdit(this);
	    de->_lblName->hide();
	    de->_name->hide();
	    de->_active->hide();
	    if(de->exec() == QDialog::Accepted) {
		new QListBoxVariant(_list, QVariant(de->_value->text().toDouble()));
	    }
	    delete de;
	    de = 0;
	} else if(varType == tr("Bool")) {
	    be = new BoolEdit(this);
	    be->_lblName->hide();
	    be->_name->hide();
	    be->_active->hide();
	    if(be->exec() == QDialog::Accepted) {
		new QListBoxVariant(_list, QVariant(be->value(), 0));
	    }
	    delete be;
	    be = 0;
	} else if(varType == tr("List")) {
	    le = new ListEdit(this);
	    le->_lblName->hide();
	    le->_name->hide();
	    le->_active->hide();
	    if(le->exec() == QDialog::Accepted) {
		new QListBoxVariant(_list, QVariant(le->list()));
	    }
	    delete le;
	    le = 0;
	} else {
	    QMessageBox::warning(this, tr("Unknown Type"), QString(tr("I do not understand the type %1.")).arg(varType));
	}
    }
}
예제 #4
0
void ListEdit::editItem()
{
    Q3ListBoxItem * item = _list->selectedItem();
    if(item) {
	if(item->rtti() == QListBoxVariant::RTTI) {
	    QListBoxVariant * lbvar = (QListBoxVariant*)item;
	    QVariant var = lbvar->variant();
	    BoolEdit * be = 0;
	    IntEdit * ie = 0;
	    DoubleEdit * de = 0;
	    StringEdit * se = 0;
	    ListEdit * le = 0;
	    switch(var.type()) {
	    case QVariant::Bool:
		be = new BoolEdit(this);
		be->_lblName->hide();
		be->_name->hide();
		be->_active->hide();
		be->setValue(var.toBool());
		if(be->exec() == QDialog::Accepted) {
		    lbvar->setVariant(QVariant(be->value(), 0));
		}
		delete be;
		be = 0;
		break;
	    case QVariant::Int:
		ie = new IntEdit(this);
		ie->_lblName->hide();
		ie->_name->hide();
		ie->_active->hide();
		ie->_value->setText(QString::number(var.toInt()));
		if(ie->exec() == QDialog::Accepted) {
		    lbvar->setVariant(QVariant(ie->_value->text().toInt()));
		}
		delete ie;
		ie = 0;
		break;
	    case QVariant::Double:
		de = new DoubleEdit(this);
		de->_lblName->hide();
		de->_name->hide();
		de->_active->hide();
		de->_value->setText(QString::number(var.toDouble()));
		if(de->exec() == QDialog::Accepted) {
		    lbvar->setVariant(QVariant(de->_value->text().toDouble()));
		}
		delete de;
		de = 0;
		break;
	    case QVariant::String:
		se = new StringEdit(this);
		se->_lblName->hide();
		se->_name->hide();
		se->_active->hide();
		se->_value->setText(var.toString());
		if(se->exec() == QDialog::Accepted) {
		    lbvar->setVariant(QVariant(se->_value->text()));
		}
		delete se;
		se = 0;
		break;
	    case QVariant::List:
		le = new ListEdit(this);
		le->_lblName->hide();
		le->_name->hide();
		le->_active->hide();
		le->setList(var.toList());
		if(le->exec() == QDialog::Accepted) {
		    lbvar->setVariant(QVariant(le->list()));
		}
		delete le;
		le = 0;
		break;
	    default:
		QMessageBox::warning(this, tr("Warning"), QString(tr("I do not know how to edit QVariant type %1.")).arg(var.typeName()));
	    };
	} else {
	    QMessageBox::warning(this, tr("Warning"), tr("The item you selected is not a QListBoxVariant item. I do not know what to do."));
	}   
    }
}
예제 #5
0
void ParameterEdit::editItem(int row)
{
    bool do_update = false;
    bool active = _table->item(row, 0)->checkState() == Qt::Checked;
    QString name = _table->item(row, 1)->text();
    QVariant var = _params[name];
    BoolEdit * be = 0;
    IntEdit * ie = 0;
    DoubleEdit * de = 0;
    StringEdit * se = 0;
    ListEdit * le = 0;
    switch(var.type()) {
      case QVariant::Bool:
        be = new BoolEdit(this);
        be->_name->setText(name);
        be->_active->setChecked(active);
        be->setValue(var.toBool());
        if(be->exec() == QDialog::Accepted) {
        var = QVariant((bool)be->value());
        active = be->_active->isChecked();
        do_update = TRUE;
        }
        delete be;
        be = 0;
        break;
      case QVariant::Int:
        ie = new IntEdit(this);
        ie->_name->setText(name);
        ie->_active->setChecked(active);
        ie->_value->setText(QString::number(var.toInt()));
        if(ie->exec() == QDialog::Accepted) {
        var = QVariant(ie->_value->text().toInt());
        active = ie->_active->isChecked();
        do_update = TRUE;
        }
        delete ie;
        ie = 0;
        break;
      case QVariant::Double:
        de = new DoubleEdit(this);
        de->_name->setText(name);
        de->_active->setChecked(active);
        de->_value->setText(QString::number(var.toDouble()));
        if(de->exec() == QDialog::Accepted) {
        var = QVariant(de->_value->text().toDouble());
        active = de->_active->isChecked();
        do_update = TRUE;
        }
        delete de;
        de = 0;
        break;
      case QVariant::String:
        se = new StringEdit(this);
        se->_name->setText(name);
        se->_active->setChecked(active);
        se->_value->setText(var.toString());
        if(se->exec() == QDialog::Accepted) {
        var = QVariant(se->_value->text());
        active = se->_active->isChecked();
        do_update = TRUE;
        }
        delete se;
        se = 0;
        break;
      case QVariant::List:
        le = new ListEdit(this);
        le->_name->setText(name);
        le->_active->setChecked(active);
        le->setList(var.toList());
        if(le->exec() == QDialog::Accepted) {
        var = QVariant(le->list());
        active = le->_active->isChecked();
        do_update = TRUE;
        }
        delete le;
        le = 0;
        break;
      default:
        QMessageBox::warning(this, tr("Warning"), QString(tr("I do not know how to edit QVariant type %1.")).arg(var.typeName()));
    };
        
    if(do_update) {
        _params[name] = var;
        _table->item(row, 0)->setCheckState((active ? Qt::Checked : Qt::Unchecked));
        _table->item(row, 1)->setText(name);
        _table->item(row, 2)->setText(var.typeName());
        _table->item(row, 3)->setText(var.toString());
    }
}
예제 #6
0
void ParameterEdit::newItem()
{
    NewVariant newVar(this);
    if(newVar.exec() == QDialog::Accepted) {
	QString varType = newVar._type->currentText();
	QString name = newVar._name->text();
	bool active = false;
	if(_params.contains(name)) {
	    QMessageBox::warning(this, tr("Name already exists"), tr("The name for the parameter you specified already exists in the list."));
	}
	BoolEdit * be = 0;
	IntEdit * ie = 0;
	DoubleEdit * de = 0;
	StringEdit * se = 0;
	ListEdit * le = 0;
	if(varType == tr("String")) {
	    se = new StringEdit(this);
	    se->_name->setText(name);
	    if(se->exec() == QDialog::Accepted) {
		_params[name] = QVariant(se->_value->text());
		active = se->_active->isChecked();
	    }
	    delete se;
	    se = 0;
	} else if(varType == tr("Int")) {
	    ie = new IntEdit(this);
	    ie->_name->setText(name);
	    if(ie->exec() == QDialog::Accepted) {
		_params[name] = QVariant(ie->_value->text().toInt());
		active = ie->_active->isChecked();
	    }
	    delete ie;
	    ie = 0;
	} else if(varType == tr("Double")) {
	    de = new DoubleEdit(this);
	    de->_name->setText(name);
	    if(de->exec() == QDialog::Accepted) {
		_params[name] = QVariant(de->_value->text().toDouble());
		active = de->_active->isChecked();
	    }
	    delete de;
	    de = 0;
	} else if(varType == tr("Bool")) {
	    be = new BoolEdit(this);
	    be->_name->setText(name);
	    if(be->exec() == QDialog::Accepted) {
		_params[name] = QVariant((bool)be->value());
		active = be->_active->isChecked();
	    }
	    delete be;
	    be = 0;
	} else if(varType == tr("List")) {
	    le = new ListEdit(this);
	    le->_name->setText(name);
	    if(le->exec() == QDialog::Accepted) {
		_params[name] = QVariant(le->list());
		active = le->_active->isChecked();
	    }
	    delete le;
	    le = 0;
	} else {
	    QMessageBox::warning(this, tr("Unknown Type"), QString(tr("I do not understand the type %1.")).arg(varType));
	    return;
	}
	int r = _table->rowCount();
	_table->setRowCount(r+1);
        QTableWidgetItem * ctItem = 0;
        ctItem = new QTableWidgetItem();
        ctItem->setFlags(Qt::ItemIsUserCheckable);
        ctItem->setCheckState((active ? Qt::Checked : Qt::Unchecked));
        _table->setItem(r, 0, ctItem);
        _table->setItem(r, 1, new QTableWidgetItem(name));
        QVariant var = _params[name];
        _table->setItem(r, 2, new QTableWidgetItem(var.typeName()));
        _table->setItem(r, 3, new QTableWidgetItem(var.toString()));
    }
}