##// END OF EJS Templates
Merge branch 'feature/ImprovePerf' into develop
Merge branch 'feature/ImprovePerf' into develop

File last commit:

r316:21cfeb46fc36
r615:4575ac2a0a6a merge
Show More
MockPlugin.cpp
79 lines | 2.8 KiB | text/x-c | CppLexer
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r121 #include "MockPlugin.h"
#include "CosinusProvider.h"
Alexandre Leroux
Create mock plugin
r96
#include <DataSource/DataSourceController.h>
#include <DataSource/DataSourceItem.h>
Alexandre Leroux
Adds action in the mock plugin to load products
r137 #include <DataSource/DataSourceItemAction.h>
Alexandre Leroux
Create mock plugin
r96
#include <SqpApplication.h>
Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
namespace {
/// Name of the data source
const auto DATA_SOURCE_NAME = QStringLiteral("MMS");
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r121 /// Creates the data provider relative to the plugin
std::unique_ptr<IDataProvider> createDataProvider() noexcept
Alexandre Leroux
Create mock plugin
r96 {
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r121 return std::make_unique<CosinusProvider>();
Alexandre Leroux
Create mock plugin
r96 }
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r155 std::unique_ptr<DataSourceItem> createProductItem(const QString &productName,
const QUuid &dataSourceUid)
Alexandre Leroux
Adds action in the mock plugin to load products
r137 {
Alexandre Leroux
Updates references to DataSourceItem after changes
r316 auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, productName);
Alexandre Leroux
Adds action in the mock plugin to load products
r137
// Add action to load product from DataSourceController
result->addAction(std::make_unique<DataSourceItemAction>(
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r155 QObject::tr("Load %1 product").arg(productName),
[productName, dataSourceUid](DataSourceItem &item) {
Alexandre Leroux
Adds action in the mock plugin to load products
r137 if (auto app = sqpApp) {
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r155 app->dataSourceController().loadProductItem(dataSourceUid, item);
Alexandre Leroux
Adds action in the mock plugin to load products
r137 }
}));
return result;
}
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r121 /// Creates the data source item relative to the plugin
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r155 std::unique_ptr<DataSourceItem> createDataSourceItem(const QUuid &dataSourceUid) noexcept
Alexandre Leroux
Create mock plugin
r96 {
// Magnetic field products
Alexandre Leroux
Updates references to DataSourceItem after changes
r316 auto magneticFieldFolder = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
QStringLiteral("Magnetic field"));
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r155 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("FGM"), dataSourceUid));
magneticFieldFolder->appendChild(createProductItem(QStringLiteral("SC"), dataSourceUid));
Alexandre Leroux
Create mock plugin
r96
// Electric field products
Alexandre Leroux
Updates references to DataSourceItem after changes
r316 auto electricFieldFolder = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
QStringLiteral("Electric field"));
Alexandre Leroux
Create mock plugin
r96
// Root
Alexandre Leroux
Updates references to DataSourceItem after changes
r316 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE, DATA_SOURCE_NAME);
Alexandre Leroux
Create mock plugin
r96 root->appendChild(std::move(magneticFieldFolder));
root->appendChild(std::move(electricFieldFolder));
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r121 return root;
}
} // namespace
void MockPlugin::initialize()
{
if (auto app = sqpApp) {
// Registers to the data source controller
auto &dataSourceController = app->dataSourceController();
auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
// Sets data source tree
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r155 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem(dataSourceUid));
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r121
// Sets data provider
dataSourceController.setDataProvider(dataSourceUid, createDataProvider());
}
else {
qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
}
Alexandre Leroux
Create mock plugin
r96 }