##// END OF EJS Templates
Handles right clicking on the tree of the data sources...
Handles right clicking on the tree of the data sources The action generates the menu associated to the selected item and shows it

File last commit:

r129:e98a7f43fb7b
r143:7b4ea0e1482b
Show More
MockPlugin.cpp
67 lines | 2.3 KiB | text/x-c | CppLexer
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129 #include "MockPlugin.h"
#include "CosinusProvider.h"
Alexandre Leroux
Create mock plugin
r99
#include <DataSource/DataSourceController.h>
#include <DataSource/DataSourceItem.h>
#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
r129 /// Creates the data provider relative to the plugin
std::unique_ptr<IDataProvider> createDataProvider() noexcept
Alexandre Leroux
Create mock plugin
r99 {
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129 return std::make_unique<CosinusProvider>();
Alexandre Leroux
Create mock plugin
r99 }
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129 /// Creates the data source item relative to the plugin
std::unique_ptr<DataSourceItem> createDataSourceItem() noexcept
Alexandre Leroux
Create mock plugin
r99 {
// Magnetic field products
auto fgmProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
QVector<QVariant>{QStringLiteral("FGM")});
auto scProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
QVector<QVariant>{QStringLiteral("SC")});
auto magneticFieldFolder = std::make_unique<DataSourceItem>(
DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
magneticFieldFolder->appendChild(std::move(fgmProduct));
magneticFieldFolder->appendChild(std::move(scProduct));
// Electric field products
auto electricFieldFolder = std::make_unique<DataSourceItem>(
DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")});
// Root
auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
QVector<QVariant>{DATA_SOURCE_NAME});
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
r129 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
dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem());
// Sets data provider
dataSourceController.setDataProvider(dataSourceUid, createDataProvider());
}
else {
qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
}
Alexandre Leroux
Create mock plugin
r99 }