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


C++ QDateTime::addSecs方法代码示例

本文整理汇总了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();

}
开发者ID:redfish64,项目名称:nomiccoin,代码行数:33,代码来源:createproposaldialog.cpp

示例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;
}
开发者ID:151706061,项目名称:sofa,代码行数:27,代码来源:qwt_date_scale_engine.cpp

示例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;
  }
}
开发者ID:Kirek,项目名称:deepin-session-ui-manjaro,代码行数:25,代码来源:RollingFileAppender.cpp

示例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;
}
开发者ID:alexckp,项目名称:qgis,代码行数:31,代码来源:exif2gpx.cpp

示例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;
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:30,代码来源:caleneditordatahandler.cpp

示例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);
}
开发者ID:sagiadinos,项目名称:garlic-player,代码行数:31,代码来源:timing.cpp

示例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);
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:9,代码来源:app.cpp

示例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));
}
开发者ID:mdbxh,项目名称:profilematic,代码行数:29,代码来源:testcalendarentrymatcherdatetime.cpp

示例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 ) );
  }
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:12,代码来源:timelineitem.cpp

示例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();
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:51,代码来源:alarmview.cpp

示例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;
}
开发者ID:OlivierJG,项目名称:Charm,代码行数:26,代码来源:EnterVacationDialog.cpp

示例12: needsUpdate

bool needsUpdate(GrabberScript* script, uint updateFreq)
{
    QDateTime now = QDateTime::currentDateTime();
    QDateTime then = lastUpdate(script);

    return then.addSecs(updateFreq * 60 * 60) < now;
}
开发者ID:microe,项目名称:mythtv,代码行数:7,代码来源:netutils.cpp

示例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);
    }

}
开发者ID:RobotRebels,项目名称:TrueGraph,代码行数:33,代码来源:rrplotpicker.cpp

示例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;
}
开发者ID:RobotRebels,项目名称:TrueGraph,代码行数:26,代码来源:rrplotpicker.cpp

示例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;
}
开发者ID:scolbeck,项目名称:mythtv,代码行数:34,代码来源:main.cpp


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