本文整理汇总了C++中TimeRange::getEndTimeSec方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeRange::getEndTimeSec方法的具体用法?C++ TimeRange::getEndTimeSec怎么用?C++ TimeRange::getEndTimeSec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeRange
的用法示例。
在下文中一共展示了TimeRange::getEndTimeSec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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"));
}