#ifndef ANDROIDS_SECTION_WIDGET_H
#define ANDROIDS_SECTION_WIDGET_H

#include "ui_androidsSectionWidget.h"
#include "softProj\DevicesWidget\deviceItemWidget.h"
#include <QtGui>
#include <cassert>
#include "protocol.h"
#include <sstream>

void setButtonIcon(QPushButton * button, const std::string & filePath, unsigned int iconSize);

class CombinedSlider;
class AndroidsWidget;

// Widget for androids repairment settings for some concrete fortress section
/** Widget for androids repairment settings for some concrete fortress section.
In this widget user can set energy priority and energy ratio for current fortress section 
and so divide energy between multiple sections depending on his preferences.
*/
class AndroidsSectionWidget : public QWidget {
	Q_OBJECT
public:
	/** Creates new instance of AndroidsSectionWidget
	@param parent Parent widget
	*/
	AndroidsSectionWidget(QWidget * parent);

	/** Sets state of the widget from given state holder
	@param state State holder that holds information about section settings
	@param fullState State holder that holds information about all androids settings
	*/
	void setState(androids_assignment & state, androids_status & fullState);

	/** Gets state of the widget to the state holder
	@return State holder that holds information about section settings
	*/
	androids_assignment getState();

	/** Sets name of the fortress section in repairment settings 
	@param sectionName Name of the fortress section
	*/
	void setSectionName(const std::wstring & sectionName);	

	/** Sets icon for section in name button 
	@param deviceIconPath Path to file with an icon 
	*/
	void setSectionIcon(const std::string & deviceIconPath);

	/** Gets energy ratio
	@return Energy ratio
	*/
	int getEnergyRatio();

	/** Sets energy ratio
	@param value Energy ratio
	*/
	void setEnergyRatio(double value);

	/** Gets energy priority
	@return Energy priority
	*/
	int getEnergyPriority();

	/** Sets energy priority
	@param value Energy priority
	*/
	void setEnergyPriority(int value);	

	/* Sets background holder 
	@param backgroundsHolder Background holder that contains information about background colors
	*/
	void setBackgroundsHolder(DeviceBackgroundsHolder * backgroundsHolder);
signals:
	/** Signals that user changed settings in the widget */
	void settingsChangedSignal();
public slots:
	/** Slot for changing value in energy priority slider
	@param value New energy priority value
	*/
	void priorityChangedSlot(int value);

	/** Slot for changing value in energy ratios slider
	@param value New energy ratio value
	*/
	void ratioChangedSlot(int value);
private:
	Ui::AndroidsSectionWidget ui_;

	int minimumPriority;
	int maximumPriority;
	int minimumRatio;
	int maximumRatio;

	void recolorFromPriority();

	DeviceBackgroundsHolder * backgroundsHolder_;
};

#endif