本文整理汇总了C++中QDateTime::date方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTime::date方法的具体用法?C++ QDateTime::date怎么用?C++ QDateTime::date使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::date方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setContextSMS
void MainWindow::setContextSMS()
{
QDateTime dateTime;
QString nullStr = "";
smsTxt = "";
//if(this->ui->smsTab->currentTabText EQ )
int index = this->ui->smsTab->currentIndex();
if(index EQ SET_SMS_INDEX)
{
smsTxt += "#@";
smsTxt += num2str(this->ui->spinBox->value(), 2) + "0";
smsTxt.append(index2asc(ui->comboBox->currentIndex())); //进入特效
smsTxt.append(index2asc(ui->comboBox_2->currentIndex())); //退出特效
smsTxt.append(index2asc(ui->comboBox_4->currentIndex())); //特效速度
int stayTime = ui->spinBox_5->value();
if(stayTime < 10)
smsTxt.append(index2asc(stayTime)); //停留时间
else if(stayTime < 10 + 26 * 5)
smsTxt.append((stayTime - 10) / 5 + 'a');
else if(stayTime < 140 + 26 * 5)
smsTxt.append((stayTime - 140) / 5 + 'A');
else
smsTxt.append("10");
smsTxt.append(index2asc(ui->comboBox_5->currentIndex())); //字体大小
smsTxt.append(index2asc(ui->comboBox_7->currentIndex() + 1)); //颜色
smsTxt.append(borderIndex2asc(ui->comboBox_3->currentIndex())); //边框特效
smsTxt.append('+'); //颜色
if(ui->textEdit_2->toPlainText().size() EQ 0)
{
nullStr = tr("(注意:显示内容为空)");
//QMessageBox::information(0, QObject::tr("提示"),QObject::tr("增加的显示内容为空!"));
}
smsTxt.append(ui->textEdit_2->toPlainText()); //颜色
}
else if(index EQ ADD_SMS_INDEX) //追加短信
{
smsTxt += "#@";
smsTxt += num2str(this->ui->spinBox_2->value(), 2);// + "0";
smsTxt += num2str(this->ui->comboBox_8->currentIndex() + 1, 1);
smsTxt.append('+'); //颜色
if(ui->textEdit_3->toPlainText().size() EQ 0)
{
nullStr = tr("(注意:显示内容为空)");
//QMessageBox::information(0, QObject::tr("提示"),QObject::tr("追加的显示内容为空!"));
}
smsTxt.append(ui->textEdit_3->toPlainText()); //颜色
}
else if(index EQ DEL_SMS_INDEX) //删除短信
{
smsTxt += "#DEL";
smsTxt += num2str(this->ui->spinBox_3->value(), 2);// + "0";
}
else if(index EQ RD_SMS_IDEX) //读取短信内容
{
smsTxt += "[email protected]";
smsTxt += num2str(this->ui->spinBox_4->value(), 2);// + "0";
if(ui->groupBox->isChecked())
smsTxt += num2str(this->ui->comboBox_6->currentIndex() + 1, 1);
else
smsTxt += '0';
}
else if(index EQ ADJ_TIME_INDEX) //校准时间
{
//CadjTimeProperty::getDateTime()
if(ui->radioButton->isChecked())
{
dateTime = QDateTime::currentDateTime();
}
else
{
dateTime = ui->dateTimeEdit->dateTime();
}
smsTxt += "#TIM";
smsTxt.append(num2str(dateTime.date().year() - 2000, 2));
smsTxt.append(num2str(dateTime.date().month(), 2));
smsTxt.append(num2str(dateTime.date().day(), 2));
smsTxt.append(num2str(dateTime.time().hour(), 2));
smsTxt.append(num2str(dateTime.time().minute(), 2));
smsTxt.append(num2str(dateTime.time().second(), 2));
int week = dateTime.date().dayOfWeek();
if(week EQ 7)
week = 0;
smsTxt.append(num2str(week, 1));
}
else if(index EQ CALL_SMS_INDEX)
{
smsTxt += "#@";
//.........这里部分代码省略.........
示例2: computeRollOverTime
void RollingFileAppender::computeRollOverTime()
{
Q_ASSERT_X(!m_datePatternString.isEmpty(), "DailyRollingFileAppender::computeRollOverTime()", "No active date pattern");
QDateTime now = QDateTime::currentDateTime();
QDate nowDate = now.date();
QTime nowTime = now.time();
QDateTime start;
switch (m_frequency)
{
case MinutelyRollover:
{
start = QDateTime(nowDate, QTime(nowTime.hour(), nowTime.minute(), 0, 0));
m_rollOverTime = start.addSecs(60);
}
break;
case HourlyRollover:
{
start = QDateTime(nowDate, QTime(nowTime.hour(), 0, 0, 0));
m_rollOverTime = start.addSecs(60*60);
}
break;
case HalfDailyRollover:
{
int hour = nowTime.hour();
if (hour >= 12)
hour = 12;
else
hour = 0;
start = QDateTime(nowDate, QTime(hour, 0, 0, 0));
m_rollOverTime = start.addSecs(60*60*12);
}
break;
case DailyRollover:
{
start = QDateTime(nowDate, QTime(0, 0, 0, 0));
m_rollOverTime = start.addDays(1);
}
break;
case WeeklyRollover:
{
// Qt numbers the week days 1..7. The week starts on Monday.
// Change it to being numbered 0..6, starting with Sunday.
int day = nowDate.dayOfWeek();
if (day == Qt::Sunday)
day = 0;
start = QDateTime(nowDate, QTime(0, 0, 0, 0)).addDays(-1 * day);
m_rollOverTime = start.addDays(7);
}
break;
case MonthlyRollover:
{
start = QDateTime(QDate(nowDate.year(), nowDate.month(), 1), QTime(0, 0, 0, 0));
m_rollOverTime = start.addMonths(1);
}
break;
default:
Q_ASSERT_X(false, "DailyRollingFileAppender::computeInterval()", "Invalid datePattern constant");
m_rollOverTime = QDateTime::fromTime_t(0);
}
m_rollOverSuffix = start.toString(m_datePatternString);
Q_ASSERT_X(now.toString(m_datePatternString) == m_rollOverSuffix,
"DailyRollingFileAppender::computeRollOverTime()", "File name changes within interval");
Q_ASSERT_X(m_rollOverSuffix != m_rollOverTime.toString(m_datePatternString),
"DailyRollingFileAppender::computeRollOverTime()", "File name does not change with rollover");
}
示例3: ComponentEditDialog
TodoEditDialog::TodoEditDialog(QWidget *parent, CTodo *todo) :
ComponentEditDialog(parent),
ui(new Ui::TodoEditDialog),
saveDue(true)
{
ui->setupUi(this);
if (todo && !todo->getId().empty()) {
todo = CWrapper::details(todo);
this->setWindowTitle(tr("Edit task"));
this->setupDeleteButton(ui->buttonBox, SLOT(deleteTodo()));
} else {
this->setWindowTitle(tr("New task"));
}
QSettings settings;
// Set up date picker
DatePickSelector *dps = new DatePickSelector();
ui->dateButton->setPickSelector(dps);
// Set up time zone picker
ZonePickSelector *zps;
if (settings.value("TimeZones", false).toBool()) {
zps = new ZonePickSelector();
ui->zoneButton->setPickSelector(zps);
} else {
zps = NULL;
ui->zoneButton->hide();
}
// Set up calendar picker
CalendarPickSelector *cps = new CalendarPickSelector();
ui->calendarButton->setPickSelector(cps);
// Set up alarm picker
AlarmPickSelector *aps = new AlarmPickSelector(E_AM_EXACTDATETIME);
ui->alarmButton->setPickSelector(aps);
// Make sure that AlarmPickSelector's reference date is set
onDateChanged();
connect(dps, SIGNAL(selected(QString)), this, SLOT(onDateChanged()));
if (todo) {
// Do not change the default settings when editing an existing todo
saveDefaults = false;
// Configure time
QString zone;
QDateTime due;
if (zps) {
// Display time in the selected time zone
zone = todo->getTzid().c_str();
due = Date::toRemote(todo->getDue(), zone);
zps->setCurrentZone(todo->getTzid().c_str());
} else {
// Display local time
due = QDateTime::fromTime_t(todo->getDue());
}
ui->summaryEdit->setText(QString::fromUtf8(todo->getSummary().c_str()));
ui->descriptionEdit->setPlainText(QString::fromUtf8(todo->getDescription().c_str()));
ui->doneBox->setChecked(todo->getStatus());
dps->setCurrentDate(due.date());
cps->setCalendar(todo->getCalendarId());
aps->setAlarm(todo->getAlarm(), zone);
} else {
todo = new CTodo();
saveDefaults = true;
// Load last used settings
settings.beginGroup("TodoEditDialog");
cps->setCalendar(settings.value("Calendar", 1).toInt());
aps->setSecondsBefore(settings.value("Alarm", -1).toInt());
// Prepre to calculate the due date
const time_t dueOffset = settings.value("DueOffset", 0).toInt() * 24*60*60;
time_t currentStamp = QDateTime::currentDateTime().toTime_t();
QDateTime due;
// Some additional processing for time zones
if (zps) {
const QString zone = settings.value("TimeZone", QString()).toString();
if (!zone.isEmpty()) {
// Display time in the selected time zone
currentStamp = Date::toRemote(currentStamp, zone).toTime_t();
// Load last used setting
zps->setCurrentZone(zone);
}
}
// Calculate the due date in an under/overflow-proof way
if (dueOffset > 0) {
due = QDateTime::fromTime_t(currentStamp > std::numeric_limits<time_t>::max() - dueOffset
? std::numeric_limits<time_t>::max()
: currentStamp + dueOffset);
//.........这里部分代码省略.........
示例4: qwtDivideToYears
static QwtScaleDiv qwtDivideToYears(
const QDateTime &minDate, const QDateTime &maxDate,
double stepSize, int maxMinSteps )
{
QList<double> majorTicks;
QList<double> mediumTicks;
QList<double> minorTicks;
double minStepSize = 0.0;
if ( maxMinSteps > 1 )
{
minStepSize = qwtDivideMajorStep(
stepSize, maxMinSteps, QwtDate::Year );
}
int numMinorSteps = 0;
if ( minStepSize > 0.0 )
numMinorSteps = qwtFloor( stepSize / minStepSize );
bool dateBC = minDate.date().year() < -1;
for ( QDateTime dt = minDate; dt <= maxDate;
dt = dt.addYears( stepSize ) )
{
if ( dateBC && dt.date().year() > 1 )
{
// there is no year 0 in the Julian calendar
dt = dt.addYears( -1 );
dateBC = false;
}
if ( !dt.isValid() )
break;
majorTicks += QwtDate::toDouble( dt );
for ( int i = 1; i < numMinorSteps; i++ )
{
QDateTime tickDate;
const double years = qRound( i * minStepSize );
if ( years >= std::numeric_limits<int>::max() / 12 )
{
tickDate = dt.addYears( years );
}
else
{
tickDate = dt.addMonths( qRound( years * 12 ) );
}
const bool isMedium = ( numMinorSteps > 2 ) &&
( numMinorSteps % 2 == 0 ) && ( i == numMinorSteps / 2 );
const double minorValue = QwtDate::toDouble( tickDate );
if ( isMedium )
mediumTicks += minorValue;
else
minorTicks += minorValue;
}
if ( QwtDate::maxDate().addYears( -stepSize ) < dt.date() )
{
break;
}
}
QwtScaleDiv scaleDiv;
scaleDiv.setInterval( QwtDate::toDouble( minDate ),
QwtDate::toDouble( maxDate ) );
scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks );
scaleDiv.setTicks( QwtScaleDiv::MediumTick, mediumTicks );
scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks );
return scaleDiv;
}
示例5: setSunRiseAndSetVectors
void MainWindow::setSunRiseAndSetVectors(const QDateTime &dateTime)
{
struct ln_equ_posn equ;
struct ln_rst_time rst;
struct ln_zonedate rise, set, transit;
struct ln_lnlat_posn observer;
struct ln_hrz_posn hpos;
double JD;
observer.lat = ui->latEdit->text().toFloat();
observer.lng = ui->lngEdit->text().toFloat();
ln_date date;
date.years = dateTime.date().year();
date.months = dateTime.date().month();
date.days = dateTime.date().day();
date.hours = dateTime.time().hour();
date.minutes = dateTime.time().minute();
date.seconds = dateTime.time().second();
JD = ln_get_julian_day(&date);
/* ra, dec */
ln_get_solar_equ_coords (JD, &equ);
ln_get_hrz_from_equ(&equ, &observer, JD, &hpos);
double a = ln_range_degrees(hpos.az - 180);
QString s;
s.sprintf("Azimut: %0.3f", a);
ui->listWidget->addItem(s);
s.sprintf("Evaluation: %0.3f", hpos.alt);
ui->listWidget->addItem(s);
/* rise, set and transit */
if (ln_get_solar_rst (JD, &observer, &rst) == 1) {
ui->listWidget->addItem(QString("Zirkumpolar"));
} else {
ln_get_local_date (rst.rise, &rise);
ln_get_local_date (rst.transit, &transit);
ln_get_local_date (rst.set, &set);
s.sprintf("Aufgang: %02d:%02d:%02d", rise.hours, rise.minutes, (int)rise.seconds);
ui->listWidget->addItem(s);
s.sprintf("Transit: %02d:%02d:%02d", transit.hours, transit.minutes, (int)transit.seconds);
ui->listWidget->addItem(s);
s.sprintf("Untergang: %02d:%02d:%02d", set.hours, set.minutes, (int)set.seconds);
ui->listWidget->addItem(s);
}
//sunHeading->setVisible(false);
setSunVectors(&rise, &observer, sunRise);
setSunVectors(&set, &observer, sunSet);
mc->setView(QPointF(observer.lng, observer.lat));
//overlay->addGeometry();
}
示例6: applySimpleProperty
//.........这里部分代码省略.........
DomString *s = new DomString();
s->setText(qvariant_cast<QKeySequence>(v).toString(QKeySequence::PortableText));
dom_prop->setElementString(s);
}
return true;
case QVariant::Locale: {
DomLocale *dom = new DomLocale();
const QLocale locale = qvariant_cast<QLocale>(v);
const QMetaEnum language_enum = metaEnum<QAbstractFormBuilderGadget>("language");
const QMetaEnum country_enum = metaEnum<QAbstractFormBuilderGadget>("country");
dom->setAttributeLanguage(QLatin1String(language_enum.valueToKey(locale.language())));
dom->setAttributeCountry(QLatin1String(country_enum.valueToKey(locale.country())));
dom_prop->setElementLocale(dom);
}
return true;
case QVariant::SizePolicy: {
DomSizePolicy *dom = new DomSizePolicy();
const QSizePolicy sizePolicy = qvariant_cast<QSizePolicy>(v);
dom->setElementHorStretch(sizePolicy.horizontalStretch());
dom->setElementVerStretch(sizePolicy.verticalStretch());
const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");
dom->setAttributeHSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy())));
dom->setAttributeVSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.verticalPolicy())));
dom_prop->setElementSizePolicy(dom);
}
return true;
case QVariant::Date: {
DomDate *dom = new DomDate();
const QDate date = qvariant_cast<QDate>(v);
dom->setElementYear(date.year());
dom->setElementMonth(date.month());
dom->setElementDay(date.day());
dom_prop->setElementDate(dom);
}
return true;
case QVariant::Time: {
DomTime *dom = new DomTime();
const QTime time = qvariant_cast<QTime>(v);
dom->setElementHour(time.hour());
dom->setElementMinute(time.minute());
dom->setElementSecond(time.second());
dom_prop->setElementTime(dom);
}
return true;
case QVariant::DateTime: {
DomDateTime *dom = new DomDateTime();
const QDateTime dateTime = qvariant_cast<QDateTime>(v);
dom->setElementHour(dateTime.time().hour());
dom->setElementMinute(dateTime.time().minute());
dom->setElementSecond(dateTime.time().second());
dom->setElementYear(dateTime.date().year());
dom->setElementMonth(dateTime.date().month());
dom->setElementDay(dateTime.date().day());
dom_prop->setElementDateTime(dom);
}
return true;
case QVariant::Url: {
DomUrl *dom = new DomUrl();
const QUrl url = v.toUrl();
DomString *str = new DomString();
str->setText(url.toString());
dom->setElementString(str);
dom_prop->setElementUrl(dom);
}
return true;
case QVariant::StringList: {
DomStringList *sl = new DomStringList;
sl->setElementString(qvariant_cast<QStringList>(v));
dom_prop->setElementStringList(sl);
}
return true;
default:
break;
}
return false;
}
示例7: alignDate
/*!
Align a date/time value for a step size
For Qt::Day alignments there is no "natural day 0" -
instead the first day of the year is used to avoid jumping
major ticks positions when panning a scale. For other alignments
( f.e according to the first day of the month ) alignDate()
has to be overloaded.
\param dateTime Date/time value
\param stepSize Step size
\param intervalType Interval type
\param up When true dateTime is ceiled - otherwise it is floored
\return Aligned date/time value
*/
QDateTime QwtDateScaleEngine::alignDate(
const QDateTime &dateTime, double stepSize,
QwtDate::IntervalType intervalType, bool up ) const
{
// what about: (year == 1582 && month == 10 && day > 4 && day < 15) ??
QDateTime dt = dateTime;
if ( dateTime.timeSpec() == Qt::OffsetFromUTC )
{
dt.setUtcOffset( 0 );
}
switch( intervalType )
{
case QwtDate::Millisecond:
{
const int ms = qwtAlignValue(
dt.time().msec(), stepSize, up ) ;
dt = QwtDate::floor( dateTime, QwtDate::Second );
dt = dt.addMSecs( ms );
break;
}
case QwtDate::Second:
{
int second = dt.time().second();
if ( up )
{
if ( dt.time().msec() > 0 )
second++;
}
const int s = qwtAlignValue( second, stepSize, up );
dt = QwtDate::floor( dt, QwtDate::Minute );
dt = dt.addSecs( s );
break;
}
case QwtDate::Minute:
{
int minute = dt.time().minute();
if ( up )
{
if ( dt.time().msec() > 0 || dt.time().second() > 0 )
minute++;
}
const int m = qwtAlignValue( minute, stepSize, up );
dt = QwtDate::floor( dt, QwtDate::Hour );
dt = dt.addSecs( m * 60 );
break;
}
case QwtDate::Hour:
{
int hour = dt.time().hour();
if ( up )
{
if ( dt.time().msec() > 0 || dt.time().second() > 0
|| dt.time().minute() > 0 )
{
hour++;
}
}
const int h = qwtAlignValue( hour, stepSize, up );
dt = QwtDate::floor( dt, QwtDate::Day );
dt = dt.addSecs( h * 3600 );
break;
}
case QwtDate::Day:
{
// What date do we expect f.e. from an alignment of 5 days ??
// Aligning them to the beginning of the year avoids at least
// jumping major ticks when panning
int day = dt.date().dayOfYear();
if ( up )
{
//.........这里部分代码省略.........
示例8: evaluate
QString CustomEdit::evaluate(QString clause)
{
int e0=0;
while (true) {
int s0 = clause.indexOf (QRegExp("\\{[A-Z]+\\}"), e0);
if (s0 < 0)
break;
e0 = clause.indexOf ("}", s0);
QString mid = clause.mid(s0 + 1, e0 - s0 - 1);
QString repl = "";
if (!mid.compare("TITLE")) {
repl = m_pginfo->GetTitle();
repl.replace("\'","\'\'");
} else if (!mid.compare("SUBTITLE")) {
repl = m_pginfo->GetSubtitle();
repl.replace("\'","\'\'");
} else if (!mid.compare("DESCR")) {
repl = m_pginfo->GetDescription();
repl.replace("\'","\'\'");
} else if (!mid.compare("SERIESID")) {
repl = QString("%1").arg(m_pginfo->GetSeriesID());
} else if (!mid.compare("PROGID")) {
repl = m_pginfo->GetProgramID();
} else if (!mid.compare("SEASON")) {
repl = QString::number(m_pginfo->GetSeason());
} else if (!mid.compare("EPISODE")) {
repl = QString::number(m_pginfo->GetEpisode());
} else if (!mid.compare("CATEGORY")) {
repl = m_pginfo->GetCategory();
} else if (!mid.compare("CHANID")) {
repl = QString("%1").arg(m_pginfo->GetChanID());
} else if (!mid.compare("CHANNUM")) {
repl = m_pginfo->GetChanNum();
} else if (!mid.compare("SCHEDID")) {
repl = m_pginfo->GetChannelSchedulingID();
} else if (!mid.compare("CHANNAME")) {
repl = m_pginfo->GetChannelName();
} else if (!mid.compare("DAYNAME")) {
repl = m_pginfo->GetScheduledStartTime().toString("dddd");
} else if (!mid.compare("STARTDATE")) {
repl = m_pginfo->GetScheduledStartTime().toString("yyyy-mm-dd hh:mm:ss");
} else if (!mid.compare("ENDDATE")) {
repl = m_pginfo->GetScheduledEndTime().toString("yyyy-mm-dd hh:mm:ss");
} else if (!mid.compare("STARTTIME")) {
repl = m_pginfo->GetScheduledStartTime().toString("hh:mm");
} else if (!mid.compare("ENDTIME")) {
repl = m_pginfo->GetScheduledEndTime().toString("hh:mm");
} else if (!mid.compare("STARTSEC")) {
QDateTime date = m_pginfo->GetScheduledStartTime();
QDateTime midnight = QDateTime(date.date());
repl = QString("%1").arg(midnight.secsTo(date));
} else if (!mid.compare("ENDSEC")) {
QDateTime date = m_pginfo->GetScheduledEndTime();
QDateTime midnight = QDateTime(date.date());
repl = QString("%1").arg(midnight.secsTo(date));
}
// unknown tags are simply removed
clause.replace(s0, e0 - s0 + 1, repl);
}
return clause;
}
示例9: SetLastModified
bool AssetCache::SetLastModified(const QString &assetRef, const QDateTime &dateTime)
{
if (!dateTime.isValid())
{
LogError("AssetCache::SetLastModified() DateTime is invalid: " + assetRef);
return false;
}
QString absolutePath = FindInCache(assetRef);
if (absolutePath.isEmpty())
return false;
QDate date = dateTime.date();
QTime time = dateTime.time();
#ifdef Q_WS_WIN
HANDLE fileHandle = (HANDLE)OpenFileHandle(absolutePath);
if (fileHandle == INVALID_HANDLE_VALUE)
{
LogError("AssetCache: Failed to open cache file to update last modified time: " + assetRef);
return false;
}
// Notes: For SYSTEMTIME Sunday is 0 and ignore msec.
SYSTEMTIME sysTime;
sysTime.wDay = (WORD)date.day();
sysTime.wDayOfWeek = (WORD)date.dayOfWeek();
if (sysTime.wDayOfWeek == 7)
sysTime.wDayOfWeek = 0;
sysTime.wMonth = (WORD)date.month();
sysTime.wYear = (WORD)date.year();
sysTime.wHour = (WORD)time.hour();
sysTime.wMinute = (WORD)time.minute();
sysTime.wSecond = (WORD)time.second();
sysTime.wMilliseconds = 0;
// Set last write time
FILETIME fileTime;
BOOL success = SystemTimeToFileTime(&sysTime, &fileTime);
if (success)
success = SetFileTime(fileHandle, 0, 0, &fileTime);
CloseHandle(fileHandle);
if (!success)
{
LogError("AssetCache: Failed to update cache file last modified time: " + assetRef);
return false;
}
return true;
#else
QString nativePath = QDir::toNativeSeparators(absolutePath);
utimbuf modTime;
modTime.actime = (time_t)(dateTime.toMSecsSinceEpoch() / 1000);
modTime.modtime = (time_t)(dateTime.toMSecsSinceEpoch() / 1000);
if (utime(nativePath.toStdString().c_str(), &modTime) == -1)
{
LogError("AssetCache: Failed to read cache file last modified time: " + assetRef);
return false;
}
else
return true;
#endif
}
示例10: setupStartTime
void DivePlannerWidget::setupStartTime(QDateTime startTime)
{
ui.startTime->setTime(startTime.time());
ui.dateEdit->setDate(startTime.date());
}
示例11: updateEndDate
void EntryDialog::updateEndDate(const QDateTime & startDate)
{
ui->endDate->setMinimumDate( startDate.date() );
ui->endDate->setMinimumTime( startDate.time() );
}
示例12: createAutoHistoryUrls
void Yahoo::createAutoHistoryUrls (QString &path, QString &d)
{
if (plug.open(path, chartIndex))
{
qDebug("Yahoo::createAutoHistoryUrls:could not open db");
return;
}
QFileInfo fi(path);
QString fn = fi.fileName();
// verify if this chart can be updated by this plugin
QString s;
DBIndexItem item;
chartIndex->getIndexItem(fn, item);
item.getQuotePlugin(s);
if (! s.length())
{
item.setQuotePlugin(pluginName);
chartIndex->setIndexItem(fn, item);
}
// else
// {
// if (s.compare(pluginName))
// {
// qDebug("Yahoo::createAutoHistoryUrls:source not same as destination");
// plug.close();
// return;
// }
// }
QDate edt = QDate::currentDate();
if (edt.dayOfWeek() == 6)
edt = edt.addDays(-1);
else
{
if (edt.dayOfWeek() == 7)
edt = edt.addDays(-2);
}
Bar bar;
plug.getLastBar(bar);
if (bar.getEmptyFlag())
{
QDate dt = edt;
dt = dt.addDays(-365);
s = dt.toString("yyyyMMdd000000");
bar.setDate(s);
}
QDateTime dt;
bar.getDate(dt);
if (dt.date() == edt)
{
// qDebug("Yahoo::createAutoHistoryUrls:barDate == endDate");
plug.close();
return;
}
s = "http://table.finance.yahoo.com/table.csv?s=";
s.append(d);
s.append("&a=");
s.append(QString::number(dt.date().month() - 1));
s.append("&b=");
s.append(dt.toString("dd"));
s.append("&c=");
s.append(dt.toString("yyyy"));
s.append("&d=");
s.append(QString::number(edt.month() - 1));
s.append("&e=");
s.append(edt.toString("dd"));
s.append("&f=");
s.append(edt.toString("yyyy"));
s.append("&g=d&ignore=.csv");
plug.close();
Setting *set = new Setting;
QString ts = "url";
set->setData(ts, s);
ts = "symbol";
set->setData(ts, d);
url.append(set);
}
示例13: isFirstSecOfMonth
static bool isFirstSecOfMonth( const QDateTime& date )
{
return date.date().day() == 1 && date.time().hour() == 0 && date.time().minute() == 0;
}
示例14: setImageDateTime
bool MetaEngine::setImageDateTime(const QDateTime& dateTime, bool setDateTimeDigitized, bool setProgramName) const
{
if(!dateTime.isValid())
return false;
if (!setProgramId(setProgramName))
return false;
try
{
// In first we write date & time into Exif.
// DateTimeDigitized is set by slide scanners etc. when a picture is digitized.
// DateTimeOriginal specifies the date/time when the picture was taken.
// For digital cameras, these dates should be both set, and identical.
// Reference: http://www.exif.org/Exif2-2.PDF, chapter 4.6.5, table 4, section F.
const std::string &exifdatetime(dateTime.toString(QString::fromLatin1("yyyy:MM:dd hh:mm:ss")).toLatin1().constData());
d->exifMetadata()["Exif.Image.DateTime"] = exifdatetime;
d->exifMetadata()["Exif.Photo.DateTimeOriginal"] = exifdatetime;
if(setDateTimeDigitized)
d->exifMetadata()["Exif.Photo.DateTimeDigitized"] = exifdatetime;
#ifdef _XMP_SUPPORT_
// In second we write date & time into Xmp.
const std::string &xmpdatetime(dateTime.toString(Qt::ISODate).toLatin1().constData());
Exiv2::Value::AutoPtr xmpTxtVal = Exiv2::Value::create(Exiv2::xmpText);
xmpTxtVal->read(xmpdatetime);
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.exif.DateTimeOriginal"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.photoshop.DateCreated"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.tiff.DateTime"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.xmp.CreateDate"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.xmp.MetadataDate"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.xmp.ModifyDate"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.video.DateTimeOriginal"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.video.DateUTC"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.video.ModificationDate"), xmpTxtVal.get());
if(setDateTimeDigitized)
{
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.exif.DateTimeDigitized"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.video.DateTimeDigitized"), xmpTxtVal.get());
}
// Tag not updated:
// "Xmp.dc.DateTime" is a sequence of date relevant of dublin core change.
// This is not the picture date as well
#endif // _XMP_SUPPORT_
// In third we write date & time into Iptc.
const std::string &iptcdate(dateTime.date().toString(Qt::ISODate).toLatin1().constData());
const std::string &iptctime(dateTime.time().toString(Qt::ISODate).toLatin1().constData());
d->iptcMetadata()["Iptc.Application2.DateCreated"] = iptcdate;
d->iptcMetadata()["Iptc.Application2.TimeCreated"] = iptctime;
if(setDateTimeDigitized)
{
d->iptcMetadata()["Iptc.Application2.DigitizationDate"] = iptcdate;
d->iptcMetadata()["Iptc.Application2.DigitizationTime"] = iptctime;
}
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError(QString::fromLatin1("Cannot set Date & Time into image using Exiv2 "), e);
}
catch(...)
{
qCCritical(DIGIKAM_METAENGINE_LOG) << "Default exception from Exiv2";
}
return false;
}
示例15: updateView
void KOWhatsNextView::updateView()
{
KIconLoader kil("kdepim");
QString *ipath = new QString();
kil.loadIcon("kdepim", KIcon::NoGroup, 32, KIcon::DefaultState, ipath);
mText = "<table width=\"100%\">\n";
mText += "<tr bgcolor=\"#3679AD\"><td><h1>";
mText += "<img src=\"";
mText += *ipath;
mText += "\">";
mText += "<font color=\"white\"> ";
mText += i18n("What's Next?") + "</font></h1>";
mText += "</td></tr>\n<tr><td>";
mText += "<h2>";
if(mStartDate.daysTo(mEndDate) < 1)
{
mText += KGlobal::locale()->formatDate(mStartDate);
}
else
{
mText += i18n("Date from - to", "%1 - %2")
.arg(KGlobal::locale()->formatDate(mStartDate))
.arg(KGlobal::locale()->formatDate(mEndDate));
}
mText += "</h2>\n";
Event::List events;
for(QDate date = mStartDate; date <= mEndDate; date = date.addDays(1))
events += calendar()->events(date, EventSortStartDate, SortDirectionAscending);
if(events.count() > 0)
{
mText += "<p></p>";
kil.loadIcon("appointment", KIcon::NoGroup, 22, KIcon::DefaultState, ipath);
mText += "<h2><img src=\"";
mText += *ipath;
mText += "\">";
mText += i18n("Events:") + "</h2>\n";
mText += "<table>\n";
Event::List::ConstIterator it;
for(it = events.begin(); it != events.end(); ++it)
{
Event *ev = *it;
if(!ev->doesRecur())
{
appendEvent(ev);
}
else
{
// FIXME: This should actually be cleaned up. Libkcal should
// provide a method to return a list of all recurrences in a
// given time span.
Recurrence *recur = ev->recurrence();
int duration = ev->dtStart().secsTo(ev->dtEnd());
QDateTime start = recur->getPreviousDateTime(
QDateTime(mStartDate, QTime()));
QDateTime end = start.addSecs(duration);
if(end.date() >= mStartDate)
{
appendEvent(ev, start, end);
}
start = recur->getNextDateTime(start);
while(start.isValid() && start.date() <= mEndDate)
{
appendEvent(ev, start);
start = recur->getNextDateTime(start);
}
}
}
mText += "</table>\n";
}
mTodos.clear();
Todo::List todos = calendar()->todos(TodoSortDueDate, SortDirectionAscending);
if(todos.count() > 0)
{
kil.loadIcon("todo", KIcon::NoGroup, 22, KIcon::DefaultState, ipath);
mText += "<h2><img src=\"";
mText += *ipath;
mText += "\">";
mText += i18n("To-do:") + "</h2>\n";
mText += "<ul>\n";
Todo::List::ConstIterator it;
for(it = todos.begin(); it != todos.end(); ++it)
{
Todo *todo = *it;
if(!todo->isCompleted() && todo->hasDueDate() && todo->dtDue().date() <= mEndDate)
appendTodo(todo);
}
bool gotone = false;
int priority = 1;
while(!gotone && priority <= 9)
{
for(it = todos.begin(); it != todos.end(); ++it)
{
Todo *todo = *it;
if(!todo->isCompleted() && (todo->priority() == priority))
{
//.........这里部分代码省略.........