/***************************************************************************
 * timesignature.h: implementation of TimeSignature
 *
 * This file is part of KGuitar, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 the KTabEdit development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * 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.
 *
 * See the file COPYING for more information.
 ***************************************************************************/
 
#include "timesignature.h"
#include "util/assert.h"

TimeSignature::TimeSignature()
{
	time[0] = time[1] = 4;
}

TimeSignature::TimeSignature(uchar time1, uchar time2)
{
	time[0] = time1;
	time[1] = time2;
}

TimeSignature::~TimeSignature()
{

}

void TimeSignature::clone(const TimeSignature* timeSignature)
{
	PRECONDITION( timeSignature != 0x0 );
	
	time[0] = timeSignature->time[0];
	time[1] = timeSignature->time[1];
}

void  TimeSignature::setNumerator(uchar i)
{
	time[0] = i;
	
	emit timeSignatureChanged();
}

uchar TimeSignature::numerator() const
{
	return time[0];
}

void  TimeSignature::setDenominator(uchar i)
{
	time[1] = i;
	
	timeSignatureChanged();
}

uchar TimeSignature::denominator() const
{
	return time[1];
}

uint TimeSignature::timeLigatures() const
{
	switch (time[1]) {
	case 2:
		return 1920;
	case 4:
		return 480;
	case 8:
		return 720;
	case 16:
		return 120;
	case 32:
		return 60;
	case 64:
		return 30;
	default:
		return 480;
	}
}

bool TimeSignature::operator==(const TimeSignature& timeSignature) const
{
	if ((time[0] == timeSignature.time[0]) && (time[1] == timeSignature.time[1]))
		return true;
	
	return false;
}

bool TimeSignature::operator!=(const TimeSignature& timeSignature) const
{
	return !(*this == timeSignature);
}

#include "timesignature.moc"
