void FilterBar::changeFilter() { m_data->string = m_lineEdit->text(); m_data->isFiltering = (!m_data->string.isEmpty() || m_data->tagFilterType != FilterData::DontCareTagsFilter); if (hasEditFocus()) m_data->isFiltering = true; emit newFilter(*m_data); }
void ExLineEdit::initStyleOption(QStyleOptionFrameV2 *option) const { option->initFrom(this); option->rect = contentsRect(); option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this); option->midLineWidth = 0; option->state |= QStyle::State_Sunken; if (m_lineEdit->isReadOnly()) option->state |= QStyle::State_ReadOnly; #ifdef QT_KEYPAD_NAVIGATION if (hasEditFocus()) option->state |= QStyle::State_HasEditFocus; #endif option->features = QStyleOptionFrameV2::None; }
void FilterBar::tagChanged(int index) { m_data->tag = 0; m_data->state = 0; switch (index) { case 0: m_data->tagFilterType = FilterData::DontCareTagsFilter; break; case 1: m_data->tagFilterType = FilterData::NotTaggedFilter; break; case 2: m_data->tagFilterType = FilterData::TaggedFilter; break; default: // Try to find if we are filtering a tag: QMap<int, Tag*>::iterator it = m_tagsMap.find(index); if (it != m_tagsMap.end()) { m_data->tagFilterType = FilterData::TagFilter; m_data->tag = *it; } else { // If not, try to find if we are filtering a state: QMap<int, State*>::iterator it2 = m_statesMap.find(index); if (it2 != m_statesMap.end()) { m_data->tagFilterType = FilterData::StateFilter; m_data->state = *it2; } else { // If not (should never happens), do as if the tags filter was reseted: m_data->tagFilterType = FilterData::DontCareTagsFilter; } } break; } m_data->isFiltering = (!m_data->string.isEmpty() || m_data->tagFilterType != FilterData::DontCareTagsFilter); if (hasEditFocus()) m_data->isFiltering = true; emit newFilter(*m_data); }
/*! \reimp */ void QAbstractSlider::keyPressEvent(QKeyEvent *ev) { Q_D(QAbstractSlider); SliderAction action = SliderNoAction; #ifdef QT_KEYPAD_NAVIGATION if (ev->isAutoRepeat()) { if (!d->firstRepeat.isValid()) d->firstRepeat.start(); else if (1 == d->repeatMultiplier) { // This is the interval in milli seconds which one key repetition // takes. const int repeatMSecs = d->firstRepeat.elapsed(); /** * The time it takes to currently navigate the whole slider. */ const qreal currentTimeElapse = (qreal(maximum()) / singleStep()) * repeatMSecs; /** * This is an arbitrarily determined constant in msecs that * specifies how long time it should take to navigate from the * start to the end(excluding starting key auto repeat). */ const int SliderRepeatElapse = 2500; d->repeatMultiplier = currentTimeElapse / SliderRepeatElapse; } } else if (d->firstRepeat.isValid()) { d->firstRepeat.invalidate(); d->repeatMultiplier = 1; } #endif switch (ev->key()) { #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Select: if (QApplication::keypadNavigationEnabled()) setEditFocus(!hasEditFocus()); else ev->ignore(); break; case Qt::Key_Back: if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { setValue(d->origValue); setEditFocus(false); } else ev->ignore(); break; #endif // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird. case Qt::Key_Left: #ifdef QT_KEYPAD_NAVIGATION // In QApplication::KeypadNavigationDirectional, we want to change the slider // value if there is no left/right navigation possible and if this slider is not // inside a tab widget. if (QApplication::keypadNavigationEnabled() && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder || d->orientation == Qt::Vertical || !hasEditFocus() && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) { ev->ignore(); return; } if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical) action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; else #endif if (isRightToLeft()) action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; else action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; break; case Qt::Key_Right: #ifdef QT_KEYPAD_NAVIGATION // Same logic as in Qt::Key_Left if (QApplication::keypadNavigationEnabled() && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder || d->orientation == Qt::Vertical || !hasEditFocus() && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) { ev->ignore(); return; } if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical) action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; else #endif if (isRightToLeft()) action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; else action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; break; case Qt::Key_Up: #ifdef QT_KEYPAD_NAVIGATION // In QApplication::KeypadNavigationDirectional, we want to change the slider // value if there is no up/down navigation possible. if (QApplication::keypadNavigationEnabled() && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder || d->orientation == Qt::Horizontal || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) { ev->ignore(); break; } #endif action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; break; case Qt::Key_Down: #ifdef QT_KEYPAD_NAVIGATION // Same logic as in Qt::Key_Up if (QApplication::keypadNavigationEnabled() && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder || d->orientation == Qt::Horizontal || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) { ev->ignore(); break; } #endif action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; break; case Qt::Key_PageUp: action = d->invertedControls ? SliderPageStepSub : SliderPageStepAdd; break; case Qt::Key_PageDown: action = d->invertedControls ? SliderPageStepAdd : SliderPageStepSub; break; case Qt::Key_Home: action = SliderToMinimum; break; case Qt::Key_End: action = SliderToMaximum; break; default: ev->ignore(); break; } if (action) triggerAction(action); }
/*! \reimp */ void QAbstractSlider::keyPressEvent(QKeyEvent *ev) { Q_D(QAbstractSlider); SliderAction action = SliderNoAction; switch (ev->key()) { #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Select: if (QApplication::keypadNavigationEnabled()) setEditFocus(!hasEditFocus()); else ev->ignore(); break; case Qt::Key_Back: if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { setValue(d->origValue); setEditFocus(false); } else ev->ignore(); break; #endif // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird. case Qt::Key_Left: #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { ev->ignore(); return; } if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical) action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; else #endif if (isRightToLeft()) action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; else action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; break; case Qt::Key_Right: #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { ev->ignore(); return; } if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical) action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; else #endif if (isRightToLeft()) action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; else action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; break; case Qt::Key_Up: #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) { ev->ignore(); break; } #endif action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; break; case Qt::Key_Down: #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) { ev->ignore(); break; } #endif action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; break; case Qt::Key_PageUp: action = d->invertedControls ? SliderPageStepSub : SliderPageStepAdd; break; case Qt::Key_PageDown: action = d->invertedControls ? SliderPageStepAdd : SliderPageStepSub; break; case Qt::Key_Home: action = SliderToMinimum; break; case Qt::Key_End: action = SliderToMaximum; break; default: ev->ignore(); break; } if (action) triggerAction(action); }