#include <QtGui>
#include <QtOpenGL/QGLWidget>
#include "InfoVisUI.h"
#include "TransitionManager.hpp"

myQtApp::myQtApp(QWidget* pParent) {
  UNREFERENCED(pParent);
	setupUi(this);

	connect(btPrevious, SIGNAL(clicked()), this, SLOT(ChangeValuesPrevious()));
  connect(btNext, SIGNAL(clicked()), this, SLOT(ChangeValuesNext()));
  connect(rbDescending, SIGNAL(toggled(bool)), this, SLOT(ChangeSortingOrder(bool)));
  connect(cbChart, SIGNAL(currentIndexChanged(int)), this, SLOT(ChangeChart(int)));
  connect(cbFiltering, SIGNAL(currentIndexChanged(int)), this, SLOT(ChangeFilter(int)));
}

void myQtApp::ChangeValuesPrevious() {
  TransitionManager* pTransitionManager = TransitionManager::GetInstance();

  pTransitionManager->PreviousDataSet();
}

void myQtApp::ChangeValuesNext() {
  TransitionManager* pTransitionManager = TransitionManager::GetInstance();

  pTransitionManager->NextDataSet();
}

void myQtApp::ChangeSortingOrder(bool bDescending) {
  TransitionManager* pTransitionManager = TransitionManager::GetInstance();

  pTransitionManager->SetSortingOrder(bDescending);
}

void myQtApp::ChangeChart(int iCurrentIndex) {
  TransitionManager* pTransitionManager = TransitionManager::GetInstance();

  pTransitionManager->SetChart(iCurrentIndex);
}

void myQtApp::ChangeFilter(int iCurrentIndex) {
  TransitionManager* pTransitionManager = TransitionManager::GetInstance();

  if (iCurrentIndex == 0) {
    pTransitionManager->SetFilter(true);
  }
  else {
    pTransitionManager->SetFilter(false);
  }
}