Save admin log state to memento and restore it.

This commit is contained in:
John Preston 2017-06-24 20:05:32 +03:00
parent 85e234938d
commit 0a9db8533b
17 changed files with 152 additions and 108 deletions

View File

@ -335,35 +335,22 @@ QPoint InnerWidget::tooltipPos() const {
return _mousePosition;
}
void InnerWidget::saveState(gsl::not_null<SectionMemento*> memento) const {
//if (auto count = _items.size()) {
// QList<gsl::not_null<PeerData*>> groups;
// groups.reserve(count);
// for_const (auto item, _items) {
// groups.push_back(item->peer);
// }
// memento->setCommonGroups(groups);
//}
void InnerWidget::saveState(gsl::not_null<SectionMemento*> memento) {
memento->setItems(std::move(_items), std::move(_itemsByIds), _upLoaded, _downLoaded);
memento->setIdManager(std::move(_idManager));
_upLoaded = _downLoaded = true; // Don't load or handle anything anymore.
}
void InnerWidget::restoreState(gsl::not_null<const SectionMemento*> memento) {
//auto list = memento->getCommonGroups();
//_allLoaded = false;
//if (!list.empty()) {
// showInitial(list);
//}
void InnerWidget::restoreState(gsl::not_null<SectionMemento*> memento) {
_items = memento->takeItems();
_itemsByIds = memento->takeItemsByIds();
_idManager = memento->takeIdManager();
_upLoaded = memento->upLoaded();
_downLoaded = memento->downLoaded();
updateMinMaxIds();
updateSize();
}
//void InnerWidget::showInitial(const QList<PeerData*> &list) {
// for_const (auto group, list) {
// if (auto item = computeItem(group)) {
// _items.push_back(item);
// }
// _preloadGroupId = group->bareId();
// }
// updateSize();
//}
void InnerWidget::preloadMore(Direction direction) {
auto &requestId = (direction == Direction::Up) ? _preloadUpRequestId : _preloadDownRequestId;
auto &loadedFlag = (direction == Direction::Up) ? _upLoaded : _downLoaded;
@ -394,6 +381,10 @@ void InnerWidget::preloadMore(Direction direction) {
auto &results = result.c_channels_adminLogResults();
App::feedUsers(results.vusers);
App::feedChats(results.vchats);
if (loadedFlag) {
return;
}
auto &events = results.vevents.v;
if (!events.empty()) {
auto oldItemsCount = _items.size();
@ -401,10 +392,14 @@ void InnerWidget::preloadMore(Direction direction) {
for_const (auto &event, events) {
t_assert(event.type() == mtpc_channelAdminLogEvent);
auto &data = event.c_channelAdminLogEvent();
if (_itemsByIds.find(data.vid.v) != _itemsByIds.cend()) {
continue;
}
auto count = 0;
GenerateItems(_history, _idManager, data, [this, id = data.vid.v, &count](HistoryItemOwned item) {
_items.push_back(std::move(item));
_itemsByIds.emplace(id, item.get());
_items.push_back(std::move(item));
++count;
});
if (count > 1) {
@ -433,11 +428,7 @@ void InnerWidget::preloadMore(Direction direction) {
}
}
}
_maxId = (--_itemsByIds.end())->first;
_minId = _itemsByIds.begin()->first;
if (_minId == 1) {
_upLoaded = true;
}
updateMinMaxIds();
itemsAdded(direction);
}
} else {
@ -449,6 +440,18 @@ void InnerWidget::preloadMore(Direction direction) {
}).send();
}
void InnerWidget::updateMinMaxIds() {
if (_itemsByIds.empty()) {
_maxId = _minId = 0;
} else {
_maxId = (--_itemsByIds.end())->first;
_minId = _itemsByIds.begin()->first;
if (_minId == 1) {
_upLoaded = true;
}
}
}
void InnerWidget::itemsAdded(Direction direction) {
updateSize();
}

View File

@ -76,8 +76,8 @@ public:
return TWidget::resizeToWidth(newWidth);
}
void saveState(gsl::not_null<SectionMemento*> memento) const;
void restoreState(gsl::not_null<const SectionMemento*> memento);
void saveState(gsl::not_null<SectionMemento*> memento);
void restoreState(gsl::not_null<SectionMemento*> memento);
void setCancelledCallback(base::lambda<void()> callback) {
_cancelledCallback = std::move(callback);
}
@ -151,6 +151,7 @@ private:
void preloadMore(Direction direction);
void itemsAdded(Direction direction);
void updateSize();
void updateMinMaxIds();
void paintEmpty(Painter &p);
void toggleScrollDateShown();
@ -213,7 +214,9 @@ private:
uint64 _minId = 0;
mtpRequestId _preloadUpRequestId = 0;
mtpRequestId _preloadDownRequestId = 0;
bool _upLoaded = false;
// Don't load anything until the memento was read.
bool _upLoaded = true;
bool _downLoaded = true;
MouseAction _mouseAction = MouseAction::None;

View File

@ -61,7 +61,7 @@ private:
};
object_ptr<Window::SectionWidget> SectionMemento::createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) const {
object_ptr<Window::SectionWidget> SectionMemento::createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) {
auto result = object_ptr<Widget>(parent, controller, _channel);
result->setInternalState(geometry, this);
return std::move(result);
@ -168,34 +168,34 @@ void Widget::doSetInnerFocus() {
_inner->setFocus();
}
bool Widget::showInternal(const Window::SectionMemento *memento) {
if (auto profileMemento = dynamic_cast<const SectionMemento*>(memento)) {
if (profileMemento->getChannel() == channel()) {
restoreState(profileMemento);
bool Widget::showInternal(gsl::not_null<Window::SectionMemento*> memento) {
if (auto logMemento = dynamic_cast<SectionMemento*>(memento.get())) {
if (logMemento->getChannel() == channel()) {
restoreState(logMemento);
return true;
}
}
return false;
}
void Widget::setInternalState(const QRect &geometry, gsl::not_null<const SectionMemento*> memento) {
void Widget::setInternalState(const QRect &geometry, gsl::not_null<SectionMemento*> memento) {
setGeometry(geometry);
myEnsureResized(this);
restoreState(memento);
}
std::unique_ptr<Window::SectionMemento> Widget::createMemento() const {
std::unique_ptr<Window::SectionMemento> Widget::createMemento() {
auto result = std::make_unique<SectionMemento>(channel());
saveState(result.get());
return std::move(result);
}
void Widget::saveState(gsl::not_null<SectionMemento*> memento) const {
void Widget::saveState(gsl::not_null<SectionMemento*> memento) {
memento->setScrollTop(_scroll->scrollTop());
_inner->saveState(memento);
}
void Widget::restoreState(gsl::not_null<const SectionMemento*> memento) {
void Widget::restoreState(gsl::not_null<SectionMemento*> memento) {
_inner->restoreState(memento);
auto scrollTop = memento->getScrollTop();
_scroll->scrollToY(scrollTop);

View File

@ -22,6 +22,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "window/section_widget.h"
#include "window/section_memento.h"
#include "history/history_admin_log_item.h"
#include "history/history_admin_log_inner.h"
namespace Notify {
struct PeerUpdate;
@ -58,10 +60,10 @@ public:
QPixmap grabForShowAnimation(const Window::SectionSlideParams &params) override;
bool showInternal(const Window::SectionMemento *memento) override;
std::unique_ptr<Window::SectionMemento> createMemento() const override;
bool showInternal(gsl::not_null<Window::SectionMemento*> memento) override;
std::unique_ptr<Window::SectionMemento> createMemento() override;
void setInternalState(const QRect &geometry, gsl::not_null<const SectionMemento*> memento);
void setInternalState(const QRect &geometry, gsl::not_null<SectionMemento*> memento);
// Float player interface.
bool wheelEventFromFloatPlayer(QEvent *e, Window::Column myColumn, Window::Column playerColumn) override;
@ -81,8 +83,8 @@ protected:
private:
void onScroll();
void updateAdaptiveLayout();
void saveState(gsl::not_null<SectionMemento*> memento) const;
void restoreState(gsl::not_null<const SectionMemento*> memento);
void saveState(gsl::not_null<SectionMemento*> memento);
void restoreState(gsl::not_null<SectionMemento*> memento);
object_ptr<Ui::ScrollArea> _scroll;
QPointer<InnerWidget> _inner;
@ -97,7 +99,7 @@ public:
SectionMemento(gsl::not_null<ChannelData*> channel) : _channel(channel) {
}
object_ptr<Window::SectionWidget> createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) const override;
object_ptr<Window::SectionWidget> createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) override;
gsl::not_null<ChannelData*> getChannel() const {
return _channel;
@ -109,9 +111,39 @@ public:
return _scrollTop;
}
void setItems(std::vector<HistoryItemOwned> &&items, std::map<uint64, HistoryItem*> &&itemsByIds, bool upLoaded, bool downLoaded) {
_items = std::move(items);
_itemsByIds = std::move(itemsByIds);
_upLoaded = upLoaded;
_downLoaded = downLoaded;
}
void setIdManager(LocalIdManager &&manager) {
_idManager = std::move(manager);
}
std::vector<HistoryItemOwned> takeItems() {
return std::move(_items);
}
std::map<uint64, HistoryItem*> takeItemsByIds() {
return std::move(_itemsByIds);
}
LocalIdManager takeIdManager() {
return std::move(_idManager);
}
bool upLoaded() const {
return _upLoaded;
}
bool downLoaded() const {
return _downLoaded;
}
private:
gsl::not_null<ChannelData*> _channel;
int _scrollTop = 0;
std::vector<HistoryItemOwned> _items;
std::map<uint64, HistoryItem*> _itemsByIds;
bool _upLoaded = false;
bool _downLoaded = true;
LocalIdManager _idManager;
};

View File

@ -2517,15 +2517,6 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::Show
}
}
dlgUpdated();
if (back || (way == Ui::ShowWay::ClearStack)) {
_peerInStack = nullptr;
_msgIdInStack = 0;
} else {
saveSectionInStack();
}
dlgUpdated();
auto wasActivePeer = activePeer();
Ui::hideSettingsAndLayer();
@ -2556,6 +2547,16 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::Show
auto animationParams = animatedShow() ? prepareHistoryAnimation(peerId) : Window::SectionSlideParams();
dlgUpdated();
if (back || (way == Ui::ShowWay::ClearStack)) {
_peerInStack = nullptr;
_msgIdInStack = 0;
} else {
// This may modify the current section, for example remove its contents.
saveSectionInStack();
}
dlgUpdated();
if (_history->peer() && _history->peer()->id != peerId && way != Ui::ShowWay::Forward) {
clearBotStartToken(_history->peer());
}
@ -2708,11 +2709,11 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
return false;
};
auto animationParams = animatedShow() ? prepareOverviewAnimation() : Window::SectionSlideParams();
setFocus(); // otherwise dialogs widget could be focused.
if (!back) {
saveSectionInStack();
}
setFocus(); // otherwise dialogs widget could be focused.
if (_overview) {
_overview->hide();
_overview->clear();
@ -2751,12 +2752,12 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
orderWidgets();
}
void MainWidget::showWideSection(const Window::SectionMemento &memento) {
void MainWidget::showWideSection(Window::SectionMemento &&memento) {
Ui::hideSettingsAndLayer();
if (_wideSection && _wideSection->showInternal(&memento)) {
return;
}
showNewWideSection(&memento, false, true);
showNewWideSection(std::move(memento), false, true);
}
Window::SectionSlideParams MainWidget::prepareShowAnimation(bool willHaveTopBarShadow, bool willHaveTabbedSection) {
@ -2856,7 +2857,7 @@ Window::SectionSlideParams MainWidget::prepareDialogsAnimation() {
return prepareShowAnimation(false, false);
}
void MainWidget::showNewWideSection(const Window::SectionMemento *memento, bool back, bool saveInStack) {
void MainWidget::showNewWideSection(Window::SectionMemento &&memento, bool back, bool saveInStack) {
QPixmap animCache;
_controller->dialogsListFocused().set(false, true);
@ -2864,7 +2865,7 @@ void MainWidget::showNewWideSection(const Window::SectionMemento *memento, bool
auto sectionTop = getSectionTop();
auto newWideGeometry = QRect(_history->x(), sectionTop, _history->width(), height() - sectionTop);
auto newWideSection = memento->createWidget(this, _controller, newWideGeometry);
auto newWideSection = memento.createWidget(this, _controller, newWideGeometry);
auto animatedShow = [this] {
if (_a_show.animating() || App::passcoded()) {
return false;
@ -2876,11 +2877,12 @@ void MainWidget::showNewWideSection(const Window::SectionMemento *memento, bool
};
auto animationParams = animatedShow() ? prepareWideSectionAnimation(newWideSection) : Window::SectionSlideParams();
setFocus(); // otherwise dialogs widget could be focused.
if (saveInStack) {
// This may modify the current section, for example remove its contents.
saveSectionInStack();
}
setFocus(); // otherwise dialogs widget could be focused.
if (_overview) {
_overview->hide();
_overview->clear();
@ -2949,7 +2951,7 @@ void MainWidget::showBackFromStack() {
_history->setReplyReturns(historyItem->peer->id, historyItem->replyReturns);
} else if (item->type() == SectionStackItem) {
auto sectionItem = static_cast<StackItemSection*>(item.get());
showNewWideSection(sectionItem->memento(), true, false);
showNewWideSection(std::move(*sectionItem->memento()), true, false);
} else if (item->type() == OverviewStackItem) {
auto overviewItem = static_cast<StackItemOverview*>(item.get());
showMediaOverview(overviewItem->peer, overviewItem->mediaType, true, overviewItem->lastScrollTop);

View File

@ -215,7 +215,7 @@ public:
int backgroundFromY() const;
PeerData *overviewPeer();
bool showMediaTypeSwitch() const;
void showWideSection(const Window::SectionMemento &memento);
void showWideSection(Window::SectionMemento &&memento);
void showMediaOverview(PeerData *peer, MediaOverviewType type, bool back = false, int32 lastScrollTop = -1);
bool stackIsEmpty() const;
void showBackFromStack();
@ -521,7 +521,7 @@ private:
void mediaOverviewUpdated(const Notify::PeerUpdate &update);
Window::SectionSlideParams prepareShowAnimation(bool willHaveTopBarShadow, bool willHaveTabbedSection);
void showNewWideSection(const Window::SectionMemento *memento, bool back, bool saveInStack);
void showNewWideSection(Window::SectionMemento &&memento, bool back, bool saveInStack);
// All this methods use the prepareShowAnimation().
Window::SectionSlideParams prepareWideSectionAnimation(Window::SectionWidget *section);

View File

@ -35,9 +35,9 @@ public:
virtual void showFinished() {
}
virtual void saveState(SectionMemento *memento) const {
virtual void saveState(gsl::not_null<SectionMemento*> memento) {
}
virtual void restoreState(const SectionMemento *memento) {
virtual void restoreState(gsl::not_null<SectionMemento*> memento) {
}
protected:

View File

@ -42,7 +42,7 @@ constexpr int kCommonGroupsPerPage = 40;
} // namespace
object_ptr<Window::SectionWidget> SectionMemento::createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) const {
object_ptr<Window::SectionWidget> SectionMemento::createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) {
auto result = object_ptr<Widget>(parent, controller, _user);
result->setInternalState(geometry, this);
return std::move(result);
@ -118,7 +118,7 @@ void InnerWidget::checkPreloadMore() {
}
}
void InnerWidget::saveState(SectionMemento *memento) const {
void InnerWidget::saveState(gsl::not_null<SectionMemento*> memento) {
if (auto count = _items.size()) {
QList<gsl::not_null<PeerData*>> groups;
groups.reserve(count);
@ -129,7 +129,7 @@ void InnerWidget::saveState(SectionMemento *memento) const {
}
}
void InnerWidget::restoreState(const SectionMemento *memento) {
void InnerWidget::restoreState(gsl::not_null<SectionMemento*> memento) {
auto list = memento->getCommonGroups();
_allLoaded = false;
if (!list.empty()) {
@ -374,8 +374,8 @@ void Widget::doSetInnerFocus() {
_inner->setFocus();
}
bool Widget::showInternal(const Window::SectionMemento *memento) {
if (auto profileMemento = dynamic_cast<const SectionMemento*>(memento)) {
bool Widget::showInternal(gsl::not_null<Window::SectionMemento*> memento) {
if (auto profileMemento = dynamic_cast<SectionMemento*>(memento.get())) {
if (profileMemento->getUser() == user()) {
restoreState(profileMemento);
return true;
@ -384,24 +384,24 @@ bool Widget::showInternal(const Window::SectionMemento *memento) {
return false;
}
void Widget::setInternalState(const QRect &geometry, const SectionMemento *memento) {
void Widget::setInternalState(const QRect &geometry, gsl::not_null<SectionMemento*> memento) {
setGeometry(geometry);
myEnsureResized(this);
restoreState(memento);
}
std::unique_ptr<Window::SectionMemento> Widget::createMemento() const {
std::unique_ptr<Window::SectionMemento> Widget::createMemento() {
auto result = std::make_unique<SectionMemento>(user());
saveState(result.get());
return std::move(result);
}
void Widget::saveState(SectionMemento *memento) const {
void Widget::saveState(gsl::not_null<SectionMemento*> memento) {
memento->setScrollTop(_scroll->scrollTop());
_inner->saveState(memento);
}
void Widget::restoreState(const SectionMemento *memento) {
void Widget::restoreState(gsl::not_null<SectionMemento*> memento) {
_inner->restoreState(memento);
auto scrollTop = memento->getScrollTop();
_scroll->scrollToY(scrollTop);

View File

@ -43,7 +43,7 @@ public:
SectionMemento(gsl::not_null<UserData*> user) : _user(user) {
}
object_ptr<Window::SectionWidget> createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) const override;
object_ptr<Window::SectionWidget> createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) override;
gsl::not_null<UserData*> getUser() const {
return _user;
@ -110,8 +110,8 @@ public:
return TWidget::resizeToWidth(newWidth);
}
void saveState(SectionMemento *memento) const;
void restoreState(const SectionMemento *memento);
void saveState(gsl::not_null<SectionMemento*> memento);
void restoreState(gsl::not_null<SectionMemento*> memento);
~InnerWidget();
@ -184,10 +184,10 @@ public:
QPixmap grabForShowAnimation(const Window::SectionSlideParams &params) override;
bool showInternal(const Window::SectionMemento *memento) override;
std::unique_ptr<Window::SectionMemento> createMemento() const override;
bool showInternal(gsl::not_null<Window::SectionMemento*> memento) override;
std::unique_ptr<Window::SectionMemento> createMemento() override;
void setInternalState(const QRect &geometry, const SectionMemento *memento);
void setInternalState(const QRect &geometry, gsl::not_null<SectionMemento*> memento);
// Float player interface.
bool wheelEventFromFloatPlayer(QEvent *e, Window::Column myColumn, Window::Column playerColumn) override;
@ -205,8 +205,8 @@ private slots:
private:
void updateAdaptiveLayout();
void saveState(SectionMemento *memento) const;
void restoreState(const SectionMemento *memento);
void saveState(gsl::not_null<SectionMemento*> memento);
void restoreState(gsl::not_null<SectionMemento*> memento);
object_ptr<Ui::ScrollArea> _scroll;
QPointer<InnerWidget> _inner;

View File

@ -89,13 +89,13 @@ bool InnerWidget::shareContactButtonShown() const {
return _cover->shareContactButtonShown();
}
void InnerWidget::saveState(SectionMemento *memento) const {
void InnerWidget::saveState(gsl::not_null<SectionMemento*> memento) {
for_const (auto &blockData, _blocks) {
blockData.block->saveState(memento);
}
}
void InnerWidget::restoreState(const SectionMemento *memento) {
void InnerWidget::restoreState(gsl::not_null<SectionMemento*> memento) {
for_const (auto &blockData, _blocks) {
blockData.block->restoreState(memento);
}

View File

@ -49,8 +49,8 @@ public:
// It should show it only if it is hidden in the cover.
bool shareContactButtonShown() const;
void saveState(SectionMemento *memento) const;
void restoreState(const SectionMemento *memento);
void saveState(gsl::not_null<SectionMemento*> memento);
void restoreState(gsl::not_null<SectionMemento*> memento);
void showFinished();

View File

@ -24,7 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Profile {
object_ptr<Window::SectionWidget> SectionMemento::createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) const {
object_ptr<Window::SectionWidget> SectionMemento::createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) {
auto result = object_ptr<Widget>(parent, controller, _peer);
result->setInternalState(geometry, this);
return std::move(result);

View File

@ -31,7 +31,7 @@ public:
SectionMemento(PeerData *peer) : _peer(peer) {
}
object_ptr<Window::SectionWidget> createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) const override;
object_ptr<Window::SectionWidget> createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) override;
PeerData *getPeer() const {
return _peer;

View File

@ -76,8 +76,8 @@ void Widget::doSetInnerFocus() {
_inner->setFocus();
}
bool Widget::showInternal(const Window::SectionMemento *memento) {
if (auto profileMemento = dynamic_cast<const SectionMemento*>(memento)) {
bool Widget::showInternal(gsl::not_null<Window::SectionMemento*> memento) {
if (auto profileMemento = dynamic_cast<SectionMemento*>(memento.get())) {
if (profileMemento->getPeer() == peer()) {
restoreState(profileMemento);
return true;
@ -86,24 +86,24 @@ bool Widget::showInternal(const Window::SectionMemento *memento) {
return false;
}
void Widget::setInternalState(const QRect &geometry, const SectionMemento *memento) {
void Widget::setInternalState(const QRect &geometry, gsl::not_null<SectionMemento*> memento) {
setGeometry(geometry);
myEnsureResized(this);
restoreState(memento);
}
std::unique_ptr<Window::SectionMemento> Widget::createMemento() const {
std::unique_ptr<Window::SectionMemento> Widget::createMemento() {
auto result = std::make_unique<SectionMemento>(peer());
saveState(result.get());
return std::move(result);
}
void Widget::saveState(SectionMemento *memento) const {
void Widget::saveState(gsl::not_null<SectionMemento*> memento) {
memento->setScrollTop(_scroll->scrollTop());
_inner->saveState(memento);
}
void Widget::restoreState(const SectionMemento *memento) {
void Widget::restoreState(gsl::not_null<SectionMemento*> memento) {
_inner->restoreState(memento);
auto scrollTop = memento->getScrollTop();
_scroll->scrollToY(scrollTop);

View File

@ -49,10 +49,10 @@ public:
QPixmap grabForShowAnimation(const Window::SectionSlideParams &params) override;
bool showInternal(const Window::SectionMemento *memento) override;
std::unique_ptr<Window::SectionMemento> createMemento() const override;
bool showInternal(gsl::not_null<Window::SectionMemento*> memento) override;
std::unique_ptr<Window::SectionMemento> createMemento() override;
void setInternalState(const QRect &geometry, const SectionMemento *memento);
void setInternalState(const QRect &geometry, gsl::not_null<SectionMemento*> memento);
// Float player interface.
bool wheelEventFromFloatPlayer(QEvent *e, Window::Column myColumn, Window::Column playerColumn) override;
@ -71,8 +71,8 @@ private slots:
private:
void updateScrollState();
void updateAdaptiveLayout();
void saveState(SectionMemento *memento) const;
void restoreState(const SectionMemento *memento);
void saveState(gsl::not_null<SectionMemento*> memento);
void restoreState(gsl::not_null<SectionMemento*> memento);
object_ptr<Ui::ScrollArea> _scroll;
QPointer<InnerWidget> _inner;

View File

@ -27,7 +27,7 @@ class SectionWidget;
class SectionMemento {
public:
virtual object_ptr<Window::SectionWidget> createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) const = 0;
virtual object_ptr<Window::SectionWidget> createWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller, const QRect &geometry) = 0;
virtual ~SectionMemento() {
}

View File

@ -96,10 +96,14 @@ public:
// Attempt to show the required section inside the existing one.
// For example if this section already shows exactly the required
// memento it can simply return true - it is shown already.
virtual bool showInternal(const SectionMemento *memento) = 0;
//
// If this method returns false it is not supposed to modify the memento.
// If this method returns true it may modify the memento ("take" heavy items).
virtual bool showInternal(gsl::not_null<SectionMemento*> memento) = 0;
// Create a memento of that section to store it in the history stack.
virtual std::unique_ptr<SectionMemento> createMemento() const = 0;
// This method may modify the section ("take" heavy items).
virtual std::unique_ptr<SectionMemento> createMemento() = 0;
void setInnerFocus() {
doSetInnerFocus();