当前位置: 首页>>代码示例>>C++>>正文


C++ Option::getDefaultIndex方法代码示例

本文整理汇总了C++中Option::getDefaultIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Option::getDefaultIndex方法的具体用法?C++ Option::getDefaultIndex怎么用?C++ Option::getDefaultIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Option的用法示例。


在下文中一共展示了Option::getDefaultIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initializeControl

//! The (overloaded) initializeControl routine is responsible for the following
//! tasks:
//!  - Ensuring the control displays the appropriate options based on the
//!    contents of the OptionDatabase.
//!  - Adding the ToolTip documentation found in the database.
//!  - Adding connections (signals & slots) between the Nodes in the
//!    OptionRegister and the control.  This allows for synchronization of the
//!    logic in InitializeQChemLogic and initializeQuiLogic.
//!  - Binding an Action to enable the control to be reset to the default value.
//!  - Binding an Update to enable the control to be reset to a string value.
void InputDialog::initializeControl(Option const& opt, QComboBox* combo) {

   QString name = opt.getName();
   QStringList opts = opt.getOptions();
   QStringList split;

   // This allows for ad hoc text replacements.  This is useful so that more
   // informative text can be presented to the user which is then obfiscated
   // before being passed to QChem.  The replacements should be set in the
   // option database and have the form text//replacement.
   for (int i = 0; i < opts.size(); ++i) {
       split = opts[i].split("//");

       if (split.size() == 1) {
          opts[i] = split[0];
       }else if (split.size() == 2) {
          opts[i] = split[0];
          QString key(name.toUpper() + "::" + split[0]);
          //Job::addAdHoc(key,split[1]);
          RemSection::addAdHoc(name, split[0], split[1]);
       }else {
          qDebug() << "InputDialog::initialiseComboBox:\n"
                   << " replacement for option" << name << "is invalid:" << opts[i];
       }
   }

   combo->clear();
   combo->addItems(opts);

#if QT_VERSION >= 0x040400
   // This just allows us to add some spacers to the lists
   bool keepLooking(true);
   while (keepLooking) {
      int i = combo->findText("---", Qt::MatchStartsWith);
      if (i > 0) {
         combo->removeItem(i);
         combo->insertSeparator(i);
      }else {
         keepLooking = false;
      }
   }
#endif

   connectControl(opt, combo);
   combo->setToolTip(opt.getDescription());

   Action* action = new Action(
      boost::bind(&QComboBox::setCurrentIndex, combo, opt.getDefaultIndex()) );
   m_resetActions.push_back(action);

   Update* update = new Update(
      boost::bind(
         static_cast<void(*)(QComboBox*, QString const&)>(SetControl), combo, _1));
   m_setUpdates[name] = update;
}
开发者ID:cryos,项目名称:QUI,代码行数:65,代码来源:InputDialog.C

示例2: initializeControl

void InputDialog::initializeControl(Option const& opt, QCheckBox* check) 
{
   connectControl(opt, check);
   check->setToolTip(prependRemName(opt.getName(), opt.getDescription()));

   Action* action = new Action(
      boost::bind(&QCheckBox::setChecked, check, opt.getDefaultIndex()) );
   m_resetActions.push_back(action);

   Update* update = new Update(
      boost::bind( 
         static_cast<void(*)(QCheckBox*, QString const&)>(SetControl), check, _1));
   QString name = opt.getName();
   m_setUpdates[name] = update;
}
开发者ID:jhgorse,项目名称:IQmol,代码行数:15,代码来源:InputDialog.C

示例3: insert

//! 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);
}
开发者ID:jwakely,项目名称:IQmol,代码行数:39,代码来源:OptionDatabase.C


注:本文中的Option::getDefaultIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。