本文整理汇总了C++中QTime::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QTime::isNull方法的具体用法?C++ QTime::isNull怎么用?C++ QTime::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTime
的用法示例。
在下文中一共展示了QTime::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QStringLiteral
static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, const QTime holdUntilTime)
{
switch (jobHold) {
case QCUPSSupport::Indefinite:
return QStringLiteral("indefinite");
case QCUPSSupport::DayTime:
return QStringLiteral("day-time");
case QCUPSSupport::Night:
return QStringLiteral("night");
case QCUPSSupport::SecondShift:
return QStringLiteral("second-shift");
case QCUPSSupport::ThirdShift:
return QStringLiteral("third-shift");
case QCUPSSupport::Weekend:
return QStringLiteral("weekend");
case QCUPSSupport::SpecificTime:
if (!holdUntilTime.isNull()) {
// CUPS expects the time in UTC, user has entered in local time, so get the UTS equivalent
QDateTime localDateTime = QDateTime::currentDateTime();
// Check if time is for tomorrow in case of DST change overnight
if (holdUntilTime < localDateTime.time())
localDateTime = localDateTime.addDays(1);
localDateTime.setTime(holdUntilTime);
return localDateTime.toUTC().time().toString(QStringLiteral("HH:mm"));
}
// else fall through:
case QCUPSSupport::NoHold:
return QString();
}
Q_UNREACHABLE();
return QString();
}
示例2: QDateTimeToDATE
static DATE QDateTimeToDATE(const QDateTime &dt)
{
if (!dt.isValid() || dt.isNull())
return 949998;
SYSTEMTIME stime;
memset(&stime, 0, sizeof(stime));
QDate date = dt.date();
QTime time = dt.time();
if (date.isValid() && !date.isNull()) {
stime.wDay = date.day();
stime.wMonth = date.month();
stime.wYear = date.year();
}
if (time.isValid() && !time.isNull()) {
stime.wMilliseconds = time.msec();
stime.wSecond = time.second();
stime.wMinute = time.minute();
stime.wHour = time.hour();
}
double vtime;
SystemTimeToVariantTime(&stime, &vtime);
return vtime;
}
示例3: paintEvent
void BenchWidget::paintEvent(QPaintEvent *)
{
if (m_done)
return;
QPainter p(this);
m_benchmark->begin(&p, 100);
PaintingRectAdjuster adjuster;
adjuster.setNewBenchmark(m_benchmark);
adjuster.reset(rect());
for (int i = 0; i < 100; ++i)
m_benchmark->draw(&p, adjuster.newPaintingRect(), i);
m_benchmark->end(&p);
++m_iteration;
uint currentElapsed = timer.isNull() ? 0 : timer.elapsed();
timer.restart();
m_total += currentElapsed;
// warm up for at most 5 iterations or half a second
if (m_iteration >= 5 || m_total >= 500) {
iterationTimes << currentElapsed;
if (iterationTimes.size() >= 5) {
qreal mean = 0;
qreal stddev = 0;
uint min = INT_MAX;
for (int i = 0; i < iterationTimes.size(); ++i) {
mean += iterationTimes.at(i);
min = qMin(min, iterationTimes.at(i));
}
mean /= qreal(iterationTimes.size());
for (int i = 0; i < iterationTimes.size(); ++i) {
qreal delta = iterationTimes.at(i) - mean;
stddev += delta * delta;
}
stddev = qSqrt(stddev / iterationTimes.size());
stddev = 100 * stddev / mean;
// do 50 iterations, break earlier if we spend more than 5 seconds or have a low std deviation after 2 seconds
if (iterationTimes.size() >= 50 || m_total >= 5000 || (m_total >= 2000 && stddev < 4)) {
m_result = min;
m_done = true;
return;
}
}
}
}
示例4: setEventTime
void AgendaWidgetEventItem::setEventTime(const QTime & start, const QTime & end)
{
QString time;
if (start.isNull()) {
m_hasStartTime = false;
} else {
m_hasStartTime = true;
m_startTime = start;
}
if (end.isNull()) {
m_hasEndTime = false;
} else {
m_hasEndTime = true;
m_endTime = end;
}
if (m_hasStartTime && m_hasEndTime) {
time += KGlobal::locale()->formatTime(m_startTime);
time += " - ";
time += KGlobal::locale()->formatTime(m_endTime);
} else if (m_hasStartTime && !m_hasEndTime) {
time += i18n("From");
time += " ";
time += KGlobal::locale()->formatTime(m_startTime);
} else if (!m_hasStartTime && m_hasEndTime) {
time += i18n("Till");
time += " ";
time += KGlobal::locale()->formatTime(m_endTime);
}
m_timeText = new Plasma::IconWidget(this);
m_timeText->setOrientation(Qt::Horizontal);
m_timeText->setMinimumWidth(50);
m_timeText->setMaximumHeight(15);
m_timeText->setText(time);
m_textLayout->addItem(m_timeText);
m_line->setMaximumHeight(30);
connect(m_timeText, SIGNAL(clicked()), SLOT(edit()));
}
示例5: setJobHold
void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime)
{
QStringList cupsOptions = cupsOptionsList(printer);
switch (jobHold) {
case NoHold: //default
break;
case Indefinite:
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
QStringLiteral("indefinite"));
break;
case DayTime:
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
QStringLiteral("day-time"));
break;
case Night:
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
QStringLiteral("night"));
break;
case SecondShift:
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
QStringLiteral("second-shift"));
break;
case ThirdShift:
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
QStringLiteral("third-shift"));
break;
case Weekend:
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
QStringLiteral("weekend"));
break;
case SpecificTime:
if (holdUntilTime.isNull()) {
setJobHold(printer, NoHold);
return;
}
// CUPS expects the time in UTC, user has entered in local time, so get the UTS equivalent
QDateTime localDateTime = QDateTime::currentDateTime();
// Check if time is for tomorrow in case of DST change overnight
if (holdUntilTime < localDateTime.time())
localDateTime = localDateTime.addDays(1);
localDateTime.setTime(holdUntilTime);
setCupsOption(cupsOptions,
QStringLiteral("job-hold-until"),
localDateTime.toUTC().time().toString(QStringLiteral("HH:mm")));
break;
}
setCupsOptions(printer, cupsOptions);
}
示例6: updateInterval
void MainTray::updateInterval(const QTime& val)
{
if (val.isNull() || val==QTime(0,0))
return;
const QTime maxTime = QTime(0, 0).addMSecs(std::numeric_limits<int>::max()-1);
if (val > maxTime)
m_updateInterval = maxTime;
else
m_updateInterval = val;
m_updateTimer.start(getUpdateMS());
}
示例7: PyBool_FromLong
static PyObject *meth_QTime_isNull(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QTime *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QTime, &sipCpp))
{
bool sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->isNull();
Py_END_ALLOW_THREADS
return PyBool_FromLong(sipRes);
}
}
示例8: setTime
/*! Sets internal time to \e time. */
void TimeComboBox::setTime(const QTime &time)
{
if (d->time == time)
return;
const int index = d->combo->findData(time);
if (index == -1) {
// custom time, not found in combo items
// QTime() is not the same as QTime(0,0)!!
d->time = time.isNull()? QTime(0, 0) : time;
d->combo->setEditText(time.toString(QLocale::system().timeFormat(QLocale::ShortFormat)));
qDebug() << "setEditText" << time;
} else {
// given time is one of the combo items
d->combo->setCurrentIndex(index);
qDebug() << "setCurrentIndex" << index << d->combo->itemData(index);
}
Q_EMIT timeChanged(d->time);
Q_EMIT dateTimeChanged(QDateTime(QDate(), d->time));
}
示例9: searchQuery
QList<int> Database::advanceSearch(const QString &keyword, const QDate &startDate, const QDate &endDate, const QTime &startTime, const QTime &endTime, int group, int domain, const QRectF & geo, const QString & weather )
{
BEGIN_FNC_DEBUG
QString query_str = "SELECT id,ctime,cdate FROM Papers WHERE ";
QHash<QString,QVariant> boundValues;
bool has_previous = false;
if( !keyword.isEmpty() )
{
query_str += "(title LIKE :fkwrd OR text LIKE :skwrd)";
has_previous = true;
}
if( !startDate.isNull() )
{
if( has_previous )
query_str += " AND ";
query_str += "cdate>=:csdate";
boundValues.insert(":csdate",QDate(1,1,1).daysTo(startDate));
has_previous = true;
}
if( !endDate.isNull() )
{
if( has_previous )
query_str += " AND ";
query_str += "cdate<=:cedate";
boundValues.insert(":cedate",QDate(1,1,1).daysTo(endDate));
has_previous = true;
}
if( !startTime.isNull() )
{
if( has_previous )
query_str += " AND ";
query_str += "ctime>=:cstime";
boundValues.insert(":cstime",QTime(0,0,0).secsTo(startTime));
has_previous = true;
}
if( !endTime.isNull() )
{
if( has_previous )
query_str += " AND ";
query_str += "ctime<=:cetime";
boundValues.insert(":cetime",QTime(0,0,0).secsTo(endTime));
has_previous = true;
}
if( group != -1 )
{
if( has_previous )
query_str += " AND ";
query_str += "grp=:grp";
boundValues.insert(":grp",group);
has_previous = true;
}
if( !weather.isEmpty() )
{
if( has_previous )
query_str += " AND ";
query_str += "weather=:wthr";
boundValues.insert(":wthr",weather);
has_previous = true;
}
if( geo.isValid() )
{
if( has_previous )
query_str += " AND ";
query_str += ":llttd<latitude AND latitude<:blttd";
boundValues.insert(":llttd",geo.y());
boundValues.insert(":blttd",geo.y()+geo.height());
query_str += " AND ";
query_str += ":llntd<longitude AND longitude<:blntd";
boundValues.insert(":llntd",geo.x());
boundValues.insert(":blntd",geo.x()+geo.width());
has_previous = true;
}
if( domain != Enums::AllPapers )
{
if( has_previous )
query_str += " AND ";
query_str += "type=:type";
switch( domain )
{
case Enums::NormalPapers:
boundValues.insert(":type",static_cast<int>(Enums::Normal));
break;
case Enums::ToDoPapers:
boundValues.insert(":type",static_cast<int>(Enums::ToDo));
break;
case Enums::UncompletedTasks:
query_str += " AND text LIKE :kwd";
//.........这里部分代码省略.........
示例10: getClockText
QString GameClockView::getClockText(const QTime &time) const
{
if(time.isNull()) return "--:--";
return time.hour()<1 ? time.toString("mm:ss") : time.toString("HH:mm:ss");
}
示例11: batteryChanged
void BatteryWatcher::batteryChanged()
{
static QTime actionTime;
static LxQt::Notification *notification = 0;
qDebug() << "BatteryChanged"
<< "discharging:" << mBattery.discharging()
<< "chargeLevel:" << mBattery.chargeLevel()
<< "powerlow:" << mBattery.powerLow()
<< "actionTime:" << actionTime;
if (mBattery.powerLow() && mSettings.getPowerLowAction() > 0)
{
if (actionTime.isNull())
{
actionTime = QTime::currentTime().addMSecs(mSettings.getPowerLowWarningTime()*1000);
}
if (notification == 0)
{
notification = new LxQt::Notification(tr("Power low!"), this);
notification->setTimeout(2000);
}
int milliSecondsToAction = QTime::currentTime().msecsTo(actionTime);
if (milliSecondsToAction > 0)
{
int secondsToAction = milliSecondsToAction/1000;
switch (mSettings.getPowerLowAction())
{
case LxQt::Power::PowerSuspend:
notification->setBody(tr("Suspending in %1 seconds").arg(secondsToAction));
break;
case LxQt::Power::PowerHibernate:
notification->setBody(tr("Hibernating in %1 seconds").arg(secondsToAction));
break;
case LxQt::Power::PowerShutdown:
notification->setBody(tr("Shutting down in %1 seconds").arg(secondsToAction));
break;
}
notification->update();
QTimer::singleShot(200, this, SLOT(batteryChanged()));
}
else
{
doAction(mSettings.getPowerLowAction());
}
}
else
{
if (!actionTime.isNull())
{
actionTime = QTime();
}
if (notification)
{
delete notification;
notification = 0;
}
}
mBatteryInfo.updateInfo(&mBattery);
if (mSettings.isShowIcon())
mTrayIcon->update(mBattery.discharging(), mBattery.chargeLevel(), mSettings.getPowerLowLevel());
}
示例12: parseDateString
//.........这里部分代码省略.........
int end = 1;
while (end < 5 && dateString.length() > at+end
&& dateString[at + end] >= '0' && dateString[at + end] <= '9')
++end;
int minutes = 0;
int hours = 0;
switch (end - 1) {
case 4:
minutes = atoi(dateString.mid(at + 3, 2).constData());
// fall through
case 2:
hours = atoi(dateString.mid(at + 1, 2).constData());
break;
case 1:
hours = atoi(dateString.mid(at + 1, 1).constData());
break;
default:
at += end;
continue;
}
if (end != 1) {
int sign = dateString[at] == '-' ? -1 : 1;
zoneOffset = sign * ((minutes * 60) + (hours * 60 * 60));
#ifdef PARSEDATESTRINGDEBUG
qDebug() << "Zone offset:" << zoneOffset << hours << minutes;
#endif
at += end;
continue;
}
}
// Time
if (isNum && time.isNull()
&& dateString.length() >= at + 3
&& (dateString[at + 2] == ':' || dateString[at + 1] == ':')) {
// While the date can be found all over the string the format
// for the time is set and a nice regexp can be used.
int pos = timeRx.indexIn(QLatin1String(dateString), at);
if (pos != -1) {
QStringList list = timeRx.capturedTexts();
int h = atoi(list.at(1).toLatin1().constData());
int m = atoi(list.at(2).toLatin1().constData());
int s = atoi(list.at(4).toLatin1().constData());
int ms = atoi(list.at(6).toLatin1().constData());
if (h < 12 && !list.at(9).isEmpty())
if (list.at(9) == QLatin1String("pm"))
h += 12;
time = QTime(h, m, s, ms);
#ifdef PARSEDATESTRINGDEBUG
qDebug() << "Time:" << list << timeRx.matchedLength();
#endif
at += timeRx.matchedLength();
continue;
}
}
// 4 digit Year
if (isNum
&& year == -1
&& dateString.length() >= at + 3) {
if (isNumber(dateString[at + 1])
&& isNumber(dateString[at + 2])
&& isNumber(dateString[at + 3])) {
year = atoi(dateString.mid(at, 4).constData());
at += 4;
示例13: EditCut
void Xport::EditCut()
{
RDCut *cut;
int cart_number;
int cut_number;
QString str;
int num;
QDateTime datetime;
QTime time;
bool rotation_changed=false;
bool length_changed=false;
//
// Verify Post
//
if(!xport_post->getValue("CART_NUMBER",&cart_number)) {
XmlExit("Missing CART_NUMBER",400);
}
if(!xport_post->getValue("CUT_NUMBER",&cut_number)) {
XmlExit("Missing CUT_NUMBER",400);
}
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
}
if(!xport_user->editAudio()) {
XmlExit("Unauthorized",401);
}
//
// Process Request
//
cut=new RDCut(cart_number,cut_number);
if(!cut->exists()) {
delete cut;
XmlExit("No such cut",404);
}
if(xport_post->getValue("EVERGREEN",&num)) {
cut->setEvergreen(num);
rotation_changed=true;
}
if(xport_post->getValue("DESCRIPTION",&str)) {
cut->setDescription(str);
}
if(xport_post->getValue("OUTCUE",&str)) {
cut->setOutcue(str);
}
if(xport_post->getValue("ISRC",&str)) {
cut->setIsrc(str);
}
if(xport_post->getValue("ISCI",&str)) {
cut->setIsci(str);
}
if(xport_post->getValue("START_DATETIME",&datetime)) {
cut->setStartDatetime(datetime,!datetime.isNull());
length_changed=true;
rotation_changed=true;
}
if(xport_post->getValue("END_DATETIME",&datetime)) {
cut->setEndDatetime(datetime,!datetime.isNull());
length_changed=true;
rotation_changed=true;
}
if(xport_post->getValue("MON",&num)) {
cut->setWeekPart(1,num);
rotation_changed=true;
}
if(xport_post->getValue("TUE",&num)) {
cut->setWeekPart(2,num);
rotation_changed=true;
}
if(xport_post->getValue("WED",&num)) {
cut->setWeekPart(3,num);
rotation_changed=true;
}
if(xport_post->getValue("THU",&num)) {
cut->setWeekPart(4,num);
rotation_changed=true;
}
if(xport_post->getValue("FRI",&num)) {
cut->setWeekPart(5,num);
rotation_changed=true;
}
if(xport_post->getValue("SAT",&num)) {
cut->setWeekPart(6,num);
rotation_changed=true;
}
if(xport_post->getValue("SUN",&num)) {
cut->setWeekPart(7,num);
rotation_changed=true;
}
if(xport_post->getValue("START_DAYPART",&time)) {
cut->setStartDaypart(time,!time.isNull());
rotation_changed=true;
}
if(xport_post->getValue("END_DAYPART",&time)) {
cut->setEndDaypart(time,!time.isNull());
//.........这里部分代码省略.........
示例14: nextGameFrame
void Game::nextGameFrame()
{
static float chaseTimer = 0.0;
static QTime lastFrameTime;
if(!lastFrameTime.isNull())
{
chaseTimer += lastFrameTime.msecsTo(QTime::currentTime())/1000.0;
}
lastFrameTime = QTime::currentTime();
Level *level = m_levels.at(m_currentLevel);
// Mouvements
QList<Ghost*> collision;
level->movePacman();
level->moveGhosts();
collision.append(level->checkUnitsPositions());
level->updateTimer();
//
if(level->eatenPellets() == level->pelletCount())
{
m_timer->stop();
m_currentLevel++;
if(m_currentLevel == m_levels.size())
{
m_victory = true;
emit gameFinished();
return;
}
else
{
m_isChangingLevel = true;
m_currentLevelImageReady = false;
Level *level = m_levels.at(m_currentLevel);
level->startLevel();
return;
}
}
if(collision.size() > 0)
{
if(!Ghost::areGhostsScared())
{
m_lifes--;
if(m_lifes>0)
{
level->resetUnitsPosition();
}
else
{
m_defeat = true;
emit gameFinished();
return;
}
m_timer->stop();
}
else
{
for(int i=0; i<collision.size(); i++)
{
m_score += 200 * qPow(2, m_consecutivesEnergizers);
m_consecutivesEnergizers ++;
QTimer::singleShot(500, this, SLOT(resumeGame()));
m_timer->stop();
}
}
}
if(!Ghost::areGhostsScared())
m_consecutivesEnergizers = 0;
QPixmap *image = level->render();
m_image = *image;
delete image;
m_currentLevelImageReady = true;
}
示例15: maybeSendBacktrace
void ServerThread::maybeSendBacktrace()
{
QFile coreFile("core");
if (!coreFile.exists()) {
qDebug() << "No core dump found";
return;
}
char *receiver = getenv("CRASH_REPORT_RECEIVER");
if (!receiver) {
qDebug() << "CRASH_REPORT_RECEIVER environment variable not set";
return;
}
QProcess gdb;
gdb.start(QString("gdb %1 core -q -x print-backtrace.gdb")
.arg(mExecutable));
if (!gdb.waitForStarted()) {
qDebug() << "Failed to launch gdb";
coreFile.remove();
return;
}
if (!gdb.waitForFinished()) {
qDebug() << "gdb process is not finishing, killing";
gdb.kill();
coreFile.remove();
return;
}
coreFile.remove();
const QByteArray gdbOutput = gdb.readAllStandardOutput();
qDebug() << "gdb output:\n" << gdbOutput.constData();
QTime current = QTime::currentTime();
if (!mLastCrash.isNull() && mLastCrash.secsTo(current) < 60 * 10) {
qDebug() << "Sent a crash report less than 10 minutes ago, "
"dropping this one";
return;
}
mLastCrash = current;
QProcess mail;
mail.start(QString("mail -s \"Crash report for %1\" %2")
.arg(mExecutable, QString::fromLocal8Bit(receiver)));
if (!mail.waitForStarted()) {
qDebug() << "Failed to launch mail";
return;
}
mail.write(gdbOutput);
mail.closeWriteChannel();
if (mail.waitForFinished()) {
qDebug() << "Crash report sent to" << receiver;
} else {
qDebug() << "mail process is not finishing, killing";
mail.kill();
}
}