Chris@1292: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@1292: Chris@1292: /* Chris@1292: Sonic Visualiser Chris@1292: An audio file viewer and annotation editor. Chris@1292: Centre for Digital Music, Queen Mary, University of London. Chris@1292: Chris@1292: This program is free software; you can redistribute it and/or Chris@1292: modify it under the terms of the GNU General Public License as Chris@1292: published by the Free Software Foundation; either version 2 of the Chris@1292: License, or (at your option) any later version. See the file Chris@1292: COPYING included with this distribution for more information. Chris@1292: */ Chris@1292: Chris@1292: #include "PluginReviewDialog.h" Chris@1292: Chris@1292: #include Chris@1292: #include Chris@1292: #include Chris@1292: #include Chris@1292: #include Chris@1292: #include Chris@1292: #include Chris@1292: Chris@1292: #include "plugin/FeatureExtractionPluginFactory.h" Chris@1292: #include "plugin/RealTimePluginFactory.h" Chris@1292: Chris@1292: PluginReviewDialog::PluginReviewDialog(QWidget *parent) : Chris@1292: QDialog(parent) Chris@1292: { Chris@1292: setWindowTitle(tr("Plugins Loaded")); Chris@1292: Chris@1292: QGridLayout *layout = new QGridLayout; Chris@1292: setLayout(layout); Chris@1292: Chris@1292: m_table = new QTableWidget; Chris@1292: layout->addWidget(m_table, 0, 1); Chris@1292: Chris@1294: QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); Chris@1292: layout->addWidget(bb, 1, 1); Chris@1294: connect(bb, SIGNAL(rejected()), this, SLOT(close())); Chris@1292: } Chris@1292: Chris@1292: PluginReviewDialog::~PluginReviewDialog() Chris@1292: { Chris@1292: } Chris@1292: Chris@1292: void Chris@1292: PluginReviewDialog::populate() Chris@1292: { Chris@1292: FeatureExtractionPluginFactory *feFactory = Chris@1292: FeatureExtractionPluginFactory::instance(); Chris@1292: QString err; Chris@1292: std::vector feIds = feFactory->getPluginIdentifiers(err); Chris@1292: Chris@1292: RealTimePluginFactory *dssiFactory = Chris@1292: RealTimePluginFactory::instance("dssi"); Chris@1292: std::vector dssiIds = dssiFactory->getPluginIdentifiers(); Chris@1292: Chris@1292: RealTimePluginFactory *ladspaFactory = Chris@1292: RealTimePluginFactory::instance("ladspa"); Chris@1292: std::vector ladspaIds = ladspaFactory->getPluginIdentifiers(); Chris@1292: Chris@1292: m_table->setRowCount(int(feIds.size() + dssiIds.size() + ladspaIds.size())); Chris@1292: m_table->setColumnCount(5); Chris@1292: Chris@1292: QStringList headers; Chris@1293: int typeCol = 0, libCol = 1, idCol = 2, dirCol = 3, nameCol = 4; Chris@1293: headers << tr("Type") << tr("Library") Chris@1293: << tr("Identifier") << tr("Found in") << tr("Name"); Chris@1292: m_table->setHorizontalHeaderLabels(headers); Chris@1292: Chris@1292: int row = 0; Chris@1292: Chris@1292: for (QString id: feIds) { Chris@1292: auto staticData = feFactory->getPluginStaticData(id); Chris@1292: m_table->setItem(row, typeCol, new QTableWidgetItem Chris@1292: (tr("Vamp"))); Chris@1292: m_table->setItem(row, idCol, new QTableWidgetItem Chris@1292: (QString::fromStdString(staticData.basic.identifier))); Chris@1292: m_table->setItem(row, nameCol, new QTableWidgetItem Chris@1292: (QString::fromStdString(staticData.basic.name))); Chris@1292: QString path = feFactory->getPluginLibraryPath(id); Chris@1292: m_table->setItem(row, libCol, new QTableWidgetItem Chris@1292: (QFileInfo(path).fileName())); Chris@1292: m_table->setItem(row, dirCol, new QTableWidgetItem Chris@1292: (QFileInfo(path).path())); Chris@1292: row++; Chris@1292: } Chris@1292: Chris@1292: for (QString id: dssiIds) { Chris@1292: auto descriptor = dssiFactory->getPluginDescriptor(id); Chris@1292: if (!descriptor) continue; Chris@1292: m_table->setItem(row, typeCol, new QTableWidgetItem Chris@1292: (tr("DSSI"))); Chris@1292: m_table->setItem(row, idCol, new QTableWidgetItem Chris@1292: (QString::fromStdString(descriptor->label))); Chris@1292: m_table->setItem(row, nameCol, new QTableWidgetItem Chris@1292: (QString::fromStdString(descriptor->name))); Chris@1292: QString path = dssiFactory->getPluginLibraryPath(id); Chris@1292: m_table->setItem(row, libCol, new QTableWidgetItem Chris@1292: (QFileInfo(path).fileName())); Chris@1292: m_table->setItem(row, dirCol, new QTableWidgetItem Chris@1292: (QFileInfo(path).path())); Chris@1292: row++; Chris@1292: } Chris@1292: Chris@1292: for (QString id: ladspaIds) { Chris@1292: auto descriptor = ladspaFactory->getPluginDescriptor(id); Chris@1292: if (!descriptor) continue; Chris@1292: m_table->setItem(row, typeCol, new QTableWidgetItem Chris@1292: (tr("LADSPA"))); Chris@1292: m_table->setItem(row, idCol, new QTableWidgetItem Chris@1292: (QString::fromStdString(descriptor->label))); Chris@1292: m_table->setItem(row, nameCol, new QTableWidgetItem Chris@1292: (QString::fromStdString(descriptor->name))); Chris@1292: QString path = ladspaFactory->getPluginLibraryPath(id); Chris@1292: m_table->setItem(row, libCol, new QTableWidgetItem Chris@1292: (QFileInfo(path).fileName())); Chris@1292: m_table->setItem(row, dirCol, new QTableWidgetItem Chris@1292: (QFileInfo(path).path())); Chris@1292: row++; Chris@1292: } Chris@1292: Chris@1292: m_table->setSortingEnabled(true); Chris@1292: m_table->setSelectionMode(QAbstractItemView::NoSelection); Chris@1292: m_table->resizeColumnsToContents(); Chris@1292: Chris@1292: int twidth = m_table->horizontalHeader()->length(); Chris@1292: int theight = m_table->verticalHeader()->length(); Chris@1292: Chris@1292: QDesktopWidget *desktop = QApplication::desktop(); Chris@1292: QRect available = desktop->availableGeometry(); Chris@1292: Chris@1292: int width = std::min(twidth + 30, (available.width() * 3) / 4); Chris@1292: int height = std::min(theight + 30, (available.height() * 3) / 4); Chris@1292: Chris@1292: resize(width, height); Chris@1292: } Chris@1292: