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


C++ TimeRange::getStartTimeSec方法代码示例

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


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

示例1: getLabelItem

string GenlistItemScenarioSchedule::getLabelItem(Evas_Object *obj, string part)
{
    string text;

    if (!scenario) return text;

    if (part == "text")
    {
        text = scenario->ioScenario->params["name"];
    }
    else if (part == "time")
    {
        text = "N/A";

        if (scenario->isScheduled())
        {
            auto getTimeForDate = [=,&text](vector<TimeRange> &range)
            {
                if (scheduleRangeNum >= 0 && scheduleRangeNum < range.size())
                {
                    TimeRange tr = range[scheduleRangeNum];
                    text = tr.getStartTimeSec(scDate.tm_year + 1900, scDate.tm_mon + 1, scDate.tm_mday);
                }
            };

            switch (scheduleRange)
            {
            case TimeRange::MONDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_monday); break;
            case TimeRange::TUESDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_tuesday); break;
            case TimeRange::WEDNESDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_wednesday); break;
            case TimeRange::THURSDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_thursday); break;
            case TimeRange::FRIDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_friday); break;
            case TimeRange::SATURDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_saturday); break;
            case TimeRange::SUNDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_sunday); break;
            default: break;
            }
        }
    }
    else if (part == "actions.text")
    {
        text = "Aucune actions.";
        if (scenario->scenario_data.steps.size() > 1)
            text = Utils::to_string(scenario->scenario_data.steps.size()) + " étapes.";
        else if (scenario->scenario_data.steps.size() == 1 &&
                 scenario->scenario_data.steps[0].actions.size() > 0)
            text = Utils::to_string(scenario->scenario_data.steps[0].actions.size()) + " actions.";
    }

    if (scenario->scenario_data.params["schedule"] != "false")
        itemEmitSignal("schedule,true", "calaos");
    else
        itemEmitSignal("schedule,false", "calaos");

    return text;
}
开发者ID:JulienMasson,项目名称:calaos_base,代码行数:55,代码来源:GenlistItemScenarioSchedule.cpp

示例2: addTreeItem

void DialogEditTimeRange::addTreeItem(TimeRange &range)
{
    QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeRanges);

    bool same = range.isSameStartEnd();
    string starttxt, subtxt;
    if (same)
        starttxt = tr("Execute at ").toUtf8().constData();
    else
        starttxt = tr("Start at ").toUtf8().constData();

    auto offsetString = [=](bool isstart)
    {
        if (isstart)
        {
            int h, m, s;
            from_string(range.shour, h);
            from_string(range.smin, m);
            from_string(range.ssec, s);
            int v = h * 3600 + m * 60 + s;

            if (range.start_offset == 1)
                return string(" +") + Utils::time2string_digit(v);
            else if (range.start_offset == -1)
                return string(" -") + Utils::time2string_digit(v);

        }
        else
        {
            int h, m, s;
            from_string(range.ehour, h);
            from_string(range.emin, m);
            from_string(range.esec, s);
            int v = h * 3600 + m * 60 + s;

            if (range.end_offset == 1)
                return string(" +") + Utils::time2string_digit(v);
            else
                if (range.end_offset == -1)
                    return string(" -") + Utils::time2string_digit(v);
        }

        return string();
    };

    if (range.start_type == TimeRange::HTYPE_NORMAL)
        starttxt = starttxt + Utils::time2string_digit(range.getStartTimeSec());
    else if (range.start_type == TimeRange::HTYPE_SUNRISE)
        starttxt = starttxt + tr("Sunrise").toUtf8().constData() + offsetString(true) + " (" + Utils::time2string_digit(range.getStartTimeSec()) + ")";
    else if (range.start_type == TimeRange::HTYPE_SUNSET)
        starttxt = starttxt + tr("Sunset").toUtf8().constData() + offsetString(true) + " (" + Utils::time2string_digit(range.getStartTimeSec()) + ")";
    else if (range.start_type == TimeRange::HTYPE_NOON)
        starttxt = starttxt + tr("Noon").toUtf8().constData() + offsetString(true) + " (" + Utils::time2string_digit(range.getStartTimeSec()) + ")";

    item->setData(0, TwoLineItemDelegate::headerTextRole, QString::fromUtf8(starttxt.c_str()));

    if (!same)
    {
        subtxt = tr("Stop at ").toUtf8().constData();

        if (range.end_type == TimeRange::HTYPE_NORMAL)
            subtxt += Utils::time2string_digit(range.getEndTimeSec());
        else if (range.end_type == TimeRange::HTYPE_SUNRISE)
            subtxt += tr("Sunrise").toUtf8().constData() + offsetString(false) + " (" + Utils::time2string_digit(range.getEndTimeSec()) + ")";
        else if (range.end_type == TimeRange::HTYPE_SUNSET)
            subtxt += tr("Sunset").toUtf8().constData() + offsetString(false) + " (" + Utils::time2string_digit(range.getEndTimeSec()) + ")";
        else if (range.end_type == TimeRange::HTYPE_NOON)
            subtxt += tr("Noon").toUtf8().constData() + offsetString(false) + " (" + Utils::time2string_digit(range.getEndTimeSec()) + ")";

        item->setData(0, TwoLineItemDelegate::subHeaderTextRole, QString::fromUtf8(subtxt.c_str()));
    }

    if (range.isNewRange)
    {
        item->setData(0, TwoLineItemDelegate::headerTextRole, tr("New empty range..."));
        item->setData(0, TwoLineItemDelegate::subHeaderTextRole, tr("Click to edit"));
    }

    QVariant uservalue = QVariant::fromValue<TimeRange>(range);
    item->setData(0, TimeRangeRole, uservalue);

    item->setIcon(0, QIcon(":/img/icon_clock.png"));
}
开发者ID:lovo63,项目名称:calaos_installer,代码行数:83,代码来源:DialogEditTimeRange.cpp


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