status-desktop/src-cpp/app/modules/main/view.cpp

57 lines
1.7 KiB
C++
Raw Normal View History

2022-01-20 14:48:57 +00:00
#include "view.h"
#include "../global/app_sections_config.h"
2022-01-20 14:48:57 +00:00
namespace Modules::Main
{
View::View(QObject* parent)
: QObject(parent)
{
m_sectionModelPtr = new Shared::Models::SectionModel(this);
}
2022-01-20 14:48:57 +00:00
void View::load()
{
// Add Wallet Section to Sections model
auto walletSectionItem = new Shared::Models::SectionItem(this,
WALLET_SECTION_ID,
Shared::Models::SectionType::Wallet,
WALLET_SECTION_NAME,
"",
"",
WALLET_SECTION_ICON,
"",
false,
true);
addItem(walletSectionItem);
setActiveSection(WALLET_SECTION_ID);
emit viewLoaded();
2022-01-20 14:48:57 +00:00
}
void View::addItem(Shared::Models::SectionItem* item)
{
m_sectionModelPtr->addItem(item);
emit sectionsModelChanged();
}
Shared::Models::SectionModel* View::getSectionsModel() const
{
return m_sectionModelPtr;
}
Shared::Models::SectionItem* View::getActiveSection() const
{
return m_sectionModelPtr->getActiveItem();
}
void View::setActiveSection(const QString& Id)
{
if(m_sectionModelPtr->getActiveItem().isNull() || (m_sectionModelPtr->getActiveItem()->getId() != Id))
{
m_sectionModelPtr->setActiveSection(Id);
activeSectionChanged();
}
}
} // namespace Modules::Main