parent
7bfec141eb
commit
0c88da4d81
|
@ -3,6 +3,8 @@ add_library(app
|
|||
boot/app_controller.cpp
|
||||
core/signals/signals.cpp
|
||||
global/singleton.cpp
|
||||
modules/shared/section_item.cpp
|
||||
modules/shared/section_model.cpp
|
||||
modules/startup/controller.cpp
|
||||
modules/startup/module.cpp
|
||||
modules/startup/view.cpp
|
||||
|
@ -34,6 +36,7 @@ target_include_directories(app
|
|||
PUBLIC
|
||||
./include/
|
||||
./boot/
|
||||
./modules/shared
|
||||
./modules/main
|
||||
./modules/startup
|
||||
)
|
||||
|
|
|
@ -67,7 +67,7 @@ AppController::AppController()
|
|||
// # Modules
|
||||
m_startupModule = new Modules::Startup::Module(this, /*keychainService,*/ m_accountsService);
|
||||
|
||||
m_mainModulePtr = std::make_unique<Modules::Main::Module>(m_walletServicePtr
|
||||
m_mainModulePtr = new Modules::Main::Module(m_walletServicePtr, this);
|
||||
// statusFoundation.status.events,
|
||||
// result.keychainService,
|
||||
// result.accountsService,
|
||||
|
@ -94,7 +94,6 @@ AppController::AppController()
|
|||
// result.nodeConfigurationService,
|
||||
// result.devicesService,
|
||||
// result.mailserversService
|
||||
);
|
||||
|
||||
// # Do connections
|
||||
connect();
|
||||
|
@ -111,7 +110,7 @@ void AppController::connect()
|
|||
// self.statusFoundation.status.events.once("nodeStopped") do(a: Args):
|
||||
// TODO: remove this once accounts are not tracked in the AccountsModel
|
||||
// self.statusFoundation.status.reset()
|
||||
QObject::connect(dynamic_cast<QObject*>(m_mainModulePtr.get()), SIGNAL(loaded()), this, SLOT(mainDidLoad()));
|
||||
QObject::connect(dynamic_cast<QObject*>(m_mainModulePtr), SIGNAL(loaded()), this, SLOT(mainDidLoad()));
|
||||
}
|
||||
|
||||
void AppController::startupDidLoad()
|
||||
|
|
|
@ -29,7 +29,7 @@ class AppController : public QObject, AppControllerDelegate
|
|||
// Modules
|
||||
// To-Do make this a shared pointer and remove circular dependency.
|
||||
Modules::Startup::ModuleAccessInterface* m_startupModule;
|
||||
std::unique_ptr<Modules::Main::IModuleAccess> m_mainModulePtr;
|
||||
Modules::Main::IModuleAccess* m_mainModulePtr;
|
||||
|
||||
public:
|
||||
AppController();
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef APPSECTION_CONFIG_H
|
||||
#define APPSECTION_CONFIG_H
|
||||
|
||||
// To Do: Currently this gets added to eahc file that its imported into need to create as enums in calss when some works on this potentially
|
||||
#include <QString>
|
||||
|
||||
const QString CHAT_SECTION_ID = "chat";
|
||||
const QString CHAT_SECTION_NAME = "Chat";
|
||||
const QString CHAT_SECTION_ICON = "chat";
|
||||
|
||||
const QString WALLET_SECTION_ID = "wallet";
|
||||
const QString WALLET_SECTION_NAME = "Wallet";
|
||||
const QString WALLET_SECTION_ICON = "wallet";
|
||||
|
||||
const QString BROWSER_SECTION_ID = "browser";
|
||||
const QString BROWSER_SECTION_NAME = "Browser";
|
||||
const QString BROWSER_SECTION_ICON = "browser";
|
||||
|
||||
const QString NODEMANAGEMENT_SECTION_ID = "nodeManagement";
|
||||
const QString NODEMANAGEMENT_SECTION_NAME = "Node Management";
|
||||
const QString NODEMANAGEMENT_SECTION_ICON = "node";
|
||||
|
||||
const QString SETTINGS_SECTION_ID = "profileSettings";
|
||||
const QString SETTINGS_SECTION_NAME = "Settings";
|
||||
const QString SETTINGS_SECTION_ICON = "settings";
|
||||
|
||||
#endif // APPSECTION_CONFIG_H
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
#include "controller.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
namespace Modules:: Main
|
||||
{
|
||||
Controller::Controller(QObject* parent)
|
||||
: QObject(parent)
|
||||
|
@ -12,5 +10,4 @@ Controller::Controller(QObject* parent)
|
|||
|
||||
void Controller::init() { }
|
||||
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
#include "interfaces/controller_interface.h"
|
||||
#include "signals.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
namespace Modules::Main
|
||||
{
|
||||
|
||||
class Controller : public QObject, IController
|
||||
class Controller : public QObject, public IController
|
||||
{
|
||||
public:
|
||||
explicit Controller(QObject* parent = nullptr);
|
||||
|
@ -20,8 +18,7 @@ public:
|
|||
void init() override;
|
||||
};
|
||||
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main
|
||||
|
||||
#endif // CONTROLLER_H
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#ifndef ICONTROLLER_H
|
||||
#define ICONTROLLER_H
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
namespace Modules::Main
|
||||
{
|
||||
// Abstract class for any input/interaction with this module.
|
||||
class IController
|
||||
|
@ -11,7 +9,6 @@ class IController
|
|||
public:
|
||||
virtual void init() = 0;
|
||||
};
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main
|
||||
|
||||
#endif // ICONTROLLER_H
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
namespace Modules::Main
|
||||
{
|
||||
class IModuleAccess
|
||||
{
|
||||
|
@ -15,8 +13,7 @@ public:
|
|||
signals:
|
||||
virtual void loaded() = 0;
|
||||
};
|
||||
}; // namespace Main
|
||||
}; // namespace Modules
|
||||
} // namespace Modules::Main
|
||||
|
||||
Q_DECLARE_INTERFACE(Modules::Main::IModuleAccess, "Modules::Main::IModuleAccess");
|
||||
|
||||
|
|
|
@ -4,18 +4,17 @@
|
|||
#include "module.h"
|
||||
#include "singleton.h"
|
||||
#include "modules/main/wallet/module.h"
|
||||
#include "../shared/section_item.h"
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main
|
||||
{
|
||||
namespace Main
|
||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent): QObject(parent)
|
||||
{
|
||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService)
|
||||
{
|
||||
m_controllerPtr = std::make_unique<Controller>();
|
||||
m_viewPtr = std::make_unique<View>();
|
||||
m_controllerPtr = new Controller(this);
|
||||
m_viewPtr = new View(this);
|
||||
|
||||
// Submodules
|
||||
m_walletModulePtr = std::make_unique<Modules::Main::Wallet::Module>(walletsService);
|
||||
m_walletModulePtr = new Modules::Main::Wallet::Module(walletsService, this);
|
||||
|
||||
m_moduleLoaded = false;
|
||||
connect();
|
||||
|
@ -23,16 +22,15 @@ Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService)
|
|||
|
||||
void Module::connect()
|
||||
{
|
||||
QObject::connect(m_viewPtr.get(), &View::viewLoaded, this, &Module::viewDidLoad);
|
||||
QObject::connect(dynamic_cast<QObject*>(m_walletModulePtr.get()), SIGNAL(loaded()), this, SLOT(walletDidLoad()));
|
||||
QObject::connect(m_viewPtr, &View::viewLoaded, this, &Module::viewDidLoad);
|
||||
QObject::connect(dynamic_cast<QObject*>(m_walletModulePtr), SIGNAL(loaded()), this, SLOT(walletDidLoad()));
|
||||
}
|
||||
|
||||
void Module::load()
|
||||
{
|
||||
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("mainModule", m_viewPtr.get());
|
||||
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("mainModule", m_viewPtr);
|
||||
m_controllerPtr->init();
|
||||
m_viewPtr->load();
|
||||
|
||||
m_walletModulePtr->load();
|
||||
}
|
||||
|
||||
|
@ -61,5 +59,4 @@ bool Module::isLoaded()
|
|||
return m_moduleLoaded;
|
||||
}
|
||||
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main
|
||||
|
|
|
@ -6,34 +6,33 @@
|
|||
|
||||
#include "interfaces/module_access_interface.h"
|
||||
#include "wallet_accounts/service_interface.h"
|
||||
#include "wallet/interfaces/module_access_interface.h"
|
||||
|
||||
#include "controller.h"
|
||||
#include "view.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
namespace Modules::Main
|
||||
{
|
||||
class Module : public QObject, virtual public IModuleAccess
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Modules::Main::IModuleAccess)
|
||||
|
||||
private:
|
||||
bool m_moduleLoaded;
|
||||
|
||||
std::unique_ptr<View> m_viewPtr;
|
||||
std::unique_ptr<Controller> m_controllerPtr;
|
||||
std::unique_ptr<Modules::Main::Wallet::IWalletModuleAccess> m_walletModulePtr;
|
||||
View* m_viewPtr;
|
||||
Controller* m_controllerPtr;
|
||||
Modules::Main::IModuleAccess* m_walletModulePtr;
|
||||
|
||||
void connect();
|
||||
void checkIfModuleDidLoad();
|
||||
|
||||
public:
|
||||
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletService);
|
||||
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletService, QObject* parent = nullptr);
|
||||
~Module() = default;
|
||||
|
||||
void load() override;
|
||||
bool isLoaded() override;
|
||||
void checkIfModuleDidLoad();
|
||||
|
||||
public slots:
|
||||
void viewDidLoad();
|
||||
|
@ -42,7 +41,6 @@ public slots:
|
|||
signals:
|
||||
void loaded() override;
|
||||
};
|
||||
}; // namespace Main
|
||||
}; // namespace Modules
|
||||
} // namespace Modules::Main
|
||||
|
||||
#endif // MODULE_H
|
||||
|
|
|
@ -1,19 +1,48 @@
|
|||
#include "view.h"
|
||||
#include "../global/app_sections_config.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
|
||||
namespace Modules::Main
|
||||
{
|
||||
View::View(QObject* parent)
|
||||
: QObject(parent)
|
||||
{ }
|
||||
{
|
||||
m_sectionModelPtr = new Shared::Models::SectionModel(this);
|
||||
}
|
||||
|
||||
void View::load()
|
||||
{
|
||||
// At some point, here, we will setup some exposed main module related things.
|
||||
// Add Wallet Section to Sections model
|
||||
auto walletSectionItem = new Shared::Models::SectionItem(WALLET_SECTION_ID, Shared::Models::SectionType::Wallet, WALLET_SECTION_NAME, "", "", WALLET_SECTION_ICON, "", false, this);
|
||||
addItem(walletSectionItem);
|
||||
setActiveSection(WALLET_SECTION_ID);
|
||||
|
||||
emit viewLoaded();
|
||||
}
|
||||
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
void View::addItem(Shared::Models::SectionItem* item)
|
||||
{
|
||||
m_sectionModelPtr->addItem(item);
|
||||
emit sectionsModelChanged();
|
||||
}
|
||||
|
||||
Shared::Models::SectionModel* View::getSectionsModel()
|
||||
{
|
||||
return m_sectionModelPtr;
|
||||
}
|
||||
|
||||
Shared::Models::SectionItem* View::getActiveSection()
|
||||
{
|
||||
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
|
||||
|
|
|
@ -2,26 +2,38 @@
|
|||
#define VIEW_H
|
||||
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
#include "../shared/section_model.h"
|
||||
|
||||
namespace Modules::Main
|
||||
{
|
||||
class View : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Shared::Models::SectionModel* sectionsModel READ getSectionsModel NOTIFY sectionsModelChanged)
|
||||
Q_PROPERTY(Shared::Models::SectionItem* activeSection READ getActiveSection NOTIFY activeSectionChanged)
|
||||
|
||||
public:
|
||||
explicit View(QObject* parent = nullptr);
|
||||
~View() = default;
|
||||
|
||||
void load();
|
||||
|
||||
void addItem(Shared::Models::SectionItem *item);
|
||||
|
||||
Shared::Models::SectionModel* getSectionsModel();
|
||||
Shared::Models::SectionItem* getActiveSection();
|
||||
void setActiveSection(const QString& Id);
|
||||
|
||||
signals:
|
||||
void viewLoaded();
|
||||
void sectionsModelChanged();
|
||||
void activeSectionChanged();
|
||||
|
||||
private:
|
||||
Shared::Models::SectionModel* m_sectionModelPtr;
|
||||
};
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main
|
||||
|
||||
#endif // VIEW_H
|
||||
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
|
||||
#include "controller.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
Controller::Controller(std::shared_ptr<Wallets::ServiceInterface> walletService,
|
||||
QObject* parent)
|
||||
|
@ -28,7 +22,4 @@ QList<Wallets::WalletAccountDto> Controller::getWalletAccounts()
|
|||
|
||||
return wallet_accounts;
|
||||
}
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
|
|
@ -8,15 +8,9 @@
|
|||
#include "interfaces/controller_interface.h"
|
||||
#include "signals.h"
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
{
|
||||
class Controller : public QObject, IAccountsController
|
||||
class Controller : public QObject, public IController
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -31,9 +25,6 @@ public:
|
|||
private:
|
||||
std::shared_ptr<Wallets::ServiceInterface> m_walletServicePtr;
|
||||
};
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
||||
#endif // WALLET_ACCOUNT_CONTROLLER_H
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef IWALLETACCOUNTSCONTROLLER_H
|
||||
#define IWALLETACCOUNTSCONTROLLER_H
|
||||
|
||||
#include "../../../interfaces/controller_interface.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
{
|
||||
// Abstract class for any input/interaction with this module.
|
||||
|
||||
class IAccountsController: public IController
|
||||
{
|
||||
public:
|
||||
virtual void init() = 0;
|
||||
};
|
||||
} // namespave Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
|
||||
#endif // IWALLETACCOUNTSCONTROLLER_H
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef IWALLETACCOUNTMODULEACCESS_H
|
||||
#define IWALLETACCOUNTMODULEACCESS_H
|
||||
|
||||
#include "../../../interfaces/module_access_interface.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
class IWalletAccountsModuleAccess: virtual public IModuleAccess
|
||||
{
|
||||
};
|
||||
}; // namespace Wallet
|
||||
}; // namespace Main
|
||||
}; // namespace Modules\
|
||||
|
||||
#endif // IWALLETACCOUNTMODULEACCESS_H
|
|
@ -1,12 +1,6 @@
|
|||
#include "item.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
Item::Item(QString name, QString address, QString path, QString color, QString publicKey, QString walletType, bool isWallet, bool isChat, float currencyBalance)
|
||||
: m_name(name),
|
||||
|
@ -20,52 +14,49 @@ Item::Item(QString name, QString address, QString path, QString color, QString p
|
|||
m_currencyBalance(currencyBalance)
|
||||
{ }
|
||||
|
||||
QString Item::getName()
|
||||
const QString& Item::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
QString Item::getAddress()
|
||||
const QString& Item::getAddress() const
|
||||
{
|
||||
return m_address;
|
||||
}
|
||||
|
||||
QString Item::getPath()
|
||||
const QString& Item::getPath() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
QString Item::getColor()
|
||||
const QString& Item::getColor() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
QString Item::getPublicKey()
|
||||
const QString& Item::getPublicKey() const
|
||||
{
|
||||
return m_publicKey;
|
||||
}
|
||||
|
||||
QString Item::getWalletType()
|
||||
const QString& Item::getWalletType() const
|
||||
{
|
||||
return m_walletType;
|
||||
}
|
||||
|
||||
bool Item::getIsWallet()
|
||||
bool Item::getIsWallet() const
|
||||
{
|
||||
return m_isWallet;
|
||||
}
|
||||
|
||||
bool Item::getIsChat()
|
||||
bool Item::getIsChat() const
|
||||
{
|
||||
return m_isChat;
|
||||
}
|
||||
|
||||
float Item::getCurrencyBalance()
|
||||
float Item::getCurrencyBalance() const
|
||||
{
|
||||
return m_currencyBalance;
|
||||
}
|
||||
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
|
|
@ -3,13 +3,7 @@
|
|||
|
||||
#include <QString>
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
class Item
|
||||
{
|
||||
|
@ -28,19 +22,16 @@ public:
|
|||
Item(QString name, QString address, QString path, QString color, QString publicKey, QString walletType, bool isWallet, bool isChat, float currencyBalance);
|
||||
~Item() = default;
|
||||
|
||||
QString getName();
|
||||
QString getAddress();
|
||||
QString getPath();
|
||||
QString getColor();
|
||||
QString getPublicKey();
|
||||
QString getWalletType();
|
||||
bool getIsWallet();
|
||||
bool getIsChat();
|
||||
float getCurrencyBalance();
|
||||
const QString& getName() const;
|
||||
const QString& getAddress() const;
|
||||
const QString& getPath() const;
|
||||
const QString& getColor() const;
|
||||
const QString& getPublicKey() const;
|
||||
const QString& getWalletType() const;
|
||||
bool getIsWallet() const;
|
||||
bool getIsChat() const;
|
||||
float getCurrencyBalance() const;
|
||||
};
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
||||
#endif // WALLET_ACCOUNT_ITEM_H
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
#include "model.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
Model::Model(QObject* parent)
|
||||
: QAbstractListModel(parent)
|
||||
|
@ -71,7 +65,4 @@ void Model::setItems(QVector<Item> &items)
|
|||
endResetModel();
|
||||
}
|
||||
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
|
|
@ -7,15 +7,8 @@
|
|||
|
||||
#include "item.h"
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
{
|
||||
|
||||
class Model : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -38,18 +31,14 @@ public:
|
|||
explicit Model(QObject* parent = nullptr);
|
||||
~Model() = default;
|
||||
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
virtual int rowCount(const QModelIndex&) const;
|
||||
virtual QVariant data(const QModelIndex& index, int role) const;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
int rowCount(const QModelIndex&) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
void setItems(QVector<Item> &items);
|
||||
|
||||
private:
|
||||
QVector<Item> m_items;
|
||||
};
|
||||
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
||||
#endif // WALLET_ACCOUNT_MODEL_H
|
||||
|
|
|
@ -4,18 +4,12 @@
|
|||
#include "module.h"
|
||||
#include "singleton.h"
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
namespace Main
|
||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject *parent): QObject(parent)
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
{
|
||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService)
|
||||
{
|
||||
m_controllerPtr = std::make_unique<Controller>(walletsService);
|
||||
m_viewPtr = std::make_unique<View>();
|
||||
m_controllerPtr = new Controller(walletsService, this);
|
||||
m_viewPtr = new View(this);
|
||||
|
||||
m_moduleLoaded = false;
|
||||
|
||||
|
@ -24,12 +18,12 @@ Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService)
|
|||
|
||||
void Module::connect()
|
||||
{
|
||||
QObject::connect(m_viewPtr.get(), &View::viewLoaded, this, &Module::viewDidLoad);
|
||||
QObject::connect(m_viewPtr, &View::viewLoaded, this, &Module::viewDidLoad);
|
||||
}
|
||||
|
||||
void Module::load()
|
||||
{
|
||||
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("walletSectionAccounts", m_viewPtr.get());
|
||||
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("walletSectionAccounts", m_viewPtr);
|
||||
m_controllerPtr->init();
|
||||
m_viewPtr->load();
|
||||
}
|
||||
|
@ -65,8 +59,4 @@ void Module::refreshWalletAccounts()
|
|||
qWarning()<<"No accounts found!";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Accounts
|
||||
} // namespace Main
|
||||
} // namespace Wallet
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
|
|
@ -8,27 +8,23 @@
|
|||
#include "controller.h"
|
||||
#include "view.h"
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
{
|
||||
class Module : public QObject, virtual public IWalletAccountsModuleAccess
|
||||
class Module : public QObject, virtual public IModuleAccess
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Modules::Main::IModuleAccess)
|
||||
|
||||
private:
|
||||
std::unique_ptr<View> m_viewPtr;
|
||||
std::unique_ptr<Controller> m_controllerPtr;
|
||||
View* m_viewPtr;
|
||||
Controller* m_controllerPtr;
|
||||
|
||||
bool m_moduleLoaded;
|
||||
|
||||
void connect();
|
||||
void refreshWalletAccounts();
|
||||
public:
|
||||
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletsService);
|
||||
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent);
|
||||
~Module() = default;
|
||||
|
||||
void load() override;
|
||||
|
@ -40,9 +36,6 @@ public slots:
|
|||
signals:
|
||||
void loaded() override;
|
||||
};
|
||||
}; // namespace Accounts
|
||||
}; // namespace Wallet
|
||||
}; // namespace Main
|
||||
}; // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
||||
#endif // WALLET_ACCOUNT_MODULE_H
|
||||
|
|
|
@ -2,18 +2,12 @@
|
|||
|
||||
#include "view.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
View::View(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_modelPtr = std::make_shared<Model>();
|
||||
m_modelPtr = new Model(this);
|
||||
}
|
||||
|
||||
void View::load()
|
||||
|
@ -23,14 +17,11 @@ void View::load()
|
|||
|
||||
Model* View::getModel()
|
||||
{
|
||||
return m_modelPtr.get();
|
||||
return m_modelPtr;
|
||||
}
|
||||
|
||||
void View::setModelItems(QVector<Item> &accounts) {
|
||||
m_modelPtr->setItems(accounts);
|
||||
modelChanged();
|
||||
}
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
|
|
@ -6,18 +6,12 @@
|
|||
|
||||
#include "model.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
namespace Modules::Main::Wallet::Accounts
|
||||
{
|
||||
class View : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Model* accountsModel READ getModel NOTIFY modelChanged)
|
||||
Q_PROPERTY(Model* model READ getModel NOTIFY modelChanged)
|
||||
|
||||
public:
|
||||
explicit View(QObject* parent = nullptr);
|
||||
|
@ -27,7 +21,7 @@ public:
|
|||
void setModelItems(QVector<Item> &accounts);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Model> m_modelPtr;
|
||||
Model* m_modelPtr;
|
||||
|
||||
public slots:
|
||||
Model* getModel();
|
||||
|
@ -36,9 +30,6 @@ signals:
|
|||
void viewLoaded();
|
||||
void modelChanged();
|
||||
};
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet::Accounts
|
||||
|
||||
#endif // WALLET_ACCOUNT_VIEW_H
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
|
||||
#include "controller.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
namespace Modules::Main::Wallet
|
||||
{
|
||||
Controller::Controller(std::shared_ptr<Wallets::ServiceInterface> walletService,
|
||||
QObject* parent)
|
||||
|
@ -17,7 +13,4 @@ Controller::Controller(std::shared_ptr<Wallets::ServiceInterface> walletService,
|
|||
void Controller::init()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace Onboarding
|
||||
} // namespace Startup
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet
|
||||
|
|
|
@ -7,13 +7,9 @@
|
|||
#include "interfaces/controller_interface.h"
|
||||
#include "signals.h"
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main::Wallet
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
class Controller : public QObject, IWalletController
|
||||
class Controller : public QObject, public IController
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -25,8 +21,6 @@ public:
|
|||
private:
|
||||
std::shared_ptr<Wallets::ServiceInterface> m_walletService;
|
||||
};
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet
|
||||
|
||||
#endif // WALLET_CONTROLLER_H
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef IWALLETCONTROLLER_H
|
||||
#define IWALLETCONTROLLER_H
|
||||
|
||||
#include "../../interfaces/controller_interface.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
|
||||
// Abstract class for any input/interaction with this module.
|
||||
class IWalletController: public IController
|
||||
{
|
||||
};
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
|
||||
#endif // IWALLETCONTROLLER_H
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef IWALLETMODULEACCESS_H
|
||||
#define IWALLETMODULEACCESS_H
|
||||
|
||||
#include "../../interfaces/module_access_interface.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
class IWalletModuleAccess: virtual public IModuleAccess
|
||||
{
|
||||
};
|
||||
}; // namespace Wallet
|
||||
}; // namespace Main
|
||||
}; // namespace Modules
|
||||
|
||||
#endif // IWALLETMODULEACCESS_H
|
|
@ -5,19 +5,15 @@
|
|||
#include "singleton.h"
|
||||
#include "accounts/module.h"
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main::Wallet
|
||||
{
|
||||
namespace Main
|
||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject *parent): QObject(parent)
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService)
|
||||
{
|
||||
m_controllerPtr = std::make_unique<Controller>(walletsService);
|
||||
m_viewPtr = std::make_unique<View>();
|
||||
m_controllerPtr = new Controller(walletsService, this);
|
||||
m_viewPtr = new View(this);
|
||||
|
||||
// Sub-Modules
|
||||
m_accountsModulePtr = std::make_unique<Modules::Main::Wallet::Accounts::Module>(walletsService);
|
||||
m_accountsModulePtr = new Modules::Main::Wallet::Accounts::Module(walletsService, this);
|
||||
|
||||
m_moduleLoaded = false;
|
||||
connect();
|
||||
|
@ -25,13 +21,13 @@ Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService)
|
|||
|
||||
void Module::connect()
|
||||
{
|
||||
QObject::connect(m_viewPtr.get(), SIGNAL(viewLoaded()), this, SLOT(viewDidLoad()));
|
||||
QObject::connect(dynamic_cast<QObject*>(m_accountsModulePtr.get()), SIGNAL(loaded()), this, SLOT(accountsDidLoad()));
|
||||
QObject::connect(m_viewPtr, SIGNAL(viewLoaded()), this, SLOT(viewDidLoad()));
|
||||
QObject::connect(dynamic_cast<QObject*>(m_accountsModulePtr), SIGNAL(loaded()), this, SLOT(accountsDidLoad()));
|
||||
}
|
||||
|
||||
void Module::load()
|
||||
{
|
||||
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("walletSection", m_viewPtr.get());
|
||||
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("walletSection", m_viewPtr);
|
||||
m_controllerPtr->init();
|
||||
m_viewPtr->load();
|
||||
m_accountsModulePtr->load();
|
||||
|
@ -62,6 +58,4 @@ void Module::accountsDidLoad()
|
|||
checkIfModuleDidLoad();
|
||||
}
|
||||
|
||||
} // namespace Main
|
||||
} // namespace Wallet
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet
|
||||
|
|
|
@ -4,30 +4,28 @@
|
|||
#include <QObject>
|
||||
|
||||
#include "wallet_accounts/service_interface.h"
|
||||
#include "interfaces/module_access_interface.h"
|
||||
#include "accounts/interfaces/module_access_interface.h"
|
||||
|
||||
#include "../interfaces/module_access_interface.h"
|
||||
#include "controller.h"
|
||||
#include "view.h"
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main::Wallet
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
class Module : public QObject, virtual public IWalletModuleAccess
|
||||
class Module : public QObject, virtual public IModuleAccess
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Modules::Main::IModuleAccess)
|
||||
|
||||
private:
|
||||
std::unique_ptr<View> m_viewPtr;
|
||||
std::unique_ptr<Controller> m_controllerPtr;
|
||||
std::unique_ptr<IWalletAccountsModuleAccess> m_accountsModulePtr;
|
||||
View* m_viewPtr;
|
||||
Controller* m_controllerPtr;
|
||||
IModuleAccess* m_accountsModulePtr;
|
||||
|
||||
bool m_moduleLoaded;
|
||||
|
||||
void connect();
|
||||
public:
|
||||
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletsService);
|
||||
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent);
|
||||
~Module() = default;
|
||||
|
||||
void load() override;
|
||||
|
@ -40,8 +38,6 @@ public slots:
|
|||
signals:
|
||||
void loaded() override;
|
||||
};
|
||||
}; // namespace Wallet
|
||||
}; // namespace Main
|
||||
}; // namespace Modules
|
||||
} // namespace Modules::Main::Wallet
|
||||
|
||||
#endif // WALLET_MODULE_H
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
|
||||
#include "view.h"
|
||||
|
||||
namespace Modules
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
namespace Modules::Main::Wallet
|
||||
{
|
||||
View::View(QObject* parent)
|
||||
: QObject(parent)
|
||||
|
@ -18,6 +14,4 @@ void View::load()
|
|||
emit viewLoaded();
|
||||
}
|
||||
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet
|
||||
|
|
|
@ -3,13 +3,8 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
namespace Modules
|
||||
namespace Modules::Main::Wallet
|
||||
{
|
||||
namespace Main
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
|
||||
class View : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -23,9 +18,7 @@ public:
|
|||
signals:
|
||||
void viewLoaded();
|
||||
};
|
||||
} // namespace Wallet
|
||||
} // namespace Main
|
||||
} // namespace Modules
|
||||
} // namespace Modules::Main::Wallet
|
||||
|
||||
#endif // WALLET_VIEW_H
|
||||
|
||||
|
|
|
@ -0,0 +1,154 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include "section_item.h"
|
||||
|
||||
namespace Shared::Models
|
||||
{
|
||||
SectionItem::SectionItem(QString id,
|
||||
SectionType sectionType,
|
||||
QString name,
|
||||
QString description,
|
||||
QString image,
|
||||
QString icon,
|
||||
QString color,
|
||||
bool active,
|
||||
bool enabled,
|
||||
bool amISectionAdmin,
|
||||
bool hasNotification,
|
||||
int notificationsCount,
|
||||
bool isMember,
|
||||
bool joined,
|
||||
bool canJoin,
|
||||
bool canManageUsers,
|
||||
bool canRequestAccess,
|
||||
int access,
|
||||
bool ensOnly,
|
||||
QObject *parent):
|
||||
QObject(parent),
|
||||
m_id(id),
|
||||
m_sectionType(sectionType) ,
|
||||
m_name(name),
|
||||
m_amISectionAdmin(amISectionAdmin),
|
||||
m_description(description),
|
||||
m_image(image),
|
||||
m_icon(icon),
|
||||
m_color(color),
|
||||
m_hasNotification(hasNotification),
|
||||
m_notificationsCount(notificationsCount),
|
||||
m_active(active),
|
||||
m_enabled(enabled),
|
||||
m_isMember(isMember),
|
||||
m_joined(joined),
|
||||
m_canJoin(canJoin),
|
||||
m_canManageUsers(canManageUsers),
|
||||
m_canRequestAccess(canRequestAccess),
|
||||
m_access(access),
|
||||
m_ensOnly(ensOnly)
|
||||
{
|
||||
}
|
||||
|
||||
SectionType SectionItem::getSectionType() const
|
||||
{
|
||||
return m_sectionType;
|
||||
}
|
||||
|
||||
const QString& SectionItem::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
const QString& SectionItem::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool SectionItem::getAmISectionAdmin() const
|
||||
{
|
||||
return m_amISectionAdmin;
|
||||
}
|
||||
|
||||
const QString& SectionItem::getDescription() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
const QString& SectionItem::getImage() const
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
|
||||
const QString& SectionItem::getIcon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
const QString& SectionItem::getColor() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
bool SectionItem::getHasNotification() const
|
||||
{
|
||||
return m_hasNotification;
|
||||
}
|
||||
|
||||
int SectionItem::getNotificationsCount() const
|
||||
{
|
||||
return m_notificationsCount;
|
||||
}
|
||||
|
||||
bool SectionItem::getIsActive() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
bool SectionItem::getIsEnabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
bool SectionItem::getIsMember() const
|
||||
{
|
||||
return m_isMember;
|
||||
}
|
||||
|
||||
bool SectionItem::getHasJoined() const
|
||||
{
|
||||
return m_joined;
|
||||
}
|
||||
|
||||
bool SectionItem::getCanJoin() const
|
||||
{
|
||||
return m_canJoin;
|
||||
}
|
||||
|
||||
bool SectionItem::getCanManageUsers() const
|
||||
{
|
||||
return m_canManageUsers;
|
||||
}
|
||||
|
||||
bool SectionItem::getCanRequestAccess() const
|
||||
{
|
||||
return m_canRequestAccess;
|
||||
}
|
||||
|
||||
int SectionItem::getAccess() const
|
||||
{
|
||||
return m_access;
|
||||
}
|
||||
|
||||
bool SectionItem::getIsEnsOnly() const
|
||||
{
|
||||
return m_ensOnly;
|
||||
}
|
||||
|
||||
void SectionItem::setIsActive(bool isActive)
|
||||
{
|
||||
if(m_active != isActive)
|
||||
{
|
||||
m_active = isActive;
|
||||
activeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Shared::Models
|
|
@ -0,0 +1,116 @@
|
|||
#ifndef SECTION_ITEM_H
|
||||
#define SECTION_ITEM_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
namespace Shared::Models
|
||||
{
|
||||
enum SectionType
|
||||
{
|
||||
Chat = 0,
|
||||
Community,
|
||||
Wallet,
|
||||
Browser,
|
||||
ProfileSettings,
|
||||
NodeManagement
|
||||
};
|
||||
class SectionItem: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString id READ getId)
|
||||
Q_PROPERTY(int sectionType READ getSectionType)
|
||||
Q_PROPERTY(QString name READ getName)
|
||||
Q_PROPERTY(bool amISectionAdmin READ getAmISectionAdmin)
|
||||
Q_PROPERTY(QString description READ getDescription)
|
||||
Q_PROPERTY(QString image READ getImage)
|
||||
Q_PROPERTY(QString icon READ getIcon)
|
||||
Q_PROPERTY(QString color READ getColor)
|
||||
Q_PROPERTY(bool hasNotification READ getHasNotification)
|
||||
Q_PROPERTY(int notificationsCount READ getNotificationsCount)
|
||||
Q_PROPERTY(bool active READ getIsActive NOTIFY activeChanged)
|
||||
Q_PROPERTY(bool enabled READ getIsEnabled)
|
||||
Q_PROPERTY(bool joined READ getHasJoined)
|
||||
Q_PROPERTY(bool isMember READ getIsMember)
|
||||
Q_PROPERTY(bool canJoin READ getCanJoin)
|
||||
Q_PROPERTY(bool canManageUsers READ getCanManageUsers)
|
||||
Q_PROPERTY(bool canRequestAccess READ getCanRequestAccess)
|
||||
Q_PROPERTY(int access READ getAccess)
|
||||
Q_PROPERTY(bool ensOnly READ getIsEnsOnly)
|
||||
|
||||
public:
|
||||
SectionItem(QString id,
|
||||
SectionType sectionType,
|
||||
QString name,
|
||||
QString description,
|
||||
QString image,
|
||||
QString icon,
|
||||
QString color,
|
||||
bool active = false,
|
||||
bool enabled = true,
|
||||
bool amISectionAdmin = false,
|
||||
bool hasNotification = false,
|
||||
int notificationsCount = 0,
|
||||
bool isMember = false,
|
||||
bool joined = false,
|
||||
bool canJoin = false,
|
||||
bool canManageUsers = false,
|
||||
bool canRequestAccess = false,
|
||||
int access = 0,
|
||||
bool ensOnly = false,
|
||||
QObject* parent = nullptr);
|
||||
~SectionItem() = default;
|
||||
|
||||
// Getters
|
||||
SectionType getSectionType() const;
|
||||
const QString& getId() const;
|
||||
const QString& getName() const;
|
||||
bool getAmISectionAdmin() const;
|
||||
const QString& getDescription() const;
|
||||
const QString& getImage() const;
|
||||
const QString& getIcon() const;
|
||||
const QString& getColor() const;
|
||||
bool getHasNotification() const;
|
||||
int getNotificationsCount() const;
|
||||
bool getIsActive() const;
|
||||
bool getIsEnabled() const;
|
||||
bool getIsMember() const;
|
||||
bool getHasJoined() const;
|
||||
bool getCanJoin() const;
|
||||
bool getCanManageUsers() const;
|
||||
bool getCanRequestAccess() const;
|
||||
int getAccess() const;
|
||||
bool getIsEnsOnly() const;
|
||||
|
||||
// Setters
|
||||
void setIsActive(bool isActive);
|
||||
|
||||
signals:
|
||||
void activeChanged();
|
||||
|
||||
private:
|
||||
SectionType m_sectionType;
|
||||
QString m_id;
|
||||
QString m_name;
|
||||
bool m_amISectionAdmin;
|
||||
QString m_description;
|
||||
QString m_image;
|
||||
QString m_icon;
|
||||
QString m_color;
|
||||
bool m_hasNotification;
|
||||
int m_notificationsCount;
|
||||
bool m_active;
|
||||
bool m_enabled;
|
||||
bool m_isMember;
|
||||
bool m_joined;
|
||||
bool m_canJoin;
|
||||
bool m_canManageUsers;
|
||||
bool m_canRequestAccess;
|
||||
int m_access;
|
||||
bool m_ensOnly;
|
||||
// membersModel: user_model.Model
|
||||
// pendingRequestsToJoinModel: PendingRequestModel
|
||||
};
|
||||
} // namespace Shared::Models
|
||||
|
||||
#endif // SECTION_ITEM_H
|
|
@ -0,0 +1,124 @@
|
|||
#include "section_model.h"
|
||||
|
||||
namespace Shared::Models
|
||||
{
|
||||
SectionModel::SectionModel(QObject* parent)
|
||||
: QAbstractListModel(parent)
|
||||
{ }
|
||||
|
||||
QHash<int, QByteArray> SectionModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
|
||||
roles[Id] = "id";
|
||||
roles[SectionType] = "sectionType";
|
||||
roles[Name] = "name";
|
||||
roles[AmISectionAdmin] = "amISectionAdmin";
|
||||
roles[Description] = "description";
|
||||
roles[Image] = "image";
|
||||
roles[Icon] = "icon";
|
||||
roles[Color] = "color";
|
||||
roles[HasNotification] = "hasNotification";
|
||||
roles[NotificationsCount] = "notificationsCount";
|
||||
roles[Active] = "active";
|
||||
roles[Enabled] = "enabled";
|
||||
roles[Joined] = "joined";
|
||||
roles[IsMember] = "isMember";
|
||||
roles[CanJoin] = "canJoin";
|
||||
roles[CanManageUsers] = "canManageUsers";
|
||||
roles[CanRequestAccess] = "canRequestAccess";
|
||||
roles[Access] = "access";
|
||||
roles[EnsOnly] = "ensOnly";
|
||||
roles[MembersModel] = "members";
|
||||
roles[PendingRequestsToJoinModel] = "pendingRequestsToJoin";
|
||||
return roles;
|
||||
}
|
||||
|
||||
int SectionModel::rowCount(const QModelIndex& parent = QModelIndex()) const
|
||||
{
|
||||
return m_items.size();
|
||||
}
|
||||
|
||||
QVariant SectionModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if(index.row() < 0 || index.row() >= m_items.size())
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
SectionItem* item = m_items.at(index.row());
|
||||
|
||||
switch(role)
|
||||
{
|
||||
case Id: return QVariant(item->getId());
|
||||
case SectionType: return QVariant(item->getSectionType());
|
||||
case Name: return QVariant(item->getName());
|
||||
case AmISectionAdmin: return QVariant(item->getAmISectionAdmin());
|
||||
case Description: return QVariant(item->getDescription());
|
||||
case Image: return QVariant(item->getImage());
|
||||
case Icon: return QVariant(item->getIcon());
|
||||
case Color: return QVariant(item->getColor());
|
||||
case HasNotification: return QVariant(item->getHasNotification());
|
||||
case NotificationsCount: return QVariant(item->getNotificationsCount());
|
||||
case Active: return QVariant(item->getIsActive());
|
||||
case Enabled: return QVariant(item->getIsEnabled());
|
||||
case Joined: return QVariant(item->getHasJoined());
|
||||
case IsMember: return QVariant(item->getIsMember());
|
||||
case CanJoin: return QVariant(item->getCanJoin());
|
||||
case CanManageUsers: return QVariant(item->getCanManageUsers());
|
||||
case CanRequestAccess: return QVariant(item->getCanRequestAccess());
|
||||
case Access: return QVariant(item->getAccess());
|
||||
case EnsOnly: return QVariant(item->getIsEnsOnly());
|
||||
// To Do
|
||||
case MembersModel: return QVariant();
|
||||
case PendingRequestsToJoinModel: return QVariant();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void SectionModel::addItem(SectionItem* item)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
|
||||
m_items.append(item);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void SectionModel::setActiveSection(const QString &Id)
|
||||
{
|
||||
|
||||
for (int i = 0; i < m_items.size(); ++i) {
|
||||
auto newIndex = createIndex(i, 0, nullptr);
|
||||
if(m_items.at(i)->getIsActive())
|
||||
{
|
||||
m_items.at(i)->setIsActive(false);
|
||||
dataChanged(newIndex, newIndex, QVector<int>(ModelRole::Active));
|
||||
|
||||
}
|
||||
if (m_items.at(i)->getId() == Id)
|
||||
{
|
||||
m_items.at(i)->setIsActive(true);
|
||||
dataChanged(newIndex, newIndex, QVector<int>(ModelRole::Active));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPointer<SectionItem> SectionModel::getActiveItem()
|
||||
{
|
||||
SectionItem* activeItem = nullptr;
|
||||
for(auto item : m_items)
|
||||
{
|
||||
if(item->getIsActive())
|
||||
{
|
||||
activeItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return activeItem;
|
||||
}
|
||||
} // namespace Shared::Models
|
|
@ -0,0 +1,63 @@
|
|||
#ifndef SECTION_MODEL_H
|
||||
#define SECTION_MODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
#include <memory>
|
||||
#include <QPointer>
|
||||
|
||||
#include "section_item.h"
|
||||
|
||||
namespace Shared::Models
|
||||
{
|
||||
class SectionModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ModelRole
|
||||
{
|
||||
Id = Qt::UserRole + 1,
|
||||
SectionType,
|
||||
Name,
|
||||
AmISectionAdmin,
|
||||
Description,
|
||||
Image,
|
||||
Icon,
|
||||
Color,
|
||||
HasNotification,
|
||||
NotificationsCount,
|
||||
Active,
|
||||
Enabled,
|
||||
Joined,
|
||||
IsMember,
|
||||
CanJoin,
|
||||
CanManageUsers,
|
||||
CanRequestAccess,
|
||||
Access,
|
||||
EnsOnly,
|
||||
MembersModel,
|
||||
PendingRequestsToJoinModel
|
||||
};
|
||||
|
||||
explicit SectionModel(QObject* parent = nullptr);
|
||||
~SectionModel() = default;
|
||||
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
int rowCount(const QModelIndex&) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
void addItem(SectionItem* item);
|
||||
void setActiveSection(const QString &Id);
|
||||
QPointer<SectionItem> getActiveItem();
|
||||
|
||||
// To add other api's later as needed
|
||||
|
||||
private:
|
||||
QVector<SectionItem*> m_items;
|
||||
};
|
||||
|
||||
} // namespace Shared::Models
|
||||
|
||||
#endif // SECTION_MODEL_H
|
|
@ -5,15 +5,9 @@
|
|||
|
||||
#include "backend/types.h"
|
||||
|
||||
namespace Backend
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
namespace Backend::Wallet::Accounts
|
||||
{
|
||||
Backend::RpcResponse<QJsonArray> getAccounts();
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Backend
|
||||
} // Backend::Wallet::Accounts
|
||||
|
||||
#endif // WALLETACCOUNT_BACKEND_H
|
||||
|
|
|
@ -7,11 +7,7 @@
|
|||
#include "backend/utils.h"
|
||||
#include "libstatus.h"
|
||||
|
||||
namespace Backend
|
||||
{
|
||||
namespace Wallet
|
||||
{
|
||||
namespace Accounts
|
||||
namespace Backend::Wallet::Accounts
|
||||
{
|
||||
RpcResponse<QJsonArray> getAccounts()
|
||||
{
|
||||
|
@ -19,7 +15,7 @@ RpcResponse<QJsonArray> getAccounts()
|
|||
auto result = CallPrivateRPC(Utils::jsonToStr(inputJSON).toUtf8().data());
|
||||
return RpcResponse<QJsonArray>(result, QJsonDocument::fromJson(result)["result"].toArray());
|
||||
}
|
||||
} // namespace Accounts
|
||||
} // namespace Wallet
|
||||
} // namespace Backend
|
||||
|
||||
|
||||
} // namespace Backend::Wallet::Accounts
|
||||
|
||||
|
|
Loading…
Reference in New Issue