Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewhelpers.cpp
Show First 20 Lines • Show All 2009 Lines • ▼ Show 20 Line(s) | 1974 | { | |||
---|---|---|---|---|---|
2010 | return None; | 2010 | return None; | ||
2011 | } | 2011 | } | ||
2012 | 2012 | | |||
2013 | void KateIconBorder::mousePressEvent(QMouseEvent *e) | 2013 | void KateIconBorder::mousePressEvent(QMouseEvent *e) | ||
2014 | { | 2014 | { | ||
2015 | const KateTextLayout &t = m_viewInternal->yToKateTextLayout(e->y()); | 2015 | const KateTextLayout &t = m_viewInternal->yToKateTextLayout(e->y()); | ||
2016 | if (t.isValid()) { | 2016 | if (t.isValid()) { | ||
2017 | m_lastClickedLine = t.line(); | 2017 | m_lastClickedLine = t.line(); | ||
2018 | if (positionToArea(e->pos()) != IconBorder && positionToArea(e->pos()) != AnnotationBorder) { | 2018 | auto area = positionToArea(e->pos()); | ||
2019 | if (area != IconBorder && area != AnnotationBorder) { | ||||
mwolff: can you comment this code, why exclude these areas? | |||||
2020 | auto pos = QPoint(0, e->y()); | ||||
2021 | if (area == LineNumbers && e->button() == Qt::LeftButton && !(e->modifiers() & Qt::ShiftModifier)) { | ||||
2022 | m_viewInternal->beginSelectLine(pos); | ||||
2023 | } | ||||
mwolff: const | |||||
2019 | QMouseEvent forward(QEvent::MouseButtonPress, | 2024 | QMouseEvent forward(QEvent::MouseButtonPress, | ||
2020 | QPoint(0, e->y()), e->button(), e->buttons(), e->modifiers()); | 2025 | pos, e->button(), e->buttons(), e->modifiers()); | ||
2021 | m_viewInternal->mousePressEvent(&forward); | 2026 | m_viewInternal->mousePressEvent(&forward); | ||
2022 | } | 2027 | } | ||
2023 | return e->accept(); | 2028 | return e->accept(); | ||
2024 | } | 2029 | } | ||
2025 | 2030 | | |||
2026 | QWidget::mousePressEvent(e); | 2031 | QWidget::mousePressEvent(e); | ||
2027 | } | 2032 | } | ||
2028 | 2033 | | |||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 2173 | { | |||
2170 | removeAnnotationHovering(); | 2175 | removeAnnotationHovering(); | ||
2171 | 2176 | | |||
2172 | QWidget::leaveEvent(event); | 2177 | QWidget::leaveEvent(event); | ||
2173 | } | 2178 | } | ||
2174 | 2179 | | |||
2175 | void KateIconBorder::mouseMoveEvent(QMouseEvent *e) | 2180 | void KateIconBorder::mouseMoveEvent(QMouseEvent *e) | ||
2176 | { | 2181 | { | ||
2177 | const KateTextLayout &t = m_viewInternal->yToKateTextLayout(e->y()); | 2182 | const KateTextLayout &t = m_viewInternal->yToKateTextLayout(e->y()); | ||
2183 | auto area = positionToArea(e->pos()); | ||||
mwolff: const | |||||
2178 | if (t.isValid()) { | 2184 | if (t.isValid()) { | ||
2179 | if (positionToArea(e->pos()) == FoldingMarkers) { | 2185 | if (area == FoldingMarkers) { | ||
2180 | showDelayedBlock(t.line()); | 2186 | showDelayedBlock(t.line()); | ||
2181 | } else { | 2187 | } else { | ||
2182 | hideBlock(); | 2188 | hideBlock(); | ||
2183 | } | 2189 | } | ||
2184 | if (positionToArea(e->pos()) == AnnotationBorder) { | 2190 | if (area == AnnotationBorder) { | ||
2185 | KTextEditor::AnnotationModel *model = m_view->annotationModel() ? | 2191 | KTextEditor::AnnotationModel *model = m_view->annotationModel() ? | ||
2186 | m_view->annotationModel() : m_doc->annotationModel(); | 2192 | m_view->annotationModel() : m_doc->annotationModel(); | ||
2187 | if (model) { | 2193 | if (model) { | ||
2188 | m_hoveredAnnotationGroupIdentifier = model->data( t.line(), | 2194 | m_hoveredAnnotationGroupIdentifier = model->data( t.line(), | ||
2189 | (Qt::ItemDataRole) KTextEditor::AnnotationModel::GroupIdentifierRole ).toString(); | 2195 | (Qt::ItemDataRole) KTextEditor::AnnotationModel::GroupIdentifierRole ).toString(); | ||
2190 | showAnnotationTooltip(t.line(), e->globalPos()); | 2196 | showAnnotationTooltip(t.line(), e->globalPos()); | ||
2191 | QTimer::singleShot(0, this, SLOT(update())); | 2197 | QTimer::singleShot(0, this, SLOT(update())); | ||
2192 | } | 2198 | } | ||
2193 | } else { | 2199 | } else { | ||
2194 | if (positionToArea(e->pos()) == IconBorder) { | 2200 | if (area == IconBorder) { | ||
2195 | m_doc->requestMarkTooltip(t.line(), e->globalPos()); | 2201 | m_doc->requestMarkTooltip(t.line(), e->globalPos()); | ||
2196 | } | 2202 | } | ||
2197 | 2203 | | |||
2198 | m_hoveredAnnotationGroupIdentifier.clear(); | 2204 | m_hoveredAnnotationGroupIdentifier.clear(); | ||
2199 | hideAnnotationTooltip(); | 2205 | hideAnnotationTooltip(); | ||
2200 | QTimer::singleShot(0, this, SLOT(update())); | 2206 | QTimer::singleShot(0, this, SLOT(update())); | ||
2201 | } | 2207 | } | ||
2202 | if (positionToArea(e->pos()) != IconBorder) { | | |||
2203 | QPoint p = m_viewInternal->mapFromGlobal(e->globalPos()); | | |||
2204 | QMouseEvent forward(QEvent::MouseMove, p, e->button(), e->buttons(), e->modifiers()); | | |||
2205 | m_viewInternal->mouseMoveEvent(&forward); | | |||
2206 | } | | |||
2207 | } else { | 2208 | } else { | ||
2208 | // remove hovering if it's still there | 2209 | // remove hovering if it's still there | ||
2209 | removeAnnotationHovering(); | 2210 | removeAnnotationHovering(); | ||
2210 | } | 2211 | } | ||
2212 | // always forward event so dragging on border to select lines will scroll down when at top | ||||
2213 | if (area != IconBorder) { | ||||
2214 | QPoint p = m_viewInternal->mapFromGlobal(e->globalPos()); | ||||
2215 | QMouseEvent forward(QEvent::MouseMove, p, e->button(), e->buttons(), e->modifiers()); | ||||
2216 | m_viewInternal->mouseMoveEvent(&forward); | ||||
2217 | } | ||||
2211 | 2218 | | |||
2212 | QWidget::mouseMoveEvent(e); | 2219 | QWidget::mouseMoveEvent(e); | ||
2213 | } | 2220 | } | ||
2214 | 2221 | | |||
2215 | void KateIconBorder::mouseReleaseEvent(QMouseEvent *e) | 2222 | void KateIconBorder::mouseReleaseEvent(QMouseEvent *e) | ||
2216 | { | 2223 | { | ||
2217 | const int cursorOnLine = m_viewInternal->yToKateTextLayout(e->y()).line(); | 2224 | const int cursorOnLine = m_viewInternal->yToKateTextLayout(e->y()).line(); | ||
2218 | if (cursorOnLine == m_lastClickedLine && cursorOnLine >= 0 && cursorOnLine <= m_doc->lastLine()) { | 2225 | if (cursorOnLine == m_lastClickedLine && cursorOnLine >= 0 && cursorOnLine <= m_doc->lastLine()) { | ||
▲ Show 20 Lines • Show All 667 Lines • Show Last 20 Lines |
can you comment this code, why exclude these areas?