#include "mainwindow.h"
#include "requetes.h"
#include "searchinblobs.h"
#include <QDebug>

MainWindowRequete::MainWindowRequete() : m_file(0),m_actions(0),m_fermer(0),m_requete(0)
{
    setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);
    createMenus();
    createActions();
    connectActions();    
}

MainWindowRequete::~MainWindowRequete(){
    qWarning() << __FILE__ << QString::number(__LINE__) << "in mainwindow destructor" ;
}


void MainWindowRequete::createMenus()
{
    m_file = menuBar()->addMenu(tr("&Fichier"));
    m_actions = menuBar()->addMenu(tr("&Actions"));
}

void MainWindowRequete::createActions()
{
    m_fermer = m_file->addAction(trUtf8("&Quitter"));
    m_fermer->setShortcut(QKeySequence::Close);
    m_requete = m_actions->addAction(trUtf8("&Requête"));
    m_searchinblobs = m_actions->addAction(trUtf8("&Chercher dans les données"));
}

void MainWindowRequete::connectActions()
{
    connect(m_fermer,SIGNAL(triggered()), this, SLOT(close()));
    connect(m_requete,SIGNAL(triggered()), this, SLOT(runRequete()));
    connect(m_searchinblobs,SIGNAL(triggered()),this,SLOT(runSearchinblobs()));    
}

void MainWindowRequete::runRequete()
{
    Requete * requete = new Requete(this);
    setCentralWidget(requete);
}

void MainWindowRequete::runSearchinblobs()
{
    Searchinblobs* search = new Searchinblobs(this);
    setCentralWidget(search);
}

