#include <QtGui>
#include <QtCore>
#include <QtSql>
#include "vision.h"
#include "../constants.h"
using namespace Common;
using namespace Constants;
vision::vision(QString & base , QList<int> & listInt){
  setupUi(this);
  QList<int>    list             = listInt;
  setAttribute                     (Qt::WA_DeleteOnClose);
  QSqlDatabase db                = QSqlDatabase::database(Constants::DB_ACCOUNTANCY);
  qDebug() << base;
  m_modelVision                  = new QSqlTableModel(this,db);
  m_modelVision                 -> setTable(base);
  m_modelVision                 -> select();
  
  tableView                     -> setModel(m_modelVision);
  tableView                     -> setSelectionBehavior(QAbstractItemView::SelectRows);
  tableView                     -> setSelectionMode(QAbstractItemView::SingleSelection);
  for(int i = 0 ; i < list.size() ; i ++){
    int j                       =  list[i];
    tableView                   -> setColumnHidden(j,true);
  }
  tableView                     -> horizontalHeader()-> setStretchLastSection ( true );
  tableView                     -> show();
  connect(pushButton,  SIGNAL(pressed()),this,SLOT(effacer()));
  connect(pushButton_2,SIGNAL(pressed()),this,SLOT(close()));
}

vision::~vision(){}

void vision::effacer(){
  QModelIndex index                     = tableView->QAbstractItemView::currentIndex();
  int i                                 = index.row();
  m_modelVision                        -> removeRows(i,1,QModelIndex());
}

