/***************************************************************************
 *   Copyright (C) 2008 by Dr Pierre-Marie DESOMBRE   *
 *   pm.desombre@medsyn.fr   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/



#include <QtGui>
#include <QtCore>
#include <QtSql>

#include "modifierdialog.h"

modifierdialog::modifierdialog()
{
QSqlDatabase db = QSqlDatabase::database();
setupUi(this);
  modeletoute = new QSqlTableModel(0,db);
  modeletoute->setTable("Alarmes");
  modeletoute->select();
  tableView2->setModel(modeletoute);
  tableView2->setSelectionBehavior(QAbstractItemView::SelectRows);
  tableView2->setSelectionMode(QAbstractItemView::SingleSelection);
  tableView2->setSortingEnabled(true);
  tableView2->setColumnHidden(0,true);
  tableView2->setColumnHidden(3,true);
  tableView2->setColumnHidden(7,true);
  tableView2->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
  tableView2->verticalHeader()->setResizeMode(QHeaderView::Stretch);
  tableView2->resizeColumnsToContents();
  tableView2->show();

/*for (int row = 0; row < modeletoute->rowCount(); ++row)
{
c_m_record = modeletoute->record(row);
//QStringList ident;
c_m_ident.append(c_m_record.value("Alarm_IDDos").toString());
}*/

  connect(pushButton_2,SIGNAL(clicked()),this,SLOT(effacer()));
  connect(pushButton,SIGNAL(clicked()),this,SLOT(close()));

}


void modifierdialog::effacer(/*modifierdialog**/)
{
//recuperer id
//QString id;
QModelIndex index = tableView2->QAbstractItemView::currentIndex();
int i = index.row();
// id = c_m_ident[i];
//on supprime la ligne
modeletoute->removeRows(i,1,QModelIndex());
modeletoute->submitAll();

//QSqlQuery query;
//query.exec("DELETE FROM Alarmes WHERE Alarm_IDDos = '"+id+"'");

}



