本文整理汇总了C++中QDateTime::addSecs方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTime::addSecs方法的具体用法?C++ QDateTime::addSecs怎么用?C++ QDateTime::addSecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::addSecs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ui
CreateProposalDialog::CreateProposalDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::CreateProposalDialog), model(0) {
ui->setupUi(this);
#ifdef Q_WS_MAC // Icons on push buttons are very uncommon on Mac
ui->addButton->setIcon(QIcon());
ui->clearButton->setIcon(QIcon());
ui->createButton->setIcon(QIcon());
#endif
connect(ui->upgradeCheckbox, &QCheckBox::clicked, this, &CreateProposalDialog::updateUpgradeFields);
connect(ui->spendPoolFundsCheckBox, &QCheckBox::clicked, this, &CreateProposalDialog::updateSpendPoolFields);
connect(ui->addButton, &QPushButton::clicked, this, &CreateProposalDialog::addEntry);
connect(ui->clearButton, &QPushButton::clicked, this, &CreateProposalDialog::clear);
QDateTime minDateTime = QDateTime::currentDateTime().addSecs(MIN_PROPOSAL_DEADLINE_TIME + 1 * HOUR);
QDateTime maxDateTime = minDateTime.addSecs(MAX_PROPOSAL_DEADLINE_TIME);
//default 3 days later at 9 pm
QDateTime defaultDateTime = minDateTime.addDays(3);
defaultDateTime.setTime(QTime());//clear time
defaultDateTime = defaultDateTime.addSecs(21 * HOUR);//set to 9 pm
connect(ui->editDeadline, &QDateTimeEdit::dateTimeChanged, this, &CreateProposalDialog::updateLabelEditDeadline);
ui->editDeadline->setDateTimeRange(minDateTime, maxDateTime);
ui->editDeadline->setDateTime(defaultDateTime);
updateUpgradeFields();
updateSpendPoolFields();
}
示例2: qwtDstTicks
static QList<double> qwtDstTicks( const QDateTime &dateTime,
int secondsMajor, int secondsMinor )
{
if ( secondsMinor <= 0 )
QList<double>();
QDateTime minDate = dateTime.addSecs( -secondsMajor );
minDate = QwtDate::floor( minDate, QwtDate::Hour );
const double utcOffset = QwtDate::utcOffset( dateTime );
// find the hours where daylight saving time happens
double dstMin = QwtDate::toDouble( minDate );
while ( minDate < dateTime &&
QwtDate::utcOffset( minDate ) != utcOffset )
{
minDate = minDate.addSecs( 3600 );
dstMin += 3600 * 1000.0;
}
QList<double> ticks;
for ( int i = 0; i < 3600; i += secondsMinor )
ticks += dstMin + i * 1000.0;
return ticks;
}
示例3: computeFrequency
void RollingFileAppender::computeFrequency()
{
QMutexLocker locker(&m_rollingMutex);
const QDateTime startTime(QDate(1999, 1, 1), QTime(0, 0));
const QString startString = startTime.toString(m_datePatternString);
if (startString != startTime.addSecs(60).toString(m_datePatternString))
m_frequency = MinutelyRollover;
else if (startString != startTime.addSecs(60 * 60).toString(m_datePatternString))
m_frequency = HourlyRollover;
else if (startString != startTime.addSecs(60 * 60 * 12).toString(m_datePatternString))
m_frequency = HalfDailyRollover;
else if (startString != startTime.addDays(1).toString(m_datePatternString))
m_frequency = DailyRollover;
else if (startString != startTime.addDays(7).toString(m_datePatternString))
m_frequency = WeeklyRollover;
else if (startString != startTime.addMonths(1).toString(m_datePatternString))
m_frequency = MonthlyRollover;
else
{
Q_ASSERT_X(false, "DailyRollingFileAppender::computeFrequency", "The pattern '%1' does not specify a frequency");
return;
}
}
示例4: file
bool Exif2GPX::writeGPX(const QStringList& pictures, const QString& gpxOutput,
bool interpolate, unsigned offset,
const QString& prefix) {
// initialize GPX DOM
QDomDocument qdd;
QDomElement gpxElt = qdd.createElement("gpx");
qdd.appendChild(gpxElt);
gpxElt.setAttribute("version", "1.0");
// add the waypoints
QStringList::const_iterator iter;
for (iter = pictures.begin(); iter != pictures.end(); ++iter) {
QDateTime timestamp = getTimeFromEXIF(*iter);
QFile file(*iter);
QFileInfo fi(file);
addWaypoint(gpxElt, computePosition(timestamp.addSecs(-offset),
interpolate),
timestamp.addSecs(-offset), prefix, fi.fileName());
}
// write the file
QFile gpxOut(gpxOutput);
if (!gpxOut.open(IO_WriteOnly)) {
std::cerr<<"Could not open "<<gpxOutput<<std::endl;
return false;
}
QTextStream str(&gpxOut);
str<<qdd.toString();
return true;
}
示例5: checkAlarmFieldsForErrors
/*!
Check the alarm fields for errors.
\return the error if found, or CalenEditorErrorNone if no error found.
*/
CalenEditorPrivate::Error CalenEditorDataHandler::checkAlarmFieldsForErrors(
bool series) const
{
OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_CHECKALARMFIELDSFORERRORS_ENTRY );
CalenEditorPrivate::Error error = CalenEditorPrivate::CalenEditorErrorNone;
// If alarm not active, no check
if (!mEditedEntry->alarm().isNull()) {
int alarm = mEditedEntry->alarm().timeOffset();
QDateTime startTime = mEditedEntry->startTime();
QDateTime alarmTime;
if (alarm > 0) {
alarmTime = startTime.addSecs(-alarm * 60);
} else {
alarmTime = startTime.addSecs(alarm * 60);
}
QDateTime currentTime = CalenDateUtils::now();
if (isAlarmInAcceptablePeriod(error, alarmTime, startTime)) {
if (!series && (alarmTime < currentTime)) {
// dont let non-repeating future entries have alarms in past
error = CalenEditorPrivate::CalenEditorErrorAlarmTimePast;
}
}
}
OstTraceFunctionExit0( CALENEDITORDATAHANDLER_CHECKALARMFIELDSFORERRORS_EXIT );
return error;
}
示例6: addWallClockIntervalOptimized
/**
* @brief TTiming::addWallClockIntervalOptimized skips to long distances
* @param actual
* @param calculated
* @return
*/
QDateTime TTiming::addWallClockIntervalOptimized(QDateTime actual, QDateTime calculated)
{
if (wall_clock.period.years == 0)
calculated = calculated.addYears(actual.date().year()-calculated.date().year()); // should give 0 on iterations
else
calculated = calculated.addYears(wall_clock.period.years);
if (wall_clock.period.months == 0)
calculated = calculated.addMonths(actual.date().month()-calculated.date().month());
else
calculated = calculated.addMonths(wall_clock.period.months);
if (wall_clock.period.days == 0)
calculated = calculated.addDays(actual.date().day()-calculated.date().day());
else
calculated = calculated.addDays(wall_clock.period.days);
if (wall_clock.period.hours == 0)
calculated = calculated.addSecs((actual.time().hour()-calculated.time().hour())*3600);
else
calculated = calculated.addSecs(wall_clock.period.hours*3600);
if (wall_clock.period.minutes == 0)
calculated = calculated.addSecs((actual.time().minute()-calculated.time().minute())*60);
else
calculated = calculated.addSecs(wall_clock.period.minutes*60);
return calculated.addSecs(wall_clock.period.seconds);
}
示例7: testQDateTime
void testQDateTime()
{
QDateTime date;
date = QDateTime::currentDateTime();
date = date.addSecs(5);
date = date.addSecs(5);
date = date.addSecs(5);
date = date.addSecs(5);
}
示例8: matcher
void
TestCalendarEntryMatcherDateTime::matchDateTime_append() {
int appendSecs = 10;
RuleConditionCalendar cond;
cond.setTimeAppend(appendSecs);
QDateTime now = QDateTime::fromString("27.09.2011 22:00", "dd.MM.yyyy hh:mm");
CalendarEntryMatcherDateTime matcher(cond, now);
CalendarEntry matchStartLimit(now, now.addSecs(60*10), QString(), QString());
CalendarEntry matchEndLimit(now.addSecs(-60*10), now, QString(), QString());
CalendarEntry nomatchStartAfterNow(now.addSecs(1), now.addSecs(2), QString(), QString());
CalendarEntry nomatchEndBeforeNow(now.addSecs(-200), now.addSecs(-100), QString(), QString());
// If start and end are same, end is used as start + 1min, so this should match
CalendarEntry matchStartAndEndSame(now.addSecs(-1), now.addSecs(-1), QString(), QString());
QCOMPARE(matcher.match(matchStartLimit), true);
QCOMPARE(matcher.match(matchEndLimit), true);
QCOMPARE(matcher.match(nomatchStartAfterNow), false);
QCOMPARE(matcher.match(nomatchEndBeforeNow), false);
QCOMPARE(matcher.match(matchStartAndEndSame), true);
// Check nextNearest values
QCOMPARE(matcher.nextNearestStartOrEnd(matchStartLimit), matchStartLimit.end().addSecs(appendSecs));
QCOMPARE(matcher.nextNearestStartOrEnd(matchEndLimit), now.addSecs(appendSecs));
QCOMPARE(matcher.nextNearestStartOrEnd(nomatchStartAfterNow), nomatchStartAfterNow.start());
QCOMPARE(matcher.nextNearestStartOrEnd(nomatchEndBeforeNow), QDateTime());
QCOMPARE(matcher.nextNearestStartOrEnd(matchStartAndEndSame), matchStartAndEndSame.start().addSecs(60).addSecs(appendSecs));
}
示例9: moveItems
void TimelineItem::moveItems( KCal::Incidence *incidence, int delta, int duration )
{
typedef QList<TimelineSubItem*> ItemList;
ItemList list = mItemMap[incidence];
for ( ItemList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it ) {
QDateTime start = (*it)->originalStart().dateTime();
start = start.addSecs( delta );
(*it)->setStartTime( start );
(*it)->setOriginalStart( KDateTime(start) );
(*it)->setEndTime( start.addSecs( duration ) );
}
}
示例10: snoozeClicked
void AlarmView::snoozeClicked()
{
mAlarmTimer.stop();
/* Snooze for some amount of time (configured in settings, say) */
int snoozeindex = mSnoozeChoices->currentIndex();
int snoozedelay = 60;
// Make sure we set alarms on the minute by rounding
QDateTime now = QDateTime::currentDateTime();
int seconds = now.time().second();
if (seconds >= 30)
now = now.addSecs(60 - seconds);
else
now = now.addSecs(-seconds);
switch(snoozeindex) {
case 0: // 5 minutes
snoozedelay = 300;
break;
case 1: // 10 minutes
snoozedelay = 600;
break;
case 2: // 15 minutes
snoozedelay = 900;
break;
case 3: // 30 minutes
snoozedelay = 1800;
break;
case 4: // 1 hour
snoozedelay = 3600;
break;
case 5: // 1 day
snoozedelay = 24 * 60;
break;
case 6: // 1 week
snoozedelay = 7 * 24 * 60;
break;
case 7: // 1 month hmm
{
QDateTime then = now.addMonths(1);
snoozedelay = now.secsTo(then);
}
break;
}
QDateTime snoozeTime = now.addSecs(snoozedelay);
Qtopia::addAlarm(snoozeTime, "Calendar", "alarm(QDateTime,int)", snoozeTime.secsTo(mStartTime) / 60);
emit closeView();
}
示例11: createEventList
static EventList createEventList( const QDate& start, const QDate& end, int minutes, const TaskId& taskId )
{
Q_ASSERT( start < end );
EventList events;
const int days = start.daysTo( end );
#if QT_VERSION >= 0x040700
events.reserve( days );
#endif
for ( int i = 0; i < days; ++i ) {
const QDate date = start.addDays( i );
//for each work day, create an event starting at 8 am
if ( isWorkDay( date ) ) {
const QDateTime startTime = QDateTime( date, QTime( 8, 0 ) );
const QDateTime endTime = startTime.addSecs( minutes * 60 );
Event event;
event.setTaskId( taskId );
event.setStartDateTime( startTime );
event.setEndDateTime( endTime );
event.setComment( QObject::tr( "(created by vacation dialog)" ) );
events.append( event );
}
}
return events;
}
示例12: needsUpdate
bool needsUpdate(GrabberScript* script, uint updateFreq)
{
QDateTime now = QDateTime::currentDateTime();
QDateTime then = lastUpdate(script);
return then.addSecs(updateFreq * 60 * 60) < now;
}
示例13: widgetMouseDoubleClickEvent
void RRPlotPicker::widgetMouseDoubleClickEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton) {
QwtScaleMap xMap = this->plot()->canvasMap(d_xAxis);
QwtScaleMap yMap = this->plot()->canvasMap(d_yAxis);
const double x = xMap.invTransform(event->pos().x());
const double y = yMap.invTransform(event->pos().y());
QString str;
if(isInited) {
QDateTime dt;
dt.setTime_t(baseDTime);
str = dt.addSecs(x).time().toString();
} else {
str = "00:00:00";
}
//QString text = new QString("( " + str + " , " + QString::number(y) + " ) ");
QString text = "( " + str + " , " + QString::number(y,'g', 10) + " ) ";
//emit doubleClickPoint(text);
//emit doubleClicked(text);
} else {
//QwtPlotZoomer::widgetMouseReleaseEvent(event);
}
}
示例14: trackerText
QwtText RRPlotPicker::trackerText (const QPoint & pos) const
{
QwtScaleMap xMap = this->plot()->canvasMap(d_xAxis);
QwtScaleMap yMap = this->plot()->canvasMap(d_yAxis);
const double x = xMap.invTransform(pos.x());
const double y = yMap.invTransform(pos.y());
QString str;
if(isInited) {
QDateTime dt;
dt.setTime_t(baseDTime);
str = dt.addSecs(x).time().toString();
} else {
str = "00:00:00";
}
QwtText text("( " + str + " , " + QString::number(y,'g', 10) + " ) ");
QColor bgColor(Qt::transparent);
//bgColor.setAlpha(160);
text.setBackgroundBrush(QBrush(bgColor));
return text;
}
示例15: setScheduledWakeupTime
static int setScheduledWakeupTime()
{
if (!gCoreContext->IsConnectedToMaster())
{
VERBOSE(VB_IMPORTANT, "setScheduledWakeupTime: "
"Attempting to connect to master server...");
if (!gCoreContext->ConnectToMasterServer(false))
{
VERBOSE(VB_IMPORTANT, "setScheduledWakeupTime: "
"Could not connect to master server!");
return 1;
}
}
QDateTime nextRecordingStart;
GetProgramDetailList(nextRecordingStart);
// set the wakeup time for the next scheduled recording
if (!nextRecordingStart.isNull())
{
int m_preRollSeconds = gCoreContext->GetNumSetting("RecordPreRoll");
QDateTime restarttime = nextRecordingStart
.addSecs((-1) * m_preRollSeconds);
int add = gCoreContext->GetNumSetting("StartupSecsBeforeRecording", 240);
if (add)
restarttime = restarttime.addSecs((-1) * add);
setWakeupTime(restarttime.toString(Qt::ISODate));
return 0;
}
return 1;
}