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(); }
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; }
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; } }
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; }
/*! 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; }
/** * @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); }
void ProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindings) { QDateTime progStart = MythDate::current(); QString searchChar = m_alphabetList->GetValue(); if (searchChar.isEmpty()) searchChar = "A"; if (searchChar.contains('@')) { where = "SELECT DISTINCT title FROM program " "LEFT JOIN channel ON program.chanid = channel.chanid " "WHERE channel.visible = 1 AND " "( title NOT REGEXP '^[A-Z0-9]' AND " " title NOT REGEXP '^The [A-Z0-9]' AND " " title NOT REGEXP '^A [A-Z0-9]' AND " " title NOT REGEXP '^An [A-Z0-9]' AND " " starttime > :STARTTIME ) "; if (!m_searchStr.isEmpty()) { where += "AND title LIKE :SEARCH "; bindings[":SEARCH"] = '%' + m_searchStr + '%'; } where += "ORDER BY title;"; bindings[":STARTTIME"] = progStart.addSecs(50 - progStart.time().second()); } else { QString one = searchChar + '%'; QString two = QString("The ") + one; QString three = QString("A ") + one; QString four = QString("An ") + one; where = "SELECT DISTINCT title FROM program " "LEFT JOIN channel ON program.chanid = channel.chanid " "WHERE channel.visible = 1 " "AND ( title LIKE :ONE OR title LIKE :TWO " " OR title LIKE :THREE " " OR title LIKE :FOUR ) " "AND starttime > :STARTTIME "; if (!m_searchStr.isEmpty()) where += "AND title LIKE :SEARCH "; where += "ORDER BY title;"; bindings[":ONE"] = one; bindings[":TWO"] = two; bindings[":THREE"] = three; bindings[":FOUR"] = four; bindings[":STARTTIME"] = progStart.addSecs(50 - progStart.time().second()); if (!m_searchStr.isEmpty()) bindings[":SEARCH"] = '%' + m_searchStr + '%'; } }
void testQDateTime() { QDateTime date; date = QDateTime::currentDateTime(); date = date.addSecs(5); date = date.addSecs(5); date = date.addSecs(5); date = date.addSecs(5); }
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)); }
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 ) ); } }
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(); }
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; }
/*! Finds a free slot in the future which has at least the same size as the initial slot. */ bool KOEditorFreeBusy::findFreeSlot( QDateTime &dtFrom, QDateTime &dtTo ) { if( tryDate( dtFrom, dtTo ) ) // Current time is acceptable return true; QDateTime tryFrom = dtFrom; QDateTime tryTo = dtTo; // Make sure that we never suggest a date in the past, even if the // user originally scheduled the meeting to be in the past. if( tryFrom < QDateTime::currentDateTime() ) { // The slot to look for is at least partially in the past. int secs = tryFrom.secsTo( tryTo ); tryFrom = QDateTime::currentDateTime(); tryTo = tryFrom.addSecs( secs ); } bool found = false; while( !found ) { found = tryDate( tryFrom, tryTo ); // PENDING(kalle) Make the interval configurable if( !found && dtFrom.daysTo( tryFrom ) > 365 ) break; // don't look more than one year in the future } dtFrom = tryFrom; dtTo = tryTo; return found; }
QDateTime GPSDataParser::findPrevDate(const QDateTime& dateTime, int secs) { // We will find the item in GPS data list where the time is // at the maximum smaller than 'secs' mn of the value to match. QDateTime itemFound = dateTime.addSecs((-1)*secs); bool found = false; for (GPSDataMap::ConstIterator it = m_GPSDataMap.constBegin(); it != m_GPSDataMap.constEnd(); ++it ) { if (it.key() < dateTime) { if (it.key() > itemFound) { itemFound = it.key(); found = true; } } } if (found) return itemFound; return QDateTime(); }
bool needsUpdate(GrabberScript* script, uint updateFreq) { QDateTime now = QDateTime::currentDateTime(); QDateTime then = lastUpdate(script); return then.addSecs(updateFreq * 60 * 60) < now; }
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); } }
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; }
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; }
void YandexNarodAuthorizator::onRequestFinished(QNetworkReply *reply) { reply->deleteLater(); if (reply != m_reply.data()) return; QVariantMap data = Json::parse(reply->readAll()).toMap(); QVariantMap::Iterator error = data.find(QLatin1String("error")); if (error != data.end() || reply->error() != QNetworkReply::NoError) { QString errorStr = error.value().toString(); m_stage = Need; if (errorStr == QLatin1String("unsupported_grant_type")) emit result(Error, tr("Unsupported grant type. Inform developers.")); else if (errorStr == QLatin1String("invalid_request")) emit result(Error, tr("Invalid request. Inform developers.")); else emit result(Error, tr("Invalid login or/and password")); return; } QString accessToken = data.value(QLatin1String("access_token")).toString(); QDateTime expiresAt; QVariantMap::Iterator expiresIn = data.find(QLatin1String("expires_in")); if (expiresIn != data.end()) { expiresAt = QDateTime::currentDateTime(); expiresAt.addSecs(expiresIn.value().toInt()); } debug() << accessToken << data; m_token = accessToken; m_stage = Already; emit result(Success); emit needSaveCookies(); }
/*! Alarm time text to display in the viewer. \return QString Holds the alarm time text. */ QString AgendaEventView::alarmTimeText() const { OstTraceFunctionEntry0( AGENDAEVENTVIEW_ALARMTIMETEXT_ENTRY ); QString alarmDateTimeText; QDateTime startTime; QDateTime alarmDateTime; if (mAgendaEntry.type() == AgendaEntry::TypeTodo) { startTime = mAgendaEntry.endTime(); } else { startTime = mAgendaEntry.startTime(); } if (!mAgendaEntry.alarm().isNull()) { int alarmTimeOffsetInMinutes = mAgendaEntry.alarm().timeOffset(); alarmDateTime = startTime.addSecs(-alarmTimeOffsetInMinutes * 60); HbExtendedLocale systemLocale = HbExtendedLocale::system(); alarmDateTimeText.append(systemLocale.format(alarmDateTime.time(), r_qtn_time_usual_with_zero)); // Show the alarm date only if its not on the same day of the entry if (!CalenDateUtils::onSameDay(alarmDateTime, startTime)) { alarmDateTimeText.append(CHARACTER_SPACE); alarmDateTimeText.append(systemLocale.format(alarmDateTime.date(), r_qtn_date_usual_with_zero)); } } OstTraceFunctionExit0( AGENDAEVENTVIEW_ALARMTIMETEXT_EXIT ); return alarmDateTimeText; }
void SatellitesMSCItem::update() { if( m_missionStart.isValid() ) { setVisible( ( m_clock->dateTime() > m_missionStart ) ); } if( m_missionEnd.isValid() ) { setVisible( ( m_clock->dateTime() < m_missionEnd ) ); } if( !isEnabled() || !isVisible() ) { return; } double period = 24 * 3600 / m_n0; QDateTime startTime = m_clock->dateTime().addSecs( - period / 2. ); QDateTime endTime = startTime.addSecs( period ); m_track->removeBefore( startTime ); m_track->removeAfter( endTime ); double step = period / 500.; // FIXME update track only if orbit is visible for( double i = startTime.toTime_t(); i < endTime.toTime_t(); i += step ) { if ( i >= m_track->firstWhen().toTime_t() ) { i = m_track->lastWhen().toTime_t() + step; } addTrackPointAt( QDateTime::fromTime_t( i ) ); } addTrackPointAt( m_clock->dateTime() ); }
//#### Why is this code duplicated in getEffectiveEvents ????? //#### Addendum. Don't use this function, lets faze it out if we can. QValueList<Event> DateBookDB::getEvents( const QDate &from, const QDate &to ) { QValueList<Event> tmpList; tmpList = getNonRepeatingEvents( from, to ); // check for repeating events... for (QValueList<Event>::ConstIterator it = repeatEvents.begin(); it != repeatEvents.end(); ++it) { QDate itDate = from; QDateTime due; /* create a false end date, to short circuit on hard MonthlyDay recurences */ Event dummy_event = *it; Event::RepeatPattern r = dummy_event.repeatPattern(); if ( !r.hasEndDate || r.endDate() > to ) { r.setEndDate( to ); r.hasEndDate = TRUE; } dummy_event.setRepeat(TRUE, r); while (nextOccurance(dummy_event, itDate, due)) { if (due.date() > to) break; Event newEvent = *it; newEvent.setStart(due); newEvent.setEnd(due.addSecs((*it).start().secsTo((*it).end()))); tmpList.append(newEvent); itDate = due.date().addDays(1); /* the next event */ } } qHeapSort(tmpList); return tmpList; }
uint32_t FileCache::queryPath ( const QString& path, int timeToLive ) { kDebug(KIO_MTP) << "Querying" << path; QPair< QDateTime, uint32_t > item = cache.value ( path ); if ( item.second != 0 ) { QDateTime dateTime = QDateTime::currentDateTime(); if ( item.first > dateTime ) { kDebug(KIO_MTP) << "Found item with ttl:" << item.first << "- now:" << dateTime; item.first = dateTime.addSecs ( timeToLive ); kDebug(KIO_MTP) << "Reset item ttl:" << item.first; cache.insert ( path, item ); return item.second; } else { kDebug(KIO_MTP) << "Item too old (" << item.first << "), removed. Current Time: " << dateTime; cache.remove( path ); return 0; } } return 0; }
int KTimeZoneDataPrivate::transitionIndex(const QDateTime &dt) const { // Do a binary search to find the last transition before this date/time int start = -1; int end = transitions.count(); if (dt.timeSpec() == Qt::UTC) { while (end - start > 1) { int i = (start + end) / 2; if (dt < transitions[i].time()) end = i; else start = i; } } else { QDateTime dtutc = dt; dtutc.setTimeSpec(Qt::UTC); while (end - start > 1) { const int i = (start + end) / 2; if (dtutc.addSecs(-transitions[i].phase().utcOffset()) < transitions[i].time()) end = i; else start = i; } } return end ? start : -1; }
/*! Checks whether the slot specified by (tryFrom, tryTo) is available for the participant specified with attendee. If yes, return true. If not, return false and change (tryFrom, tryTo) to contain the next possible slot for this participant (not necessarily a slot that is available for all participants). */ bool KOEditorFreeBusy::tryDate( FreeBusyItem *attendee, QDateTime &tryFrom, QDateTime &tryTo ) { // If we don't have any free/busy information, assume the // participant is free. Otherwise a participant without available // information would block the whole allocation. KCal::FreeBusy *fb = attendee->freeBusy(); if( !fb ) return true; QValueList<KCal::Period> busyPeriods = fb->busyPeriods(); for( QValueList<KCal::Period>::Iterator it = busyPeriods.begin(); it != busyPeriods.end(); ++it ) { if( (*it).end() <= tryFrom || // busy period ends before try period (*it).start() >= tryTo ) // busy period starts after try period continue; else { // the current busy period blocks the try period, try // after the end of the current busy period int secsDuration = tryFrom.secsTo( tryTo ); tryFrom = (*it).end(); tryTo = tryFrom.addSecs( secsDuration ); // try again with the new try period tryDate( attendee, tryFrom, tryTo ); // we had to change the date at least once return false; } } return true; }
bool Control::checkDurationValid_4() { QDateTime start = ui->startDateTimeEdit_4->dateTime(); start = start.addSecs(3600); QDateTime end = ui->endDateTimeEdit_4->dateTime(); return start <= end; }
// search title_pronounce // we hope japanese HIRAGANA and alphabets, numerics is inserted // these character must required ZENKAKU // because query work not fine, if mysql's default charset latin1 void JaProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindings) { QDateTime progStart = MythDate::current(); int charNum = m_alphabetList->GetCurrentPos(); where = "SELECT DISTINCT title FROM program " "LEFT JOIN channel ON program.chanid = channel.chanid " "WHERE channel.visible = 1 "; switch (charNum) { case 0: where += "AND ( title_pronounce >= 'あ' AND title_pronounce <= 'お') "; break; case 1: where += "AND ( title_pronounce >= 'か' AND title_pronounce <= 'ご') "; break; case 2: where += "AND ( title_pronounce >= 'さ' AND title_pronounce <= 'そ') "; break; case 3: where += "AND ( title_pronounce >= 'た' AND title_pronounce <= 'ど') "; break; case 4: where += "AND ( title_pronounce >= 'な' AND title_pronounce <= 'の') "; break; case 5: where += "AND ( title_pronounce >= 'は' AND title_pronounce <= 'ぽ') "; break; case 6: where += "AND ( title_pronounce >= 'ま' AND title_pronounce <= 'も') "; break; case 7: where += "AND ( title_pronounce >= 'や' AND title_pronounce <= 'よ') "; break; case 8: where += "AND ( title_pronounce >= 'ら' AND title_pronounce <= 'ろ') "; break; case 9: where += "AND ( title_pronounce >= 'わ' AND title_pronounce <= 'ん') "; break; case 10: where += "AND ( title_pronounce >= 'A' AND title_pronounce <= 'z') "; break; case 11: where += "AND ( title_pronounce >= '0' AND title_pronounce <= '9') "; break; } where += "AND starttime > :STARTTIME "; if (!m_searchStr.isEmpty()) { where += "AND title_pronounce LIKE :SEARCH "; bindings[":SEARCH"] = '%' + m_searchStr + '%'; } where += "ORDER BY title_pronounce;"; bindings[":STARTTIME"] = progStart.addSecs(50 - progStart.time().second()); }
void EventEditTest::shouldHaveDefaultValuesOnCreation() { MessageViewer::EventEdit edit; QVERIFY(edit.collection().isValid()); QVERIFY(!edit.message()); QLineEdit *eventedit = edit.findChild<QLineEdit *>(QStringLiteral("eventedit")); QVERIFY(eventedit); QCOMPARE(eventedit->text(), QString()); QPushButton *openEditor = edit.findChild<QPushButton *>(QStringLiteral("open-editor-button")); QPushButton *save = edit.findChild<QPushButton *>(QStringLiteral("save-button")); QVERIFY(openEditor); QVERIFY(save); QCOMPARE(openEditor->isEnabled(), false); QCOMPARE(save->isEnabled(), false); QDateTime currentDateTime = QDateTime::currentDateTime(); MessageViewer::EventDateTimeWidget *startDateTime = edit.findChild<MessageViewer::EventDateTimeWidget *>(QStringLiteral("startdatetimeedit")); QVERIFY(startDateTime); QCOMPARE(startDateTime->dateTime().date(), currentDateTime.date()); QCOMPARE(startDateTime->dateTime().time().hour(), currentDateTime.time().hour()); QCOMPARE(startDateTime->dateTime().time().minute(), currentDateTime.time().minute()); MessageViewer::EventDateTimeWidget *endDateTime = edit.findChild<MessageViewer::EventDateTimeWidget *>(QStringLiteral("enddatetimeedit")); QVERIFY(endDateTime); currentDateTime = currentDateTime.addSecs(3600); // +1hour QCOMPARE(endDateTime->dateTime().date(), currentDateTime.date()); QCOMPARE(endDateTime->dateTime().time().hour(), currentDateTime.time().hour()); QCOMPARE(endDateTime->dateTime().time().minute(), currentDateTime.time().minute()); }
void EITHelper::CompleteEvent(uint atsc_major, uint atsc_minor, const ATSCEvent &event, const QString &ett) { uint chanid = GetChanID(atsc_major, atsc_minor); if (!chanid) return; QDateTime starttime = MythDate::fromTime_t( event.start_time + GPS_EPOCH + gps_offset); // fix starttime only if the duration is a multiple of a minute if (!(event.length % 60)) EITFixUp::TimeFix(starttime); QDateTime endtime = starttime.addSecs(event.length); desc_list_t list = MPEGDescriptor::Parse(event.desc, event.desc_length); unsigned char subtitle_type = MPEGDescriptor::Find(list, DescriptorID::caption_service) ? SUB_HARDHEAR : SUB_UNKNOWN; unsigned char audio_properties = AUD_UNKNOWN; unsigned char video_properties = VID_UNKNOWN; uint atsc_key = (atsc_major << 16) | atsc_minor; QMutexLocker locker(&eitList_lock); QString title = event.title; QString subtitle = ett; db_events.enqueue(new DBEventEIT(chanid, title, subtitle, starttime, endtime, fixup.value(atsc_key), subtitle_type, audio_properties, video_properties)); }
void DateVariable::update() { QDateTime target; switch (m_type) { case Fixed: target = m_time; break; case AutoUpdate: target = QDateTime::currentDateTime(); break; } target = target.addSecs(m_secsOffset); target = target.addDays(m_daysOffset); target = target.addMonths(m_monthsOffset); target = target.addYears(m_yearsOffset); switch (m_displayType) { case Custom: setValue(target.toString(m_definition)); break; case Time: setValue(target.time().toString(Qt::LocalDate)); break; case Date: setValue(target.date().toString(Qt::LocalDate)); break; } }