Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateview.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 1364 | { | |||
---|---|---|---|---|---|
1369 | if (!m_viewInternal->m_inputModes.contains(mode)) { | 1369 | if (!m_viewInternal->m_inputModes.contains(mode)) { | ||
1370 | return; | 1370 | return; | ||
1371 | } | 1371 | } | ||
1372 | 1372 | | |||
1373 | m_viewInternal->m_currentInputMode->deactivate(); | 1373 | m_viewInternal->m_currentInputMode->deactivate(); | ||
1374 | m_viewInternal->m_currentInputMode = m_viewInternal->m_inputModes[mode]; | 1374 | m_viewInternal->m_currentInputMode = m_viewInternal->m_inputModes[mode]; | ||
1375 | m_viewInternal->m_currentInputMode->activate(); | 1375 | m_viewInternal->m_currentInputMode->activate(); | ||
1376 | 1376 | | |||
1377 | config()->setInputMode(mode); // TODO: this could be called from read config procedure, so it's not a good idea to set a specific view mode here | 1377 | config()->setValue(KateViewConfig::InputMode, mode); // TODO: this could be called from read config procedure, so it's not a good idea to set a specific view mode here | ||
1378 | 1378 | | |||
1379 | /* small duplication, but need to do this if not toggled by action */ | 1379 | /* small duplication, but need to do this if not toggled by action */ | ||
1380 | Q_FOREACH(QAction *action, m_inputModeActions->actions()) { | 1380 | Q_FOREACH(QAction *action, m_inputModeActions->actions()) { | ||
1381 | if (static_cast<InputMode>(action->data().toInt()) == mode) { | 1381 | if (static_cast<InputMode>(action->data().toInt()) == mode) { | ||
1382 | action->setChecked(true); | 1382 | action->setChecked(true); | ||
1383 | break; | 1383 | break; | ||
1384 | } | 1384 | } | ||
1385 | } | 1385 | } | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 1453 | if (m_viewInternal->m_columnScroll->isVisible()) { | |||
1454 | m_viewInternal->m_columnScroll->update(); | 1454 | m_viewInternal->m_columnScroll->update(); | ||
1455 | } | 1455 | } | ||
1456 | 1456 | | |||
1457 | emit focusOut(this); | 1457 | emit focusOut(this); | ||
1458 | } | 1458 | } | ||
1459 | 1459 | | |||
1460 | void KTextEditor::ViewPrivate::setDynWrapIndicators(int mode) | 1460 | void KTextEditor::ViewPrivate::setDynWrapIndicators(int mode) | ||
1461 | { | 1461 | { | ||
1462 | config()->setDynWordWrapIndicators(mode); | 1462 | config()->setValue(KateViewConfig::DynWordWrapIndicators, mode); | ||
1463 | } | 1463 | } | ||
1464 | 1464 | | |||
1465 | bool KTextEditor::ViewPrivate::isOverwriteMode() const | 1465 | bool KTextEditor::ViewPrivate::isOverwriteMode() const | ||
1466 | { | 1466 | { | ||
1467 | return doc()->config()->ovr(); | 1467 | return doc()->config()->ovr(); | ||
1468 | } | 1468 | } | ||
1469 | 1469 | | |||
1470 | void KTextEditor::ViewPrivate::reloadFile() | 1470 | void KTextEditor::ViewPrivate::reloadFile() | ||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | |||||
1605 | 1605 | | |||
1606 | void KTextEditor::ViewPrivate::readSessionConfig(const KConfigGroup &config, const QSet<QString> &flags) | 1606 | void KTextEditor::ViewPrivate::readSessionConfig(const KConfigGroup &config, const QSet<QString> &flags) | ||
1607 | { | 1607 | { | ||
1608 | Q_UNUSED(flags) | 1608 | Q_UNUSED(flags) | ||
1609 | 1609 | | |||
1610 | // cursor position | 1610 | // cursor position | ||
1611 | setCursorPositionInternal(KTextEditor::Cursor(config.readEntry("CursorLine", 0), config.readEntry("CursorColumn", 0))); | 1611 | setCursorPositionInternal(KTextEditor::Cursor(config.readEntry("CursorLine", 0), config.readEntry("CursorColumn", 0))); | ||
1612 | 1612 | | |||
1613 | // restore dyn word wrap if set for this view | 1613 | m_config->setDynWordWrap(config.readEntry("Dynamic Word Wrap", false)); | ||
1614 | if (config.hasKey("Dynamic Word Wrap")) { | | |||
1615 | m_config->setDynWordWrap(config.readEntry("Dynamic Word Wrap", false)); | | |||
1616 | } | | |||
1617 | 1614 | | |||
1618 | // restore text folding | 1615 | // restore text folding | ||
1619 | m_savedFoldingState = QJsonDocument::fromJson(config.readEntry("TextFolding", QByteArray())); | 1616 | m_savedFoldingState = QJsonDocument::fromJson(config.readEntry("TextFolding", QByteArray())); | ||
1620 | applyFoldingState(); | 1617 | applyFoldingState(); | ||
1621 | 1618 | | |||
1622 | Q_FOREACH(KateAbstractInputMode *mode, m_viewInternal->m_inputModes) { | 1619 | Q_FOREACH(KateAbstractInputMode *mode, m_viewInternal->m_inputModes) { | ||
1623 | mode->readSessionConfig(config); | 1620 | mode->readSessionConfig(config); | ||
1624 | } | 1621 | } | ||
1625 | } | 1622 | } | ||
1626 | 1623 | | |||
1627 | void KTextEditor::ViewPrivate::writeSessionConfig(KConfigGroup &config, const QSet<QString> &flags) | 1624 | void KTextEditor::ViewPrivate::writeSessionConfig(KConfigGroup &config, const QSet<QString> &flags) | ||
1628 | { | 1625 | { | ||
1629 | Q_UNUSED(flags) | 1626 | Q_UNUSED(flags) | ||
1630 | 1627 | | |||
1631 | // cursor position | 1628 | // cursor position | ||
1632 | config.writeEntry("CursorLine", cursorPosition().line()); | 1629 | config.writeEntry("CursorLine", cursorPosition().line()); | ||
1633 | config.writeEntry("CursorColumn", cursorPosition().column()); | 1630 | config.writeEntry("CursorColumn", cursorPosition().column()); | ||
1634 | 1631 | | |||
1635 | // save dyn word wrap if set for this view | 1632 | config.writeEntry("Dynamic Word Wrap", m_config->dynWordWrap()); | ||
1636 | if (m_config->dynWordWrapSet()) { | | |||
1637 | config.writeEntry("Dynamic Word Wrap", m_config->dynWordWrap()); | | |||
1638 | } | | |||
1639 | 1633 | | |||
1640 | // save text folding state | 1634 | // save text folding state | ||
1641 | saveFoldingState(); | 1635 | saveFoldingState(); | ||
1642 | config.writeEntry("TextFolding", m_savedFoldingState.toJson(QJsonDocument::Compact)); | 1636 | config.writeEntry("TextFolding", m_savedFoldingState.toJson(QJsonDocument::Compact)); | ||
1643 | m_savedFoldingState = QJsonDocument(); | 1637 | m_savedFoldingState = QJsonDocument(); | ||
1644 | 1638 | | |||
1645 | Q_FOREACH(KateAbstractInputMode *mode, m_viewInternal->m_inputModes) { | 1639 | Q_FOREACH(KateAbstractInputMode *mode, m_viewInternal->m_inputModes) { | ||
1646 | mode->writeSessionConfig(config); | 1640 | mode->writeSessionConfig(config); | ||
Show All 32 Lines | 1666 | { | |||
1679 | } | 1673 | } | ||
1680 | 1674 | | |||
1681 | doc()->config()->setBom(enabled); | 1675 | doc()->config()->setBom(enabled); | ||
1682 | doc()->bomSetByUser(); | 1676 | doc()->bomSetByUser(); | ||
1683 | } | 1677 | } | ||
1684 | 1678 | | |||
1685 | void KTextEditor::ViewPrivate::setIconBorder(bool enable) | 1679 | void KTextEditor::ViewPrivate::setIconBorder(bool enable) | ||
1686 | { | 1680 | { | ||
1687 | config()->setIconBar(enable); | 1681 | config()->setValue(KateViewConfig::ShowIconBar, enable); | ||
1688 | } | 1682 | } | ||
1689 | 1683 | | |||
1690 | void KTextEditor::ViewPrivate::toggleIconBorder() | 1684 | void KTextEditor::ViewPrivate::toggleIconBorder() | ||
1691 | { | 1685 | { | ||
1692 | config()->setIconBar(!config()->iconBar()); | 1686 | config()->setValue(KateViewConfig::ShowIconBar, config()->iconBar()); | ||
1693 | } | 1687 | } | ||
1694 | 1688 | | |||
1695 | void KTextEditor::ViewPrivate::setLineNumbersOn(bool enable) | 1689 | void KTextEditor::ViewPrivate::setLineNumbersOn(bool enable) | ||
1696 | { | 1690 | { | ||
1697 | config()->setLineNumbers(enable); | 1691 | config()->setValue(KateViewConfig::ShowLineNumbers, enable); | ||
1698 | } | 1692 | } | ||
1699 | 1693 | | |||
1700 | void KTextEditor::ViewPrivate::toggleLineNumbersOn() | 1694 | void KTextEditor::ViewPrivate::toggleLineNumbersOn() | ||
1701 | { | 1695 | { | ||
1702 | config()->setLineNumbers(!config()->lineNumbers()); | 1696 | config()->setValue(KateViewConfig::ShowLineNumbers, !config()->lineNumbers()); | ||
1703 | } | 1697 | } | ||
1704 | 1698 | | |||
1705 | void KTextEditor::ViewPrivate::setScrollBarMarks(bool enable) | 1699 | void KTextEditor::ViewPrivate::setScrollBarMarks(bool enable) | ||
1706 | { | 1700 | { | ||
1707 | config()->setScrollBarMarks(enable); | 1701 | config()->setValue(KateViewConfig::ShowScrollBarMarks, enable); | ||
1708 | } | 1702 | } | ||
1709 | 1703 | | |||
1710 | void KTextEditor::ViewPrivate::toggleScrollBarMarks() | 1704 | void KTextEditor::ViewPrivate::toggleScrollBarMarks() | ||
1711 | { | 1705 | { | ||
1712 | config()->setScrollBarMarks(!config()->scrollBarMarks()); | 1706 | config()->setValue(KateViewConfig::ShowScrollBarMarks, !config()->scrollBarMarks()); | ||
1713 | } | 1707 | } | ||
1714 | 1708 | | |||
1715 | void KTextEditor::ViewPrivate::setScrollBarMiniMap(bool enable) | 1709 | void KTextEditor::ViewPrivate::setScrollBarMiniMap(bool enable) | ||
1716 | { | 1710 | { | ||
1717 | config()->setScrollBarMiniMap(enable); | 1711 | config()->setValue(KateViewConfig::ShowScrollBarMiniMap, enable); | ||
1718 | } | 1712 | } | ||
1719 | 1713 | | |||
1720 | void KTextEditor::ViewPrivate::toggleScrollBarMiniMap() | 1714 | void KTextEditor::ViewPrivate::toggleScrollBarMiniMap() | ||
1721 | { | 1715 | { | ||
1722 | config()->setScrollBarMiniMap(!config()->scrollBarMiniMap()); | 1716 | config()->setValue(KateViewConfig::ShowScrollBarMiniMap, !config()->scrollBarMiniMap()); | ||
1723 | } | 1717 | } | ||
1724 | 1718 | | |||
1725 | void KTextEditor::ViewPrivate::setScrollBarMiniMapAll(bool enable) | 1719 | void KTextEditor::ViewPrivate::setScrollBarMiniMapAll(bool enable) | ||
1726 | { | 1720 | { | ||
1727 | config()->setScrollBarMiniMapAll(enable); | 1721 | config()->setValue(KateViewConfig::ShowScrollBarMiniMapAll, enable); | ||
1728 | } | 1722 | } | ||
1729 | 1723 | | |||
1730 | void KTextEditor::ViewPrivate::toggleScrollBarMiniMapAll() | 1724 | void KTextEditor::ViewPrivate::toggleScrollBarMiniMapAll() | ||
1731 | { | 1725 | { | ||
1732 | config()->setScrollBarMiniMapAll(!config()->scrollBarMiniMapAll()); | 1726 | config()->setValue(KateViewConfig::ShowScrollBarMiniMapAll, !config()->scrollBarMiniMapAll()); | ||
1733 | } | 1727 | } | ||
1734 | 1728 | | |||
1735 | void KTextEditor::ViewPrivate::setScrollBarMiniMapWidth(int width) | 1729 | void KTextEditor::ViewPrivate::setScrollBarMiniMapWidth(int width) | ||
1736 | { | 1730 | { | ||
1737 | config()->setScrollBarMiniMapWidth(width); | 1731 | config()->setValue(KateViewConfig::ScrollBarMiniMapWidth, width); | ||
1738 | } | 1732 | } | ||
1739 | 1733 | | |||
1740 | void KTextEditor::ViewPrivate::toggleDynWordWrap() | 1734 | void KTextEditor::ViewPrivate::toggleDynWordWrap() | ||
1741 | { | 1735 | { | ||
1742 | config()->setDynWordWrap(!config()->dynWordWrap()); | 1736 | config()->setDynWordWrap(!config()->dynWordWrap()); | ||
1743 | } | 1737 | } | ||
1744 | 1738 | | |||
1745 | void KTextEditor::ViewPrivate::toggleWWMarker() | 1739 | void KTextEditor::ViewPrivate::toggleWWMarker() | ||
Show All 9 Lines | |||||
1755 | 1749 | | |||
1756 | void KTextEditor::ViewPrivate::toggleWordCount(bool on) | 1750 | void KTextEditor::ViewPrivate::toggleWordCount(bool on) | ||
1757 | { | 1751 | { | ||
1758 | config()->setShowWordCount(on); | 1752 | config()->setShowWordCount(on); | ||
1759 | } | 1753 | } | ||
1760 | 1754 | | |||
1761 | void KTextEditor::ViewPrivate::setFoldingMarkersOn(bool enable) | 1755 | void KTextEditor::ViewPrivate::setFoldingMarkersOn(bool enable) | ||
1762 | { | 1756 | { | ||
1763 | config()->setFoldingBar(enable); | 1757 | config()->setValue(KateViewConfig::ShowFoldingBar, enable); | ||
1764 | } | 1758 | } | ||
1765 | 1759 | | |||
1766 | void KTextEditor::ViewPrivate::toggleFoldingMarkers() | 1760 | void KTextEditor::ViewPrivate::toggleFoldingMarkers() | ||
1767 | { | 1761 | { | ||
1768 | config()->setFoldingBar(!config()->foldingBar()); | 1762 | config()->setValue(KateViewConfig::ShowFoldingBar, !config()->foldingBar()); | ||
1769 | } | 1763 | } | ||
1770 | 1764 | | |||
1771 | bool KTextEditor::ViewPrivate::iconBorder() | 1765 | bool KTextEditor::ViewPrivate::iconBorder() | ||
1772 | { | 1766 | { | ||
1773 | return m_viewInternal->m_leftBorder->iconBorderOn(); | 1767 | return m_viewInternal->m_leftBorder->iconBorderOn(); | ||
1774 | } | 1768 | } | ||
1775 | 1769 | | |||
1776 | bool KTextEditor::ViewPrivate::lineNumbersOn() | 1770 | bool KTextEditor::ViewPrivate::lineNumbersOn() | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | |||||
2608 | 2602 | | |||
2609 | bool KTextEditor::ViewPrivate::isAutomaticInvocationEnabled() const | 2603 | bool KTextEditor::ViewPrivate::isAutomaticInvocationEnabled() const | ||
2610 | { | 2604 | { | ||
2611 | return !m_temporaryAutomaticInvocationDisabled && m_config->automaticCompletionInvocation(); | 2605 | return !m_temporaryAutomaticInvocationDisabled && m_config->automaticCompletionInvocation(); | ||
2612 | } | 2606 | } | ||
2613 | 2607 | | |||
2614 | void KTextEditor::ViewPrivate::setAutomaticInvocationEnabled(bool enabled) | 2608 | void KTextEditor::ViewPrivate::setAutomaticInvocationEnabled(bool enabled) | ||
2615 | { | 2609 | { | ||
2616 | config()->setAutomaticCompletionInvocation(enabled); | 2610 | config()->setValue(KateViewConfig::AutomaticCompletionInvocation, enabled); | ||
2617 | } | 2611 | } | ||
2618 | 2612 | | |||
2619 | void KTextEditor::ViewPrivate::sendCompletionExecuted(const KTextEditor::Cursor &position, KTextEditor::CodeCompletionModel *model, const QModelIndex &index) | 2613 | void KTextEditor::ViewPrivate::sendCompletionExecuted(const KTextEditor::Cursor &position, KTextEditor::CodeCompletionModel *model, const QModelIndex &index) | ||
2620 | { | 2614 | { | ||
2621 | emit completionExecuted(this, position, model, index); | 2615 | emit completionExecuted(this, position, model, index); | ||
2622 | } | 2616 | } | ||
2623 | 2617 | | |||
2624 | void KTextEditor::ViewPrivate::sendCompletionAborted() | 2618 | void KTextEditor::ViewPrivate::sendCompletionAborted() | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 3252 | { | |||
3301 | } | 3295 | } | ||
3302 | 3296 | | |||
3303 | // return invalid variant | 3297 | // return invalid variant | ||
3304 | return QVariant(); | 3298 | return QVariant(); | ||
3305 | } | 3299 | } | ||
3306 | 3300 | | |||
3307 | void KTextEditor::ViewPrivate::setConfigValue(const QString &key, const QVariant &value) | 3301 | void KTextEditor::ViewPrivate::setConfigValue(const QString &key, const QVariant &value) | ||
3308 | { | 3302 | { | ||
3303 | // First, try the new config interface | ||||
3304 | if (config()->setValue(key, value)) { | ||||
3305 | return; | ||||
3306 | | ||||
3307 | } else if (renderer()->config()->setValue(key, value)) { | ||||
3308 | return; | ||||
3309 | } | ||||
3310 | | ||||
3311 | // No success? Go the old way | ||||
3309 | if (value.canConvert(QVariant::Color)) { | 3312 | if (value.canConvert(QVariant::Color)) { | ||
3310 | if (key == QLatin1String("background-color")) { | 3313 | if (key == QLatin1String("background-color")) { | ||
3311 | renderer()->config()->setBackgroundColor(value.value<QColor>()); | 3314 | renderer()->config()->setBackgroundColor(value.value<QColor>()); | ||
3312 | } else if (key == QLatin1String("selection-color")) { | 3315 | } else if (key == QLatin1String("selection-color")) { | ||
3313 | renderer()->config()->setSelectionColor(value.value<QColor>()); | 3316 | renderer()->config()->setSelectionColor(value.value<QColor>()); | ||
3314 | } else if (key == QLatin1String("search-highlight-color")) { | 3317 | } else if (key == QLatin1String("search-highlight-color")) { | ||
3315 | renderer()->config()->setSearchHighlightColor(value.value<QColor>()); | 3318 | renderer()->config()->setSearchHighlightColor(value.value<QColor>()); | ||
3316 | } else if (key == QLatin1String("replace-highlight-color")) { | 3319 | } else if (key == QLatin1String("replace-highlight-color")) { | ||
3317 | renderer()->config()->setReplaceHighlightColor(value.value<QColor>()); | 3320 | renderer()->config()->setReplaceHighlightColor(value.value<QColor>()); | ||
3318 | } else if (key == QLatin1String("icon-border-color")) { | 3321 | } else if (key == QLatin1String("icon-border-color")) { | ||
3319 | renderer()->config()->setIconBarColor(value.value<QColor>()); | 3322 | renderer()->config()->setIconBarColor(value.value<QColor>()); | ||
3320 | } else if (key == QLatin1String("folding-marker-color")) { | 3323 | } else if (key == QLatin1String("folding-marker-color")) { | ||
3321 | renderer()->config()->setFoldingColor(value.value<QColor>()); | 3324 | renderer()->config()->setFoldingColor(value.value<QColor>()); | ||
3322 | } else if (key == QLatin1String("line-number-color")) { | 3325 | } else if (key == QLatin1String("line-number-color")) { | ||
3323 | renderer()->config()->setLineNumberColor(value.value<QColor>()); | 3326 | renderer()->config()->setLineNumberColor(value.value<QColor>()); | ||
3324 | } else if (key == QLatin1String("current-line-number-color")) { | 3327 | } else if (key == QLatin1String("current-line-number-color")) { | ||
3325 | renderer()->config()->setCurrentLineNumberColor(value.value<QColor>()); | 3328 | renderer()->config()->setCurrentLineNumberColor(value.value<QColor>()); | ||
3326 | } | 3329 | } | ||
3327 | 3330 | | |||
3328 | } else if (value.type() == QVariant::Bool) { | 3331 | } else if (value.type() == QVariant::Bool) { | ||
3329 | // Note explicit type check above. If we used canConvert, then | 3332 | // Note explicit type check above. If we used canConvert, then | ||
3330 | // values of type UInt will be trapped here. | 3333 | // values of type UInt will be trapped here. | ||
3331 | if (key == QLatin1String("icon-bar")) { | 3334 | if (key == QLatin1String("dynamic-word-wrap")) { | ||
3332 | config()->setIconBar(value.toBool()); | | |||
3333 | } else if (key == QLatin1String("line-numbers")) { | | |||
3334 | config()->setLineNumbers(value.toBool()); | | |||
3335 | } else if (key == QLatin1String("dynamic-word-wrap")) { | | |||
3336 | config()->setDynWordWrap(value.toBool()); | 3335 | config()->setDynWordWrap(value.toBool()); | ||
3337 | } else if (key == QLatin1String("allow-mark-menu")) { | 3336 | } else if (key == QLatin1String("allow-mark-menu")) { | ||
3338 | config()->setAllowMarkMenu(value.toBool()); | 3337 | config()->setAllowMarkMenu(value.toBool()); | ||
3339 | } else if (key == QLatin1String("folding-bar")) { | | |||
3340 | config()->setFoldingBar(value.toBool()); | | |||
3341 | } else if (key == QLatin1String("folding-preview")) { | | |||
3342 | config()->setFoldingPreview(value.toBool()); | | |||
3343 | } else if (key == QLatin1String("modification-markers")) { | | |||
3344 | config()->setLineModification(value.toBool()); | | |||
3345 | } else if (key == QLatin1String("keyword-completion")) { | | |||
3346 | config()->setKeywordCompletion(value.toBool()); | | |||
3347 | } else if (key == QLatin1String("word-count")) { | 3338 | } else if (key == QLatin1String("word-count")) { | ||
3348 | config()->setShowWordCount(value.toBool()); | 3339 | config()->setShowWordCount(value.toBool()); | ||
3349 | } else if (key == QLatin1String("scrollbar-minimap")) { | | |||
3350 | config()->setScrollBarMiniMap(value.toBool()); | | |||
3351 | } else if (key == QLatin1String("scrollbar-preview")) { | | |||
3352 | config()->setScrollBarPreview(value.toBool()); | | |||
3353 | } | | |||
3354 | | ||||
3355 | } else if (value.canConvert(QVariant::UInt)) { | | |||
3356 | if (key == QLatin1String("default-mark-type")) { | | |||
3357 | config()->setDefaultMarkType(value.toUInt()); | | |||
3358 | } | 3340 | } | ||
3359 | 3341 | | |||
3360 | } else if (value.canConvert(QVariant::Font)) { | 3342 | } else if (value.canConvert(QVariant::Font)) { | ||
3361 | if (key == QLatin1String("font")) { | 3343 | if (key == QLatin1String("font")) { | ||
3362 | renderer()->config()->setFont(value.value<QFont>()); | 3344 | renderer()->config()->setFont(value.value<QFont>()); | ||
3363 | } | 3345 | } | ||
3364 | } | 3346 | } | ||
3365 | } | 3347 | } | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |