#include "plugins_window.h"
#include "SH_plugins.h"
#include <QScrollBar>
#include <QFileDialog>
#include <QImageReader>
#include <QDialogButtonBox>
#include <QBuffer>
#include <QMetaMethod>


enum Column {
	cName,
	cVersion,
	cRequest,
	cAnswer,
	cDesigner,
	cLibrary,
	cDescription,
};


PluginsWindow::PluginsWindow(QWidget * parent): QDialog(parent), Ui::PluginsWindow() {
	setupUi(this);
	tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
	//connect(buttonReload, SIGNAL(clicked(bool)), SHCORE, SLOT(reloadPlugins()));
	//connect(SHCORE, SIGNAL(changedPlugins()), this, SLOT(updateList()));
}


PluginsWindow::~PluginsWindow() {
}


void PluginsWindow::showEvent(QShowEvent * e) {
	updateList();
	QDialog::showEvent(e);
}


void PluginsWindow::updateList() {
	/*tree->clear();
	plugins.loadPlugins();
	auto pl = plugins.getPlugins(SHPluginBase::Extra);
	for (const SHPluginsLoader::PluginInfo & p, pl) {
		QTreeWidgetItem * ni = new QTreeWidgetItem();
		SHPluginBaseExtra * plugin = (SHPluginBaseExtra * )p.plugin;
		ni->setText(cName, plugin->name());
		ni->setText(cVersion, plugin->version());
		ni->setText(cRequest, plugin->deviceWatcherRequest());
		ni->setText(cAnswer, plugin->deviceWatcherAnswer());
		ni->setIcon(cDesigner, plugin->deviceWatcherDesignerIcon());
		ni->setText(cDesigner, plugin->deviceWatcherDesignerName() + " (" + plugin->deviceWatcherDesignerPath() + ")");
		ni->setText(cLibrary, p.manifest.file);
		ni->setText(cDescription, plugin->description());
		tree->addTopLevelItem(ni);
	}*/
}
