mirror of https://github.com/procxx/kepka.git
Refresh filtered results on more dialogs.
This commit is contained in:
parent
df389a365c
commit
219b824338
|
@ -215,7 +215,7 @@ void ShareBox::prepare() {
|
||||||
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
|
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
|
||||||
|
|
||||||
_select->setQueryChangedCallback([=](const QString &query) {
|
_select->setQueryChangedCallback([=](const QString &query) {
|
||||||
onFilterUpdate(query);
|
applyFilterUpdate(query);
|
||||||
});
|
});
|
||||||
_select->setItemRemovedCallback([=](uint64 itemId) {
|
_select->setItemRemovedCallback([=](uint64 itemId) {
|
||||||
if (const auto peer = App::peerLoaded(itemId)) {
|
if (const auto peer = App::peerLoaded(itemId)) {
|
||||||
|
@ -403,7 +403,7 @@ void ShareBox::createButtons() {
|
||||||
addButton(langFactory(lng_cancel), [=] { closeBox(); });
|
addButton(langFactory(lng_cancel), [=] { closeBox(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareBox::onFilterUpdate(const QString &query) {
|
void ShareBox::applyFilterUpdate(const QString &query) {
|
||||||
onScrollToY(0);
|
onScrollToY(0);
|
||||||
_inner->updateFilter(query);
|
_inner->updateFilter(query);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ private:
|
||||||
|
|
||||||
void scrollTo(Ui::ScrollToRequest request);
|
void scrollTo(Ui::ScrollToRequest request);
|
||||||
void needSearchByUsername();
|
void needSearchByUsername();
|
||||||
void onFilterUpdate(const QString &query);
|
void applyFilterUpdate(const QString &query);
|
||||||
void selectedChanged();
|
void selectedChanged();
|
||||||
void createButtons();
|
void createButtons();
|
||||||
int getTopScrollSkip() const;
|
int getTopScrollSkip() const;
|
||||||
|
|
|
@ -1598,7 +1598,7 @@ void DialogsInner::handlePeerNameChange(
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsInner::onFilterUpdate(QString newFilter, bool force) {
|
void DialogsInner::applyFilterUpdate(QString newFilter, bool force) {
|
||||||
const auto mentionsSearch = (newFilter == qstr("@"));
|
const auto mentionsSearch = (newFilter == qstr("@"));
|
||||||
const auto words = mentionsSearch
|
const auto words = mentionsSearch
|
||||||
? QStringList(newFilter)
|
? QStringList(newFilter)
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
void searchInChat(Dialogs::Key key, UserData *from);
|
void searchInChat(Dialogs::Key key, UserData *from);
|
||||||
|
|
||||||
void onFilterUpdate(QString newFilter, bool force = false);
|
void applyFilterUpdate(QString newFilter, bool force = false);
|
||||||
void onHashtagFilterUpdate(QStringRef newFilter);
|
void onHashtagFilterUpdate(QStringRef newFilter);
|
||||||
|
|
||||||
PeerData *updateFromParentDrag(QPoint globalPosition);
|
PeerData *updateFromParentDrag(QPoint globalPosition);
|
||||||
|
|
|
@ -165,13 +165,20 @@ DialogsWidget::DialogsWidget(QWidget *parent, not_null<Window::Controller*> cont
|
||||||
connect(_inner, SIGNAL(cancelSearchInChat()), this, SLOT(onCancelSearchInChat()));
|
connect(_inner, SIGNAL(cancelSearchInChat()), this, SLOT(onCancelSearchInChat()));
|
||||||
subscribe(_inner->searchFromUserChanged, [this](UserData *user) {
|
subscribe(_inner->searchFromUserChanged, [this](UserData *user) {
|
||||||
setSearchInChat(_searchInChat, user);
|
setSearchInChat(_searchInChat, user);
|
||||||
onFilterUpdate(true);
|
applyFilterUpdate(true);
|
||||||
});
|
});
|
||||||
connect(_scroll, SIGNAL(geometryChanged()), _inner, SLOT(onParentGeometryChanged()));
|
connect(_scroll, SIGNAL(geometryChanged()), _inner, SLOT(onParentGeometryChanged()));
|
||||||
connect(_scroll, SIGNAL(scrolled()), this, SLOT(onListScroll()));
|
connect(_scroll, SIGNAL(scrolled()), this, SLOT(onListScroll()));
|
||||||
connect(_filter, SIGNAL(cancelled()), this, SLOT(onCancel()));
|
connect(_filter, &Ui::FlatInput::cancelled, [=] {
|
||||||
connect(_filter, SIGNAL(changed()), this, SLOT(onFilterUpdate()));
|
onCancel();
|
||||||
connect(_filter, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(onFilterCursorMoved(int,int)));
|
});
|
||||||
|
connect(_filter, &Ui::FlatInput::changed, [=] {
|
||||||
|
applyFilterUpdate();
|
||||||
|
});
|
||||||
|
connect(
|
||||||
|
_filter,
|
||||||
|
&Ui::FlatInput::cursorPositionChanged,
|
||||||
|
[=](int from, int to) { onFilterCursorMoved(from, to); });
|
||||||
|
|
||||||
if (!Core::UpdaterDisabled()) {
|
if (!Core::UpdaterDisabled()) {
|
||||||
Core::UpdateChecker checker;
|
Core::UpdateChecker checker;
|
||||||
|
@ -395,7 +402,7 @@ void DialogsWidget::animationCallback() {
|
||||||
updateJumpToDateVisibility(true);
|
updateJumpToDateVisibility(true);
|
||||||
updateSearchFromVisibility(true);
|
updateSearchFromVisibility(true);
|
||||||
|
|
||||||
onFilterUpdate();
|
applyFilterUpdate();
|
||||||
if (App::wnd()) App::wnd()->setInnerFocus();
|
if (App::wnd()) App::wnd()->setInnerFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,6 +449,7 @@ void DialogsWidget::dialogsReceived(
|
||||||
if (!_dialogsRequestId) {
|
if (!_dialogsRequestId) {
|
||||||
refreshLoadMoreButton();
|
refreshLoadMoreButton();
|
||||||
}
|
}
|
||||||
|
refreshSupportFilteredResults();
|
||||||
|
|
||||||
Auth().data().moreChatsLoaded().notify();
|
Auth().data().moreChatsLoaded().notify();
|
||||||
if (_dialogsFull && _pinnedDialogsReceived) {
|
if (_dialogsFull && _pinnedDialogsReceived) {
|
||||||
|
@ -450,6 +458,15 @@ void DialogsWidget::dialogsReceived(
|
||||||
Auth().api().requestContacts();
|
Auth().api().requestContacts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogsWidget::refreshSupportFilteredResults() {
|
||||||
|
if (!Auth().supportMode()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto top = _scroll->scrollTop();
|
||||||
|
applyFilterUpdate(true);
|
||||||
|
_scroll->scrollToY(top);
|
||||||
|
}
|
||||||
|
|
||||||
void DialogsWidget::updateDialogsOffset(
|
void DialogsWidget::updateDialogsOffset(
|
||||||
const QVector<MTPDialog> &dialogs,
|
const QVector<MTPDialog> &dialogs,
|
||||||
const QVector<MTPMessage> &messages) {
|
const QVector<MTPMessage> &messages) {
|
||||||
|
@ -741,7 +758,7 @@ void DialogsWidget::searchMessages(
|
||||||
}
|
}
|
||||||
_filter->setText(query);
|
_filter->setText(query);
|
||||||
_filter->updatePlaceholder();
|
_filter->updatePlaceholder();
|
||||||
onFilterUpdate(true);
|
applyFilterUpdate(true);
|
||||||
_searchTimer.stop();
|
_searchTimer.stop();
|
||||||
onSearchMessages();
|
onSearchMessages();
|
||||||
|
|
||||||
|
@ -1115,11 +1132,11 @@ void DialogsWidget::onListScroll() {
|
||||||
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
|
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsWidget::onFilterUpdate(bool force) {
|
void DialogsWidget::applyFilterUpdate(bool force) {
|
||||||
if (_a_show.animating() && !force) return;
|
if (_a_show.animating() && !force) return;
|
||||||
|
|
||||||
auto filterText = _filter->getLastText();
|
auto filterText = _filter->getLastText();
|
||||||
_inner->onFilterUpdate(filterText, force);
|
_inner->applyFilterUpdate(filterText, force);
|
||||||
if (filterText.isEmpty() && !_searchFromUser) {
|
if (filterText.isEmpty() && !_searchFromUser) {
|
||||||
clearSearchCache();
|
clearSearchCache();
|
||||||
}
|
}
|
||||||
|
@ -1146,7 +1163,7 @@ void DialogsWidget::onFilterUpdate(bool force) {
|
||||||
void DialogsWidget::searchInChat(Dialogs::Key chat) {
|
void DialogsWidget::searchInChat(Dialogs::Key chat) {
|
||||||
onCancelSearch();
|
onCancelSearch();
|
||||||
setSearchInChat(chat);
|
setSearchInChat(chat);
|
||||||
onFilterUpdate(true);
|
applyFilterUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsWidget::setSearchInChat(Dialogs::Key chat, UserData *from) {
|
void DialogsWidget::setSearchInChat(Dialogs::Key chat, UserData *from) {
|
||||||
|
@ -1202,7 +1219,7 @@ void DialogsWidget::showSearchFrom() {
|
||||||
crl::guard(this, [=](not_null<UserData*> user) {
|
crl::guard(this, [=](not_null<UserData*> user) {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
setSearchInChat(chat, user);
|
setSearchInChat(chat, user);
|
||||||
onFilterUpdate(true);
|
applyFilterUpdate(true);
|
||||||
}),
|
}),
|
||||||
crl::guard(this, [=] { _filter->setFocus(); }));
|
crl::guard(this, [=] { _filter->setFocus(); }));
|
||||||
}
|
}
|
||||||
|
@ -1239,7 +1256,7 @@ void DialogsWidget::onCompleteHashtag(QString tag) {
|
||||||
r = t.mid(0, start + 1) + tag + ' ' + t.mid(cur);
|
r = t.mid(0, start + 1) + tag + ' ' + t.mid(cur);
|
||||||
_filter->setText(r);
|
_filter->setText(r);
|
||||||
_filter->setCursorPosition(start + 1 + tag.size() + 1);
|
_filter->setCursorPosition(start + 1 + tag.size() + 1);
|
||||||
onFilterUpdate(true);
|
applyFilterUpdate(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1248,7 +1265,7 @@ void DialogsWidget::onCompleteHashtag(QString tag) {
|
||||||
}
|
}
|
||||||
_filter->setText(t.mid(0, cur) + '#' + tag + ' ' + t.mid(cur));
|
_filter->setText(t.mid(0, cur) + '#' + tag + ' ' + t.mid(cur));
|
||||||
_filter->setCursorPosition(cur + 1 + tag.size() + 1);
|
_filter->setCursorPosition(cur + 1 + tag.size() + 1);
|
||||||
onFilterUpdate(true);
|
applyFilterUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsWidget::resizeEvent(QResizeEvent *e) {
|
void DialogsWidget::resizeEvent(QResizeEvent *e) {
|
||||||
|
@ -1451,7 +1468,7 @@ void DialogsWidget::scrollToEntry(const Dialogs::RowDescriptor &entry) {
|
||||||
|
|
||||||
void DialogsWidget::removeDialog(Dialogs::Key key) {
|
void DialogsWidget::removeDialog(Dialogs::Key key) {
|
||||||
_inner->removeDialog(key);
|
_inner->removeDialog(key);
|
||||||
onFilterUpdate();
|
applyFilterUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialogs::IndexedList *DialogsWidget::contactsList() {
|
Dialogs::IndexedList *DialogsWidget::contactsList() {
|
||||||
|
@ -1488,7 +1505,7 @@ bool DialogsWidget::onCancelSearch() {
|
||||||
_inner->clearFilter();
|
_inner->clearFilter();
|
||||||
_filter->clear();
|
_filter->clear();
|
||||||
_filter->updatePlaceholder();
|
_filter->updatePlaceholder();
|
||||||
onFilterUpdate();
|
applyFilterUpdate();
|
||||||
return clearing;
|
return clearing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1512,7 +1529,7 @@ void DialogsWidget::onCancelSearchInChat() {
|
||||||
_inner->clearFilter();
|
_inner->clearFilter();
|
||||||
_filter->clear();
|
_filter->clear();
|
||||||
_filter->updatePlaceholder();
|
_filter->updatePlaceholder();
|
||||||
onFilterUpdate();
|
applyFilterUpdate();
|
||||||
if (!Adaptive::OneColumn() && !App::main()->selectingPeer()) {
|
if (!Adaptive::OneColumn() && !App::main()->selectingPeer()) {
|
||||||
emit cancelled();
|
emit cancelled();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,6 @@ public slots:
|
||||||
void onCancel();
|
void onCancel();
|
||||||
void onListScroll();
|
void onListScroll();
|
||||||
void activate();
|
void activate();
|
||||||
void onFilterUpdate(bool force = false);
|
|
||||||
bool onCancelSearch();
|
bool onCancelSearch();
|
||||||
void onCancelSearchInChat();
|
void onCancelSearchInChat();
|
||||||
|
|
||||||
|
@ -162,6 +161,8 @@ private:
|
||||||
void updateForwardBar();
|
void updateForwardBar();
|
||||||
void checkUpdateStatus();
|
void checkUpdateStatus();
|
||||||
|
|
||||||
|
void applyFilterUpdate(bool force = false);
|
||||||
|
void refreshSupportFilteredResults();
|
||||||
bool loadingBlockedByDate() const;
|
bool loadingBlockedByDate() const;
|
||||||
void refreshLoadMoreButton();
|
void refreshLoadMoreButton();
|
||||||
|
|
||||||
|
|
|
@ -234,15 +234,19 @@ void CountrySelectBox::prepare() {
|
||||||
setTitle(langFactory(lng_country_select));
|
setTitle(langFactory(lng_country_select));
|
||||||
|
|
||||||
_select->resizeToWidth(st::boxWidth);
|
_select->resizeToWidth(st::boxWidth);
|
||||||
_select->setQueryChangedCallback([this](const QString &query) { onFilterUpdate(query); });
|
_select->setQueryChangedCallback([=](const QString &query) {
|
||||||
_select->setSubmittedCallback([this](Qt::KeyboardModifiers) { onSubmit(); });
|
applyFilterUpdate(query);
|
||||||
|
});
|
||||||
|
_select->setSubmittedCallback([=](Qt::KeyboardModifiers) {
|
||||||
|
submit();
|
||||||
|
});
|
||||||
|
|
||||||
_inner = setInnerWidget(
|
_inner = setInnerWidget(
|
||||||
object_ptr<Inner>(this, _type),
|
object_ptr<Inner>(this, _type),
|
||||||
st::countriesScroll,
|
st::countriesScroll,
|
||||||
_select->height());
|
_select->height());
|
||||||
|
|
||||||
addButton(langFactory(lng_close), [this] { closeBox(); });
|
addButton(langFactory(lng_close), [=] { closeBox(); });
|
||||||
|
|
||||||
setDimensions(st::boxWidth, st::boxMaxListHeight);
|
setDimensions(st::boxWidth, st::boxMaxListHeight);
|
||||||
|
|
||||||
|
@ -250,7 +254,7 @@ void CountrySelectBox::prepare() {
|
||||||
connect(_inner, SIGNAL(countryChosen(const QString&)), this, SIGNAL(countryChosen(const QString&)));
|
connect(_inner, SIGNAL(countryChosen(const QString&)), this, SIGNAL(countryChosen(const QString&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CountrySelectBox::onSubmit() {
|
void CountrySelectBox::submit() {
|
||||||
_inner->chooseCountry();
|
_inner->chooseCountry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +281,7 @@ void CountrySelectBox::resizeEvent(QResizeEvent *e) {
|
||||||
_inner->resizeToWidth(width());
|
_inner->resizeToWidth(width());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CountrySelectBox::onFilterUpdate(const QString &query) {
|
void CountrySelectBox::applyFilterUpdate(const QString &query) {
|
||||||
onScrollToY(0);
|
onScrollToY(0);
|
||||||
_inner->updateFilter(query);
|
_inner->updateFilter(query);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,11 +77,9 @@ protected:
|
||||||
void keyPressEvent(QKeyEvent *e) override;
|
void keyPressEvent(QKeyEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onSubmit();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onFilterUpdate(const QString &query);
|
void submit();
|
||||||
|
void applyFilterUpdate(const QString &query);
|
||||||
|
|
||||||
Type _type = Type::Phones;
|
Type _type = Type::Phones;
|
||||||
object_ptr<Ui::MultiSelect> _select;
|
object_ptr<Ui::MultiSelect> _select;
|
||||||
|
|
Loading…
Reference in New Issue