#ifndef DATABASEBUSES_H
#define DATABASEBUSES_H

#include <QMenu>
#include "core.h"
#include "ui_database_buses.h"


class DatabaseBuses: public QWidget, public Ui::DatabaseBuses {
	Q_OBJECT
public:
	explicit DatabaseBuses(QWidget * parent = 0);
	~DatabaseBuses();

	bool ask_for_save;
	
private:
	void loadImageIntoLabel(ImageView * l);
	QSqlQuery updateQuery(int id);
	
	QMenu menu;
	BlockBusItem busitem;
	QSqlQueryModel model;
	QSqlQuery prev_query;
	int cur_id, prev_id;
	
public slots:
	void reload();
	void reloadPlugins();
	void showID(int id);
	
private slots:
	void popupMenuBus(QPoint p);
	void filterList();
	void treeSelectionChanged();
	void treeClicked(const QModelIndex & index);
	void on_actionAddBus_triggered();
	void on_actionRemoveBus_triggered();
	void on_buttonImageBLoad_clicked() {loadImageIntoLabel(labelImageB);}
	void on_buttonImageELoad_clicked() {loadImageIntoLabel(labelImageE);}
	void on_buttonImageBClear_clicked() {labelImageB->clear();}
	void on_buttonImageEClear_clicked() {labelImageE->clear();}
	void on_buttonReset_clicked();
	void on_buttonCommit_clicked();
	
};

#endif // DATABASEBUSES_H
