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()15 TSelection::TSelection() : m_view(0) {}
16 
17 //-----------------------------------------------------------------------------
18 
~TSelection()19 TSelection::~TSelection() {}
20 
21 //-----------------------------------------------------------------------------
22 
makeCurrent()23 void TSelection::makeCurrent() {
24   TSelectionHandle::getCurrent()->setSelection(this);
25 }
26 
27 //-----------------------------------------------------------------------------
28 
makeNotCurrent()29 void TSelection::makeNotCurrent() {
30   TSelectionHandle *sh = TSelectionHandle::getCurrent();
31   if (sh->getSelection() == this) sh->setSelection(0);
32 }
33 
34 //-----------------------------------------------------------------------------
35 
getCurrent()36 TSelection *TSelection::getCurrent() {
37   return TSelectionHandle::getCurrent()->getSelection();
38 }
39 
40 //-----------------------------------------------------------------------------
41 
setCurrent(TSelection * selection)42 void TSelection::setCurrent(TSelection *selection) {
43   // assert(0);
44   TSelectionHandle::getCurrent()->setSelection(selection);
45 }
46 
47 //-----------------------------------------------------------------------------
48 
enableCommand(CommandId cmdId,CommandHandlerInterface * handler)49 void TSelection::enableCommand(CommandId cmdId,
50                                CommandHandlerInterface *handler) {
51   TSelectionHandle::getCurrent()->enableCommand(cmdId, handler);
52 }
53 
addMenuAction(QMenu * menu,CommandId cmdId)54 void TSelection::addMenuAction(QMenu *menu, CommandId cmdId) {
55   menu->addAction(CommandManager::instance()->getAction(cmdId));
56 }
57 
notifyView()58 void TSelection::notifyView() {
59   if (m_view) m_view->onSelectionChanged();
60 }
61