/***************************************************************************
 *   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 "modifierdialog.h"
#include "lecturedialog.h"

modifierdialog::modifierdialog()
{
setupUi(this);

modeletoute->setTable("Alarmes");
modeletoute->select();

tabletoute->setModel(modeletoute);
tabletoute->setSelectionBehavior(QAbstractItemView::SelectRows);
tabletoute->setSelectionMode(QAbstractItemView::SingleSelection);
tabletoute->setColumnHidden(0,true);
tabletoute->setColumnHidden(3,true);
tabletoute->setColumnHidden(6,true);
tabletoute->setColumnHidden(7,true);

tabletoute->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,SIGNAL(clicked()),this,SLOT(accept()));
connect(pushButton_2,SIGNAL(clicked()),this,SLOT(reject()));

}


void modifierdialog::effacer(modifierdialog*)
{

//recuperer id
QString id;
QModelIndex index = tabletoute->QAbstractItemView::currentIndex();
int i = index.row();
 id = c_m_ident[i];

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

}



