Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateview.cpp
Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Line(s) | 225 | if (messageWidget) { | |||
---|---|---|---|---|---|
230 | connect(this, SIGNAL(cursorPositionChanged(KTextEditor::View*,KTextEditor::Cursor)), messageWidget, SLOT(startAutoHideTimer())); | 230 | connect(this, SIGNAL(cursorPositionChanged(KTextEditor::View*,KTextEditor::Cursor)), messageWidget, SLOT(startAutoHideTimer())); | ||
231 | } | 231 | } | ||
232 | } | 232 | } | ||
233 | 233 | | |||
234 | // folding restoration on reload | 234 | // folding restoration on reload | ||
235 | connect(m_doc, SIGNAL(aboutToReload(KTextEditor::Document*)), SLOT(saveFoldingState())); | 235 | connect(m_doc, SIGNAL(aboutToReload(KTextEditor::Document*)), SLOT(saveFoldingState())); | ||
236 | connect(m_doc, SIGNAL(reloaded(KTextEditor::Document*)), SLOT(applyFoldingState())); | 236 | connect(m_doc, SIGNAL(reloaded(KTextEditor::Document*)), SLOT(applyFoldingState())); | ||
237 | 237 | | |||
238 | connect(m_doc, &KTextEditor::DocumentPrivate::reloaded, this, &KTextEditor::ViewPrivate::slotDocumentReloaded); | ||||
239 | connect(m_doc, &KTextEditor::DocumentPrivate::aboutToReload, this, &KTextEditor::ViewPrivate::slotDocumentAboutToReload); | ||||
dhaumann: Could you use new-style signal/slot syntax for new code? :) | |||||
Yeah, normally I do. Here I was not sure if it will keeped/accepted and only did lazy copy old code :-) BTW I'm surprised that such function (slot) didn't alrady exist. Instead will in the doc all views at some points directly called to update some things. See e.g. DocumentPrivate::documentReload:4310 loh.tar: Yeah, normally I do. Here I was not sure if it will keeped/accepted and only did lazy copy old… | |||||
240 | | ||||
238 | // update highlights on scrolling and co | 241 | // update highlights on scrolling and co | ||
239 | connect(this, SIGNAL(displayRangeChanged(KTextEditor::ViewPrivate*)), this, SLOT(createHighlights())); | 242 | connect(this, SIGNAL(displayRangeChanged(KTextEditor::ViewPrivate*)), this, SLOT(createHighlights())); | ||
240 | 243 | | |||
241 | // clear highlights on reload | 244 | // clear highlights on reload | ||
242 | connect(m_doc, SIGNAL(aboutToReload(KTextEditor::Document*)), SLOT(clearHighlights())); | 245 | connect(m_doc, SIGNAL(aboutToReload(KTextEditor::Document*)), SLOT(clearHighlights())); | ||
243 | 246 | | |||
244 | // setup layout | 247 | // setup layout | ||
245 | setupLayout(); | 248 | setupLayout(); | ||
▲ Show 20 Lines • Show All 497 Lines • ▼ Show 20 Line(s) | 470 | { | |||
743 | a->setWhatsThis(i18n("Show/hide the marks on the vertical scrollbar.<br /><br />The marks show bookmarks, for instance.")); | 746 | a->setWhatsThis(i18n("Show/hide the marks on the vertical scrollbar.<br /><br />The marks show bookmarks, for instance.")); | ||
744 | connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMarks())); | 747 | connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMarks())); | ||
745 | 748 | | |||
746 | a = m_toggleScrollBarMiniMap = toggleAction = new KToggleAction(i18n("Show Scrollbar Mini-Map"), this); | 749 | a = m_toggleScrollBarMiniMap = toggleAction = new KToggleAction(i18n("Show Scrollbar Mini-Map"), this); | ||
747 | ac->addAction(QStringLiteral("view_scrollbar_minimap"), a); | 750 | ac->addAction(QStringLiteral("view_scrollbar_minimap"), a); | ||
748 | a->setWhatsThis(i18n("Show/hide the mini-map on the vertical scrollbar.<br /><br />The mini-map shows an overview of the whole document.")); | 751 | a->setWhatsThis(i18n("Show/hide the mini-map on the vertical scrollbar.<br /><br />The mini-map shows an overview of the whole document.")); | ||
749 | connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMiniMap())); | 752 | connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMiniMap())); | ||
750 | 753 | | |||
754 | a = m_doc->autoReloadToggleAction(); | ||||
755 | ac->addAction(QStringLiteral("view_auto_reload"), a); | ||||
756 | | ||||
751 | // a = m_toggleScrollBarMiniMapAll = toggleAction = new KToggleAction(i18n("Show the whole document in the Mini-Map"), this); | 757 | // a = m_toggleScrollBarMiniMapAll = toggleAction = new KToggleAction(i18n("Show the whole document in the Mini-Map"), this); | ||
752 | // ac->addAction(QLatin1String("view_scrollbar_minimap_all"), a); | 758 | // ac->addAction(QLatin1String("view_scrollbar_minimap_all"), a); | ||
753 | // a->setWhatsThis(i18n("Display the whole document in the mini-map.<br /><br />With this option set the whole document will be visible in the mini-map.")); | 759 | // a->setWhatsThis(i18n("Display the whole document in the mini-map.<br /><br />With this option set the whole document will be visible in the mini-map.")); | ||
754 | // connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMiniMapAll())); | 760 | // connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMiniMapAll())); | ||
755 | // connect(m_toggleScrollBarMiniMap, SIGNAL(triggered(bool)), m_toggleScrollBarMiniMapAll, SLOT(setEnabled(bool))); | 761 | // connect(m_toggleScrollBarMiniMap, SIGNAL(triggered(bool)), m_toggleScrollBarMiniMapAll, SLOT(setEnabled(bool))); | ||
756 | 762 | | |||
757 | a = m_toggleNPSpaces = new KToggleAction(i18n("Show Non-Printable Spaces"), this); | 763 | a = m_toggleNPSpaces = new KToggleAction(i18n("Show Non-Printable Spaces"), this); | ||
758 | ac->addAction(QStringLiteral("view_non_printable_spaces"), a); | 764 | ac->addAction(QStringLiteral("view_non_printable_spaces"), a); | ||
▲ Show 20 Lines • Show All 552 Lines • ▼ Show 20 Line(s) | 1313 | Q_FOREACH(QAction *action, m_inputModeActions->actions()) { | |||
1311 | } | 1317 | } | ||
1312 | } | 1318 | } | ||
1313 | 1319 | | |||
1314 | /* inform the rest of the system about the change */ | 1320 | /* inform the rest of the system about the change */ | ||
1315 | emit viewInputModeChanged(this, mode); | 1321 | emit viewInputModeChanged(this, mode); | ||
1316 | emit viewModeChanged(this, viewMode()); | 1322 | emit viewModeChanged(this, viewMode()); | ||
1317 | } | 1323 | } | ||
1318 | 1324 | | |||
1325 | void KTextEditor::ViewPrivate::slotDocumentAboutToReload() | ||||
1326 | { | ||||
1327 | if (doc()->isAutoReload()) { | ||||
1328 | const int lastVisibleLine = m_viewInternal->endLine(); | ||||
1329 | const int currentLine = cursorPosition().line(); | ||||
1330 | m_gotoBottomAfterReload = (lastVisibleLine == currentLine) && (currentLine == doc()->lastLine()); | ||||
1331 | if (!m_gotoBottomAfterReload) { | ||||
1332 | // Ensure the view jumps not back when user scrolls around | ||||
1333 | const int firstVisibleLine = 1 + lastVisibleLine - m_viewInternal->linesDisplayed(); | ||||
1334 | const int newLine = qBound(firstVisibleLine, currentLine, lastVisibleLine); | ||||
1335 | setCursorPositionVisual(KTextEditor::Cursor(newLine, cursorPosition().column())); | ||||
1336 | } | ||||
1337 | } else { | ||||
1338 | m_gotoBottomAfterReload = false; | ||||
1339 | } | ||||
1340 | } | ||||
1341 | | ||||
1342 | void KTextEditor::ViewPrivate::slotDocumentReloaded() | ||||
1343 | { | ||||
1344 | if (m_gotoBottomAfterReload) { | ||||
1345 | bottom(); | ||||
1346 | } | ||||
1347 | } | ||||
1348 | | ||||
1319 | void KTextEditor::ViewPrivate::slotGotFocus() | 1349 | void KTextEditor::ViewPrivate::slotGotFocus() | ||
1320 | { | 1350 | { | ||
1321 | //qCDebug(LOG_KTE) << "KTextEditor::ViewPrivate::slotGotFocus"; | 1351 | //qCDebug(LOG_KTE) << "KTextEditor::ViewPrivate::slotGotFocus"; | ||
1322 | currentInputMode()->gotFocus(); | 1352 | currentInputMode()->gotFocus(); | ||
1323 | 1353 | | |||
1324 | /** | 1354 | /** | ||
1325 | * update current view and scrollbars | 1355 | * update current view and scrollbars | ||
1326 | * it is needed for styles that implement different frame and scrollbar | 1356 | * it is needed for styles that implement different frame and scrollbar | ||
▲ Show 20 Lines • Show All 2517 Lines • Show Last 20 Lines |
Could you use new-style signal/slot syntax for new code? :)