/***************************************************************************
 *   Copyright (C) 2007 by Lars Pfennig   *
 *      *
 *                                                                         *
 *   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 "guimain.h"


/**
* \class guiMain.cpp
* \brief 
* \author Lars Pfennig <>
* \version 1.05
* \date 2007
*
*  Its the main windows in the program.
*/
GuiMain::GuiMain ( QWidget *parent ) : QMainWindow ( parent ), Ui::GuiMain()
{
	//window-ui from designer
	setupUi ( this );
	setupModel();
	int rows=6;
	tableWidget->setRowCount(rows);
	for(int row=0; row<rows; row++)
	{
		QDate now = QDate::currentDate();

		qDebug() << "The date is now: " << now;

		tableWidget->setItem (row,0, new QTableWidgetItem("Title"));

		tableWidget->setItem (row,1, new QTableWidgetItem("Author"));

		tableWidget->setItem (row,2, new QTableWidgetItem("Price"));

		tableWidget->setItem (row,3, new QTableWidgetItem("Total Price"));

		tableWidget->setItem (row,4, new QTableWidgetItem("VAT"));

		tableWidget->setItem (row,5, new QTableWidgetItem("PublishingDate"));

		tableWidget->setItem (row,6, new QTableWidgetItem("TitlePicure"));
		//CDvd * dvdo = new CDvd ("TestDvd","ich",1.2,1.0,16.0,now);
	   	//dvdo->writeToTable(tableWidget, row);
	   	//liste.push_back(dvdo);		
	}
	
}

/*!
destructor GuiMain
*/
GuiMain::~GuiMain()
{
}

/*!
on_actionEnter_Password GuiMain
returns no value
set _Password with the password from the user
*/
void GuiMain::on_actionEnter_Password_triggered()
{
	GuiPasswordDialog dig ( this );
	if ( dig.exec() )
	{
		_Password = dig.Password();
	}
	qDebug() << "The password is now: " << _Password;

}

/*!
on_action_About GuiMain
returns no value
by clicking on About a window named GuiAboutDialog shows the information about the program
*/
void GuiMain::on_action_About_triggered()
{
	GuiAboutDialog about ( this );
	/* open window GuiAboutDialog() */
	about.exec();
}

/*!
on_action_Exit GuiMain
returns no value
the close function is called by clicking on Exit in menu
*/
void GuiMain::on_action_Exit_triggered()
{
	close();
}

/*!
on_tableWidget_cellDoubleClicked(int row)
returns no value
the open the DvdDialog if a cell is double clicked
*/
void GuiMain::on_tableWidget_cellDoubleClicked(int row)
{
	DvdDialog dvdd ( this );
	dvdd.exec();
}

void GuiMain::setupModel()
{
	//model = new QStandardItemModel();
}
