~aleteoryx/muditaos

ba863035e5eb8d78ea9db65befc557993a47f553 — Przemyslaw Brudny 4 years ago b5f580a
[EGD-7408] Phonebook empty list fix

Fixed phonebook empty list. Added deep refresh
for other empty lists.
M module-apps/application-alarm-clock/windows/AlarmClockMainWindow.cpp => module-apps/application-alarm-clock/windows/AlarmClockMainWindow.cpp +2 -0
@@ 113,6 113,7 @@ namespace app::alarmClock
        emptyListIcon->setVisible(true);
        bottomBar->setActive(gui::BottomBar::Side::LEFT, false);
        bottomBar->setActive(gui::BottomBar::Side::CENTER, false);
        application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
    }

    void AlarmClockMainWindow::onListFilled()


@@ 120,5 121,6 @@ namespace app::alarmClock
        emptyListIcon->setVisible(false);
        bottomBar->setActive(gui::BottomBar::Side::LEFT, true);
        bottomBar->setActive(gui::BottomBar::Side::CENTER, true);
        application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
    }
} // namespace app::alarmClock

M module-apps/application-calllog/windows/CallLogMainWindow.cpp => module-apps/application-calllog/windows/CallLogMainWindow.cpp +2 -0
@@ 104,6 104,7 @@ namespace gui
        bottomBar->setActive(gui::BottomBar::Side::LEFT, false);
        bottomBar->setActive(gui::BottomBar::Side::CENTER, false);
        emptyListIcon->setVisible(true);
        application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
    }

    void CallLogMainWindow::onListFilled()


@@ 111,5 112,6 @@ namespace gui
        bottomBar->setActive(gui::BottomBar::Side::LEFT, true);
        bottomBar->setActive(gui::BottomBar::Side::CENTER, true);
        emptyListIcon->setVisible(false);
        application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
    }
} /* namespace gui */

M module-apps/application-messages/windows/MessagesMainWindow.cpp => module-apps/application-messages/windows/MessagesMainWindow.cpp +2 -0
@@ 88,12 88,14 @@ namespace gui
            emptyListIcon->setVisible(true);
            bottomBar->setActive(BottomBar::Side::LEFT, false);
            bottomBar->setActive(BottomBar::Side::CENTER, false);
            application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
        };

        list->notEmptyListCallback = [this]() {
            emptyListIcon->setVisible(false);
            bottomBar->setActive(BottomBar::Side::LEFT, true);
            bottomBar->setActive(BottomBar::Side::CENTER, true);
            application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
        };

        setFocusItem(list);

M module-apps/application-notes/windows/NoteMainWindow.cpp => module-apps/application-notes/windows/NoteMainWindow.cpp +2 -0
@@ 98,6 98,7 @@ namespace app::notes
        bottomBar->setActive(gui::BottomBar::Side::CENTER, false);
        emptyListIcon->setVisible(true);
        header->navigationIndicatorRemove(gui::header::BoxSelection::Right);
        application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
    }

    void NoteMainWindow::onListFilled()


@@ 106,6 107,7 @@ namespace app::notes
        bottomBar->setActive(gui::BottomBar::Side::CENTER, true);
        emptyListIcon->setVisible(false);
        header->navigationIndicatorAdd(new gui::header::SearchAction(), gui::header::BoxSelection::Right);
        application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
    }

    bool NoteMainWindow::onInput(const gui::InputEvent &inputEvent)

M module-apps/application-phonebook/data/ContactsMap.hpp => module-apps/application-phonebook/data/ContactsMap.hpp +2 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 33,5 33,5 @@ struct ContactsMapData
{
    std::map<std::string, std::uint32_t> firstLetterDictionary;
    std::uint32_t favouritesCount;
    std::uint32_t itemCount;
    std::uint32_t itemCount = 0;
};

M module-apps/application-phonebook/models/PhonebookModel.cpp => module-apps/application-phonebook/models/PhonebookModel.cpp +3 -1
@@ 35,7 35,9 @@ auto PhonebookModel::requestRecordsCount() -> unsigned int

    auto dispMode = static_cast<ContactDisplayMode>(getDisplayMode());
    if (dispMode == ContactDisplayMode::SortedByLetter) {
        return letterMap.itemCount;
        letterMap    = requestLetterMap();
        recordsCount = letterMap.itemCount;
        return recordsCount;
    }

    auto [code, msg] = DBServiceAPI::GetQueryWithReply(

M module-apps/application-phonebook/windows/PhonebookMainWindow.cpp => module-apps/application-phonebook/windows/PhonebookMainWindow.cpp +2 -1
@@ 60,7 60,6 @@ namespace gui
        contactsList->emptyListCallback    = [this]() { onEmptyList(); };
        contactsList->notEmptyListCallback = [this]() { onListFilled(); };

        phonebookModel->letterMap = phonebookModel->requestLetterMap();
        phonebookModel->setDisplayMode(static_cast<uint32_t>(ContactDisplayMode::SortedByLetter));
        contactsList->rebuildList(gui::listview::RebuildType::Full);



@@ 176,6 175,7 @@ namespace gui
        bottomBar->setActive(gui::BottomBar::Side::CENTER, false);
        emptyListIcon->setVisible(true);
        header->navigationIndicatorRemove(gui::header::BoxSelection::Right);
        application->refreshWindow(RefreshModes::GUI_REFRESH_DEEP);
    }

    void PhonebookMainWindow::onListFilled()


@@ 184,5 184,6 @@ namespace gui
        bottomBar->setActive(gui::BottomBar::Side::CENTER, true);
        emptyListIcon->setVisible(false);
        header->navigationIndicatorAdd(new gui::header::SearchAction(), gui::header::BoxSelection::Right);
        application->refreshWindow(RefreshModes::GUI_REFRESH_DEEP);
    }
} /* namespace gui */

M module-gui/gui/widgets/ListViewEngine.cpp => module-gui/gui/widgets/ListViewEngine.cpp +22 -10
@@ 21,8 21,7 @@ namespace gui
    void ListViewEngine::setElementsCount(unsigned int count)
    {
        if (elementsCount != count || elementsCount == 0) {
            elementsCount = count;
            onElementsCountChanged();
            onElementsCountChanged(count);
        }
    }



@@ 201,6 200,7 @@ namespace gui
        }

        clear();
        checkEmptyListCallbacks();

        addItemsOnPage();



@@ 401,22 401,34 @@ namespace gui
        }
    }

    void ListViewEngine::onElementsCountChanged()
    void ListViewEngine::onElementsCountChanged(unsigned int count)
    {
        if (isEmpty()) {
            if (emptyListCallback) {
                emptyListCallback();
            }
        }
        else if (notEmptyListCallback) {
            notEmptyListCallback();
        if (elementsCount == 0 || count == 0) {
            shouldCallEmptyListCallbacks = true;
        }

        elementsCount = count;

        if (checkFullRenderRequirementCallback) {
            checkFullRenderRequirementCallback();
        }
    }

    void ListViewEngine::checkEmptyListCallbacks()
    {
        if (shouldCallEmptyListCallbacks) {
            if (isEmpty()) {
                if (emptyListCallback) {
                    emptyListCallback();
                }
            }
            else if (notEmptyListCallback) {
                notEmptyListCallback();
            }
            shouldCallEmptyListCallbacks = false;
        }
    }

    void ListViewEngine::recalculateOnBoxRequestedResize()
    {
        if (currentPageSize != body->getVisibleChildrenCount()) {

M module-gui/gui/widgets/ListViewEngine.hpp => module-gui/gui/widgets/ListViewEngine.hpp +3 -1
@@ 104,7 104,9 @@ namespace gui
        /// Total provider elements count
        unsigned int elementsCount = 0;
        void setElementsCount(unsigned int count);
        void onElementsCountChanged();
        void onElementsCountChanged(unsigned int count);
        bool shouldCallEmptyListCallbacks = false;
        void checkEmptyListCallbacks();

        /// Data model provider
        std::shared_ptr<ListItemProvider> provider = nullptr;