#ifndef BUDDY_WIDGET_H
#define BUDDY_WIDGET_H

#include <QtGui>
#include "softProj\ChatWidget\ChatMessage.h"

/// Represents chat buddy in a buddies table
/** Represents chat buddy in a buddies table. Stores QTableWidgetItem
that are related to widget holding buddy name and widget holding unread
messages count from that buddy. Also stores ChatBuddy that is related to 
those two items in a table.
*/
class BuddyHolder {
public:
	BuddyHolder(ChatBuddy * buddy);
	~BuddyHolder();

	/** Gets buddy id
	@return Buddy id
	*/
	int getBuddyId();

	/** Gets ChatBuddy that is related to represented row
	@return ChatBuddy related to represented row
	*/
	ChatBuddy * getBuddy();
	
	/** Refreshes both QTableWidget item according to related ChatBuddy. 		
	That means, name and unread messages count is updated and displayed.
	*/
	void setTitle();

	/** Increases count of unread messages from related buddy and refreshes displayed value */
	void addUnreadMessage();

	/** Sets count of unread messages from related buddy to zero and refreshes displayed value */
	void readAllMessages();

	/** Sets widget representing buddy name in a table
	@param item Widget that represents buddy name in a table
	*/
	void setNameItem(QTableWidgetItem * item);

	/** Sets widget representing unread messages count from related buddy in a table
	@param item Widget that represents unread messages count from related buddy in a table
	*/
	void setMsgItem(QTableWidgetItem * item);

	/** Refreshes look of both QTableWidget items do they represents umselected row */
	void setUnselected();

	/** Refreshes look of both QTableWidget items do they represents selected row */
	void setSelected();
private:
	ChatBuddy * buddy_;
	int unreadMessagesCount_;

	QString selectedStyle;
	QString unselectedStyle;

	QTableWidgetItem * nameItem_;
	QTableWidgetItem * msgItem_;
};

#endif