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
Shinya Kitaoka 120a6e
TSelection::TSelection() : m_view(0) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TSelection::~TSelection() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TSelection::makeCurrent() {
Shinya Kitaoka 120a6e
  TSelectionHandle::getCurrent()->setSelection(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TSelection::makeNotCurrent() {
Shinya Kitaoka 120a6e
  TSelectionHandle *sh = TSelectionHandle::getCurrent();
Shinya Kitaoka 120a6e
  if (sh->getSelection() == this) sh->setSelection(0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TSelection *TSelection::getCurrent() {
Shinya Kitaoka 120a6e
  return TSelectionHandle::getCurrent()->getSelection();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TSelection::setCurrent(TSelection *selection) {
Shinya Kitaoka 120a6e
  // assert(0);
Shinya Kitaoka 120a6e
  TSelectionHandle::getCurrent()->setSelection(selection);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TSelection::enableCommand(CommandId cmdId,
Shinya Kitaoka 120a6e
                               CommandHandlerInterface *handler) {
Shinya Kitaoka 120a6e
  TSelectionHandle::getCurrent()->enableCommand(cmdId, handler);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TSelection::addMenuAction(QMenu *menu, CommandId cmdId) {
Shinya Kitaoka 120a6e
  menu->addAction(CommandManager::instance()->getAction(cmdId));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TSelection::notifyView() {
Shinya Kitaoka 120a6e
  if (m_view) m_view->onSelectionChanged();
Toshihiro Shimizu 890ddd
}