##// END OF EJS Templates
Updates IDataProvider::requestDataLoading() method's signature...
Updates IDataProvider::requestDataLoading() method's signature The parameters needed for data retrieval are passed to a DataProviderParameters object. For now, it concerns only the list of datetimes to process, but the object will be completed with extra data which may be necessary for certain providers

File last commit:

r352:86fdbf82f68d
r375:49f712bf7e59
Show More
AmdaPlugin.cpp
68 lines | 2.1 KiB | text/x-c | CppLexer
Alexandre Leroux
Initializes plugin
r325 #include "AmdaPlugin.h"
Alexandre Leroux
Creates JSON parser
r327 #include "AmdaParser.h"
Alexandre Leroux
Creates actions to load a product in the data source tree
r352 #include "AmdaProvider.h"
Alexandre Leroux
Initializes plugin
r325
#include <DataSource/DataSourceController.h>
Alexandre Leroux
Creates JSON parser
r327 #include <DataSource/DataSourceItem.h>
Alexandre Leroux
Creates actions to load a product in the data source tree
r352 #include <DataSource/DataSourceItemAction.h>
Alexandre Leroux
Initializes plugin
r325
#include <SqpApplication.h>
Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin")
namespace {
/// Name of the data source
const auto DATA_SOURCE_NAME = QStringLiteral("AMDA");
Alexandre Leroux
Adds a sample JSON file as a resource in AMDA plugin...
r326 /// Path of the file used to generate the data source item for AMDA
const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSample.json");
Alexandre Leroux
Creates actions to load a product in the data source tree
r352 void associateActions(DataSourceItem &item, const QUuid &dataSourceUid)
{
if (item.type() == DataSourceItemType::PRODUCT) {
auto itemName = item.name();
item.addAction(std::make_unique<DataSourceItemAction>(
QObject::tr("Load %1 product").arg(itemName),
[itemName, dataSourceUid](DataSourceItem &item) {
if (auto app = sqpApp) {
app->dataSourceController().loadProductItem(dataSourceUid, item);
}
}));
}
auto count = item.childCount();
for (auto i = 0; i < count; ++i) {
if (auto child = item.child(i)) {
associateActions(*child, dataSourceUid);
}
}
}
Alexandre Leroux
Initializes plugin
r325 } // namespace
void AmdaPlugin::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
Creates JSON parser
r327 if (auto dataSourceItem = AmdaParser::readJson(JSON_FILE_PATH)) {
Alexandre Leroux
Creates actions to load a product in the data source tree
r352 associateActions(*dataSourceItem, dataSourceUid);
Alexandre Leroux
Creates JSON parser
r327 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
r348
// Sets data provider
dataSourceController.setDataProvider(dataSourceUid, std::make_unique<AmdaProvider>());
Alexandre Leroux
Initializes plugin
r325 }
else {
qCWarning(LOG_AmdaPlugin()) << tr("Can't access to SciQlop application");
}
}