void aniadir::setDate(QDate date){ ui->anadir_dia->setValue(date.day()); ui->anadir_mes->setValue(date.month()); ui->anadir_anio->setValue(date.year()); }
static HostComboBox *ZMDateFormat() { HostComboBox *gc = new HostComboBox("ZoneMinderDateFormat"); gc->setLabel(QObject::tr("Date format")); QDate sampdate = QDate::currentDate(); QString sampleStr = QObject::tr("Samples are shown using today's date."); if (sampdate.month() == sampdate.day()) { sampdate = sampdate.addDays(1); sampleStr = QObject::tr("Samples are shown using tomorrow's date."); } gc->addSelection(sampdate.toString("ddd - dd/MM"), "ddd - dd/MM"); gc->addSelection(sampdate.toString("ddd MMM d"), "ddd MMM d"); gc->addSelection(sampdate.toString("ddd MMMM d"), "ddd MMMM d"); gc->addSelection(sampdate.toString("MMM d"), "MMM d"); gc->addSelection(sampdate.toString("MM/dd"), "MM/dd"); gc->addSelection(sampdate.toString("MM.dd"), "MM.dd"); gc->addSelection(sampdate.toString("ddd d MMM"), "ddd d MMM"); gc->addSelection(sampdate.toString("M/d/yyyy"), "M/d/yyyy"); gc->addSelection(sampdate.toString("dd.MM.yyyy"), "dd.MM.yyyy"); gc->addSelection(sampdate.toString("yyyy-MM-dd"), "yyyy-MM-dd"); gc->addSelection(sampdate.toString("ddd MMM d yyyy"), "ddd MMM d yyyy"); gc->addSelection(sampdate.toString("ddd yyyy-MM-dd"), "ddd yyyy-MM-dd"); gc->addSelection(sampdate.toString("ddd dd MMM yyyy"), "ddd dd MMM yyyy"); gc->setHelpText(QObject::tr("Your preferred date format to use on the events screens.") + " " + sampleStr); return gc; }
void DialogAjouterVente::on_boutonAjouterVente_clicked() { string nom = ui->valNom->text().toStdString(); string categorie = ui->valCat->text().toStdString(); float prix = ui->valPrix->value(); unsigned int qte = ui->valQte->text().toUInt(); string etat = ui->buttonGroup->checkedButton()->text().toStdString(); if(nom != "" && categorie != "" && prix > 0.00 && qte > 0) { if(etat == "Vente aux enchères") { QDate date = ui->valDateLimite->date(); int year = date.year(); int month = date.month(); int day = date.day(); struct tm dateLimite; dateLimite.tm_mday = day; dateLimite.tm_mon = month; dateLimite.tm_year = year; gestionBdd->ajouterVente(nom, categorie, prix, qte, true, dateLimite); close(); } else { gestionBdd->ajouterVente(nom, categorie, prix, qte, false); close(); } } }
void MainWindow::saveCouplesToFile() { QDate date = QDate::currentDate(); QString path = QFileDialog::getSaveFileName(this, tr("Введите имя файла для " "сохранения"), QDir::homePath() + QDir::separator() + "draw_" + QString::number(date.year()) + "." + QString::number(date.month()) + "." + QString::number(date.day()) + "_.txt", tr("Текстовые файлы (*.txt)")); if (path.length()) { QFile file(path); if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { QMessageBox::warning(this, tr("Ошибка"), tr("Невозможно открыть файл для записи.")); } QTextStream stream(&file); #ifdef Q_OS_UNIX stream << ui->couples->toPlainText(); #endif #ifdef Q_OS_WIN stream << ui->couples->toPlainText().replace("\n", "\r\n"); #endif file.close(); } }
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; }
int CalendarBox::Context::daysShiftForMonth(QDate month) { Assert(!month.isNull()); constexpr auto kMaxRows = 6; auto inMonthIndex = month.day() - 1; auto inWeekIndex = month.dayOfWeek() - 1; return ((kMaxRows * kDaysInWeek) + inWeekIndex - inMonthIndex) % kDaysInWeek; }
QList<int> tradeDateCalendar::computeFrequencyTradeMonthly(int date_, int minimumDate_, int maximumDate_) { QList<int> tradeDates; QDate monthDayCounter = QDate::fromJulianDay(minimumDate_); int dayOfMonth = QDate::fromJulianDay(date_).day(); forever { QDate monthDayComputation = monthDayCounter; if (monthDayComputation.day() > dayOfMonth) monthDayComputation = monthDayComputation.addMonths(1); if (dayOfMonth > monthDayComputation.daysInMonth()) { monthDayComputation = monthDayComputation.addMonths(1); monthDayComputation = QDate(monthDayComputation.year(), monthDayComputation.month(), 1); } else monthDayComputation = QDate(monthDayComputation.year(), monthDayComputation.month(), dayOfMonth); date_ = checkTradeDate(monthDayComputation.toJulianDay(), direction_ascending); if (date_ > maximumDate_) break; tradeDates.append(date_); monthDayCounter = monthDayCounter.addMonths(1); } return tradeDates; }
void tst_QDate::addDays_data() { QTest::addColumn<int>("year"); QTest::addColumn<int>("month"); QTest::addColumn<int>("day"); QTest::addColumn<int>("amountToAdd"); QTest::addColumn<int>("expectedYear"); QTest::addColumn<int>("expectedMonth"); QTest::addColumn<int>("expectedDay"); QTest::newRow( "data0" ) << 2000 << 1 << 1 << 1 << 2000 << 1 << 2; QTest::newRow( "data1" ) << 2000 << 1 << 31 << 1 << 2000 << 2 << 1; QTest::newRow( "data2" ) << 2000 << 2 << 28 << 1 << 2000 << 2 << 29; QTest::newRow( "data3" ) << 2000 << 2 << 29 << 1 << 2000 << 3 << 1; QTest::newRow( "data4" ) << 2000 << 12 << 31 << 1 << 2001 << 1 << 1; QTest::newRow( "data5" ) << 2001 << 2 << 28 << 1 << 2001 << 3 << 1; QTest::newRow( "data6" ) << 2001 << 2 << 28 << 30 << 2001 << 3 << 30; QTest::newRow( "data7" ) << 2001 << 3 << 30 << 5 << 2001 << 4 << 4; QTest::newRow( "data8" ) << 2000 << 1 << 1 << -1 << 1999 << 12 << 31; QTest::newRow( "data9" ) << 2000 << 1 << 31 << -1 << 2000 << 1 << 30; QTest::newRow( "data10" ) << 2000 << 2 << 28 << -1 << 2000 << 2 << 27; QTest::newRow( "data11" ) << 2001 << 2 << 28 << -30 << 2001 << 1 << 29; QDate invalid; QTest::newRow( "data12" ) << -4713 << 1 << 2 << -2 << invalid.year() << invalid.month() << invalid.day(); }
QString QCalendarDayValidator::text(const QDate &date, int repeat) const { if (repeat <= 1) { return QString::number(date.day()); } else if (repeat == 2) { QString str; if (date.day() / 10 == 0) str += QLatin1String("0"); return str + QString::number(date.day()); } else if (repeat == 3) { return m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat); } else if (repeat >= 4) { return m_locale.dayName(date.dayOfWeek(), QLocale::LongFormat); } return QString(); }
static HostComboBox *MythArchiveDateFormat() { HostComboBox *gc = new HostComboBox("MythArchiveDateFormat"); gc->setLabel(QObject::tr("Date format")); QDate sampdate = QDate::currentDate(); QString sampleStr = QObject::tr("Samples are shown using today's date."); if (sampdate.month() == sampdate.day()) { sampdate = sampdate.addDays(1); sampleStr = QObject::tr("Samples are shown using tomorrow's date."); } gc->addSelection(sampdate.toString("ddd MMM d"), "%a %b %d"); gc->addSelection(sampdate.toString("ddd MMMM d"), "%a %B %d"); gc->addSelection(sampdate.toString("MMM d"), "%b %d"); gc->addSelection(sampdate.toString("MM/dd"), "%m/%d"); gc->addSelection(sampdate.toString("MM.dd"), "%m.%d"); gc->addSelection(sampdate.toString("ddd d MMM"), "%a %d %b"); gc->addSelection(sampdate.toString("M/d/yyyy"), "%m/%d/%Y"); gc->addSelection(sampdate.toString("dd.MM.yyyy"), "%d.%m.%Y"); gc->addSelection(sampdate.toString("yyyy-MM-dd"), "%Y-%m-%d"); gc->addSelection(sampdate.toString("ddd MMM d yyyy"), "%a %b %d %Y"); gc->addSelection(sampdate.toString("ddd yyyy-MM-dd"), "%a %Y-%m-%d"); gc->addSelection(sampdate.toString("ddd dd MMM yyyy"), "%a %d %b %Y"); gc->setHelpText(QObject::tr("Your preferred date format to use on DVD menus.") + " " + sampleStr); return gc; }
DateItem::DateItem(QDate date) { date_ = date; setText(0,date.toString(Qt::SystemLocaleDate)); QString sort = QString(date.year()* 10000 +date.month()*100 + date.day()); setText(1,sort); }
bool cal2::showtodomark(QDate date) { if(date.year()!=cur_date.year() || date.month()!=cur_date.month()) return false; QDate firstday(date.year(),date.month(),1); labels[date.day()+firstday.dayOfWeek()-1]->btodo->show(); return true; }
void ShowDate::showDate() { QDate date = QDate::currentDate(); QString date_text; date_text.sprintf("%d-%02d-%02d", date.year(), date.month(), date.day()); ymdlcd->display(date_text); }
void SchedulesTabController::setDstEndDate(const QDate & newdate) { model::RunPeriodControlDaylightSavingTime dst = m_model.getUniqueModelObject<model::RunPeriodControlDaylightSavingTime>(); dst.setEndDate(monthOfYear(newdate.month()),newdate.day()); }
void DLineEdit::validateDate() { QString dateString = _lineedit.text().stripWhiteSpace(); bool isNumeric; #ifdef OpenMFGGUIClient_h QDate today = ofmgThis->dbDate(); #else QDate today = QDate::currentDate(); #endif _valid = false; if (dateString == _nullString || dateString.isEmpty()) setNull(); else if (dateString == "0") // today setDate(today, TRUE); else if (dateString.contains(QRegExp("^[+-][0-9]+"))) // offset from today { int offset = dateString.toInt(&isNumeric); if (isNumeric) setDate(today.addDays(offset), true); } else if (dateString[0] == '#') // julian day { int offset = dateString.right(dateString.length() - 1).toInt(&isNumeric); if (isNumeric) setDate(QDate(today.year(), 1, 1).addDays(offset - 1), TRUE); } else if (dateString.contains(QRegExp("^[0-9][0-9]?$"))) // date in month { int offset = dateString.toInt(&isNumeric, 10); if (isNumeric) { if (offset > today.daysInMonth()) offset = today.daysInMonth(); setDate(QDate(today.year(), today.month(), 1).addDays(offset - 1), TRUE); } } else // interpret with locale { // Qt bug 193079: setDate(QDate::fromString(dateString, Qt::LocaleDate), true); QDate tmp = QDate::fromString(dateString, QLocale().dateFormat(QLocale::ShortFormat)); setDate(QDate(tmp.year(), tmp.month(), tmp.day()), true ); } if (!_valid) _lineedit.setText(""); _parsed = true; }
// Calcul de l'âge du capitaine int AddressBook::calculAge(QDate birthdate) { int age = QDate::currentDate().year() - birthdate.year(); if((QDate::currentDate().month() - birthdate.month()) < 0) age--; else if ((QDate::currentDate().month() - birthdate.month()) == 0) { if((QDate::currentDate().day() - birthdate.day()) < 0) age--; } return age; }
void tst_QDate::yearsZeroToNinetyNine() { { QDate dt(-1, 2, 3); QCOMPARE(dt.year(), -1); QCOMPARE(dt.month(), 2); QCOMPARE(dt.day(), 3); } { QDate dt(1, 2, 3); QCOMPARE(dt.year(), 1); QCOMPARE(dt.month(), 2); QCOMPARE(dt.day(), 3); } { QDate dt(99, 2, 3); QCOMPARE(dt.year(), 99); QCOMPARE(dt.month(), 2); QCOMPARE(dt.day(), 3); } QVERIFY(!QDate::isValid(0, 2, 3)); QVERIFY(QDate::isValid(1, 2, 3)); QVERIFY(QDate::isValid(-1, 2, 3)); { QDate dt; dt.setYMD(1, 2, 3); QCOMPARE(dt.year(), 1901); QCOMPARE(dt.month(), 2); QCOMPARE(dt.day(), 3); } { QDate dt; dt.setDate(1, 2, 3); QCOMPARE(dt.year(), 1); QCOMPARE(dt.month(), 2); QCOMPARE(dt.day(), 3); dt.setDate(0, 2, 3); QVERIFY(!dt.isValid()); } }
/****************************************************************************** * Return a list of events for birthdays chosen. */ QList<KAEvent> BirthdayDlg::events() const { QList<KAEvent> list; QModelIndexList indexes = mListView->selectionModel()->selectedRows(); int count = indexes.count(); if (!count) return list; QDate today = KDateTime::currentLocalDate(); KDateTime todayStart(today, KDateTime::ClockTime); int thisYear = today.year(); int reminder = mReminder->minutes(); const BirthdaySortModel* model = static_cast<const BirthdaySortModel*>(indexes[0].model()); for (int i = 0; i < count; ++i) { BirthdayModel::Data* data = model->rowData(indexes[i]); if (!data) continue; QDate date = data->birthday; date.setYMD(thisYear, date.month(), date.day()); if (date <= today) date.setYMD(thisYear + 1, date.month(), date.day()); KAEvent event(KDateTime(date, KDateTime::ClockTime), mPrefix->text() + data->name + mSuffix->text(), mFontColourButton->bgColour(), mFontColourButton->fgColour(), mFontColourButton->font(), KAEventData::MESSAGE, mLateCancel->minutes(), mFlags, true); float fadeVolume; int fadeSecs; float volume = mSoundPicker->volume(fadeVolume, fadeSecs); event.setAudioFile(mSoundPicker->file().prettyUrl(), volume, fadeVolume, fadeSecs); QList<int> months; months.append(date.month()); event.setRecurAnnualByDate(1, months, 0, KARecurrence::defaultFeb29Type(), -1, QDate()); event.setRepetition(mSubRepetition->repetition()); event.setNextOccurrence(todayStart); if (reminder) event.setReminder(reminder, false); if (mSpecialActionsButton) event.setActions(mSpecialActionsButton->preAction(), mSpecialActionsButton->postAction(), mSpecialActionsButton->cancelOnError()); event.endChanges(); list.append(event); } return list; }
TimeStamp::TimeStamp ( const QDate& dt, QString zone) { initDefault(); m_zone="UTC"; m_year=dt.year();m_month=dt.month();m_day=dt.day(); m_hour=m_min=m_sec=m_msec=0; moveToZone(zone); }
/* * Initialize app icon */ const QIcon &lamexp_app_icon(void) { QReadLocker readLock(&g_lamexp_app_icon.lock); //Already initialized? if(g_lamexp_app_icon.appIcon) { return *g_lamexp_app_icon.appIcon; } readLock.unlock(); QWriteLocker writeLock(&g_lamexp_app_icon.lock); while(!g_lamexp_app_icon.appIcon) { QDate currentDate = QDate::currentDate(); QTime currentTime = QTime::currentTime(); if(lamexp_thanksgiving(currentDate)) { g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon6.png"); } else if(((currentDate.month() == 12) && (currentDate.day() == 31) && (currentTime.hour() >= 20)) || ((currentDate.month() == 1) && (currentDate.day() == 1) && (currentTime.hour() <= 19))) { g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon5.png"); } else if(((currentDate.month() == 10) && (currentDate.day() == 31) && (currentTime.hour() >= 12)) || ((currentDate.month() == 11) && (currentDate.day() == 1) && (currentTime.hour() <= 11))) { g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon4.png"); } else if((currentDate.month() == 12) && (currentDate.day() >= 24) && (currentDate.day() <= 26)) { g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon3.png"); } else if(lamexp_computus(currentDate)) { g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon2.png"); } else { g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon1.png"); } } return *g_lamexp_app_icon.appIcon; }
void setTime( tm_zip &tm, QDate date, QTime time ){ tm.tm_sec = time.second(); tm.tm_min = time.minute(); tm.tm_hour = time.hour(); tm.tm_mday = date.day(); tm.tm_mon = date.month(); tm.tm_year = date.year(); }
bool CalendarModel::getEventForDate(int index, const QDate &date) { // qDebug()<<date.day()<<", "<<date.month()<<", "<<date.year(); // qDebug()<<date.dayOfWeek(); 7 is sunday return group[index][date.month()-1][date.day()]; // return true; }
static bool isRtdHoliday(const QDate& date) { // New Years' if (date.month() == 1 && date.day() == 1) return true; // Memorial Day: last Monday in May if (date.month() == 5 && date.dayOfWeek() == Qt::Monday && date.day() > 24) return true; // Independance Day if (date.month() == 6 && date.day() == 4) return true; // Labor Day: first Monday in September if (date.month() == 9 && date.dayOfWeek() == Qt::Monday && date.day() < 8) return true; // Thanksgiving Day: 4th Thursday in November if (date.month() == 11 && date.dayOfWeek() == Qt::Thursday && date.day() > 21 && date.day() <= 28) return true; // Christmas Day if (date.month() == 12 && date.day() == 25) return true; return false; }
/****************************************************************************** * Return a list of events for birthdays chosen. */ QVector<KAEvent> BirthdayDlg::events() const { QVector<KAEvent> list; QModelIndexList indexes = mListView->selectionModel()->selectedRows(); int count = indexes.count(); if (!count) return list; QDate today = KDateTime::currentLocalDate(); KDateTime todayStart(today, KDateTime::Spec(KDateTime::ClockTime)); int thisYear = today.year(); int reminder = mReminder->minutes(); for (int i = 0; i < count; ++i) { const QModelIndex nameIndex = indexes.at(i).model()->index(indexes.at(i).row(), 0); const QModelIndex birthdayIndex = indexes.at(i).model()->index(indexes.at(i).row(), 1); const QString name = nameIndex.data(Qt::DisplayRole).toString(); QDate date = birthdayIndex.data(BirthdayModel::DateRole).toDate(); date.setYMD(thisYear, date.month(), date.day()); if (date <= today) date.setYMD(thisYear + 1, date.month(), date.day()); KAEvent event(KDateTime(date, KDateTime::Spec(KDateTime::ClockTime)), mPrefix->text() + name + mSuffix->text(), mFontColourButton->bgColour(), mFontColourButton->fgColour(), mFontColourButton->font(), KAEvent::MESSAGE, mLateCancel->minutes(), mFlags, true); float fadeVolume; int fadeSecs; float volume = mSoundPicker->volume(fadeVolume, fadeSecs); int repeatPause = mSoundPicker->repeatPause(); event.setAudioFile(mSoundPicker->file().toDisplayString(), volume, fadeVolume, fadeSecs, repeatPause); QVector<int> months(1, date.month()); event.setRecurAnnualByDate(1, months, 0, KARecurrence::defaultFeb29Type(), -1, QDate()); event.setRepetition(mSubRepetition->repetition()); event.setNextOccurrence(todayStart); if (reminder) event.setReminder(reminder, false); if (mSpecialActionsButton) event.setActions(mSpecialActionsButton->preAction(), mSpecialActionsButton->postAction(), mSpecialActionsButton->options()); event.endChanges(); list.append(event); } return list; }
wxDateTime wxQtConvertDate(const QDate& date) { if ( !date.isNull() ) return wxDateTime(date.day(), static_cast<wxDateTime::Month>(date.month() - 1), date.year(), 0, 0, 0, 0); else return wxDateTime(); }
DateDialog::DateDialog( QString &date, QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "DateDialog" ); DateDialogLayout = new QVBoxLayout( this, 11, 6, "DateDialogLayout"); dateTextLabel = new QLabel( this, "dateTextLabel" ); DateDialogLayout->addWidget( dateTextLabel ); layout2 = new QHBoxLayout( 0, 0, 6, "layout2"); dayTextLabel = new QLabel( this, "dayTextLabel" ); layout2->addWidget( dayTextLabel ); daySpinBox = new QSpinBox( this, "daySpinBox" ); layout2->addWidget( daySpinBox ); monthTextLabel = new QLabel( this, "monthTextLabel" ); layout2->addWidget( monthTextLabel ); monthSpinBox = new QSpinBox( this, "monthSpinBox" ); layout2->addWidget( monthSpinBox ); yearTextLabel = new QLabel( this, "yearTextLabel" ); layout2->addWidget( yearTextLabel ); yearSpinBox = new QSpinBox( this, "yearSpinBox" ); yearSpinBox->setMaxValue(3000); layout2->addWidget( yearSpinBox ); DateDialogLayout->addLayout( layout2 ); layout1 = new QHBoxLayout( 0, 0, 6, "layout1"); spacer1 = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); layout1->addItem( spacer1 ); okButton = new QPushButton( this, "okButton" ); layout1->addWidget( okButton ); cancelButton = new QPushButton( this, "cancelButton" ); layout1->addWidget( cancelButton ); DateDialogLayout->addLayout( layout1 ); languageChange(); resize( QSize(315, 129).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); connect(cancelButton, SIGNAL( clicked() ), this, SLOT( cancel() )); connect(okButton, SIGNAL( clicked() ), this, SLOT( ok() )); QDate tDate = QDate::currentDate(); daySpinBox->setValue( tDate.day() ); monthSpinBox->setValue( tDate.month() ); yearSpinBox->setValue( tDate.year() ); gDate = &date; }
DateProperty AsemanCalendarConverterCore::getDate(const QDate &d) { DateProperty res; switch( static_cast<int>(p->calendar) ) { case AsemanCalendarConverterCore::Gregorian: res = toDateGregorian( fromDateGregorian(d.year(),d.month(),d.day()) ); break; case AsemanCalendarConverterCore::Jalali: res = toDateJalali( fromDateGregorian(d.year(),d.month(),d.day()) ); break; case AsemanCalendarConverterCore::Hijri: res = toDateHijri( fromDateGregorian(d.year(),d.month(),d.day()) ); break; } return res; }
void createDateNode( QDomDocument& doc, QDomNode& parent, const QString& elementName, const QDate& date ) { QDomElement dateElement = doc.createElement( elementName ); parent.appendChild( dateElement ); dateElement.setAttribute( "Year", QString::number( date.year() ) ); dateElement.setAttribute( "Month", QString::number( date.month() ) ); dateElement.setAttribute( "Day", QString::number( date.day() ) ); }
void AdvancedDistance::UpdateTable() { table_view_->horizontalHeader()->setClickable(false); table_view_->setSelectionMode(QAbstractItemView::SingleSelection); table_view_->verticalHeader()->setHidden(true); QMap<QDate, float> map; if (handler_->GetDayAdvanceDistance(map)) { QStandardItemModel *model = new QStandardItemModel(map.count(), 2); model->setHorizontalHeaderItem(0, new QStandardItem(STRING_ADVANCED_DISTANCE_DATE)); model->setHorizontalHeaderItem(1, new QStandardItem(STRING_ADVANCED_DISTANCE_MINEING_DAILY_ADVANCE_DISTANCE + "(m)")); table_view_->setModel(model); SpinBoxDelegate *delegate = new SpinBoxDelegate; table_view_->setItemDelegateForColumn(1, delegate); table_view_->horizontalHeader()->setStretchLastSection(true); int cnt = 0; QMapIterator<QDate, float> i(map); while(i.hasNext()) { i.next(); QDate date = i.key(); float distance = i.value(); QString datestr = QString().sprintf("%d", date.month()) + STRING_ADVANCED_MONTH + QString().sprintf("%2d", date.day()) + STRING_ADVANCED_DAY; model->setItem(cnt, 0, new QStandardItem(datestr)); model->item(cnt, 0)->setTextAlignment(Qt::AlignCenter); model->item(cnt, 0)->setFlags(Qt::NoItemFlags); model->setItem(cnt, 1, new QStandardItem); model->item(cnt, 1)->setTextAlignment(Qt::AlignCenter); QModelIndex index = model->index(cnt, 1, QModelIndex()); // if (distance == UN_INITID_FLOAT) // { // model->setData(index, QVariant(0.0)); // } // else // { // model->setData(index, QVariant(distance)); // } model->setData(index, QVariant(distance)); cnt++; } table_view_->horizontalHeader()->setResizeMode(0, QHeaderView::Fixed); table_view_->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed); } }
void pkmviewer::on_dtMetDate_dateChanged(const QDate &date) { if(redisplayok) { temppkm->metdate.year = byte(date.year()-2000); temppkm->metdate.month = byte(date.month()); temppkm->metdate.day = byte(date.day()); } }