#ifndef STOCK_TABLE_WIDGET_H
#define STOCK_TABLE_WIDGET_H

#include <QtGui>
#include <map>
#include <vector>
#include "ui_stockTableWidget.h"
#include "softProj\clientServer\structs.h"

class WarehouseItemWidget;

class StockTableWidget : public QWidget {
    Q_OBJECT

private:
	Ui::StockTableWidget ui_;
	QRegExp * currentFilter_;
public:
    StockTableWidget(QWidget *parent);

    void clearFilteredContentKeepFilter();
    void clearAllContentKeepFilter();
	void clearFilterString();
    
	void removeRow(int row);
	void removeRowAndItem(id_t itemId);

	void insertItem(const warehouse_item_status & item);

	void updateItems(std::map<id_t, warehouse_item_status> & newItems);
protected:            	
	typedef std::map<QString, warehouse_item_status> ItemsMap;
    typedef std::vector<warehouse_item_status> ItemsVector;
   
    std::map<id_t, warehouse_item_status> rows_;

	void connectSignals();

	int findRowOfItem(id_t id);
	bool matchesFilterIfAny(const std::string & name);
signals:
	void itemClickedSignal(const warehouse_item_status & item);
private slots:
    void searchClickedSlot();
    void showAllClickedSlot();

	void itemClickedSlot(const warehouse_item_status & item);
	void cellClickedSlot(int row, int col);
};

#endif