1 2 3 #include "toonzqt/selection.h" 4 #include "toonzqt/tselectionhandle.h" 5 #include "assert.h" 6 7 //#include "menubar.h" 8 #include <QMenu> 9 #include <QWidget> 10 11 //============================================================================= 12 // TSelection 13 //----------------------------------------------------------------------------- 14 TSelection()15TSelection::TSelection() : m_view(0) {} 16 17 //----------------------------------------------------------------------------- 18 ~TSelection()19TSelection::~TSelection() {} 20 21 //----------------------------------------------------------------------------- 22 makeCurrent()23void TSelection::makeCurrent() { 24 TSelectionHandle::getCurrent()->setSelection(this); 25 } 26 27 //----------------------------------------------------------------------------- 28 makeNotCurrent()29void TSelection::makeNotCurrent() { 30 TSelectionHandle *sh = TSelectionHandle::getCurrent(); 31 if (sh->getSelection() == this) sh->setSelection(0); 32 } 33 34 //----------------------------------------------------------------------------- 35 getCurrent()36TSelection *TSelection::getCurrent() { 37 return TSelectionHandle::getCurrent()->getSelection(); 38 } 39 40 //----------------------------------------------------------------------------- 41 setCurrent(TSelection * selection)42void TSelection::setCurrent(TSelection *selection) { 43 // assert(0); 44 TSelectionHandle::getCurrent()->setSelection(selection); 45 } 46 47 //----------------------------------------------------------------------------- 48 enableCommand(CommandId cmdId,CommandHandlerInterface * handler)49void TSelection::enableCommand(CommandId cmdId, 50 CommandHandlerInterface *handler) { 51 TSelectionHandle::getCurrent()->enableCommand(cmdId, handler); 52 } 53 addMenuAction(QMenu * menu,CommandId cmdId)54void TSelection::addMenuAction(QMenu *menu, CommandId cmdId) { 55 menu->addAction(CommandManager::instance()->getAction(cmdId)); 56 } 57 notifyView()58void TSelection::notifyView() { 59 if (m_view) m_view->onSelectionChanged(); 60 } 61