/***************************************************************************
 * clipboard.cpp: implementation of Clipboard class
 *
 * This file is part of KTabEdit, a KDE tabulature edimTor
 *
 * copyright (C) 2003-2006 the KTabEdit development team <mrgwen@gmail.com>
 * copyright (C) 2002-2003 the KGuitar 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 "clipboard.h"

Clipboard::Clipboard(uint begin, uint bar, QWidget* parent, const char* name)
: QDialog(parent, name),
  mLayout(this, 5, 2, 0, -1, "Clipboard layout"),
  mFromLabel("from", this, "from label"),
  mToLabel("to", this, "to label"),
  mFrom(1, bar, 1, this, "from spinbox"),
  mTo(1, bar, 1, this ,"to spinbox"),
  mOk(this, "ok button"),
  mCancel(this, "cancel button"),
  mToEnd("to the end", this, "end checkbox"),
  mLastBar(bar)
{
	mFrom.setValue(begin);
	mTo.setValue(begin);
	
	mOk.setText("ok");
	mCancel.setText("cancel");
	
	mLayout.addWidget(&mFromLabel, 0,0);
	mLayout.addWidget(&mFrom, 0, 1);
	mLayout.addWidget(&mToLabel, 1,0);
	mLayout.addWidget(&mTo, 1, 1);
	mLayout.addWidget(&mToEnd, 2, 0);
	mLayout.addWidget(&mOk, 3, 0);
	mLayout.addWidget(&mCancel, 3, 1);
	
	connect(&mOk, SIGNAL(clicked()), this, SLOT(okClick()));
	connect(&mCancel, SIGNAL(clicked()), this, SLOT(cancelClick()));
}

uint Clipboard::getFrom() const
{
	return mFrom.value();
}

uint Clipboard::getTo() const
{
	return mTo.value();
}

void Clipboard::okClick()
{
	if (mToEnd.isChecked() == true)
		mTo.setValue(mLastBar);
	
	setResult(QDialog::Accepted);
	hide();
}

void Clipboard::cancelClick()
{
	setResult(QDialog::Rejected);
	hide();
}

Clipboard::~Clipboard()
{
}

#include "clipboard.moc"
