#include #include #include #include #include #include #include #include #include #include #include #include int main(int ac, char** av) { // openDAQ part auto instance = daq::Instance(MODULE_PATH); auto moduleManager = instance.getModuleManager(); auto modules = moduleManager.getModules(); auto devices = instance.getAvailableDevices(); // QT part QApplication app(ac, av); auto createModuleList = [&modules]() -> QLayout* { auto* moduleList = new QListWidget(); for (const auto& module: modules) { auto moduleName = module.getName(); auto* listItem = new QListWidgetItem(moduleName.getCharPtr()); moduleList->addItem(listItem); } auto* moduleInfoTree = new QTreeWidget(); moduleInfoTree->setColumnCount(2); QStringList moduleInfoTreeHeaders; moduleInfoTreeHeaders << "Content" << "Info"; moduleInfoTree->setHeaderLabels(moduleInfoTreeHeaders); auto* moduleTable = new QTableWidget(); moduleTable->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows); moduleTable->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection); moduleTable->setEditTriggers(QAbstractItemView::NoEditTriggers); moduleTable->setRowCount(moduleList->count()); moduleTable->setColumnCount(2); QStringList moduleTableHeaders; moduleTableHeaders << "Name" << "Version"; moduleTable->setHorizontalHeaderLabels(moduleTableHeaders); moduleTable->horizontalHeader()->setStretchLastSection(true); auto row = int{0}; for (const auto& module: modules) { auto moduleName = module.getName(); auto moduleVersionInfo = module.getVersionInfo(); auto moduleVersion = fmt::format("{}.{}.{}", moduleVersionInfo.getMajor(), moduleVersionInfo.getMinor(), moduleVersionInfo.getPatch()); moduleTable->setItem(row, 0, new QTableWidgetItem(moduleName.toStdString().c_str())); moduleTable->setItem(row, 1, new QTableWidgetItem(moduleVersion.c_str())); ++row; } moduleTable->resizeColumnsToContents(); auto* moduleListLabel = new QLabel("Module list"); moduleListLabel->setBuddy(moduleList); auto* moduleListLayout = new QVBoxLayout(); moduleListLayout->addWidget(moduleListLabel); // moduleListLayout->addWidget(moduleList); moduleListLayout->addWidget(moduleTable); moduleListLayout->addWidget(moduleInfoTree); return moduleListLayout; }; auto createDeviceList = [&devices]() -> QLayout* { auto* deviceList = new QListWidget(); for (const auto& device: devices) { auto deviceName = device.getName(); auto* listItem = new QListWidgetItem(deviceName.getCharPtr()); deviceList->addItem(listItem); } auto* deviceListLabel = new QLabel("Device list"); deviceListLabel->setBuddy(deviceList); auto* deviceListLayout = new QVBoxLayout(); deviceListLayout->addWidget(deviceListLabel); deviceListLayout->addWidget(deviceList); return deviceListLayout; }; auto* moduleListLayout = createModuleList(); // auto* deviceListLayout = createDeviceList(); auto* mainWindow = new QMainWindow(); auto* mainLayout = new QHBoxLayout(); auto* centralWidget = new QWidget(); mainLayout->addLayout(moduleListLayout); // mainLayout->addLayout(deviceListLayout); centralWidget->setLayout(mainLayout); mainWindow->setCentralWidget(centralWidget); mainWindow->showMaximized(); return app.exec(); }