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


C++ DateAndTime::day方法代码示例

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


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

示例1: setPreviousValue

/** Set a value for a widget.
 *
 * The function needs to know about the types of widgets
 * that are being used. Currently it knows about QComboBox, QLineEdit and
 * QCheckBox
 * @param widget :: A pointer to the widget
 * @param propName :: The property name
 */
void AlgorithmDialog::setPreviousValue(QWidget *widget,
                                       const QString &propName) {
  // If is called from a script, check if we have such property
  if (isForScript() && !getAlgorithmProperty(propName))
    return;

  QString value = getPreviousValue(propName);

  Mantid::Kernel::Property *property = getAlgorithmProperty(propName);

  // Do the right thing for the widget type
  if (QComboBox *opts = qobject_cast<QComboBox *>(widget)) {
    if (property && value.isEmpty()) {
      value = QString::fromStdString(property->value());
    }
    int index = opts->findText(value);
    if (index >= 0) {
      opts->setCurrentIndex(index);
    }
    return;
  }
  if (QAbstractButton *checker = qobject_cast<QAbstractButton *>(widget)) {
    if (value.isEmpty() &&
        dynamic_cast<Mantid::Kernel::PropertyWithValue<bool> *>(property))
      value = QString::fromStdString(property->value());
    checker->setChecked(value != "0");
    return;
  }
  if (QDateTimeEdit *dateEdit = qobject_cast<QDateTimeEdit *>(widget)) {
    // String in ISO8601 format
    DateAndTime t = DateAndTime::getCurrentTime();
    try {
      t.setFromISO8601(verifyAndSanitizeISO8601(value.toStdString()));
    } catch (std::exception &) {
    }
    dateEdit->setDate(QDate(t.year(), t.month(), t.day()));
    dateEdit->setTime(QTime(t.hour(), t.minute(), t.second(), 0));
    return;
  }

  QLineEdit *textfield = qobject_cast<QLineEdit *>(widget);
  MantidWidget *mtdwidget = qobject_cast<MantidWidget *>(widget);
  if (textfield || mtdwidget) {
    if (!isForScript()) {
      if (textfield)
        textfield->setText(value);
      else
        mtdwidget->setUserInput(value);
    } else {
      // Need to check if this is the default value as we don't fill them in if
      // they are
      if (m_python_arguments.contains(propName) || !property->isDefault()) {
        if (textfield)
          textfield->setText(value);
        else
          mtdwidget->setUserInput(value);
      }
    }
    return;
  }

  PropertyWidget *propWidget = qobject_cast<PropertyWidget *>(widget);
  if (propWidget) {
    propWidget->setPreviousValue(value);

    return;
  }

  // Reaching here means we have a widget type we don't understand. Tell the
  // developer
  QMessageBox::warning(
      this, windowTitle(),
      QString("Cannot set value for ") + widget->metaObject()->className() +
          ". Update AlgorithmDialog::setValue() to cope with this widget.");
}
开发者ID:DanNixon,项目名称:mantid,代码行数:83,代码来源:AlgorithmDialog.cpp


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