// Refresh plugin listing.
void qtractorPluginSelectForm::refresh (void)
{
	m_ui.PluginListView->clear();

	qtractorPluginFactory *pPluginFactory
		= qtractorPluginFactory::getInstance();
	if (pPluginFactory == NULL)
		return;

	// FIXME: Should this be a global (singleton) registry?
	if (pPluginFactory->types().isEmpty()) {
		// Tell the world we'll take some time...
		QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
		const bool bRescan = m_ui.PluginRescanPushButton->isVisible();
		if (bRescan) m_ui.PluginRescanPushButton->hide();
		m_ui.DialogButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
		m_ui.PluginScanProgressBar->show();
		pPluginFactory->scan();
		m_ui.PluginScanProgressBar->hide();
		m_ui.DialogButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(true);
		if (bRescan) m_ui.PluginRescanPushButton->show();
		// We're formerly done.
		QApplication::restoreOverrideCursor();
	}

	if (m_pPluginList == NULL) {
		stabilize();
		return;
	}

	const unsigned short iChannels = m_pPluginList->channels();
	const bool bMidi = m_pPluginList->isMidi();

	QString sSearch = m_ui.PluginSearchComboBox->currentText().simplified();
	const QRegExp rx(sSearch.replace(QRegExp("[\\s]+"), ".*"), Qt::CaseInsensitive);

	QStringList cols;
	QList<QTreeWidgetItem *> items;
	QListIterator<qtractorPluginType *> type_iter(pPluginFactory->types());
	while (type_iter.hasNext()) {
		qtractorPluginType *pType = type_iter.next();
		const QString& sFilename = pType->filename();
		const QString& sName = pType->name();
		if (rx.isEmpty()
			|| rx.indexIn(sName) >= 0
			|| rx.indexIn(sFilename) >= 0) {
			// Try primary instantiation...
			const int iAudioIns    = pType->audioIns();
			const int iAudioOuts   = pType->audioOuts();
			const int iMidiIns     = pType->midiIns();
			const int iMidiOuts    = pType->midiOuts();
			const int iControlIns  = pType->controlIns();
			const int iControlOuts = pType->controlOuts();
			// All that to check whether it will get properly instantiated.
			const unsigned short iInstances
				= pType->instances(iChannels, bMidi);
			cols.clear();
			cols << sName;
			cols << QString("%1:%2").arg(iAudioIns).arg(iAudioOuts);
			cols << QString("%1:%2").arg(iMidiIns).arg(iMidiOuts);
			cols << QString("%1:%2").arg(iControlIns).arg(iControlOuts);
			QStringList modes;
			if (pType->isEditor())
				modes << tr("GUI");
			if (pType->isConfigure())
				modes << tr("EXT");
			if (pType->isRealtime())
				modes << tr("RT");
			if (modes.isEmpty())
				cols << "-";
			else
				cols << modes.join(",");
			cols << sFilename;
			cols << QString::number(pType->index());
			cols << QString::number(iInstances);
			cols << qtractorPluginType::textFromHint(pType->typeHint());
			QTreeWidgetItem *pItem = new QTreeWidgetItem(cols);
			if (iInstances < 1) {
				pItem->setFlags(pItem->flags() & ~Qt::ItemIsSelectable);
				const int iColumnCount = m_ui.PluginListView->columnCount();
				const QPalette& pal = m_ui.PluginListView->palette();
				const QColor& rgbForeground
					= pal.color(QPalette::Disabled, QPalette::WindowText);
				for (int i = 0; i < iColumnCount; ++i)
					pItem->setForeground(i, rgbForeground);
			}
			pItem->setTextAlignment(1, Qt::AlignHCenter);	// Audio
			pItem->setTextAlignment(2, Qt::AlignHCenter);	// MIDI
			pItem->setTextAlignment(3, Qt::AlignHCenter);	// Controls
			pItem->setTextAlignment(4, Qt::AlignHCenter);	// Modes
			items.append(pItem);
		}
	}
	m_ui.PluginListView->addTopLevelItems(items);

	QHeaderView *pHeader = m_ui.PluginListView->header();
	m_ui.PluginListView->sortItems(
		pHeader->sortIndicatorSection(),
		pHeader->sortIndicatorOrder());

	m_ui.PluginResetToolButton->setEnabled(!rx.isEmpty());

	stabilize();
}
Exemple #2
0
int HeaderView::sortIndicatorSection(lua_State * L) // const : int
{
    QHeaderView* obj = QtObject<QHeaderView>::check( L, 1);
	Util::push( L, obj->sortIndicatorSection() );
	return 1;
}