Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonzqt/selection.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/tselectionhandle.h"
Toshihiro Shimizu 890ddd
#include "assert.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "menubar.h"
Toshihiro Shimizu 890ddd
#include <qmenu></qmenu>
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// TSelection
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TSelection::TSelection()
Toshihiro Shimizu 890ddd
	: m_view(0)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TSelection::~TSelection()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TSelection::makeCurrent()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TSelectionHandle::getCurrent()->setSelection(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TSelection::makeNotCurrent()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TSelectionHandle *sh = TSelectionHandle::getCurrent();
Toshihiro Shimizu 890ddd
	if (sh->getSelection() == this)
Toshihiro Shimizu 890ddd
		sh->setSelection(0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TSelection *TSelection::getCurrent()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return TSelectionHandle::getCurrent()->getSelection();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TSelection::setCurrent(TSelection *selection)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	//assert(0);
Toshihiro Shimizu 890ddd
	TSelectionHandle::getCurrent()->setSelection(selection);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TSelection::enableCommand(CommandId cmdId, CommandHandlerInterface *handler)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TSelectionHandle::getCurrent()->enableCommand(cmdId, handler);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TSelection::addMenuAction(QMenu *menu, CommandId cmdId)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	menu->addAction(CommandManager::instance()->getAction(cmdId));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TSelection::notifyView()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_view)
Toshihiro Shimizu 890ddd
		m_view->onSelectionChanged();
Toshihiro Shimizu 890ddd
}