1 #pragma once 2 3 #ifndef TSELECTIONHANDLE_H 4 #define TSELECTIONHANDLE_H 5 6 #include <QObject> 7 #include <string> 8 #include <vector> 9 10 #include "toonzqt/menubarcommand.h" 11 #include "tcommon.h" 12 13 #undef DVAPI 14 #undef DVVAR 15 #ifdef TOONZQT_EXPORTS 16 #define DVAPI DV_EXPORT_API 17 #define DVVAR DV_EXPORT_VAR 18 #else 19 #define DVAPI DV_IMPORT_API 20 #define DVVAR DV_IMPORT_VAR 21 #endif 22 23 // forward declaration 24 class TSelection; 25 class CommandHandlerInterface; 26 27 //============================================================================= 28 // TSelectionHandle 29 //----------------------------------------------------------------------------- 30 31 class DVAPI TSelectionHandle final : public QObject { 32 Q_OBJECT 33 34 std::vector<TSelection *> m_selectionStack; 35 std::vector<std::string> m_enabledCommandIds; 36 37 public: 38 TSelectionHandle(); 39 ~TSelectionHandle(); 40 41 TSelection *getSelection() const; 42 void setSelection(TSelection *selection); 43 44 void pushSelection(); 45 void popSelection(); 46 47 // called by TSelection::enableCommand 48 void enableCommand(std::string cmdId, CommandHandlerInterface *handler); 49 50 void notifySelectionChanged(); 51 52 static TSelectionHandle *getCurrent(); 53 54 signals: 55 void selectionSwitched(TSelection *oldSelection, TSelection *newSelection); 56 void selectionChanged(TSelection *selection); 57 }; 58 59 #endif // TSELECTIONHANDLE_H 60