Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateview.cpp
Show First 20 Lines • Show All 1531 Lines • ▼ Show 20 Line(s) | 1521 | static const auto l = { | |||
---|---|---|---|---|---|
1532 | , QStringLiteral("tools_lowercase") | 1532 | , QStringLiteral("tools_lowercase") | ||
1533 | , QStringLiteral("tools_capitalize") | 1533 | , QStringLiteral("tools_capitalize") | ||
1534 | , QStringLiteral("tools_join_lines") | 1534 | , QStringLiteral("tools_join_lines") | ||
1535 | , QStringLiteral("tools_apply_wordwrap") | 1535 | , QStringLiteral("tools_apply_wordwrap") | ||
1536 | , QStringLiteral("tools_spelling_from_cursor") | 1536 | , QStringLiteral("tools_spelling_from_cursor") | ||
1537 | , QStringLiteral("tools_spelling_selection") | 1537 | , QStringLiteral("tools_spelling_selection") | ||
1538 | }; | 1538 | }; | ||
1539 | 1539 | | |||
1540 | foreach (const auto &action, l) { | 1540 | for (const auto &action : l) { | ||
1541 | QAction *a = actionCollection()->action(action); | 1541 | QAction *a = actionCollection()->action(action); | ||
1542 | if (a) { | 1542 | if (a) { | ||
1543 | a->setEnabled(doc()->isReadWrite()); | 1543 | a->setEnabled(doc()->isReadWrite()); | ||
1544 | } | 1544 | } | ||
1545 | } | 1545 | } | ||
1546 | slotUpdateUndo(); | 1546 | slotUpdateUndo(); | ||
1547 | 1547 | | |||
1548 | currentInputMode()->readWriteChanged(doc()->isReadWrite()); | 1548 | currentInputMode()->readWriteChanged(doc()->isReadWrite()); | ||
▲ Show 20 Lines • Show All 1644 Lines • ▼ Show 20 Line(s) | 3190 | { | |||
3193 | } else { | 3193 | } else { | ||
3194 | KXMLGUIClient *client = const_cast<KTextEditor::ViewPrivate *>(this); | 3194 | KXMLGUIClient *client = const_cast<KTextEditor::ViewPrivate *>(this); | ||
3195 | while (client->parentClient()) { | 3195 | while (client->parentClient()) { | ||
3196 | client = client->parentClient(); | 3196 | client = client->parentClient(); | ||
3197 | } | 3197 | } | ||
3198 | 3198 | | |||
3199 | //qCDebug(LOG_KTE) << "looking up all menu containers"; | 3199 | //qCDebug(LOG_KTE) << "looking up all menu containers"; | ||
3200 | if (client->factory()) { | 3200 | if (client->factory()) { | ||
3201 | QList<QWidget *> conts = client->factory()->containers(QStringLiteral("menu")); | 3201 | const QList<QWidget *> menuContainers = client->factory()->containers(QStringLiteral("menu")); | ||
3202 | foreach (QWidget *w, conts) { | 3202 | for (QWidget *w : menuContainers) { | ||
3203 | if (w->objectName() == QLatin1String("ktexteditor_popup")) { | 3203 | if (w->objectName() == QLatin1String("ktexteditor_popup")) { | ||
3204 | //perhaps optimize this block | 3204 | //perhaps optimize this block | ||
3205 | QMenu *menu = (QMenu *)w; | 3205 | QMenu *menu = (QMenu *)w; | ||
3206 | // menu is a reusable instance shared among all views. Therefore, | 3206 | // menu is a reusable instance shared among all views. Therefore, | ||
3207 | // disconnect the current receiver(s) from the menu show/hide signals | 3207 | // disconnect the current receiver(s) from the menu show/hide signals | ||
3208 | // before connecting `this` view. This ensures that only the current | 3208 | // before connecting `this` view. This ensures that only the current | ||
3209 | // view gets a signal when the menu is about to be shown or hidden, | 3209 | // view gets a signal when the menu is about to be shown or hidden, | ||
3210 | // and not also the view(s) that previously had the menu open. | 3210 | // and not also the view(s) that previously had the menu open. | ||
▲ Show 20 Lines • Show All 284 Lines • ▼ Show 20 Line(s) | 3493 | if (contentsRect.isValid()) { | |||
3495 | opt.initFrom(this); | 3495 | opt.initFrom(this); | ||
3496 | opt.frameShape = QFrame::StyledPanel; | 3496 | opt.frameShape = QFrame::StyledPanel; | ||
3497 | opt.state |= QStyle::State_Sunken; | 3497 | opt.state |= QStyle::State_Sunken; | ||
3498 | 3498 | | |||
3499 | // clear mouseOver and focus state | 3499 | // clear mouseOver and focus state | ||
3500 | // update from relevant widgets | 3500 | // update from relevant widgets | ||
3501 | opt.state &= ~(QStyle::State_HasFocus|QStyle::State_MouseOver); | 3501 | opt.state &= ~(QStyle::State_HasFocus|QStyle::State_MouseOver); | ||
3502 | const QList<QWidget *> widgets = QList<QWidget *>() << m_viewInternal << m_viewInternal->m_leftBorder << m_viewInternal->m_lineScroll << m_viewInternal->m_columnScroll; | 3502 | const QList<QWidget *> widgets = QList<QWidget *>() << m_viewInternal << m_viewInternal->m_leftBorder << m_viewInternal->m_lineScroll << m_viewInternal->m_columnScroll; | ||
3503 | foreach (const QWidget *w, widgets) { | 3503 | for (const QWidget *w : widgets) { | ||
3504 | if (w->hasFocus()) opt.state |= QStyle::State_HasFocus; | 3504 | if (w->hasFocus()) opt.state |= QStyle::State_HasFocus; | ||
3505 | if (w->underMouse()) opt.state |= QStyle::State_MouseOver; | 3505 | if (w->underMouse()) opt.state |= QStyle::State_MouseOver; | ||
3506 | } | 3506 | } | ||
3507 | 3507 | | |||
3508 | // update rect | 3508 | // update rect | ||
3509 | opt.rect=contentsRect; | 3509 | opt.rect=contentsRect; | ||
3510 | 3510 | | |||
3511 | // render | 3511 | // render | ||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 3602 | { | |||
3614 | foreach (Kate::TextRange *range, oldSet) | 3614 | foreach (Kate::TextRange *range, oldSet) | ||
3615 | if (doc()->buffer().rangePointerValid(range)) { | 3615 | if (doc()->buffer().rangePointerValid(range)) { | ||
3616 | validRanges.insert(range); | 3616 | validRanges.insert(range); | ||
3617 | } | 3617 | } | ||
3618 | 3618 | | |||
3619 | // cursor valid? else no new ranges can be found | 3619 | // cursor valid? else no new ranges can be found | ||
3620 | if (currentCursor.isValid() && currentCursor.line() < doc()->buffer().lines()) { | 3620 | if (currentCursor.isValid() && currentCursor.line() < doc()->buffer().lines()) { | ||
3621 | // now: get current ranges for the line of cursor with an attribute | 3621 | // now: get current ranges for the line of cursor with an attribute | ||
3622 | QList<Kate::TextRange *> rangesForCurrentCursor = doc()->buffer().rangesForLine(currentCursor.line(), this, false); | 3622 | const QList<Kate::TextRange *> rangesForCurrentCursor = doc()->buffer().rangesForLine(currentCursor.line(), this, false); | ||
3623 | 3623 | | |||
3624 | // match which ranges really fit the given cursor | 3624 | // match which ranges really fit the given cursor | ||
3625 | foreach (Kate::TextRange *range, rangesForCurrentCursor) { | 3625 | for (Kate::TextRange *range : rangesForCurrentCursor) { | ||
3626 | // range has no dynamic attribute of right type and no feedback object | 3626 | // range has no dynamic attribute of right type and no feedback object | ||
3627 | if ((!range->attribute() || !range->attribute()->dynamicAttribute(activationType)) && !range->feedback()) { | 3627 | if ((!range->attribute() || !range->attribute()->dynamicAttribute(activationType)) && !range->feedback()) { | ||
3628 | continue; | 3628 | continue; | ||
3629 | } | 3629 | } | ||
3630 | 3630 | | |||
3631 | // range doesn't contain cursor, not interesting | 3631 | // range doesn't contain cursor, not interesting | ||
3632 | if ((range->start().insertBehavior() == KTextEditor::MovingCursor::StayOnInsert) | 3632 | if ((range->start().insertBehavior() == KTextEditor::MovingCursor::StayOnInsert) | ||
3633 | ? (currentCursor < range->start().toCursor()) : (currentCursor <= range->start().toCursor())) { | 3633 | ? (currentCursor < range->start().toCursor()) : (currentCursor <= range->start().toCursor())) { | ||
Show All 33 Lines | |||||
3667 | #ifdef VIEW_RANGE_DEBUG | 3667 | #ifdef VIEW_RANGE_DEBUG | ||
3668 | // found new range for activation | 3668 | // found new range for activation | ||
3669 | qCDebug(LOG_KTE) << "activated new range" << range << "by" << activationType; | 3669 | qCDebug(LOG_KTE) << "activated new range" << range << "by" << activationType; | ||
3670 | #endif | 3670 | #endif | ||
3671 | } | 3671 | } | ||
3672 | } | 3672 | } | ||
3673 | 3673 | | |||
3674 | // now: notify for left ranges! | 3674 | // now: notify for left ranges! | ||
3675 | foreach (Kate::TextRange *range, validRanges) { | 3675 | for (Kate::TextRange *range : qAsConst(validRanges)) { | ||
3676 | // range valid + right dynamic attribute, trigger update | 3676 | // range valid + right dynamic attribute, trigger update | ||
3677 | if (range->toRange().isValid() && range->attribute() && range->attribute()->dynamicAttribute(activationType)) { | 3677 | if (range->toRange().isValid() && range->attribute() && range->attribute()->dynamicAttribute(activationType)) { | ||
3678 | notifyAboutRangeChange(range->start().line(), range->end().line(), true); | 3678 | notifyAboutRangeChange(range->start().line(), range->end().line(), true); | ||
3679 | } | 3679 | } | ||
3680 | 3680 | | |||
3681 | // feedback | 3681 | // feedback | ||
3682 | if (range->feedback()) { | 3682 | if (range->feedback()) { | ||
3683 | if (activationType == KTextEditor::Attribute::ActivateMouseIn) { | 3683 | if (activationType == KTextEditor::Attribute::ActivateMouseIn) { | ||
▲ Show 20 Lines • Show All 277 Lines • Show Last 20 Lines |