void InputDialog::initializeControl(Option const& opt, QLineEdit* edit) { connectControl(opt, edit); edit->setToolTip(opt.getDescription()); Action* action = new Action( boost::bind(&QLineEdit::setText, edit, opt.getOptionString()) ); m_resetActions.push_back(action); Update* update = new Update( boost::bind( static_cast<void(*)(QLineEdit*, QString const&)>(SetControl), edit, _1)); QString name = opt.getName(); m_setUpdates[name] = update; }
void InputDialog::initializeControl(Option const& opt, QLineEdit* edit) { connectControl(opt, edit); edit->setToolTip(prependRemName(opt.getName(), opt.getDescription())); Action* action = new Action( boost::bind(&QLineEdit::setText, edit, opt.getOptionString()) ); m_resetActions.push_back(action); Update* update = new Update( boost::bind( static_cast<void(*)(QLineEdit*, QString const&)>(SetControl), edit, _1)); QString name = opt.getName(); m_setUpdates[name] = update; if (opt.getType() == Option::Type_Array) { QRegExp rx("^\\[(\\d+,?)+\\]$"); QValidator* validator(new QRegExpValidator(rx, this)); edit->setValidator(validator); //edit->setMask(""); } }
//! Inserts an Option into the database, overwriting the record if the //! option name already exists. The user is prompted if an overwrite will //! occur and if \var promptOnOverwrite is set to true. bool OptionDatabase::insert(Option const& opt, bool const promptOnOverwrite) { Option tmp; QString name(opt.getName()); if ( get(name, tmp) ) { if (promptOnOverwrite) { QString msg("Option name "); msg += name; msg += " already exists in database, overwrite?"; int ret = QMsgBox::question(0, "Option Exists",msg, QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Cancel) { return false; } } remove(name,false); } QString buf("insert into options( 'Name', 'Type', 'Default', 'Options', " "'Description', 'Implementation' ) values ( '"); buf += opt.getName() + "', "; buf += QString::number(opt.getType()) + ", "; buf += QString::number(opt.getDefaultIndex()) + ", '"; buf += opt.getOptionString() + "', "; // No quote! QSqlField desc("Description", QVariant::String); desc.setValue(opt.getDescription()); buf += QSqlDatabase::database("QChem").driver()->formatValue(desc); buf += ", "; buf += QString::number(opt.getImplementation()) + ");"; qDebug() << "Database insert: " << buf; return execute(buf); }