MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / MultiSelect

Method MultiSelect

Telegram/SourceFiles/ui/widgets/multi_select.cpp:512–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510};
511
512MultiSelect::MultiSelect(
513 QWidget *parent,
514 const style::MultiSelect &st,
515 rpl::producer<QString> placeholder,
516 const QString &query)
517: RpWidget(parent)
518, _st(st)
519, _scroll(this, _st.scroll) {
520 const auto scrollCallback = [=](int activeTop, int activeBottom) {
521 scrollTo(activeTop, activeBottom);
522 };
523 _inner = _scroll->setOwnedWidget(object_ptr<Inner>(
524 this,
525 st,
526 std::move(placeholder),
527 query,
528 scrollCallback));
529 _scroll->installEventFilter(this);
530 _inner->setResizedCallback([this](int innerHeightDelta) {
531 auto newHeight = resizeGetHeight(width());
532 if (innerHeightDelta > 0) {
533 _scroll->scrollToY(_scroll->scrollTop() + innerHeightDelta);
534 }
535 if (newHeight != height()) {
536 resize(width(), newHeight);
537 if (_resizedCallback) {
538 _resizedCallback();
539 }
540 }
541 });
542 _inner->setQueryChangedCallback([this](const QString &query) {
543 _scroll->scrollToY(_scroll->scrollTopMax());
544 if (_queryChangedCallback) {
545 _queryChangedCallback(query);
546 }
547 });
548
549 setAttribute(Qt::WA_OpaquePaintEvent);
550 auto defaultWidth = _st.item.maxWidth + _st.fieldMinWidth + _st.fieldCancelSkip;
551 resizeToWidth(_st.padding.left() + defaultWidth + _st.padding.right());
552}
553
554bool MultiSelect::eventFilter(QObject *o, QEvent *e) {
555 if (o == _scroll && e->type() == QEvent::KeyPress) {

Callers

nothing calls this directly

Calls 4

setResizedCallbackMethod · 0.80
scrollToYMethod · 0.45
scrollTopMethod · 0.45

Tested by

no test coverage detected