コード例 #1
0
void CXTPCalendarWeekView::ScrollV(int /*nPos*/, int nPos_raw)
{
	if (nPos_raw == m_nCurrPos || m_bScrollV_Disabled)
		return;

	CXTPCalendarControl::CViewChangedContext viewChanged(this);

	if (IsEditingSubject())
	{
		EndEditSubject(xtpCalendarEditSubjectCommit, FALSE);
	}

	int nShift = nPos_raw - m_nCurrPos;
	COleDateTimeSpan spWeeks(nShift * 7, 0, 0, 0);

	m_dtBeginDate += spWeeks;

	m_nCurrPos = nPos_raw;

	if (GetSelection())
	{
		m_selectedBlock.dtBegin += spWeeks;
		m_selectedBlock.dtEnd += spWeeks;

		CSelectionChangedContext selChanged(this, xtpCalendarSelectionDays);
	}
	UnselectAllEvents();

	Populate();
}
コード例 #2
0
ファイル: folderview.cpp プロジェクト: crashd/pcmanfm-qt
void FolderView::onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) {
  QItemSelectionModel* selModel = static_cast<QItemSelectionModel*>(sender());
  int nSel = 0;
  if(viewMode() == DetailedListMode)
    nSel = selModel->selectedRows().count();
  else
    nSel = selModel->selectedIndexes().count();
  // qDebug()<<"selected:" << nSel;
  Q_EMIT selChanged(nSel); // FIXME: this is inefficient
}
コード例 #3
0
void CXTPCalendarWeekView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	CSelectionChangedContext selChanged(this);

	TBase::OnKeyDown(nChar, nRepCnt, nFlags);

	if (nChar == VK_LEFT || nChar == VK_RIGHT || nChar == VK_UP || nChar == VK_DOWN ||
			nChar == VK_PRIOR || nChar == VK_NEXT)
	{
		CXTPCalendarControl::CUpdateContext updateContext(m_pControl, xtpCalendarUpdateRedraw);

		BOOL bVKShift = (GetKeyState(VK_SHIFT)  < 0);
		COleDateTimeSpan spDay(1, 0, 0, 0);
		COleDateTimeSpan spWeek(7, 0, 0, 0);

		int nDVCount = GetViewDayCount();
		BOOL bSelReseted = !m_selectedBlock.dtEnd.GetStatus() == COleDateTime::valid;

		COleDateTime dtLastSelDay = GetLastSelectedDate();
		int nLastSelDayIdx = (dtLastSelDay.GetDayOfWeek() - m_nFirstDayOfWeekIndex + 7) % 7;

		COleDateTime dtNewSelDay = dtLastSelDay;

		int nSatDayIdx = 7 - m_nFirstDayOfWeekIndex;
		int nNewIdx = nLastSelDayIdx + 3;
		int nHalfShift = nNewIdx > nSatDayIdx && nLastSelDayIdx <= nSatDayIdx ||
			nNewIdx > nSatDayIdx + 7 && nLastSelDayIdx <= nSatDayIdx + 7 ? 4 : 3;

		COleDateTimeSpan spHalfWeekPlus(nHalfShift, 0, 0, 0);
		COleDateTimeSpan spHalfWeekMinus(7 - nHalfShift, 0, 0, 0);

		CXTPDrawHelpers::KeyToLayout(m_pControl, nChar);

		if (nChar == VK_LEFT)
		{
			dtNewSelDay -= spHalfWeekMinus;
		}
		else if (nChar == VK_RIGHT)
		{
			dtNewSelDay += spHalfWeekPlus;
		}
		else if (nChar == VK_UP)
		{
			dtNewSelDay -= spDay;
		}
		else if (nChar == VK_DOWN)
		{
			dtNewSelDay += spDay;
		}
		else if (nChar == VK_PRIOR)
		{
			dtNewSelDay -= spWeek;
		}
		else if (nChar == VK_NEXT)
		{
			dtNewSelDay += spWeek;
		}
		//---------------------------------------------------------------------------
		COleDateTime dtFirstDay = GetViewDayDate(0);
		COleDateTime dtLastDay = GetViewDayDate(nDVCount-1);

		BOOL bNeedScroll = dtNewSelDay < dtFirstDay || dtNewSelDay > dtLastDay;
		if (bNeedScroll && !m_bScrollV_Disabled)
		{
			if (dtNewSelDay < dtFirstDay)
			{
				ScrollV(m_nCurrPos-1, m_nCurrPos-1);
				bSelReseted = TRUE;
				CXTPCalendarControl::CUpdateContext updateContext1(m_pControl, xtpCalendarUpdateScrollBar);
			}
			if (dtNewSelDay > dtLastDay)
			{
				ScrollV(m_nCurrPos + 1, m_nCurrPos + 1);
				bSelReseted = TRUE;
				CXTPCalendarControl::CUpdateContext updateContext1(m_pControl, xtpCalendarUpdateScrollBar);
			}
		}

		//---------------------------------------------------------------------------
		if (!bNeedScroll || !m_bScrollV_Disabled)
		{
			if (bVKShift && !bSelReseted)
			{
				SelectDays(dtNewSelDay);
			}
			else
			{
				SelectDay(dtNewSelDay);
			}
		}
	}
}