Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewhelpers.cpp
Show First 20 Lines • Show All 2305 Lines • ▼ Show 20 Line(s) | 2305 | if (!m_foldingPreview) { | |||
---|---|---|---|---|---|
2306 | m_foldingPreview = new KateTextPreview(m_view, this); | 2306 | m_foldingPreview = new KateTextPreview(m_view, this); | ||
2307 | m_foldingPreview->setAttribute(Qt::WA_ShowWithoutActivating); | 2307 | m_foldingPreview->setAttribute(Qt::WA_ShowWithoutActivating); | ||
2308 | m_foldingPreview->setFrameStyle(QFrame::StyledPanel); | 2308 | m_foldingPreview->setFrameStyle(QFrame::StyledPanel); | ||
2309 | 2309 | | |||
2310 | // event filter to catch application WindowDeactivate event, to hide the preview window | 2310 | // event filter to catch application WindowDeactivate event, to hide the preview window | ||
2311 | // qApp->installEventFilter(this); | 2311 | // qApp->installEventFilter(this); | ||
2312 | } | 2312 | } | ||
2313 | 2313 | | |||
2314 | // TODO: use KateViewInternal::maxLen() somehow to compute proper width for amount of lines to display | 2314 | // Calc how many lines can be displayed in popup | ||
2315 | 2315 | const int lineHeight = m_view->renderer()->lineHeight(); | |||
2316 | // try using the end line of the range for proper popup height | 2316 | const int lineInDisplay = pos.y() / lineHeight; | ||
2317 | // Allow slightly overpainting of the view bottom to proper cover all lines | ||||
2318 | const int extra = (m_viewInternal->height() % lineHeight) > (lineHeight * 0.6) ? 1 : 0; | ||||
2317 | const int lineCount = qMin(m_foldingRange->numberOfLines() + 1, | 2319 | const int lineCount = qMin(m_foldingRange->numberOfLines() + 1, | ||
2318 | (height() - pos.y()) / m_view->renderer()->lineHeight()); | 2320 | m_viewInternal->linesDisplayed() - lineInDisplay + extra); | ||
2319 | 2321 | | |||
2320 | m_foldingPreview->resize(m_view->width() / 2, lineCount * m_view->renderer()->lineHeight() + 2 * m_foldingPreview->frameWidth()); | 2322 | m_foldingPreview->resize(m_viewInternal->width(), lineCount * lineHeight + 2 * m_foldingPreview->frameWidth()); | ||
2321 | const int xGlobal = mapToGlobal(QPoint(width(), 0)).x(); | 2323 | const int xGlobal = mapToGlobal(QPoint(width(), 0)).x(); | ||
2322 | const int yGlobal = m_view->mapToGlobal(m_view->cursorToCoordinate(KTextEditor::Cursor(realLine, 0))).y(); | 2324 | const int yGlobal = m_view->mapToGlobal(m_view->cursorToCoordinate(KTextEditor::Cursor(realLine, 0))).y(); | ||
2323 | m_foldingPreview->move(QPoint(xGlobal, yGlobal) - m_foldingPreview->contentsRect().topLeft()); | 2325 | m_foldingPreview->move(QPoint(xGlobal, yGlobal) - m_foldingPreview->contentsRect().topLeft()); | ||
2324 | m_foldingPreview->setLine(realLine); | 2326 | m_foldingPreview->setLine(realLine); | ||
2325 | m_foldingPreview->setCenterView(false); | 2327 | m_foldingPreview->setCenterView(false); | ||
2326 | m_foldingPreview->setShowFoldedLines(true); | 2328 | m_foldingPreview->setShowFoldedLines(true); | ||
2327 | m_foldingPreview->raise(); | 2329 | m_foldingPreview->raise(); | ||
2328 | m_foldingPreview->show(); | 2330 | m_foldingPreview->show(); | ||
▲ Show 20 Lines • Show All 850 Lines • Show Last 20 Lines |