//***************************************************************************************** void CBCGPDateTimeCtrl::ChangeMonth (UINT uiMonthLetter) { ASSERT (m_monthFormat == 0 || m_monthFormat == 1); CBCGPDefaultLocale dl; int iDay = m_Date.GetDay (); int iMonth = m_Date.GetMonth (); int iYear = m_Date.GetYear (); int iHour = m_Date.GetHour (); int iMin = m_Date.GetMinute (); BOOL bLastDayInMonth = (iDay == GetDaysInMonth (iMonth, iYear)); BOOL bFound = FALSE; for (int i = iMonth + 1; i != iMonth; i ++) { if (i > 12) { i = 1; } if (i == iMonth) { break; } //-------------------------------------------------- // Compare manth 'i' first char with the typed char: //-------------------------------------------------- CString strMonth = COleDateTime (iYear, i, 1, 0, 0, 0). Format (m_monthFormat == 0 ? _T ("%b") : _T ("%B")); if (strMonth.GetLength () > 1 && strMonth.GetAt (0) == (char) uiMonthLetter) { iMonth = i; bFound = TRUE; break; } } if (bFound) { if (bLastDayInMonth || iDay > GetDaysInMonth (iMonth, iYear)) { iDay = GetDaysInMonth (iMonth, iYear); } COleDateTime date (iYear, iMonth, iDay, iHour, iMin, 0); if (IsDateValid (date)) { m_Date = date; RedrawWindow (m_rectText); OnDateChanged (); } } }
//***************************************************************************************** void CBCGPDateTimeCtrl::ToggleCheck () { m_bIsChecked = !m_bIsChecked; if (m_spinButton) { m_wndSpin.EnableWindow (m_bIsChecked); } COleDateTime emptyDate; if (m_bIsChecked && m_Date == emptyDate) { m_Date = COleDateTime::GetCurrentTime (); OnDateChanged (); } RedrawWindow (); }
//**************************************************************************************** void CBCGPDateTimeCtrl::SetMinDate(DATE newValue) { COleDateTime dateMin = newValue; COleDateTime dateEmpty; if (m_MaxDate > dateMin || m_MaxDate == dateEmpty) { m_MinDate = dateMin; if (m_Date < m_MinDate) { m_Date = m_MinDate; OnDateChanged (); } if (GetSafeHwnd()!=NULL) { RedrawWindow (); } } }
//******************************************************************************* void CBCGPDateTimeCtrl::ClosePopupCalendar (COleDateTime date/* = COleDateTime ()*/) { if (m_pPopup == NULL) { return; } ASSERT_VALID (m_pPopup); ASSERT(::IsWindow (m_pPopup->GetSafeHwnd ())); BOOL bIsDateChanged = FALSE; if (date != COleDateTime ()) { COleDateTime dateOld = GetDate (); if (dateOld.GetDay () != date.GetDay () || dateOld.GetMonth () != date.GetMonth () || dateOld.GetYear () != date.GetYear ()) { bIsDateChanged = TRUE; } SetDate (date); } m_pPopup->SendMessage (WM_CLOSE); if (::IsWindow (GetSafeHwnd ())) { m_pPopup = NULL; SetFocus (); if (bIsDateChanged) { OnDateChanged (); } } }
RouteCommentsDlg::RouteCommentsDlg(Configuration *cfg, QWidget *parent) : QDialog(parent), ui(new Ui::RouteCommentsDlg) { ui->setupUi(this); _route = -1; _companyKey = -1; //_date.setYMD(1800,1,1); _date = QDate(1800,1,1); config = cfg; //sql->setConfig(config); sql = SQL::instance(); ui->txtComments->setReadOnly(false); connect(ui->txtTags, SIGNAL(editingFinished()), this, SLOT(OnTagsLeave())); connect(ui->btnOK, SIGNAL(clicked()), this, SLOT(btnOK_Clicked())); connect(ui->btnApply, SIGNAL(clicked()), this, SLOT(OnBtnApply_clicked())); connect(ui->btnCancel, SIGNAL(clicked()),this, SLOT(btnCancel_Clicked())); connect(ui->btnDelete, SIGNAL(clicked()), this, SLOT(btnDelete_Clicked())); connect(ui->dateEdit, SIGNAL(dateChanged(QDate)), this, SLOT(OnDateChanged())); connect(ui->dateEdit, SIGNAL(editingFinished()), this, SLOT(OnDateLeave())); connect(ui->txtComments, SIGNAL(dirtySet(bool)), this, SLOT(OnDirtySet(bool))); setWindowTitle(tr("Route Comments")); connect(ui->btnNext, SIGNAL(clicked()), this, SLOT(OnBtnNext())); connect(ui->btnPrev, SIGNAL(clicked()), this, SLOT(OnBtnPrev())); connect(ui->txtRoute, SIGNAL(textChanged(QString)), this, SLOT(OnRouteTextChanged(QString))); connect(ui->txtRoute, SIGNAL(editingFinished()), this, SLOT(OnRouteLeave())); connect(ui->txtRouteAlpha,SIGNAL(textChanged(QString)), this, SLOT(OnAlphaRouteTextChanged(QString))); connect(ui->txtRouteAlpha, SIGNAL(editingFinished()), this, SLOT(OnAlphaRouteLeave())); ui->btnApply->setEnabled(false); ui->btnOK->setEnabled(false); }
LRESULT CBCGPPlannerManagerView::OnNotifyDateChanged (WPARAM /*wParam*/, LPARAM /*lParam*/) { OnDateChanged (); return 0L; }
//***************************************************************************************** void CBCGPDateTimeCtrl::PushDigit (int iDigit) { int iDay = m_Date.GetDay (); int iMonth = m_Date.GetMonth (); int iYear = m_Date.GetYear (); int iHour = m_Date.GetHour (); int iMin = m_Date.GetMinute (); const int iYearDigits = m_type2DigitsInYear ? 2 : 4; int iNumber; if (m_iPrevDigit == -1) { iNumber = iDigit; m_iYearPos = 0; } else { iNumber = m_iPrevDigit * 10 + iDigit; } switch (m_CurrPartType) { case NO: case CHECK_BOX: case AMPM: return; case DAY: iDay = iNumber; break; case HOUR: if (!m_b24HoursFormat) { BOOL bPM = (iHour >= 12); iHour = iNumber; if (iHour > 12) { iHour = iDigit; } if (bPM) { iHour += 12; } if (iHour == 24) { iHour = 0; } if (iDigit != 1) // Only 10, 11 or 12 are allowed! { iDigit = -1; } } else // Normal format { iHour = iNumber; } break; case MIN: iMin = iNumber; break; case MONTH: if (m_monthFormat == 2 && iNumber >= 1 && iNumber <= 12) { iMonth = iNumber; if (iDigit > 1 && m_iPrevDigit == -1) { m_iPrevDigit = 0; // Stimulate junp to the next part } } break; case YEAR: if (m_type2DigitsInYear) { iYear = iYear / 100 * 100 + iNumber; if (iYear < m_maxYear2Digits - 99) { iYear = m_maxYear2Digits / 100 * 100 + iNumber; } if (iYear > m_maxYear2Digits) { iYear = (m_maxYear2Digits - 100) / 100 * 100 + iNumber; } } else { ASSERT (m_iYearPos >= 0); ASSERT (m_iYearPos < iYearDigits); //------------------------------------------------ // Replace digit in position m_iYearPos to iDigit: //------------------------------------------------ int iYearNew = 0; for (int iPos = 0; iPos < iYearDigits; iPos ++) { int iTens = 1; for (int i = 0; i < iYearDigits - iPos - 1; i ++) { iTens *= 10; } iYearNew *= 10; if (iPos == m_iYearPos) { iYearNew += iDigit; } else { iYearNew += iYear / iTens; } iYear %= iTens; } iYear = iYearNew; } m_iYearPos ++; break; } COleDateTime date (iYear, iMonth, iDay, iHour, iMin, 0); BOOL bValidDate = IsDateValid (date); if (bValidDate) { m_Date = date; RedrawWindow (m_rectText); OnDateChanged (); } if (m_iPrevDigit == -1) // First push { m_iPrevDigit = iDigit; } else { if (bValidDate && m_iPartNum < m_iPartsNumber - 1) { if (m_CurrPartType != YEAR || m_iYearPos == iYearDigits) { m_iPrevDigit = -1; SelectNext (); } } } }
//***************************************************************************************** void CBCGPDateTimeCtrl::ScrollCurrPartToLimit (BOOL bTop) { int iDay = m_Date.GetDay (); int iMonth = m_Date.GetMonth (); int iYear = m_Date.GetYear (); int iHour = m_Date.GetHour (); int iMin = m_Date.GetMinute (); switch (m_CurrPartType) { case NO: case CHECK_BOX: case AMPM: case YEAR: return; case DAY: if (bTop) { iDay = 1; } else { iDay = GetDaysInMonth (iMonth, iYear); } break; case MONTH: if (bTop) { iMonth = 1; } else { iMonth = 12; } break; case HOUR: if (bTop) { iHour = 0; } else { iHour = 23; } break; case MIN: if (bTop) { iMin = 0; } else { iMin = 59; } break; } COleDateTime date (iYear, iMonth, iDay, iHour, iMin, 0); if (IsDateValid (date) && m_Date != date) { m_Date = date; RedrawWindow (m_rectText); OnDateChanged (); } }
//***************************************************************************************** void CBCGPDateTimeCtrl::ScrollCurrPart (int iDir) { int iDay = m_Date.GetDay (); int iMonth = m_Date.GetMonth (); int iYear = m_Date.GetYear (); int iHour = m_Date.GetHour (); int iMin = m_Date.GetMinute (); BOOL bLastDayInMonth = (iDay == GetDaysInMonth (iMonth, iYear)); switch (m_CurrPartType) { case NO: case CHECK_BOX: return; case DAY: iDay += iDir; if (iDay <= 0) { iDay = GetDaysInMonth (iMonth, iYear); } if (iDay > GetDaysInMonth (iMonth, iYear)) { iDay = 1; } break; case MONTH: iMonth += iDir; if (iMonth <= 0) { iMonth = 12; } if (iMonth > 12) { iMonth = 1; } if (bLastDayInMonth || iDay > GetDaysInMonth (iMonth, iYear)) { iDay = GetDaysInMonth (iMonth, iYear); } break; case YEAR: iYear += iDir; iYear = min(iLastAllowedYear, max(iFirstAllowedYear, iYear)); if (iDay > GetDaysInMonth (iMonth, iYear)) { iDay = GetDaysInMonth (iMonth, iYear); } break; case HOUR: iHour += iDir; if (iHour < 0) { iHour = 23; } if (iHour > 23) { iHour = 0; } break; case MIN: iMin += iDir; if (iMin < 0) { iMin = 59; } if (iMin > 59) { iMin = 0; } break; case AMPM: if (iHour < 12) { iHour += 12; } else { iHour -= 12; } } COleDateTime date (iYear, iMonth, iDay, iHour, iMin, 0); COleDateTime dateEmpty; if (iDir > 0 && date > m_MaxDate && m_MaxDate != dateEmpty) { date = m_MaxDate; } if (iDir < 0 && date < m_MinDate) { date = m_MinDate; } if (m_Date != date && IsDateValid (date)) { m_Date = date; RedrawWindow (m_rectText); OnDateChanged (); } }