##// END OF EJS Templates
Updates model after an event has been created through the colored zone
Updates model after an event has been created through the colored zone

File last commit:

r1147:ca11941ca506
r1286:073d4af7c849
Show More
AmdaPlugin.cpp
78 lines | 2.6 KiB | text/x-c | CppLexer
Alexandre Leroux
Initializes plugin
r352 #include "AmdaPlugin.h"
Alexandre Leroux
Hack to download first component of a parameter if the parameter is a vector...
r417 #include "AmdaDefs.h"
Alexandre Leroux
Creates JSON parser
r354 #include "AmdaParser.h"
Alexandre Leroux
Creates actions to load a product in the data source tree
r381 #include "AmdaProvider.h"
Alexandre Leroux
Uses previous class to generate data source's name (uses server's name)
r1147 #include "AmdaServer.h"
Alexandre Leroux
Initializes plugin
r352
#include <DataSource/DataSourceController.h>
Alexandre Leroux
Creates JSON parser
r354 #include <DataSource/DataSourceItem.h>
Alexandre Leroux
Creates actions to load a product in the data source tree
r381 #include <DataSource/DataSourceItemAction.h>
Alexandre Leroux
Initializes plugin
r352
#include <SqpApplication.h>
Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin")
namespace {
Alexandre Leroux
Adds a sample JSON file as a resource in AMDA plugin...
r353 /// Path of the file used to generate the data source item for AMDA
Alexandre Leroux
Updates AMDA JSON file to handle spectrograms...
r983 const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSampleV3.json");
Alexandre Leroux
Adds a sample JSON file as a resource in AMDA plugin...
r353
Alexandre Leroux
Creates actions to load a product in the data source tree
r381 void associateActions(DataSourceItem &item, const QUuid &dataSourceUid)
{
Alexandre Leroux
Amda provider update (3)...
r414 auto addLoadAction = [&item, dataSourceUid](const QString &label) {
item.addAction(
std::make_unique<DataSourceItemAction>(label, [dataSourceUid](DataSourceItem &item) {
Alexandre Leroux
Creates actions to load a product in the data source tree
r381 if (auto app = sqpApp) {
app->dataSourceController().loadProductItem(dataSourceUid, item);
}
}));
Alexandre Leroux
Amda provider update (3)...
r414 };
const auto itemType = item.type();
Alexandre Leroux
Sets the name of the plugin for products and components...
r1076 if (itemType == DataSourceItemType::PRODUCT || itemType == DataSourceItemType::COMPONENT) {
// Adds plugin name to item metadata
Alexandre Leroux
Uses previous class to generate data source's name (uses server's name)
r1147 item.setData(DataSourceItem::PLUGIN_DATA_KEY, AmdaServer::instance().name());
Alexandre Leroux
Sets the name of the plugin for products and components...
r1076
// Adds load action
auto actionLabel = QObject::tr(
itemType == DataSourceItemType::PRODUCT ? "Load %1 product" : "Load %1 component");
addLoadAction(actionLabel.arg(item.name()));
Alexandre Leroux
Creates actions to load a product in the data source tree
r381 }
auto count = item.childCount();
for (auto i = 0; i < count; ++i) {
if (auto child = item.child(i)) {
associateActions(*child, dataSourceUid);
}
}
}
Alexandre Leroux
Initializes plugin
r352 } // namespace
void AmdaPlugin::initialize()
{
if (auto app = sqpApp) {
Alexandre Leroux
Uses previous class to generate data source's name (uses server's name)
r1147 auto dataSourceName = AmdaServer::instance().name();
Alexandre Leroux
Initializes plugin
r352 // Registers to the data source controller
auto &dataSourceController = app->dataSourceController();
Alexandre Leroux
Uses previous class to generate data source's name (uses server's name)
r1147 auto dataSourceUid = dataSourceController.registerDataSource(dataSourceName);
Alexandre Leroux
Initializes plugin
r352
// Sets data source tree
Alexandre Leroux
Creates JSON parser
r354 if (auto dataSourceItem = AmdaParser::readJson(JSON_FILE_PATH)) {
Alexandre Leroux
Uses previous class to generate data source's name (uses server's name)
r1147 dataSourceItem->setData(DataSourceItem::NAME_DATA_KEY, dataSourceName);
Alexandre Leroux
Creates actions to load a product in the data source tree
r381
Alexandre Leroux
Uses previous class to generate data source's name (uses server's name)
r1147 associateActions(*dataSourceItem, dataSourceUid);
Alexandre Leroux
Creates JSON parser
r354 dataSourceController.setDataSourceItem(dataSourceUid, std::move(dataSourceItem));
}
else {
qCCritical(LOG_AmdaPlugin()) << tr("No data source item could be generated for AMDA");
}
Alexandre Leroux
Inits Amda provider
r377
// Sets data provider
dataSourceController.setDataProvider(dataSourceUid, std::make_unique<AmdaProvider>());
Alexandre Leroux
Initializes plugin
r352 }
else {
qCWarning(LOG_AmdaPlugin()) << tr("Can't access to SciQlop application");
}
}