#include "disTabWdg.h"
#include "ui_disTabWdg.h"
#include "Control/flowControl.h"
#include <QScrollBar>
#include <QMapIterator>

disTabWdg::disTabWdg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::disTabWdg)
{
    ui->setupUi(this);
    ui->disTabWdg_btnsj->hide();
    ui->disTabWdg_btnxj->hide();
}

disTabWdg::~disTabWdg()
{
    delete ui;
}

void disTabWdg::IniDishesData(QMap<QString, dishesObject> dishesMap)
{
    int index = 0;
    foreach(dishesObject dObj, dishesMap.values())
    {
        dishesItem *item = new dishesItem(dObj, this);
        int row;
        if(index==0)
        {
            row = ui->disTabWdg_tablewdg->rowCount();
            ui->disTabWdg_tablewdg->insertRow(row);
        }
        ui->disTabWdg_tablewdg->setCellWidget(row, index, item);
        index++;
        if(index==2)
        {
            index=0;
        }
    }
}

void disTabWdg::on_disTabWdg_close_clicked()
{
    emit doHide();
}

void disTabWdg::on_disTabWdg_btnup_clicked()
{
    ui->disTabWdg_tablewdg->verticalScrollBar()->setValue(ui->disTabWdg_tablewdg->verticalScrollBar()->value()-15);
}

void disTabWdg::on_disTabWdg_btndown_clicked()
{
    ui->disTabWdg_tablewdg->verticalScrollBar()->setValue(ui->disTabWdg_tablewdg->verticalScrollBar()->value()+15);
}

void disTabWdg::on_disTabWdg_btnsj_clicked()
{
//    QMap<QString, int> map;
//    foreach(dishesObject obj, m_disObjList)
//    {
//        map.insert(obj.code, 1);
//    }

//    emit doUpdDishes(m_channelCode, map);
}

void disTabWdg::on_disTabWdg_btnxj_clicked()
{
//    QMap<QString, int> map;
//    foreach(dishesObject obj, m_disObjList)
//    {
//        map.insert(obj.code, 0);
//    }

//    emit doUpdDishes(m_channelCode, map);
}
